mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
Use explicit dir in cli_run tests
This commit is contained in:
parent
a6b57aea87
commit
1f183769c4
1 changed files with 15 additions and 36 deletions
|
@ -15,21 +15,10 @@ mod cli_run {
|
|||
example_file, extract_valgrind_errors, run_cmd, run_roc, run_with_valgrind,
|
||||
};
|
||||
use serial_test::serial;
|
||||
use std::path::Path;
|
||||
|
||||
fn check_output(
|
||||
folder: &str,
|
||||
file: &str,
|
||||
flags: &[&str],
|
||||
expected_ending: &str,
|
||||
use_valgrind: bool,
|
||||
) {
|
||||
let compile_out = run_roc(
|
||||
&[
|
||||
&["build", example_file(folder, file).to_str().unwrap()],
|
||||
flags,
|
||||
]
|
||||
.concat(),
|
||||
);
|
||||
fn check_output(file: &Path, flags: &[&str], expected_ending: &str, use_valgrind: bool) {
|
||||
let compile_out = run_roc(&[&["build", file.to_str().unwrap()], flags].concat());
|
||||
if !compile_out.stderr.is_empty() {
|
||||
panic!(compile_out.stderr);
|
||||
}
|
||||
|
@ -37,14 +26,14 @@ mod cli_run {
|
|||
|
||||
let out = if use_valgrind {
|
||||
let (valgrind_out, raw_xml) =
|
||||
run_with_valgrind(&[example_file(folder, "app").to_str().unwrap()]);
|
||||
run_with_valgrind(&[file.with_file_name("app").to_str().unwrap()]);
|
||||
let memory_errors = extract_valgrind_errors(&raw_xml);
|
||||
if !memory_errors.is_empty() {
|
||||
panic!("{:?}", memory_errors);
|
||||
}
|
||||
valgrind_out
|
||||
} else {
|
||||
run_cmd(example_file(folder, "app").to_str().unwrap(), &[])
|
||||
run_cmd(file.with_file_name("app").to_str().unwrap(), &[])
|
||||
};
|
||||
if !&out.stdout.ends_with(expected_ending) {
|
||||
panic!(
|
||||
|
@ -59,8 +48,7 @@ mod cli_run {
|
|||
#[serial(hello_world)]
|
||||
fn run_hello_world() {
|
||||
check_output(
|
||||
"hello-world",
|
||||
"Hello.roc",
|
||||
&example_file("hello-world", "Hello.roc"),
|
||||
&[],
|
||||
"Hello, World!!!!!!!!!!!!!\n",
|
||||
true,
|
||||
|
@ -71,8 +59,7 @@ mod cli_run {
|
|||
#[serial(hello_world)]
|
||||
fn run_hello_world_optimized() {
|
||||
check_output(
|
||||
"hello-world",
|
||||
"Hello.roc",
|
||||
&example_file("hello-world", "Hello.roc"),
|
||||
&[],
|
||||
"Hello, World!!!!!!!!!!!!!\n",
|
||||
true,
|
||||
|
@ -83,8 +70,7 @@ mod cli_run {
|
|||
#[serial(quicksort)]
|
||||
fn run_quicksort_not_optimized() {
|
||||
check_output(
|
||||
"quicksort",
|
||||
"Quicksort.roc",
|
||||
&example_file("quicksort", "Quicksort.roc"),
|
||||
&[],
|
||||
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n",
|
||||
false,
|
||||
|
@ -95,8 +81,7 @@ mod cli_run {
|
|||
#[serial(quicksort)]
|
||||
fn run_quicksort_optimized() {
|
||||
check_output(
|
||||
"quicksort",
|
||||
"Quicksort.roc",
|
||||
&example_file("quicksort", "Quicksort.roc"),
|
||||
&["--optimize"],
|
||||
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n",
|
||||
false,
|
||||
|
@ -109,8 +94,7 @@ mod cli_run {
|
|||
#[ignore]
|
||||
fn run_quicksort_valgrind() {
|
||||
check_output(
|
||||
"quicksort",
|
||||
"Quicksort.roc",
|
||||
&example_file("quicksort", "Quicksort.roc"),
|
||||
&[],
|
||||
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n",
|
||||
true,
|
||||
|
@ -123,8 +107,7 @@ mod cli_run {
|
|||
#[ignore]
|
||||
fn run_quicksort_optimized_valgrind() {
|
||||
check_output(
|
||||
"quicksort",
|
||||
"Quicksort.roc",
|
||||
&example_file("quicksort", "Quicksort.roc"),
|
||||
&["--optimize"],
|
||||
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n",
|
||||
true,
|
||||
|
@ -135,8 +118,7 @@ mod cli_run {
|
|||
#[serial(multi_module)]
|
||||
fn run_multi_module() {
|
||||
check_output(
|
||||
"multi-module",
|
||||
"Quicksort.roc",
|
||||
&example_file("multi-module", "Quicksort.roc"),
|
||||
&[],
|
||||
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n",
|
||||
false,
|
||||
|
@ -147,8 +129,7 @@ mod cli_run {
|
|||
#[serial(multi_module)]
|
||||
fn run_multi_module_optimized() {
|
||||
check_output(
|
||||
"multi-module",
|
||||
"Quicksort.roc",
|
||||
&example_file("multi-module", "Quicksort.roc"),
|
||||
&["--optimize"],
|
||||
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n",
|
||||
false,
|
||||
|
@ -161,8 +142,7 @@ mod cli_run {
|
|||
#[ignore]
|
||||
fn run_multi_module_valgrind() {
|
||||
check_output(
|
||||
"multi-module",
|
||||
"Quicksort.roc",
|
||||
&example_file("multi-module", "Quicksort.roc"),
|
||||
&[],
|
||||
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n",
|
||||
true,
|
||||
|
@ -175,8 +155,7 @@ mod cli_run {
|
|||
#[ignore]
|
||||
fn run_multi_module_optimized_valgrind() {
|
||||
check_output(
|
||||
"multi-module",
|
||||
"Quicksort.roc",
|
||||
&example_file("multi-module", "Quicksort.roc"),
|
||||
&["--optimize"],
|
||||
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n",
|
||||
true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue