Skip to content

Commit

Permalink
add test case moon_test_with_failure_json
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Flash committed Aug 26, 2024
1 parent 840ce7d commit 37992ec
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 0 deletions.
15 changes: 15 additions & 0 deletions crates/moon/tests/test_cases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"#]],
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
.mooncakes/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# username/hello
10 changes: 10 additions & 0 deletions crates/moon/tests/test_cases/test_with_failure_json/moon.mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "username/hello",
"version": "0.1.0",
"readme": "README.md",
"repository": "",
"license": "Apache-2.0",
"keywords": [],
"description": "",
"source": "src"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pub fn hello() -> String {
"Hello, world!"
}


test "test_1" {
fail!("test_1 failed")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test "hello" {
if @lib1.hello() != "Hello, world!" {
fail!("@lib.hello() != \"Hello, world!\"")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main {
println(@lib1.hello())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"is-main": true,
"import": [
"username/hello/lib1"
]
}

0 comments on commit 37992ec

Please sign in to comment.