diff --git a/crates/moon/tests/test_cases/mod.rs b/crates/moon/tests/test_cases/mod.rs index 192d29a8b..9114ef236 100644 --- a/crates/moon/tests/test_cases/mod.rs +++ b/crates/moon/tests/test_cases/mod.rs @@ -5906,3 +5906,18 @@ fn test_snapshot_test_target_js() { expect!["Hello, world!"], ); } + +#[test] +fn moon_test_with_failure_json() { + let dir = TestDir::new("test_with_failure_json"); + + let output = get_err_stdout_with_args_and_replace_dir(&dir, ["test", "--test-failure-json"]); + check( + &output, + // should keep in this format, it's used in ide test explorer + expect![[r#" + {"package":"username/hello/lib1","filename":"hello.mbt","index":"0","test_name":"test_1","message":"FAILED: $ROOT/src/lib1/hello.mbt:7:3-7:25 test_1 failed"} + Total tests: 2, passed: 1, failed: 1. + "#]], + ); +} diff --git a/crates/moon/tests/test_cases/test_with_failure_json/.gitignore b/crates/moon/tests/test_cases/test_with_failure_json/.gitignore new file mode 100644 index 000000000..b1283a746 --- /dev/null +++ b/crates/moon/tests/test_cases/test_with_failure_json/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/test_with_failure_json/README.md b/crates/moon/tests/test_cases/test_with_failure_json/README.md new file mode 100644 index 000000000..ae00983f7 --- /dev/null +++ b/crates/moon/tests/test_cases/test_with_failure_json/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_with_failure_json/moon.mod.json b/crates/moon/tests/test_cases/test_with_failure_json/moon.mod.json new file mode 100644 index 000000000..6c31689d6 --- /dev/null +++ b/crates/moon/tests/test_cases/test_with_failure_json/moon.mod.json @@ -0,0 +1,10 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "Apache-2.0", + "keywords": [], + "description": "", + "source": "src" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_with_failure_json/src/lib1/hello.mbt b/crates/moon/tests/test_cases/test_with_failure_json/src/lib1/hello.mbt new file mode 100644 index 000000000..25f37ff2f --- /dev/null +++ b/crates/moon/tests/test_cases/test_with_failure_json/src/lib1/hello.mbt @@ -0,0 +1,8 @@ +pub fn hello() -> String { + "Hello, world!" +} + + +test "test_1" { + fail!("test_1 failed") +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_with_failure_json/src/lib1/hello_test.mbt b/crates/moon/tests/test_cases/test_with_failure_json/src/lib1/hello_test.mbt new file mode 100644 index 000000000..b1d0ee90d --- /dev/null +++ b/crates/moon/tests/test_cases/test_with_failure_json/src/lib1/hello_test.mbt @@ -0,0 +1,5 @@ +test "hello" { + if @lib1.hello() != "Hello, world!" { + fail!("@lib.hello() != \"Hello, world!\"") + } +} diff --git a/crates/moon/tests/test_cases/test_with_failure_json/src/lib1/moon.pkg.json b/crates/moon/tests/test_cases/test_with_failure_json/src/lib1/moon.pkg.json new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/crates/moon/tests/test_cases/test_with_failure_json/src/lib1/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_with_failure_json/src/main/main.mbt b/crates/moon/tests/test_cases/test_with_failure_json/src/main/main.mbt new file mode 100644 index 000000000..00fdb7ca7 --- /dev/null +++ b/crates/moon/tests/test_cases/test_with_failure_json/src/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib1.hello()) +} diff --git a/crates/moon/tests/test_cases/test_with_failure_json/src/main/moon.pkg.json b/crates/moon/tests/test_cases/test_with_failure_json/src/main/moon.pkg.json new file mode 100644 index 000000000..1c7a42141 --- /dev/null +++ b/crates/moon/tests/test_cases/test_with_failure_json/src/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib1" + ] +} \ No newline at end of file