Skip to content

Commit

Permalink
add test case for third party dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Flash committed Jul 9, 2024
1 parent 63c24fb commit 7fbb5c7
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 0 deletions.
70 changes: 70 additions & 0 deletions crates/moon/tests/test_cases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4092,3 +4092,73 @@ fn test_moon_run_with_cli_args() {
"#]],
);
}

#[test]
fn test_third_party() {
let dir = TestDir::new("third_party.in");

check(
&get_stdout_with_args_and_replace_dir(&dir, ["check"]),
expect![[r#"
moonc check -error-format json $ROOT/.mooncakes/lijunchen/hello18/lib/hello.mbt -o $ROOT/target/wasm-gc/release/check/.mooncakes/lijunchen/hello18/lib/lib.mi -pkg lijunchen/hello18/lib -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources lijunchen/hello18/lib:$ROOT/.mooncakes/lijunchen/hello18/lib -target wasm-gc
moonc check -error-format json $ROOT/lib/test.mbt -o $ROOT/target/wasm-gc/release/check/lib/lib.mi -pkg username/hello/lib -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/lib:$ROOT/lib -target wasm-gc
moonc check -error-format json $ROOT/.mooncakes/lijunchen/hello18/lib/hello.mbt -o $ROOT/target/wasm-gc/release/check/.mooncakes/lijunchen/hello18/lib/lib.mi -pkg lijunchen/hello18/lib -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources lijunchen/hello18/lib:$ROOT/.mooncakes/lijunchen/hello18/lib -target wasm-gc
[1002] Warning: Warning: Unused variable 'a'
╭─[$ROOT/.mooncakes/lijunchen/hello18/lib/hello.mbt:2:7]
2 │ let a = 1
│ ┬
│ ╰── Warning: Unused variable 'a'
───╯
moonc check -error-format json $ROOT/.mooncakes/lijunchen/hello18/main/main.mbt -o $ROOT/target/wasm-gc/release/check/.mooncakes/lijunchen/hello18/main/main.mi -pkg lijunchen/hello18/main -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -i $ROOT/target/wasm-gc/release/check/.mooncakes/lijunchen/hello18/lib/lib.mi:lib -pkg-sources lijunchen/hello18/main:$ROOT/.mooncakes/lijunchen/hello18/main -target wasm-gc
moonc check -error-format json $ROOT/main/main.mbt -o $ROOT/target/wasm-gc/release/check/main/main.mi -pkg username/hello/main -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -i $ROOT/target/wasm-gc/release/check/.mooncakes/lijunchen/hello18/lib/lib.mi:lib -pkg-sources username/hello/main:$ROOT/main -target wasm-gc
moon: ran 4 tasks, now up to date
"#]],
);

check(
&get_stdout_with_args_and_replace_dir(&dir, ["test"]),
expect![[r#"
Hello, world!
Total tests: 1, passed: 1, failed: 0.
"#]],
);

check(
&get_stdout_with_args_and_replace_dir(&dir, ["build"]),
expect![[r#"
moonc build-package -error-format json $ROOT/.mooncakes/lijunchen/hello18/lib/hello.mbt -o $ROOT/target/wasm-gc/release/build/.mooncakes/lijunchen/hello18/lib/lib.core -pkg lijunchen/hello18/lib -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources lijunchen/hello18/lib:$ROOT/.mooncakes/lijunchen/hello18/lib -target wasm-gc
[1002] Warning: Warning: Unused variable 'a'
╭─[$ROOT/.mooncakes/lijunchen/hello18/lib/hello.mbt:2:7]
2 │ let a = 1
│ ┬
│ ╰── Warning: Unused variable 'a'
───╯
moonc build-package -error-format json $ROOT/main/main.mbt -o $ROOT/target/wasm-gc/release/build/main/main.core -pkg username/hello/main -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -i $ROOT/target/wasm-gc/release/build/.mooncakes/lijunchen/hello18/lib/lib.mi:lib -pkg-sources username/hello/main:$ROOT/main -target wasm-gc
moonc build-package -error-format json $ROOT/.mooncakes/lijunchen/hello18/main/main.mbt -o $ROOT/target/wasm-gc/release/build/.mooncakes/lijunchen/hello18/main/main.core -pkg lijunchen/hello18/main -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -i $ROOT/target/wasm-gc/release/build/.mooncakes/lijunchen/hello18/lib/lib.mi:lib -pkg-sources lijunchen/hello18/main:$ROOT/.mooncakes/lijunchen/hello18/main -target wasm-gc
moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core $ROOT/target/wasm-gc/release/build/.mooncakes/lijunchen/hello18/lib/lib.core $ROOT/target/wasm-gc/release/build/.mooncakes/lijunchen/hello18/main/main.core -main lijunchen/hello18/main -o $ROOT/target/wasm-gc/release/build/.mooncakes/lijunchen/hello18/main/main.wasm -pkg-sources lijunchen/hello18/lib:$ROOT/lib -pkg-sources lijunchen/hello18/main:$ROOT/main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc
moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core $ROOT/target/wasm-gc/release/build/.mooncakes/lijunchen/hello18/lib/lib.core $ROOT/target/wasm-gc/release/build/main/main.core -main username/hello/main -o $ROOT/target/wasm-gc/release/build/main/main.wasm -pkg-sources lijunchen/hello18/lib:$ROOT/lib -pkg-sources username/hello/main:$ROOT/main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc
moon: ran 5 tasks, now up to date
"#]],
);

check(
&get_stdout_with_args_and_replace_dir(&dir, ["run", "main"]),
expect![[r#"
moonc build-package -error-format json $ROOT/.mooncakes/lijunchen/hello18/lib/hello.mbt -o $ROOT/target/wasm-gc/release/build/.mooncakes/lijunchen/hello18/lib/lib.core -pkg lijunchen/hello18/lib -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources lijunchen/hello18/lib:$ROOT/.mooncakes/lijunchen/hello18/lib -target wasm-gc
[1002] Warning: Warning: Unused variable 'a'
╭─[$ROOT/.mooncakes/lijunchen/hello18/lib/hello.mbt:2:7]
2 │ let a = 1
│ ┬
│ ╰── Warning: Unused variable 'a'
───╯
moonc build-package -error-format json $ROOT/main/main.mbt -o $ROOT/target/wasm-gc/release/build/main/main.core -pkg username/hello/main -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -i $ROOT/target/wasm-gc/release/build/.mooncakes/lijunchen/hello18/lib/lib.mi:lib -pkg-sources username/hello/main:$ROOT/main -target wasm-gc
moonc build-package -error-format json $ROOT/.mooncakes/lijunchen/hello18/main/main.mbt -o $ROOT/target/wasm-gc/release/build/.mooncakes/lijunchen/hello18/main/main.core -pkg lijunchen/hello18/main -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -i $ROOT/target/wasm-gc/release/build/.mooncakes/lijunchen/hello18/lib/lib.mi:lib -pkg-sources lijunchen/hello18/main:$ROOT/.mooncakes/lijunchen/hello18/main -target wasm-gc
moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core $ROOT/target/wasm-gc/release/build/.mooncakes/lijunchen/hello18/lib/lib.core $ROOT/target/wasm-gc/release/build/.mooncakes/lijunchen/hello18/main/main.core -main lijunchen/hello18/main -o $ROOT/target/wasm-gc/release/build/.mooncakes/lijunchen/hello18/main/main.wasm -pkg-sources lijunchen/hello18/lib:$ROOT/lib -pkg-sources lijunchen/hello18/main:$ROOT/main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc
moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core $ROOT/target/wasm-gc/release/build/.mooncakes/lijunchen/hello18/lib/lib.core $ROOT/target/wasm-gc/release/build/main/main.core -main username/hello/main -o $ROOT/target/wasm-gc/release/build/main/main.wasm -pkg-sources lijunchen/hello18/lib:$ROOT/lib -pkg-sources username/hello/main:$ROOT/main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc
Hello, world!
"#]],
);
}
2 changes: 2 additions & 0 deletions crates/moon/tests/test_cases/third_party.in/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
.mooncakes/
1 change: 1 addition & 0 deletions crates/moon/tests/test_cases/third_party.in/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# username/hello
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 4 additions & 0 deletions crates/moon/tests/test_cases/third_party.in/lib/test.mbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

test {
println("Hello, world!")
}
3 changes: 3 additions & 0 deletions crates/moon/tests/test_cases/third_party.in/main/main.mbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main {
println(@lib.hello())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"is-main": true,
"import": [
"lijunchen/hello18/lib"
]
}
12 changes: 12 additions & 0 deletions crates/moon/tests/test_cases/third_party.in/moon.mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "username/hello",
"version": "0.1.0",
"deps": {
"lijunchen/hello18": "0.1.30"
},
"readme": "README.md",
"repository": "",
"license": "",
"keywords": [],
"description": ""
}

0 comments on commit 7fbb5c7

Please sign in to comment.