Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/trunk' into remove-call-result-a…
Browse files Browse the repository at this point in the history
…gain
  • Loading branch information
folkertdev committed Oct 22, 2021
2 parents 10b9307 + 9b76f0c commit da3787f
Show file tree
Hide file tree
Showing 34 changed files with 6,473 additions and 116 deletions.
7 changes: 5 additions & 2 deletions BUILDING_FROM_SOURCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ For macOS, you can install LLVM 12 using `brew install llvm@12` and then adding
`/usr/local/opt/llvm/bin` to your `PATH`. You can confirm this worked by
running `llc --version` - it should mention "LLVM version 12.0.0" at the top.

For Ubuntu and Debian, you can use the `Automatic installation script` at [apt.llvm.org](https://apt.llvm.org):
For Ubuntu and Debian:
```
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
sudo apt -y install lsb-release software-properties-common gnupg
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
./llvm.sh 12
```

If you use this script, you'll need to add `clang` and `llvm-as` to your `PATH`.
Expand Down
87 changes: 77 additions & 10 deletions cli/tests/cli_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod cli_run {
run_with_valgrind, ValgrindError, ValgrindErrorXWhat,
};
use serial_test::serial;
use std::path::Path;
use std::path::{Path, PathBuf};

#[cfg(not(debug_assertions))]
use roc_collections::all::MutMap;
Expand All @@ -39,6 +39,7 @@ mod cli_run {
filename: &'a str,
executable_filename: &'a str,
stdin: &'a [&'a str],
input_file: Option<&'a str>,
expected_ending: &'a str,
use_valgrind: bool,
}
Expand All @@ -48,6 +49,7 @@ mod cli_run {
stdin: &[&str],
executable_filename: &str,
flags: &[&str],
input_file: Option<PathBuf>,
expected_ending: &str,
use_valgrind: bool,
) {
Expand All @@ -59,10 +61,20 @@ mod cli_run {
assert!(compile_out.status.success(), "bad status {:?}", compile_out);

let out = if use_valgrind && ALLOW_VALGRIND {
let (valgrind_out, raw_xml) = run_with_valgrind(
stdin,
&[file.with_file_name(executable_filename).to_str().unwrap()],
);
let (valgrind_out, raw_xml) = if let Some(input_file) = input_file {
run_with_valgrind(
stdin,
&[
file.with_file_name(executable_filename).to_str().unwrap(),
input_file.to_str().unwrap(),
],
)
} else {
run_with_valgrind(
stdin,
&[file.with_file_name(executable_filename).to_str().unwrap()],
)
};

if valgrind_out.status.success() {
let memory_errors = extract_valgrind_errors(&raw_xml).unwrap_or_else(|err| {
Expand Down Expand Up @@ -100,11 +112,19 @@ mod cli_run {

valgrind_out
} else {
run_cmd(
file.with_file_name(executable_filename).to_str().unwrap(),
stdin,
&[],
)
if let Some(input_file) = input_file {
run_cmd(
file.with_file_name(executable_filename).to_str().unwrap(),
stdin,
&[input_file.to_str().unwrap()],
)
} else {
run_cmd(
file.with_file_name(executable_filename).to_str().unwrap(),
stdin,
&[],
)
}
};
if !&out.stdout.ends_with(expected_ending) {
panic!(
Expand All @@ -121,8 +141,10 @@ mod cli_run {
stdin: &[&str],
executable_filename: &str,
flags: &[&str],
input_file: Option<PathBuf>,
expected_ending: &str,
) {
assert_eq!(input_file, None, "Wasm does not support input files");
let mut flags = flags.to_vec();
flags.push("--backend=wasm32");

Expand Down Expand Up @@ -178,6 +200,7 @@ mod cli_run {
example.stdin,
example.executable_filename,
&[],
example.input_file.and_then(|file| Some(example_file(dir_name, file))),
example.expected_ending,
example.use_valgrind,
);
Expand All @@ -187,6 +210,7 @@ mod cli_run {
example.stdin,
example.executable_filename,
&["--optimize"],
example.input_file.and_then(|file| Some(example_file(dir_name, file))),
example.expected_ending,
example.use_valgrind,
);
Expand All @@ -199,6 +223,7 @@ mod cli_run {
example.stdin,
example.executable_filename,
&["--roc-linker"],
example.input_file.and_then(|file| Some(example_file(dir_name, file))),
example.expected_ending,
example.use_valgrind,
);
Expand Down Expand Up @@ -235,86 +260,108 @@ mod cli_run {
filename: "Hello.roc",
executable_filename: "hello-world",
stdin: &[],
input_file: None,
expected_ending:"Hello, World!\n",
use_valgrind: true,
},
hello_zig:"hello-zig" => Example {
filename: "Hello.roc",
executable_filename: "hello-world",
stdin: &[],
input_file: None,
expected_ending:"Hello, World!\n",
use_valgrind: true,
},
hello_rust:"hello-rust" => Example {
filename: "Hello.roc",
executable_filename: "hello-rust",
stdin: &[],
input_file: None,
expected_ending:"Hello, World!\n",
use_valgrind: true,
},
hello_web:"hello-web" => Example {
filename: "Hello.roc",
executable_filename: "hello-web",
stdin: &[],
input_file: None,
expected_ending:"Hello, World!\n",
use_valgrind: true,
},
fib:"fib" => Example {
filename: "Fib.roc",
executable_filename: "fib",
stdin: &[],
input_file: None,
expected_ending:"55\n",
use_valgrind: true,
},
quicksort:"quicksort" => Example {
filename: "Quicksort.roc",
executable_filename: "quicksort",
stdin: &[],
input_file: None,
expected_ending: "[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n",
use_valgrind: true,
},
// shared_quicksort:"shared-quicksort" => Example {
// filename: "Quicksort.roc",
// executable_filename: "quicksort",
// stdin: &[],
// input_file: None,
// expected_ending: "[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n",
// use_valgrind: true,
// },
effect:"effect" => Example {
filename: "Main.roc",
executable_filename: "effect-example",
stdin: &["hi there!"],
input_file: None,
expected_ending: "hi there!\nIt is known\n",
use_valgrind: true,
},
// tea:"tea" => Example {
// filename: "Main.roc",
// executable_filename: "tea-example",
// stdin: &[],
// input_file: None,
// expected_ending: "",
// use_valgrind: true,
// },
cli:"cli" => Example {
filename: "Echo.roc",
executable_filename: "echo",
stdin: &["Giovanni\n", "Giorgio\n"],
input_file: None,
expected_ending: "Hi, Giovanni Giorgio!\n",
use_valgrind: true,
},
// custom_malloc:"custom-malloc" => Example {
// filename: "Main.roc",
// executable_filename: "custom-malloc-example",
// stdin: &[],
// input_file: None,
// expected_ending: "ms!\nThe list was small!\n",
// use_valgrind: true,
// },
// task:"task" => Example {
// filename: "Main.roc",
// executable_filename: "task-example",
// stdin: &[],
// input_file: None,
// expected_ending: "successfully wrote to file\n",
// use_valgrind: true,
// },
false_interpreter:"false-interpreter" => {
Example {
filename: "False.roc",
executable_filename: "false",
stdin: &[],
input_file: Some("examples/hello.false"),
expected_ending:"Hello, World!\n",
use_valgrind: false,
}
},
}

macro_rules! benchmarks {
Expand All @@ -341,6 +388,7 @@ mod cli_run {
benchmark.stdin,
benchmark.executable_filename,
&[],
benchmark.input_file.and_then(|file| Some(examples_dir("benchmarks").join(file))),
benchmark.expected_ending,
benchmark.use_valgrind,
);
Expand All @@ -350,6 +398,7 @@ mod cli_run {
benchmark.stdin,
benchmark.executable_filename,
&["--optimize"],
benchmark.input_file.and_then(|file| Some(examples_dir("benchmarks").join(file))),
benchmark.expected_ending,
benchmark.use_valgrind,
);
Expand Down Expand Up @@ -382,6 +431,7 @@ mod cli_run {
benchmark.stdin,
benchmark.executable_filename,
&[],
benchmark.input_file.and_then(|file| Some(examples_dir("benchmarks").join(file))),
benchmark.expected_ending,
);

Expand All @@ -390,6 +440,7 @@ mod cli_run {
benchmark.stdin,
benchmark.executable_filename,
&["--optimize"],
benchmark.input_file.and_then(|file| Some(examples_dir("benchmarks").join(file))),
benchmark.expected_ending,
);
}
Expand Down Expand Up @@ -421,6 +472,7 @@ mod cli_run {
benchmark.stdin,
benchmark.executable_filename,
&["--backend=x86_32"],
benchmark.input_file.and_then(|file| Some(examples_dir("benchmarks").join(file))),
benchmark.expected_ending,
benchmark.use_valgrind,
);
Expand All @@ -430,6 +482,7 @@ mod cli_run {
benchmark.stdin,
benchmark.executable_filename,
&["--backend=x86_32", "--optimize"],
benchmark.input_file.and_then(|file| Some(examples_dir("benchmarks").join(file))),
benchmark.expected_ending,
benchmark.use_valgrind,
);
Expand Down Expand Up @@ -458,69 +511,79 @@ mod cli_run {
filename: "NQueens.roc",
executable_filename: "nqueens",
stdin: &["6"],
input_file: None,
expected_ending: "4\n",
use_valgrind: true,
},
cfold => Example {
filename: "CFold.roc",
executable_filename: "cfold",
stdin: &["3"],
input_file: None,
expected_ending: "11 & 11\n",
use_valgrind: true,
},
deriv => Example {
filename: "Deriv.roc",
executable_filename: "deriv",
stdin: &["2"],
input_file: None,
expected_ending: "1 count: 6\n2 count: 22\n",
use_valgrind: true,
},
rbtree_ck => Example {
filename: "RBTreeCk.roc",
executable_filename: "rbtree-ck",
stdin: &["100"],
input_file: None,
expected_ending: "10\n",
use_valgrind: true,
},
rbtree_insert => Example {
filename: "RBTreeInsert.roc",
executable_filename: "rbtree-insert",
stdin: &[],
input_file: None,
expected_ending: "Node Black 0 {} Empty Empty\n",
use_valgrind: true,
},
// rbtree_del => Example {
// filename: "RBTreeDel.roc",
// executable_filename: "rbtree-del",
// stdin: &["420"],
// input_file: None,
// expected_ending: "30\n",
// use_valgrind: true,
// },
astar => Example {
filename: "TestAStar.roc",
executable_filename: "test-astar",
stdin: &[],
input_file: None,
expected_ending: "True\n",
use_valgrind: false,
},
base64 => Example {
filename: "TestBase64.roc",
executable_filename: "test-base64",
stdin: &[],
input_file: None,
expected_ending: "encoded: SGVsbG8gV29ybGQ=\ndecoded: Hello World\n",
use_valgrind: true,
},
closure => Example {
filename: "Closure.roc",
executable_filename: "closure",
stdin: &[],
input_file: None,
expected_ending: "",
use_valgrind: true,
},
quicksort_app => Example {
filename: "QuicksortApp.roc",
executable_filename: "quicksortapp",
stdin: &[],
input_file: None,
expected_ending: "todo put the correct quicksort answer here",
use_valgrind: true,
},
Expand Down Expand Up @@ -600,6 +663,7 @@ mod cli_run {
&[],
"multi-dep-str",
&[],
None,
"I am Dep2.str2\n",
true,
);
Expand All @@ -613,6 +677,7 @@ mod cli_run {
&[],
"multi-dep-str",
&["--optimize"],
None,
"I am Dep2.str2\n",
true,
);
Expand All @@ -626,6 +691,7 @@ mod cli_run {
&[],
"multi-dep-thunk",
&[],
None,
"I am Dep2.value2\n",
true,
);
Expand All @@ -639,6 +705,7 @@ mod cli_run {
&[],
"multi-dep-thunk",
&["--optimize"],
None,
"I am Dep2.value2\n",
true,
);
Expand Down
Loading

0 comments on commit da3787f

Please sign in to comment.