Skip to content

Commit

Permalink
Include cli tests stderr output
Browse files Browse the repository at this point in the history
  • Loading branch information
imaqtkatt committed Mar 6, 2024
1 parent 6888296 commit b29ced1
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/golden_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn run_golden_test_dir_multiple(test_name: &str, run: &[&dyn Fn(&str, &Path) ->

let walker = WalkDir::new(&root).sort_by_file_name().max_depth(2).into_iter().filter_entry(|e| {
let path = e.path();
path == root || (path.is_file() && path.extension().is_some_and(|x| x == "hvm"))
path == root || path.is_dir() || (path.is_file() && path.extension().is_some_and(|x| x == "hvm"))
});

for entry in walker {
Expand Down Expand Up @@ -318,8 +318,9 @@ fn cli() {
args_file.read_to_string(&mut args_buf).expect("Read args");
let args = args_buf.lines();

let output = std::process::Command::new("cargo").arg("run").args(args).output().expect("Run process");
let output =
std::process::Command::new("cargo").arg("run").arg("-q").args(args).output().expect("Run process");

Ok(format!("{}", String::from_utf8_lossy(&output.stdout)))
Ok(format!("{}\n{}", String::from_utf8_lossy(&output.stderr), String::from_utf8_lossy(&output.stdout)))
})
}
11 changes: 11 additions & 0 deletions tests/golden_tests/cli/compile_no_opts.args
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
compile
tests/golden_tests/cli/compile_no_opts.hvm
-Ono-all
-Ono-eta
-Ono-prune
-Ono-ref-to-ref
-Ono-pre-reduce
-Ono-float-combinators
-Ono-simplify-main
-Ono-merge
-Ono-inline
1 change: 1 addition & 0 deletions tests/golden_tests/cli/compile_no_opts.hvm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
main = *
3 changes: 3 additions & 0 deletions tests/golden_tests/cli/compile_wrong_opt.args
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
compile
tests/golden_tests/cli/compile_wrong_opt.hvm
-Ofoo
1 change: 1 addition & 0 deletions tests/golden_tests/cli/compile_wrong_opt.hvm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
main = *
5 changes: 5 additions & 0 deletions tests/snapshots/cli__compile_no_opts.hvm.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/cli/compile_no_opts.hvm
---
@main = *
3 changes: 3 additions & 0 deletions tests/snapshots/cli__compile_pre_reduce.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/cli/compile_pre_reduce.hvm
---
Warnings:
Unused definition 'I'.

@I = #5
@main = *
10 changes: 10 additions & 0 deletions tests/snapshots/cli__compile_wrong_opt.hvm.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/cli/compile_wrong_opt.hvm
---
error: invalid value 'foo' for '-O <COMP_OPTS>'
[possible values: all, no-all, eta, no-eta, prune, no-prune, ref-to-ref, no-ref-to-ref, pre-reduce, no-pre-reduce, linearize-matches, linearize-matches-extra, no-linearize-matches, float-combinators, no-float-combinators, simplify-main, no-simplify-main, merge, no-merge, inline, no-inline, adt-scott, adt-tagged-scott]

tip: a similar value exists: 'float-combinators'

For more information, try '--help'.

0 comments on commit b29ced1

Please sign in to comment.