From: Skgland Date: Mon, 4 Dec 2023 21:16:04 +0000 (+0100) Subject: move .pl files from tests-pl next to the .toml of the test that uses them X-Git-Tag: v0.9.4~82^2~3 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=fcf2e2db05e7259bff2143a4ee895519551e77eb;p=scryer-prolog.git move .pl files from tests-pl next to the .toml of the test that uses them --- diff --git a/tests-pl/issue812-singleton-warning.pl b/tests-pl/issue812-singleton-warning.pl deleted file mode 100644 index 9c8673b9..00000000 --- a/tests-pl/issue812-singleton-warning.pl +++ /dev/null @@ -1,4 +0,0 @@ -% hello -% line! - -a :- b(X). \ No newline at end of file diff --git a/tests/scryer/cli/issues/compound_goal.toml b/tests/scryer/cli/issues/compound_goal.toml index 354705ac..0ad32366 100644 --- a/tests/scryer/cli/issues/compound_goal.toml +++ b/tests/scryer/cli/issues/compound_goal.toml @@ -1,3 +1,3 @@ # issue 820 -args = ["-f", "--no-add-history", "-g", "test,halt", "tests-pl/issue820-goals.pl"] +args = ["-f", "--no-add-history", "-g", "test,halt", "tests/scryer/cli/issues/issue820-goals.pl"] binary = true diff --git a/tests/scryer/cli/issues/do_not_duplicate_path_components.stdin b/tests/scryer/cli/issues/do_not_duplicate_path_components.stdin index 8b66cc85..9860cb27 100644 --- a/tests/scryer/cli/issues/do_not_duplicate_path_components.stdin +++ b/tests/scryer/cli/issues/do_not_duplicate_path_components.stdin @@ -1,3 +1,3 @@ -['tests-pl/issue852-throw_e.pl']. -['tests-pl/issue852-throw_e.pl']. +['tests/scryer/cli/issues/issue852-throw_e.pl']. +['tests/scryer/cli/issues/issue852-throw_e.pl']. halt. diff --git a/tests-pl/issue820-goals.pl b/tests/scryer/cli/issues/issue820-goals.pl similarity index 100% rename from tests-pl/issue820-goals.pl rename to tests/scryer/cli/issues/issue820-goals.pl diff --git a/tests-pl/issue839-op3.pl b/tests/scryer/cli/issues/issue839-op3.pl similarity index 100% rename from tests-pl/issue839-op3.pl rename to tests/scryer/cli/issues/issue839-op3.pl diff --git a/tests-pl/issue841-occurs-check.pl b/tests/scryer/cli/issues/issue841-occurs-check.pl similarity index 100% rename from tests-pl/issue841-occurs-check.pl rename to tests/scryer/cli/issues/issue841-occurs-check.pl diff --git a/tests-pl/issue852-throw_e.pl b/tests/scryer/cli/issues/issue852-throw_e.pl similarity index 100% rename from tests-pl/issue852-throw_e.pl rename to tests/scryer/cli/issues/issue852-throw_e.pl diff --git a/tests/scryer/cli/issues/multiple_goals.toml b/tests/scryer/cli/issues/multiple_goals.toml index 3b80d759..5e9c9155 100644 --- a/tests/scryer/cli/issues/multiple_goals.toml +++ b/tests/scryer/cli/issues/multiple_goals.toml @@ -1,3 +1,3 @@ # issue 820 -args = ["-f", "--no-add-history", "-g", "test", "-g", "halt", "tests-pl/issue820-goals.pl"] +args = ["-f", "--no-add-history", "-g", "test", "-g", "halt", "tests/scryer/cli/issues/issue820-goals.pl"] binary = true diff --git a/tests/scryer/cli/issues/occurs_check_flag.toml b/tests/scryer/cli/issues/occurs_check_flag.toml index 89946f05..2754c362 100644 --- a/tests/scryer/cli/issues/occurs_check_flag.toml +++ b/tests/scryer/cli/issues/occurs_check_flag.toml @@ -1,3 +1,3 @@ # issue 841 -args = ["-f", "--no-add-history", "tests-pl/issue841-occurs-check.pl"] +args = ["-f", "--no-add-history", "tests/scryer/cli/issues/issue841-occurs-check.pl"] binary = true diff --git a/tests/scryer/cli/issues/op3.toml b/tests/scryer/cli/issues/op3.toml index 44a9109f..cbd1f64c 100644 --- a/tests/scryer/cli/issues/op3.toml +++ b/tests/scryer/cli/issues/op3.toml @@ -1,3 +1,3 @@ # issue 839 -args = ["-f", "--no-add-history", "tests-pl/issue839-op3.pl", "-g", "halt"] +args = ["-f", "--no-add-history", "tests/scryer/cli/issues/issue839-op3.pl", "-g", "halt"] binary = true diff --git a/tests/scryer/cli/issues/singleton_warning.stdin b/tests/scryer/cli/issues/singleton_warning.stdin index ba37e689..f82cad20 100644 --- a/tests/scryer/cli/issues/singleton_warning.stdin +++ b/tests/scryer/cli/issues/singleton_warning.stdin @@ -1,2 +1,2 @@ -['tests-pl/issue812-singleton-warning.pl']. +['tests/scryer/cli/issues/issue812-singleton-warning.pl']. halt. diff --git a/tests/scryer/helper.rs b/tests/scryer/helper.rs index 623994ff..467a06d1 100644 --- a/tests/scryer/helper.rs +++ b/tests/scryer/helper.rs @@ -1,5 +1,3 @@ -use assert_cmd::Command; -use std::ffi::OsStr; pub(crate) trait Expectable { #[track_caller] @@ -34,30 +32,3 @@ pub(crate) fn load_module_test(file: &str, expected: T) { let mut wam = Machine::with_test_streams(); expected.assert_eq(wam.test_load_file(file).as_slice()); } - -pub const SCRYER_PROLOG: &str = "scryer-prolog"; - -/// Test whether scryer-prolog -/// produces the expected output when called with the supplied -/// arguments and fed the supplied input -pub fn run_top_level_test_with_args< - A: IntoIterator, - S: Into>, - O: assert_cmd::assert::IntoOutputPredicate

, - AS: AsRef, - P: predicates_core::Predicate<[u8]>, ->( - args: A, - stdin: S, - expected_stdout: O, -) { - Command::cargo_bin(SCRYER_PROLOG) - .unwrap() - .arg("-f") - .arg("--no-add-history") - .args(args) - .write_stdin(stdin) - .assert() - .stdout(expected_stdout.into_output()) - .success(); -} diff --git a/tests/scryer/main.rs b/tests/scryer/main.rs index 8b3fdeb1..643f8d71 100644 --- a/tests/scryer/main.rs +++ b/tests/scryer/main.rs @@ -2,10 +2,15 @@ mod helper; mod issues; mod src_tests; -/// to generate new reference output files into dump/ run `TRYCMD=dump cargo test -- cli_test` -/// check that the output is as expected, then move them next to the .toml file +/// To add new cli test copy an existing .toml file in `tests/scryer/cli/issues/` or `tests/scryer/cli/issues/src_tests/`, +/// adjust as necessary the `-f` and `--no-add-history` args should be kept but additional args may be added. +/// For input on stdin add a .stdin file with the same filename. +/// Then to generate new reference output files into dump/ run `TRYCMD=dump cargo test -- cli_test` +/// check that the output in the .stdout and .stderr file is as expected, then move them next to the .toml file. /// -/// to re-generate reference output files run `TRYCMD=overwrite cargo test -- cli_test` +/// If a test does not have a .stderr or .stdout the corresponding output is ignored i.e. any and no output is accepted +/// +/// to re-generate all reference output files run `TRYCMD=overwrite cargo test -- cli_test` /// then check that the changes are as expected e.g. by looking at the `git diff` #[test] fn cli_tests() { diff --git a/tests/scryer/src_tests.rs b/tests/scryer/src_tests.rs index 6b95ee45..99272686 100644 --- a/tests/scryer/src_tests.rs +++ b/tests/scryer/src_tests.rs @@ -1,4 +1,4 @@ -use crate::helper::{load_module_test, run_top_level_test_with_args}; +use crate::helper::load_module_test; use serial_test::serial; #[serial]