Skip to content

Commit

Permalink
internal: prefixing some definition in test driver
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Flash committed Sep 12, 2024
1 parent 489b8f4 commit 0ddbd72
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 128 deletions.
16 changes: 9 additions & 7 deletions crates/moon/src/cli/generate_test_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ pub fn generate_test_driver(
}

fn generate_driver(data: &str, pkgname: &str, target_backend: Option<TargetBackend>) -> String {
let index = data.find("let with_args_tests =").unwrap_or(data.len());
let index = data
.find("let moonbit_test_driver_internal_with_args_tests =")
.unwrap_or(data.len());
let no_args = &data[0..index];
let with_args = &data[index..];

Expand Down Expand Up @@ -239,20 +241,20 @@ fn generate_driver(data: &str, pkgname: &str, target_backend: Option<TargetBacke
template = template
.replace("\r\n", "\n")
.replace(
"let no_args_tests : TestDriver_No_Args_Map = { } // WILL BE REPLACED\n",
"let moonbit_test_driver_internal_no_args_tests : Moonbit_Test_Driver_Internal_No_Args_Map = { } // WILL BE REPLACED\n",
no_args,
)
.replace(
"let with_args_tests : TestDriver_With_Args_Map = { } // WILL BE REPLACED\n",
"let moonbit_test_driver_internal_with_args_tests : Moonbit_Test_Driver_Internal_TestDriver_With_Args_Map = { } // WILL BE REPLACED\n",
with_args,
)
.replace(
"let no_args_tests =",
"let no_args_tests : TestDriver_No_Args_Map =",
"let moonbit_test_driver_internal_no_args_tests =",
"let moonbit_test_driver_internal_no_args_tests : Moonbit_Test_Driver_Internal_No_Args_Map =",
)
.replace(
"let with_args_tests =",
"let with_args_tests : TestDriver_With_Args_Map =",
"let moonbit_test_driver_internal_with_args_tests =",
"let moonbit_test_driver_internal_with_args_tests : Moonbit_Test_Driver_Internal_TestDriver_With_Args_Map =",
)
.replace("{PACKAGE}", pkgname)
.replace("{BEGIN_MOONTEST}", MOON_TEST_DELIMITER_BEGIN)
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 @@ -42,10 +42,10 @@
moon generate-test-driver --source-dir . --target-dir ./target/js/debug/test --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 -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
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 execute -js-format cjs -target js -g
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
moonc build-package ./src/lib/all.mbt ./src/lib/js_or_wasm.mbt ./src/lib/only_debug.mbt ./src/lib/only_js.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 execute -js-format cjs -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

$ moon bundle --dry-run --target js --sort-input --nostd
moonc build-package ./src/lib/all.mbt ./src/lib/js_and_release.mbt ./src/lib/js_or_wasm.mbt ./src/lib/only_js.mbt -o ./target/js/release/bundle/lib/lib.core -pkg username/hello/lib -pkg-sources username/hello/lib:./lib -target js
Expand Down
Loading

0 comments on commit 0ddbd72

Please sign in to comment.