Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move cli_testing_examples under crates/cli/tests #6558

Merged
merged 6 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ exclude = [
"ci/benchmarks/bench-runner",
"ci/repl_basic_test",
# Examples sometimes have Rust hosts in their platforms. The compiler should ignore those.
"crates/cli_testing_examples",
jschear marked this conversation as resolved.
Show resolved Hide resolved
"examples",
]
# Needed to be able to run `cargo run -p roc_cli --no-default-features` -
Expand Down
27 changes: 13 additions & 14 deletions ci/benchmarks/bench-runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ fn do_all_benches(nr_repeat_benchmarks: usize) -> HashSet<String> {
return HashSet::new();
}

println!("\n\nDoing benchmarks {:?} times to reduce flukes.\n\n", nr_repeat_benchmarks);
println!(
"\n\nDoing benchmarks {:?} times to reduce flukes.\n\n",
nr_repeat_benchmarks
);

for _ in 1..nr_repeat_benchmarks {
delete_old_bench_results();
Expand All @@ -111,19 +114,16 @@ fn do_all_benches(nr_repeat_benchmarks: usize) -> HashSet<String> {

// returns Vec with names of regressed benchmarks
fn do_benchmark(branch_name: &'static str) -> HashSet<String> {
let mut bench_cmd =
Command::new(format!(
"./bench-folder-{}/target/release/deps/time_bench",
branch_name
));
let mut bench_cmd = Command::new(format!(
"./bench-folder-{}/target/release/deps/time_bench",
branch_name
));

let bench_cmd_w_args =
bench_cmd.args(&["--bench", "--noplot"]);
let bench_cmd_w_args = bench_cmd.args(&["--bench", "--noplot"]);

let bench_cmd_as_str = format!("{bench_cmd_w_args:?}");

let mut bench_cmd_child =
bench_cmd_w_args
let mut bench_cmd_child = bench_cmd_w_args
.stdout(Stdio::piped())
.stderr(Stdio::inherit())
.spawn()
Expand Down Expand Up @@ -163,8 +163,7 @@ fn do_benchmark(branch_name: &'static str) -> HashSet<String> {
"Error: time-bench execution failed with exit code {}.\n\
See output above for error info.\n\
Command was:\n\t{}",
exit_status,
bench_cmd_as_str
exit_status, bench_cmd_as_str
);
}

Expand Down Expand Up @@ -220,7 +219,7 @@ fn sha_file(file_path: &Path) -> Result<String, io::Error> {
assert!(disassembly_output.status.success());

let mut reader = BufReader::new(disassembly_output.stdout.as_slice());

// the first line contains the path, we want to skip it
let mut _discard_lines = String::new();
reader.read_line(&mut _discard_lines)?;
Expand Down Expand Up @@ -265,7 +264,7 @@ fn calc_hashes_for_folder(benches_path_str: &str) -> HashMap<String, String> {
}

fn check_if_bench_executables_changed() -> bool {
let bench_folder_str = "/crates/cli_testing_examples/benchmarks/";
let bench_folder_str = "/crates/cli/tests/benchmarks/";

let main_benches_path_str = [BENCH_FOLDER_MAIN, bench_folder_str].join("");

Expand Down
6 changes: 3 additions & 3 deletions ci/benchmarks/prep_folder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ BENCH_SUFFIX=$1

cargo criterion -V
cd crates/cli && cargo criterion --no-run && cd ../..
mkdir -p bench-folder/crates/cli_testing_examples/benchmarks
mkdir -p bench-folder/crates/cli/tests/benchmarks
mkdir -p bench-folder/crates/compiler/builtins/bitcode/src
mkdir -p bench-folder/target/release/deps
cp "crates/cli_testing_examples/benchmarks/"*".roc" bench-folder/crates/cli_testing_examples/benchmarks/
cp -r crates/cli_testing_examples/benchmarks/platform bench-folder/crates/cli_testing_examples/benchmarks/
cp "crates/cli/tests/benchmarks/"*".roc" bench-folder/crates/cli/tests/benchmarks/
cp -r crates/cli/tests/benchmarks/platform bench-folder/crates/cli/tests/benchmarks/
cp crates/compiler/builtins/bitcode/src/str.zig bench-folder/crates/compiler/builtins/bitcode/src
cp target/release/roc bench-folder/target/release

Expand Down
16 changes: 8 additions & 8 deletions crates/cli/tests/cli_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,14 +547,14 @@ mod cli_run {
// on the building of the platform

test_roc_app(
"crates/cli_testing_examples/expects",
"crates/cli/tests/expects",
"expects.roc",
&[],
&[],
&[],
indoc!(
r#"
── EXPECT FAILED in ...roc/roc/crates/cli_testing_examples/expects/expects.roc ─
── EXPECT FAILED in tests/expects/expects.roc ─────────────────────────────────
This expectation failed:
Expand All @@ -580,14 +580,14 @@ mod cli_run {
);

test_roc_app(
"crates/cli_testing_examples/expects",
"crates/cli/tests/expects",
"expects.roc",
&[],
&[],
&[],
indoc!(
r#"
── EXPECT FAILED in ...roc/roc/crates/cli_testing_examples/expects/expects.roc ─
── EXPECT FAILED in tests/expects/expects.roc ─────────────────────────────────
This expectation failed:
Expand All @@ -599,7 +599,7 @@ mod cli_run {
a : Num *
a = 1
── EXPECT FAILED in ...roc/roc/crates/cli_testing_examples/expects/expects.roc ─
── EXPECT FAILED in tests/expects/expects.roc ─────────────────────────────────
This expectation failed:
Expand All @@ -611,7 +611,7 @@ mod cli_run {
a : Num *
a = 1
── EXPECT FAILED in ...roc/roc/crates/cli_testing_examples/expects/expects.roc ─
── EXPECT FAILED in tests/expects/expects.roc ─────────────────────────────────
This expectation failed:
Expand Down Expand Up @@ -659,7 +659,7 @@ mod cli_run {
)]
fn fibonacci() {
test_roc_app_slim(
"crates/cli_testing_examples/algorithms",
"crates/cli/tests/algorithms",
"fibonacci.roc",
"",
UseValgrind::Yes,
Expand Down Expand Up @@ -698,7 +698,7 @@ mod cli_run {
#[cfg_attr(windows, ignore)]
fn quicksort() {
test_roc_app_slim(
"crates/cli_testing_examples/algorithms",
"crates/cli/tests/algorithms",
"quicksort.roc",
"[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n",
UseValgrind::Yes,
Expand Down
12 changes: 6 additions & 6 deletions crates/cli_utils/src/bench_utils.rs

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions crates/cli_utils/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,14 +404,15 @@ pub fn extract_valgrind_errors(xml: &str) -> Result<Vec<ValgrindError>, serde_xm
Ok(answer)
}

// start the dir with crates/cli_testing_examples
// start the dir with crates/cli/tests
#[allow(dead_code)]
pub fn cli_testing_dir(dir_name: &str) -> PathBuf {
let mut path = root_dir();

// Descend into examples/{dir_name}
path.push("crates");
path.push("cli_testing_examples");
path.push("cli");
path.push("tests");
path.extend(dir_name.split('/')); // Make slashes cross-target

path
Expand Down
4 changes: 2 additions & 2 deletions crates/compiler/build/src/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ pub fn build_zig_host_wasm32(
"c",
"-target",
"wasm32-wasi",
// "-femit-llvm-ir=/home/folkertdev/roc/roc/crates/cli_testing_examples/benchmarks/platform/host.ll",
// "-femit-llvm-ir=/home/folkertdev/roc/roc/crates/cli/tests/benchmarks/platform/host.ll",
"-fPIC",
"-fstrip",
]);
Expand Down Expand Up @@ -1241,7 +1241,7 @@ fn link_wasm32(
"ReleaseSmall",
"-rdynamic",
// useful for debugging
// "-femit-llvm-ir=/home/folkertdev/roc/roc/crates/cli_testing_examples/benchmarks/platform/host.ll",
// "-femit-llvm-ir=/home/folkertdev/roc/roc/crates/cli/tests/benchmarks/platform/host.ll",
])
.spawn()?;

Expand Down
2 changes: 1 addition & 1 deletion getting_started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ cd examples
roc dev helloWorld.roc
```

[crates/cli_testing_examples/benchmarks](https://github.com/roc-lang/roc/tree/main/crates/cli_testing_examples/benchmarks) contains more examples.
[crates/cli/tests/benchmarks](https://github.com/roc-lang/roc/tree/main/crates/cli/tests/benchmarks) contains more examples.


## Getting Involved
Expand Down
Loading