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

[sc-460] Update tests to show HVM.log output #228

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
34 changes: 20 additions & 14 deletions tests/golden_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
use stdext::function_name;
use walkdir::WalkDir;

fn format_output(output: std::process::Output) -> String {
format!("{}\n{}", String::from_utf8_lossy(&output.stderr), String::from_utf8_lossy(&output.stdout))
}

fn do_parse_term(code: &str) -> Result<Term, String> {
parse_term(code).map_err(|errs| errs.into_iter().map(|e| e.to_string()).join("\n"))
}
Expand Down Expand Up @@ -141,19 +145,21 @@
#[test]
fn run_file() {
run_golden_test_dir_multiple(function_name!(), &[
(&|code, path| {
let book = do_parse_book(code, path)?;
// 1 million nodes for the test runtime. Smaller doesn't seem to make it any faster
let (res, info) =
run_book(book, 1 << 24, RunOpts::lazy(), WarningOpts::deny_all(), CompileOpts::heavy(), None)?;
Ok(format!("{}{}", display_readback_errors(&info.readback_errors), res))
(&|_code, path| {
let output = std::process::Command::new(env!("CARGO_BIN_EXE_hvml"))
.args(["run", path.to_str().unwrap(), "-Dall", "-Oall", "-L"])

Check warning on line 150 in tests/golden_tests.rs

View workflow job for this annotation

GitHub Actions / cspell

Unknown word (Dall)
imaqtkatt marked this conversation as resolved.
Show resolved Hide resolved
.output()
.expect("Run process");

Ok(format_output(output))
}),
(&|code, path| {
let book = do_parse_book(code, path)?;
// 1 million nodes for the test runtime. Smaller doesn't seem to make it any faster
let (res, info) =
run_book(book, 1 << 24, RunOpts::default(), WarningOpts::deny_all(), CompileOpts::heavy(), None)?;
Ok(format!("{}{}", display_readback_errors(&info.readback_errors), res))
(&|_code, path| {
let output = std::process::Command::new(env!("CARGO_BIN_EXE_hvml"))
.args(["run", path.to_str().unwrap(), "-Dall", "-Oall"])

Check warning on line 158 in tests/golden_tests.rs

View workflow job for this annotation

GitHub Actions / cspell

Unknown word (Dall)
.output()
.expect("Run process");

Ok(format_output(output))
}),
])
}
Expand Down Expand Up @@ -319,8 +325,8 @@
let args = args_buf.lines();

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

Ok(format!("{}\n{}", String::from_utf8_lossy(&output.stderr), String::from_utf8_lossy(&output.stdout)))
Ok(format_output(output))
})
}
2 changes: 2 additions & 0 deletions tests/snapshots/run_file__log.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_file/log.hvm
---
59
(Some "Hello world")
"Hi"
1 change: 1 addition & 0 deletions tests/snapshots/run_file__print.hvm.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
source: tests/golden_tests.rs
input_file: tests/golden_tests/run_file/print.hvm
---
hello world
"goodbye world"
Loading