Skip to content

Commit

Permalink
Merge pull request #430 from moonbitlang/target_dir_in_gen_test_drive…
Browse files Browse the repository at this point in the history
…r_subcommand

internal: refactor --target-dir arg for generate-test-driver subcommand
  • Loading branch information
Young-Flash authored Oct 29, 2024
2 parents 3337443 + 4f4f34b commit 3be14fb
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 97 deletions.
14 changes: 11 additions & 3 deletions crates/moon/src/cli/generate_test_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ pub fn generate_test_driver(
} = cli.source_tgt_dir.try_into_package_dirs()?;

let mut cmd = cmd;
let target_backend = cmd.build_flags.target.as_ref().and_then(|surface_targets| {
let target_backend = cmd.build_flags.target.as_ref().map(|surface_targets| {
if surface_targets.is_empty() {
None
TargetBackend::WasmGC
} else {
Some(lower_surface_targets(surface_targets)[0])
lower_surface_targets(surface_targets)[0]
}
});
cmd.build_flags.target_backend = target_backend;
Expand All @@ -138,6 +138,14 @@ pub fn generate_test_driver(
cli.quiet,
)?;
let raw_target_dir = target_dir.to_path_buf();
let target_dir = target_dir
.join(target_backend.unwrap().to_dir_name())
.join(if cmd.build_flags.release {
"release"
} else {
"debug"
})
.join("test");

let moonbuild_opt = MoonbuildOpt {
source_dir,
Expand Down
4 changes: 2 additions & 2 deletions crates/moon/tests/test_cases/cond_comp.in/moon.test
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
moonc check ./src/lib/hello_test.mbt ./src/lib/js_only_test.mbt -o ./target/js/release/check/lib/lib.blackbox_test.mi -pkg username/hello/lib_blackbox_test -i ./target/js/release/check/lib/lib.mi:lib -pkg-sources username/hello/lib_blackbox_test:./src/lib -target js -blackbox-test

$ moon test --dry-run --target js --sort-input --nostd
moon generate-test-driver --source-dir . --target-dir ./target/js/debug/test --package username/hello/lib --sort-input --target js --driver-kind blackbox
moon generate-test-driver --source-dir . --target-dir ./target --package username/hello/lib --sort-input --target js --driver-kind blackbox
moonc build-package ./src/lib/all.mbt ./src/lib/js_or_wasm.mbt ./src/lib/only_debug.mbt ./src/lib/only_js.mbt ./src/lib/wasm_release_or_js_debug.mbt -o ./target/js/debug/test/lib/lib.core -pkg username/hello/lib -pkg-sources username/hello/lib:./src/lib -target js -g
moonc build-package ./src/lib/hello_test.mbt ./src/lib/js_only_test.mbt ./target/js/debug/test/lib/__generated_driver_for_blackbox_test.mbt -o ./target/js/debug/test/lib/lib.blackbox_test.core -pkg username/hello/lib_blackbox_test -is-main -i ./target/js/debug/test/lib/lib.mi:lib -pkg-sources username/hello/lib_blackbox_test:./src/lib -target js -g -blackbox-test
moonc link-core ./target/js/debug/test/lib/lib.core ./target/js/debug/test/lib/lib.blackbox_test.core -main username/hello/lib_blackbox_test -o ./target/js/debug/test/lib/lib.blackbox_test.js -test-mode -pkg-sources username/hello/lib:./src/lib -pkg-sources username/hello/lib_blackbox_test:./src/lib -exported_functions moonbit_test_driver_internal_execute -js-format cjs -target js -g
moon generate-test-driver --source-dir . --target-dir ./target/js/debug/test --package username/hello/lib --sort-input --target js --driver-kind internal
moon generate-test-driver --source-dir . --target-dir ./target --package username/hello/lib --sort-input --target js --driver-kind internal
moonc build-package ./src/lib/all.mbt ./src/lib/js_or_wasm.mbt ./src/lib/only_debug.mbt ./src/lib/only_js.mbt ./src/lib/wasm_release_or_js_debug.mbt ./target/js/debug/test/lib/__generated_driver_for_internal_test.mbt -o ./target/js/debug/test/lib/lib.internal_test.core -pkg username/hello/lib -is-main -pkg-sources username/hello/lib:./src/lib -target js -g
moonc link-core ./target/js/debug/test/lib/lib.internal_test.core -main username/hello/lib -o ./target/js/debug/test/lib/lib.internal_test.js -test-mode -pkg-sources username/hello/lib:./src/lib -exported_functions moonbit_test_driver_internal_execute -js-format cjs -target js -g

Expand Down
Loading

0 comments on commit 3be14fb

Please sign in to comment.