From 31445510e2ad0ca4744e6330bdfa8ec140f2229c Mon Sep 17 00:00:00 2001 From: Li Junchen Date: Tue, 23 Jul 2024 18:40:39 +0800 Subject: [PATCH] open source moon was originally developed starting in May 2023 at the International Digital Economy Academy. This commit cleans up the history and squashes it into one commit in preparation for open-sourcing. Co-authored-by: Rynco Maekawa Co-authored-by: Young-Flash --- .cargo/config.toml | 2 + .github/workflows/cd.yml | 121 + .github/workflows/check-merge-commit.yml | 35 + .github/workflows/ci.yml | 246 + .github/workflows/test-on-main.yml | 134 + .gitignore | 4 + Cargo.lock | 2761 +++++++++ Cargo.toml | 93 + README.md | 54 + crates/moon/Cargo.toml | 46 + crates/moon/src/cli.rs | 219 + crates/moon/src/cli/build.rs | 143 + crates/moon/src/cli/build_matrix.rs | 56 + crates/moon/src/cli/bundle.rs | 138 + crates/moon/src/cli/check.rs | 170 + crates/moon/src/cli/clean.rs | 28 + crates/moon/src/cli/coverage.rs | 103 + crates/moon/src/cli/deps.rs | 120 + crates/moon/src/cli/doc.rs | 107 + crates/moon/src/cli/fmt.rs | 61 + crates/moon/src/cli/generate_test_driver.rs | 283 + crates/moon/src/cli/info.rs | 133 + crates/moon/src/cli/mooncake_adapter.rs | 73 + crates/moon/src/cli/new.rs | 167 + crates/moon/src/cli/run.rs | 240 + crates/moon/src/cli/test.rs | 351 ++ crates/moon/src/cli/update.rs | 17 + crates/moon/src/cli/upgrade.rs | 10 + crates/moon/src/cli/version.rs | 145 + crates/moon/src/main.rs | 71 + crates/moon/tests/mod.rs | 202 + .../tests/test_cases/alert_list.in/.gitignore | 2 + .../tests/test_cases/alert_list.in/README.md | 1 + .../test_cases/alert_list.in/lib/hello.mbt | 12 + .../alert_list.in/lib/moon.pkg.json | 4 + .../test_cases/alert_list.in/main/main.mbt | 13 + .../alert_list.in/main/moon.pkg.json | 8 + .../test_cases/alert_list.in/moon.mod.json | 9 + .../tests/test_cases/avl_tree.in/README.md | 3 + .../tests/test_cases/avl_tree.in/lib/avl.mbt | 254 + .../test_cases/avl_tree.in/lib/moon.pkg.json | 3 + .../test_cases/avl_tree.in/main/main.mbt | 36 + .../test_cases/avl_tree.in/main/moon.pkg.json | 6 + .../test_cases/avl_tree.in/moon.mod.json | 3 + .../test_cases/backend-flag.in/.gitignore | 2 + .../test_cases/backend-flag.in/README.md | 1 + .../test_cases/backend-flag.in/lib/hello.mbt | 3 + .../backend-flag.in/lib/hello_wbtest.mbt | 5 + .../backend-flag.in/lib/moon.pkg.json | 1 + .../test_cases/backend-flag.in/main/main.mbt | 3 + .../backend-flag.in/main/moon.pkg.json | 6 + .../test_cases/backend-flag.in/moon.mod.json | 10 + .../test_cases/backend_config.in/.gitignore | 2 + .../test_cases/backend_config.in/README.md | 1 + .../backend_config.in/lib/hello.mbt | 7 + .../backend_config.in/lib/hello_wbtest.mbt | 5 + .../backend_config.in/lib/moon.pkg.json | 20 + .../backend_config.in/main/main.mbt | 3 + .../backend_config.in/main/moon.pkg.json | 6 + .../backend_config.in/moon.mod.json | 9 + .../tests/test_cases/backtrace.in/.gitignore | 2 + .../tests/test_cases/backtrace.in/README.md | 1 + .../test_cases/backtrace.in/main/main.mbt | 11 + .../backtrace.in/main/moon.pkg.json | 3 + .../test_cases/backtrace.in/moon.mod.json | 9 + .../bench2_test.in/dir_0_0/m_0_0_0_0/main.mbt | 3 + .../dir_0_0/m_0_0_0_0/moon.pkg.json | 1 + .../bench2_test.in/dir_0_0/m_0_0_0_1/main.mbt | 3 + .../dir_0_0/m_0_0_0_1/moon.pkg.json | 1 + .../bench2_test.in/dir_0_0/m_0_0_1_0/main.mbt | 5 + .../dir_0_0/m_0_0_1_0/moon.pkg.json | 6 + .../bench2_test.in/dir_0_0/m_0_0_1_1/main.mbt | 5 + .../dir_0_0/m_0_0_1_1/moon.pkg.json | 6 + .../bench2_test.in/dir_0_1/m_0_1_0_0/main.mbt | 3 + .../dir_0_1/m_0_1_0_0/moon.pkg.json | 1 + .../bench2_test.in/dir_0_1/m_0_1_0_1/main.mbt | 3 + .../dir_0_1/m_0_1_0_1/moon.pkg.json | 1 + .../bench2_test.in/dir_0_1/m_0_1_1_0/main.mbt | 5 + .../dir_0_1/m_0_1_1_0/moon.pkg.json | 6 + .../bench2_test.in/dir_0_1/m_0_1_1_1/main.mbt | 5 + .../dir_0_1/m_0_1_1_1/moon.pkg.json | 6 + .../bench2_test.in/dir_1_0/m_1_0_0_0/main.mbt | 7 + .../dir_1_0/m_1_0_0_0/moon.pkg.json | 8 + .../bench2_test.in/dir_1_0/m_1_0_0_1/main.mbt | 7 + .../dir_1_0/m_1_0_0_1/moon.pkg.json | 8 + .../bench2_test.in/dir_1_0/m_1_0_1_0/main.mbt | 5 + .../dir_1_0/m_1_0_1_0/moon.pkg.json | 6 + .../bench2_test.in/dir_1_0/m_1_0_1_1/main.mbt | 5 + .../dir_1_0/m_1_0_1_1/moon.pkg.json | 6 + .../bench2_test.in/dir_1_1/m_1_1_0_0/main.mbt | 7 + .../dir_1_1/m_1_1_0_0/moon.pkg.json | 8 + .../bench2_test.in/dir_1_1/m_1_1_0_1/main.mbt | 7 + .../dir_1_1/m_1_1_0_1/moon.pkg.json | 8 + .../bench2_test.in/dir_1_1/m_1_1_1_0/main.mbt | 5 + .../dir_1_1/m_1_1_1_0/moon.pkg.json | 6 + .../bench2_test.in/dir_1_1/m_1_1_1_1/main.mbt | 5 + .../dir_1_1/m_1_1_1_1/moon.pkg.json | 6 + .../test_cases/bench2_test.in/main/main.mbt | 19 + .../bench2_test.in/main/moon.pkg.json | 21 + .../test_cases/bench2_test.in/moon.mod.json | 3 + .../blackbox_failed_test.in/A/hello.mbt | 7 + .../blackbox_failed_test.in/A/hello_test.mbt | 10 + .../A/hello_wbtest.mbt | 13 + .../blackbox_failed_test.in/A/moon.pkg.json | 9 + .../blackbox_failed_test.in/B/hello.mbt | 4 + .../blackbox_failed_test.in/B/moon.pkg.json | 3 + .../blackbox_failed_test.in/C/hello.mbt | 4 + .../blackbox_failed_test.in/C/moon.pkg.json | 3 + .../blackbox_failed_test.in/main/main.mbt | 3 + .../main/moon.pkg.json | 3 + .../blackbox_failed_test.in/moon.mod.json | 3 + .../blackbox_success_test.in/A/hello.mbt | 22 + .../blackbox_success_test.in/A/hello_test.mbt | 17 + .../A/hello_wbtest.mbt | 4 + .../blackbox_success_test.in/A/moon.pkg.json | 11 + .../blackbox_success_test.in/B/hello.mbt | 4 + .../blackbox_success_test.in/B/moon.pkg.json | 3 + .../blackbox_success_test.in/C/hello.mbt | 4 + .../blackbox_success_test.in/C/moon.pkg.json | 3 + .../blackbox_success_test.in/D/hello.mbt | 4 + .../blackbox_success_test.in/D/moon.pkg.json | 3 + .../blackbox_success_test.in/main/main.mbt | 3 + .../main/moon.pkg.json | 3 + .../blackbox_success_test.in/moon.mod.json | 3 + .../test_cases/cakenew_test.in/.gitignore | 2 + .../test_cases/cakenew_test.in/lib/hello.mbt | 3 + .../cakenew_test.in/lib/moon.pkg.json | 1 + .../test_cases/cakenew_test.in/main/main.mbt | 3 + .../cakenew_test.in/main/moon.pkg.json | 6 + .../test_cases/cakenew_test.in/moon.mod.json | 4 + .../capture_abort_test.in/lib/hello.mbt | 4 + .../capture_abort_test.in/lib/moon.pkg.json | 3 + .../capture_abort_test.in/main/main.mbt | 4 + .../capture_abort_test.in/main/moon.pkg.json | 6 + .../capture_abort_test.in/moon.mod.json | 3 + .../lib/hello.mbt | 4 + .../lib/moon.pkg.json | 3 + .../main/main.mbt | 3 + .../main/moon.pkg.json | 6 + .../moon.mod.json | 3 + .../circle_pkg_AB_001_test.in/A/lib.mbt | 4 + .../circle_pkg_AB_001_test.in/A/moon.pkg.json | 5 + .../circle_pkg_AB_001_test.in/B/lib.mbt | 4 + .../circle_pkg_AB_001_test.in/B/moon.pkg.json | 5 + .../circle_pkg_AB_001_test.in/main/main.mbt | 5 + .../main/moon.pkg.json | 7 + .../circle_pkg_AB_001_test.in/moon.mod.json | 3 + .../tests/test_cases/core_order.in/.gitignore | 2 + .../tests/test_cases/core_order.in/A/a.mbt | 11 + .../test_cases/core_order.in/A/a_wbtest.mbt | 7 + .../test_cases/core_order.in/A/moon.pkg.json | 5 + .../tests/test_cases/core_order.in/B/b.mbt | 11 + .../test_cases/core_order.in/B/b_wbtest.mbt | 7 + .../test_cases/core_order.in/B/moon.pkg.json | 5 + .../test_cases/core_order.in/T/moon.pkg.json | 1 + .../tests/test_cases/core_order.in/T/t.mbt | 11 + .../test_cases/core_order.in/T/t_wbtest.mbt | 8 + .../test_cases/core_order.in/main/main.mbt | 3 + .../core_order.in/main/moon.pkg.json | 7 + .../test_cases/core_order.in/moon.mod.json | 5 + .../debug_flag_test.in/lib/hello.mbt | 4 + .../debug_flag_test.in/lib/moon.pkg.json | 1 + .../debug_flag_test.in/main/main.mbt | 3 + .../debug_flag_test.in/main/moon.pkg.json | 6 + .../debug_flag_test.in/moon.mod.json | 3 + .../test_cases/design.in/lib/list/lib.mbt | 3 + .../design.in/lib/list/moon.pkg.json | 3 + .../test_cases/design.in/lib/queue/lib.mbt | 4 + .../design.in/lib/queue/moon.pkg.json | 5 + .../test_cases/design.in/lib/stack/lib.mbt | 4 + .../design.in/lib/stack/moon.pkg.json | 5 + .../test_cases/design.in/lib/vec/lib.mbt | 3 + .../design.in/lib/vec/moon.pkg.json | 3 + .../test_cases/design.in/lib/vec/vec.mbt | 3 + .../tests/test_cases/design.in/main1/main.mbt | 6 + .../test_cases/design.in/main1/moon.pkg.json | 8 + .../tests/test_cases/design.in/main2/main.mbt | 4 + .../test_cases/design.in/main2/moon.pkg.json | 6 + .../tests/test_cases/design.in/moon.mod.json | 3 + .../test_cases/diamond-pkg-001.in/A/lib.mbt | 3 + .../diamond-pkg-001.in/A/moon.pkg.json | 3 + .../test_cases/diamond-pkg-001.in/B/lib.mbt | 4 + .../diamond-pkg-001.in/B/moon.pkg.json | 5 + .../test_cases/diamond-pkg-001.in/C/lib.mbt | 4 + .../diamond-pkg-001.in/C/moon.pkg.json | 5 + .../diamond-pkg-001.in/main/main.mbt | 5 + .../diamond-pkg-001.in/main/moon.pkg.json | 7 + .../diamond-pkg-001.in/moon.mod.json | 3 + .../diamond-pkg-002.in/A/A0/lib.mbt | 3 + .../diamond-pkg-002.in/A/A0/moon.pkg.json | 3 + .../diamond-pkg-002.in/A/A1/lib.mbt | 3 + .../diamond-pkg-002.in/A/A1/moon.pkg.json | 3 + .../diamond-pkg-002.in/A/A2/lib.mbt | 3 + .../diamond-pkg-002.in/A/A2/moon.pkg.json | 3 + .../test_cases/diamond-pkg-002.in/A/lib.mbt | 6 + .../diamond-pkg-002.in/A/moon.pkg.json | 7 + .../diamond-pkg-002.in/B/B0/lib.mbt | 3 + .../diamond-pkg-002.in/B/B0/moon.pkg.json | 3 + .../diamond-pkg-002.in/B/B1/lib.mbt | 3 + .../diamond-pkg-002.in/B/B1/moon.pkg.json | 3 + .../diamond-pkg-002.in/B/B2/lib.mbt | 3 + .../diamond-pkg-002.in/B/B2/moon.pkg.json | 3 + .../test_cases/diamond-pkg-002.in/B/lib.mbt | 7 + .../diamond-pkg-002.in/B/moon.pkg.json | 8 + .../diamond-pkg-002.in/C/C0/lib.mbt | 3 + .../diamond-pkg-002.in/C/C0/moon.pkg.json | 3 + .../diamond-pkg-002.in/C/C1/lib.mbt | 3 + .../diamond-pkg-002.in/C/C1/moon.pkg.json | 3 + .../diamond-pkg-002.in/C/C2/lib.mbt | 3 + .../diamond-pkg-002.in/C/C2/moon.pkg.json | 3 + .../test_cases/diamond-pkg-002.in/C/lib.mbt | 7 + .../diamond-pkg-002.in/C/moon.pkg.json | 8 + .../diamond-pkg-002.in/main/main.mbt | 5 + .../diamond-pkg-002.in/main/moon.pkg.json | 7 + .../diamond-pkg-002.in/moon.mod.json | 3 + .../diamond-pkg-003.in/A/A0/lib.mbt | 3 + .../diamond-pkg-003.in/A/A0/moon.pkg.json | 3 + .../diamond-pkg-003.in/A/A1/lib.mbt | 3 + .../diamond-pkg-003.in/A/A1/moon.pkg.json | 3 + .../diamond-pkg-003.in/A/A2/lib.mbt | 3 + .../diamond-pkg-003.in/A/A2/moon.pkg.json | 3 + .../test_cases/diamond-pkg-003.in/A/lib.mbt | 6 + .../diamond-pkg-003.in/A/moon.pkg.json | 7 + .../diamond-pkg-003.in/B/B0/lib.mbt | 3 + .../diamond-pkg-003.in/B/B0/moon.pkg.json | 3 + .../diamond-pkg-003.in/B/B1/lib.mbt | 3 + .../diamond-pkg-003.in/B/B1/moon.pkg.json | 3 + .../diamond-pkg-003.in/B/B2/lib.mbt | 3 + .../diamond-pkg-003.in/B/B2/moon.pkg.json | 3 + .../test_cases/diamond-pkg-003.in/B/lib.mbt | 7 + .../diamond-pkg-003.in/B/moon.pkg.json | 8 + .../diamond-pkg-003.in/C/C0/lib.mbt | 3 + .../diamond-pkg-003.in/C/C0/moon.pkg.json | 3 + .../diamond-pkg-003.in/C/C1/lib.mbt | 3 + .../diamond-pkg-003.in/C/C1/moon.pkg.json | 3 + .../diamond-pkg-003.in/C/C2/lib.mbt | 3 + .../diamond-pkg-003.in/C/C2/moon.pkg.json | 3 + .../test_cases/diamond-pkg-003.in/C/lib.mbt | 7 + .../diamond-pkg-003.in/C/moon.pkg.json | 8 + .../diamond-pkg-003.in/main/main.mbt | 5 + .../diamond-pkg-003.in/main/moon.pkg.json | 7 + .../diamond-pkg-003.in/moon.mod.json | 3 + .../test_cases/docstring-demo.in/README.md | 5 + .../docstring-demo.in/lib/hello.mbt | 9 + .../docstring-demo.in/lib/moon.pkg.json | 3 + .../docstring-demo.in/main/main.mbt | 3 + .../docstring-demo.in/main/moon.pkg.json | 6 + .../docstring-demo.in/moon.mod.json | 3 + .../tests/test_cases/dummy-core.in/0/lib.mbt | 0 .../test_cases/dummy-core.in/0/moon.pkg.json | 3 + .../tests/test_cases/dummy-core.in/0/y.js.mbt | 0 .../test_cases/dummy-core.in/0/y.wasm-gc.mbt | 0 .../test_cases/dummy-core.in/0/y.wasm.mbt | 0 .../dummy-core.in/0/y_wbtest.js.mbt | 0 .../test_cases/dummy-core.in/0/y_wbtest.mbt | 0 .../dummy-core.in/0/y_wbtest.wasm-gc.mbt | 0 .../dummy-core.in/0/y_wbtest.wasm.mbt | 0 .../tests/test_cases/dummy-core.in/1/lib.mbt | 0 .../test_cases/dummy-core.in/1/moon.pkg.json | 3 + .../tests/test_cases/dummy-core.in/1/x.js.mbt | 0 .../test_cases/dummy-core.in/1/x.wasm-gc.mbt | 0 .../test_cases/dummy-core.in/1/x.wasm.mbt | 0 .../dummy-core.in/1/x_wbtest.wasm-gc.mbt | 0 .../tests/test_cases/dummy-core.in/2/lib.mbt | 0 .../test_cases/dummy-core.in/2/moon.pkg.json | 6 + .../dummy-core.in/char/moon.pkg.json | 5 + .../dummy-core.in/coverage/moon.pkg.json | 1 + .../dummy-core.in/iter/moon.pkg.json | 8 + .../test_cases/dummy-core.in/moon.mod.json | 3 + .../error_duplicate_alias.in/.gitignore | 2 + .../error_duplicate_alias.in/lib/hello.mbt | 3 + .../lib/hello_wbtest.mbt | 5 + .../lib/moon.pkg.json | 1 + .../error_duplicate_alias.in/lib2/hello.mbt | 3 + .../lib2/hello_wbtest.mbt | 5 + .../lib2/moon.pkg.json | 1 + .../error_duplicate_alias.in/main/main.mbt | 3 + .../main/moon.pkg.json | 7 + .../error_duplicate_alias.in/moon.mod.json | 5 + .../test_cases/expect_test.in/.gitignore | 2 + .../tests/test_cases/expect_test.in/README.md | 1 + .../test_cases/expect_test.in/lib/hello.mbt | 153 + .../expect_test.in/lib/hello_wbtest.mbt | 11 + .../expect_test.in/lib/issue_188_wbtest.mbt | 21 + .../expect_test.in/lib/issue_209.mbt | 4 + .../expect_test.in/lib/moon.pkg.json | 1 + .../test_cases/expect_test.in/main/main.mbt | 3 + .../expect_test.in/main/moon.pkg.json | 6 + .../test_cases/expect_test.in/moon.mod.json | 9 + .../test_cases/export_memory.in/.gitignore | 2 + .../test_cases/export_memory.in/README.md | 1 + .../test_cases/export_memory.in/lib/hello.mbt | 3 + .../export_memory.in/lib/hello_wbtest.mbt | 5 + .../export_memory.in/lib/moon.pkg.json | 1 + .../test_cases/export_memory.in/main/main.mbt | 3 + .../export_memory.in/main/moon.pkg.json | 14 + .../test_cases/export_memory.in/moon.mod.json | 9 + .../test_cases/extra_flags.in/lib/hello.mbt | 4 + .../extra_flags.in/lib/moon.pkg.json | 1 + .../test_cases/extra_flags.in/main/main.mbt | 3 + .../extra_flags.in/main/moon.pkg.json | 6 + .../test_cases/extra_flags.in/moon.mod.json | 10 + .../fancy_import.in/import001/.gitignore | 2 + .../fancy_import.in/import001/lib/hello.mbt | 3 + .../import001/lib/moon.pkg.json | 3 + .../fancy_import.in/import001/main/main.mbt | 3 + .../import001/main/moon.pkg.json | 6 + .../fancy_import.in/import001/moon.mod.json | 4 + .../fancy_import.in/import002/lib/hello.mbt | 3 + .../import002/lib/moon.pkg.json | 3 + .../fancy_import.in/import002/main/main.mbt | 3 + .../import002/main/moon.pkg.json | 6 + .../fancy_import.in/import002/moon.mod.json | 4 + .../fancy_import.in/import003/.gitignore | 2 + .../fancy_import.in/import003/lib/hello.mbt | 3 + .../import003/lib/moon.pkg.json | 1 + .../fancy_import.in/import003/lib2/hello.mbt | 3 + .../import003/lib2/moon.pkg.json | 1 + .../fancy_import.in/import003/main/main.mbt | 4 + .../import003/main/moon.pkg.json | 10 + .../fancy_import.in/import003/moon.mod.json | 4 + .../fancy_import.in/import004/.gitignore | 2 + .../fancy_import.in/import004/lib/hello.mbt | 3 + .../import004/lib/moon.pkg.json | 3 + .../fancy_import.in/import004/lib2/hello.mbt | 3 + .../import004/lib2/moon.pkg.json | 3 + .../fancy_import.in/import004/lib3/hello.mbt | 3 + .../import004/lib3/moon.pkg.json | 3 + .../fancy_import.in/import004/lib4/hello.mbt | 3 + .../import004/lib4/moon.pkg.json | 3 + .../fancy_import.in/import004/main/main.mbt | 6 + .../import004/main/moon.pkg.json | 18 + .../fancy_import.in/import004/moon.mod.json | 4 + .../tests/test_cases/hello.in/main/main.mbt | 3 + .../test_cases/hello.in/main/moon.pkg.json | 4 + .../tests/test_cases/hello.in/moon.mod.json | 3 + .../test_cases/import_memory.in/.gitignore | 2 + .../test_cases/import_memory.in/README.md | 1 + .../test_cases/import_memory.in/lib/hello.mbt | 3 + .../import_memory.in/lib/hello_test.mbt | 5 + .../import_memory.in/lib/moon.pkg.json | 1 + .../test_cases/import_memory.in/main/main.mbt | 3 + .../import_memory.in/main/moon.pkg.json | 21 + .../test_cases/import_memory.in/moon.mod.json | 9 + .../test_cases/internal_package.in/.gitignore | 2 + .../test_cases/internal_package.in/README.md | 1 + .../internal_package.in/lib/a/lib.mbt | 3 + .../internal_package.in/lib/a/moon.pkg.json | 5 + .../internal_package.in/lib/hello.mbt | 3 + .../internal_package.in/lib/hello_wbtest.mbt | 5 + .../lib/internal/b/lib.mbt | 3 + .../lib/internal/b/moon.pkg.json | 5 + .../internal_package.in/lib/internal/lib.mbt | 3 + .../lib/internal/moon.pkg.json | 1 + .../internal_package.in/lib/moon.pkg.json | 5 + .../internal_package.in/lib2/lib.mbt | 0 .../internal_package.in/lib2/moon.pkg.json | 6 + .../internal_package.in/main/main.mbt | 3 + .../internal_package.in/main/moon.pkg.json | 7 + .../internal_package.in/moon.mod.json | 10 + .../tests/test_cases/js_format.in/.gitignore | 2 + .../tests/test_cases/js_format.in/README.md | 1 + .../test_cases/js_format.in/lib0/hello.mbt | 3 + .../js_format.in/lib0/hello_wbtest.mbt | 5 + .../js_format.in/lib0/moon.pkg.json | 9 + .../test_cases/js_format.in/lib1/hello.mbt | 3 + .../js_format.in/lib1/hello_wbtest.mbt | 5 + .../js_format.in/lib1/moon.pkg.json | 10 + .../test_cases/js_format.in/lib2/hello.mbt | 3 + .../js_format.in/lib2/hello_wbtest.mbt | 5 + .../js_format.in/lib2/moon.pkg.json | 10 + .../test_cases/js_format.in/lib3/hello.mbt | 3 + .../js_format.in/lib3/hello_wbtest.mbt | 5 + .../js_format.in/lib3/moon.pkg.json | 10 + .../test_cases/js_format.in/moon.mod.json | 9 + .../moon/tests/test_cases/mbti.in/.gitignore | 2 + .../moon/tests/test_cases/mbti.in/README.md | 1 + .../tests/test_cases/mbti.in/lib/hello.mbt | 3 + .../test_cases/mbti.in/lib/hello_wbtest.mbt | 5 + .../tests/test_cases/mbti.in/lib/lib.mbti | 11 + .../test_cases/mbti.in/lib/moon.pkg.json | 1 + .../tests/test_cases/mbti.in/main/main.mbt | 3 + .../tests/test_cases/mbti.in/main/main.mbti | 10 + .../test_cases/mbti.in/main/moon.pkg.json | 6 + .../tests/test_cases/mbti.in/moon.mod.json | 9 + crates/moon/tests/test_cases/mod.rs | 4969 +++++++++++++++++ .../moo_run_with_cli_args.in/.gitignore | 2 + .../moo_run_with_cli_args.in/README.md | 1 + .../moo_run_with_cli_args.in/main/main.mbt | 89 + .../main/moon.pkg.json | 3 + .../moo_run_with_cli_args.in/moon.mod.json | 9 + .../tests/test_cases/moon_bundle.in/A/lib.mbt | 3 + .../test_cases/moon_bundle.in/A/moon.pkg.json | 3 + .../tests/test_cases/moon_bundle.in/B/lib.mbt | 4 + .../test_cases/moon_bundle.in/B/moon.pkg.json | 5 + .../tests/test_cases/moon_bundle.in/C/lib.mbt | 4 + .../test_cases/moon_bundle.in/C/moon.pkg.json | 5 + .../test_cases/moon_bundle.in/Orphan/lib.mbt | 3 + .../moon_bundle.in/Orphan/moon.pkg.json | 3 + .../test_cases/moon_bundle.in/moon.mod.json | 3 + .../moon_commands.in/lib/list/lib.mbt | 3 + .../moon_commands.in/lib/list/moon.pkg.json | 3 + .../moon_commands.in/lib/queue/lib.mbt | 3 + .../moon_commands.in/lib/queue/moon.pkg.json | 5 + .../moon_commands.in/lib/stack/lib.mbt | 3 + .../moon_commands.in/lib/stack/moon.pkg.json | 5 + .../moon_commands.in/lib/vec/lib.mbt | 3 + .../moon_commands.in/lib/vec/moon.pkg.json | 3 + .../moon_commands.in/main1/main.mbt | 3 + .../moon_commands.in/main1/moon.pkg.json | 6 + .../moon_commands.in/main2/main.mbt | 3 + .../moon_commands.in/main2/moon.pkg.json | 6 + .../test_cases/moon_commands.in/moon.mod.json | 3 + .../tests/test_cases/moon_fmt.in/.gitignore | 2 + .../tests/test_cases/moon_fmt.in/README.md | 1 + .../test_cases/moon_fmt.in/lib/hello.mbt | 1 + .../moon_fmt.in/lib/hello_wbtest.mbt | 5 + .../test_cases/moon_fmt.in/lib/moon.pkg.json | 1 + .../test_cases/moon_fmt.in/main/main.mbt | 1 + .../test_cases/moon_fmt.in/main/moon.pkg.json | 6 + .../test_cases/moon_fmt.in/moon.mod.json | 9 + .../moon_inline_test_001.in/.gitignore | 2 + .../moon_inline_test_001.in/README.md | 1 + .../moon_inline_test_001.in/lib/hello.mbt | 3 + .../lib/hello_wbtest.mbt | 3 + .../moon_inline_test_001.in/lib/moon.pkg.json | 1 + .../moon_inline_test_001.in/main/main.mbt | 3 + .../main/moon.pkg.json | 6 + .../moon_inline_test_001.in/moon.mod.json | 8 + .../moon_inline_test_002.in/.gitignore | 2 + .../moon_inline_test_002.in/README.md | 1 + .../moon_inline_test_002.in/lib/hello.mbt | 3 + .../lib/hello_wbtest.mbt | 5 + .../moon_inline_test_002.in/lib/moon.pkg.json | 1 + .../moon_inline_test_002.in/main/main.mbt | 3 + .../main/moon.pkg.json | 6 + .../moon_inline_test_002.in/moon.mod.json | 8 + .../moon_inline_test_003.in/.gitignore | 2 + .../moon_inline_test_003.in/README.md | 1 + .../moon_inline_test_003.in/lib/hello.mbt | 3 + .../lib/hello_wbtest.mbt | 3 + .../moon_inline_test_003.in/lib/moon.pkg.json | 1 + .../moon_inline_test_003.in/main/main.mbt | 3 + .../main/moon.pkg.json | 6 + .../moon_inline_test_003.in/moon.mod.json | 8 + .../moon_inline_test_004.in/.gitignore | 2 + .../moon_inline_test_004.in/README.md | 1 + .../moon_inline_test_004.in/lib/hello.mbt | 7 + .../lib/hello_wbtest.mbt | 5 + .../moon_inline_test_004.in/lib/moon.pkg.json | 1 + .../moon_inline_test_004.in/main/main.mbt | 3 + .../main/moon.pkg.json | 6 + .../moon_inline_test_004.in/moon.mod.json | 8 + .../moon_inline_test_order.in/.gitignore | 2 + .../moon_inline_test_order.in/A/A_wbtest.mbt | 7 + .../moon_inline_test_order.in/A/hello.mbt | 7 + .../moon_inline_test_order.in/A/moon.pkg.json | 1 + .../moon_inline_test_order.in/B/B_wbtest.mbt | 7 + .../moon_inline_test_order.in/B/hello.mbt | 7 + .../moon_inline_test_order.in/B/moon.pkg.json | 5 + .../moon_inline_test_order.in/README.md | 1 + .../moon_inline_test_order.in/main/main.mbt | 3 + .../main/moon.pkg.json | 6 + .../moon_inline_test_order.in/moon.mod.json | 9 + .../test_cases/moon_new.in/lib/hello.mbt | 4 + .../test_cases/moon_new.in/lib/moon.pkg.json | 3 + .../test_cases/moon_new.in/main/main.mbt | 3 + .../test_cases/moon_new.in/main/moon.pkg.json | 6 + .../test_cases/moon_new.in/moon.mod.json | 3 + .../moon_new_and_watch/lib/hello.mbt | 4 + .../moon_new_and_watch/lib/moon.pkg.json | 3 + .../moon_new_and_watch/main/main.mbt | 3 + .../moon_new_and_watch/main/moon.pkg.json | 6 + .../moon_new_and_watch/moon.mod.json | 3 + .../test_cases/moon_new_exist.in/.gitkeep | 0 .../tests/test_cases/moon_new_new.in/.gitkeep | 0 .../test_cases/moon_new_snapshot.in/.gitkeep | 0 .../moon_run_with_cli_args.in/main/main.mbt | 89 + .../test_cases/moon_test.in/lib/hello.mbt | 4 + .../moon_test.in/lib/hello_wbtest.mbt | 5 + .../test_cases/moon_test.in/lib/moon.pkg.json | 3 + .../test_cases/moon_test.in/lib2/hello.mbt | 4 + .../moon_test.in/lib2/hello_wbtest.mbt | 5 + .../moon_test.in/lib2/moon.pkg.json | 3 + .../moon_test.in/lib2/nested/lib.mbt | 3 + .../moon_test.in/lib2/nested/lib_wbtest.mbt | 11 + .../moon_test.in/lib2/nested/moon.pkg.json | 8 + .../test_cases/moon_test.in/lib3/hello.mbt | 4 + .../moon_test.in/lib3/hello_wbtest.mbt | 5 + .../moon_test.in/lib3/moon.pkg.json | 3 + .../test_cases/moon_test.in/lib4/hello.mbt | 4 + .../moon_test.in/lib4/hello_wbtest.mbt | 5 + .../moon_test.in/lib4/moon.pkg.json | 3 + .../moon_test.in/lib5/hello_wbtest.mbt | 29 + .../moon_test.in/lib5/moon.pkg.json | 3 + .../test_cases/moon_test.in/main/main.mbt | 3 + .../moon_test.in/main/moon.pkg.json | 6 + .../test_cases/moon_test.in/moon.mod.json | 3 + .../moon_test_hello_exec.in/.gitignore | 2 + .../moon_test_hello_exec.in/lib/hello.mbt | 3 + .../lib/hello_wbtest.mbt | 6 + .../moon_test_hello_exec.in/lib/moon.pkg.json | 1 + .../moon_test_hello_exec.in/main/main.mbt | 3 + .../main/main_wbtest.mbt | 3 + .../main/moon.pkg.json | 6 + .../moon_test_hello_exec.in/moon.mod.json | 4 + .../moon_test_hello_exec_fntest.in/.gitignore | 2 + .../lib/hello.mbt | 7 + .../lib/hello_wbtest.mbt | 3 + .../lib/moon.pkg.json | 1 + .../main/main.mbt | 3 + .../main/moon.pkg.json | 6 + .../moon.mod.json | 4 + .../moon_test_hello_lib.in/.gitignore | 2 + .../moon_test_hello_lib.in/lib/hello.mbt | 3 + .../lib/hello_wbtest.mbt | 5 + .../moon_test_hello_lib.in/lib/moon.pkg.json | 1 + .../moon_test_hello_lib.in/moon.mod.json | 4 + .../moon_test_hello_lib.in/moon.pkg.json | 5 + .../test_cases/moon_test_hello_lib.in/top.mbt | 3 + .../main/main.mbt | 3 + .../main/moon.pkg.json | 4 + .../moon.mod.json | 3 + .../moon_test_succ.in/lib/hello.mbt | 4 + .../moon_test_succ.in/lib/hello_wbtest.mbt | 5 + .../moon_test_succ.in/lib/moon.pkg.json | 3 + .../moon_test_succ.in/lib2/hello.mbt | 4 + .../moon_test_succ.in/lib2/hello_wbtest.mbt | 5 + .../moon_test_succ.in/lib2/moon.pkg.json | 3 + .../moon_test_succ.in/lib2/nested/lib.mbt | 4 + .../lib2/nested/lib_wbtest.mbt | 11 + .../lib2/nested/moon.pkg.json | 5 + .../moon_test_succ.in/lib3/hello.mbt | 4 + .../moon_test_succ.in/lib3/hello_wbtest.mbt | 5 + .../moon_test_succ.in/lib3/moon.pkg.json | 3 + .../moon_test_succ.in/lib4/hello.mbt | 4 + .../moon_test_succ.in/lib4/hello_wbtest.mbt | 5 + .../moon_test_succ.in/lib4/moon.pkg.json | 3 + .../moon_test_succ.in/main/main.mbt | 3 + .../moon_test_succ.in/main/moon.pkg.json | 6 + .../moon_test_succ.in/moon.mod.json | 3 + .../moon_test_with_local_dep.in/.gitignore | 2 + .../moon_test_with_local_dep.in/lib/hello.mbt | 3 + .../lib/hello_wbtest.mbt | 1 + .../lib/moon.pkg.json | 1 + .../moon_test_with_local_dep.in/main/main.mbt | 3 + .../main/moon.pkg.json | 7 + .../mods/lijunchen/mooncake/lib/hello.mbt | 3 + .../lijunchen/mooncake/lib/hello_wbtest.mbt | 5 + .../mods/lijunchen/mooncake/lib/moon.pkg.json | 1 + .../mods/lijunchen/mooncake/moon.mod.json | 4 + .../mods/lijunchen/mooncake/moon.pkg.json | 5 + .../mods/lijunchen/mooncake/top.mbt | 3 + .../moon_test_with_local_dep.in/moon.mod.json | 8 + .../multidimensional_arrays.in/README.md | 3 + .../multidimensional_arrays.in/lib/arrays.mbt | 40 + .../lib/moon.pkg.json | 3 + .../multidimensional_arrays.in/main/main.mbt | 5 + .../main/moon.pkg.json | 6 + .../multidimensional_arrays.in/moon.mod.json | 3 + .../tests/test_cases/need_link.in/.gitignore | 2 + .../tests/test_cases/need_link.in/README.md | 1 + .../test_cases/need_link.in/lib/hello.mbt | 3 + .../need_link.in/lib/hello_wbtest.mbt | 5 + .../test_cases/need_link.in/lib/moon.pkg.json | 3 + .../test_cases/need_link.in/main/main.mbt | 3 + .../need_link.in/main/moon.pkg.json | 6 + .../test_cases/need_link.in/moon.mod.json | 9 + .../test_cases/no_block_params.in/.gitignore | 2 + .../test_cases/no_block_params.in/README.md | 1 + .../no_block_params.in/lib/hello.mbt | 3 + .../no_block_params.in/lib/hello_wbtest.mbt | 5 + .../no_block_params.in/lib/moon.pkg.json | 1 + .../no_block_params.in/main/main.mbt | 3 + .../no_block_params.in/main/moon.pkg.json | 18 + .../no_block_params.in/moon.mod.json | 9 + .../only_update_expect.in/.gitignore | 2 + .../only_update_expect.in/README.md | 1 + .../only_update_expect.in/lib/hello.mbt | 3 + .../only_update_expect.in/lib/moon.pkg.json | 1 + .../only_update_expect.in/main/main.mbt | 3 + .../only_update_expect.in/main/moon.pkg.json | 6 + .../only_update_expect.in/moon.mod.json | 9 + .../test_cases/output-format.in/lib/hello.mbt | 4 + .../output-format.in/lib/moon.pkg.json | 1 + .../test_cases/output-format.in/main/main.mbt | 3 + .../output-format.in/main/moon.pkg.json | 6 + .../test_cases/output-format.in/moon.mod.json | 3 + .../test_cases/palindrome_string.in/README.md | 3 + .../palindrome_string.in/lib/moon.pkg.json | 3 + .../palindrome_string.in/lib/str_iter.mbt | 18 + .../palindrome_string.in/main/main.mbt | 12 + .../palindrome_string.in/main/moon.pkg.json | 6 + .../palindrome_string.in/moon.mod.json | 3 + .../moon/tests/test_cases/panic.in/.gitignore | 2 + .../moon/tests/test_cases/panic.in/README.md | 1 + .../tests/test_cases/panic.in/lib/hello.mbt | 3 + .../test_cases/panic.in/lib/hello_wbtest.mbt | 9 + .../test_cases/panic.in/lib/moon.pkg.json | 1 + .../tests/test_cases/panic.in/main/main.mbt | 3 + .../test_cases/panic.in/main/moon.pkg.json | 6 + .../tests/test_cases/panic.in/moon.mod.json | 9 + .../render_no_location.in/lib/hello.mbt | 4 + .../render_no_location.in/lib/moon.pkg.json | 3 + .../render_no_location.in/main/main.mbt | 0 .../render_no_location.in/main/moon.pkg.json | 6 + .../render_no_location.in/moon.mod.json | 3 + .../run_single_mbt_file.in/a/b/c/.gitkeep | 0 .../run_single_mbt_file.in/a/b/single.mbt | 3 + .../test_cases/simple-pkg-A-001.in/A/lib.mbt | 3 + .../simple-pkg-A-001.in/A/moon.pkg.json | 3 + .../simple-pkg-A-001.in/main/main.mbt | 4 + .../simple-pkg-A-001.in/main/moon.pkg.json | 6 + .../simple-pkg-A-001.in/moon.mod.json | 3 + .../test_cases/simple-pkg-A-002.in/A/lib.mbt | 3 + .../simple-pkg-A-002.in/A/moon.pkg.json | 3 + .../simple-pkg-A-002.in/main/main.mbt | 4 + .../simple-pkg-A-002.in/main/moon.pkg.json | 6 + .../simple-pkg-A-002.in/moon.mod.json | 3 + .../test_cases/simple-pkg-A-003.in/A/lib.mbt | 3 + .../simple-pkg-A-003.in/A/moon.pkg.json | 3 + .../simple-pkg-A-003.in/main/main.mbt | 4 + .../simple-pkg-A-003.in/main/moon.pkg.json | 6 + .../simple-pkg-A-003.in/moon.mod.json | 3 + .../simple-pkg-A-004.in/lib/A/lib.mbt | 3 + .../simple-pkg-A-004.in/lib/A/moon.pkg.json | 3 + .../simple-pkg-A-004.in/main/main.mbt | 4 + .../simple-pkg-A-004.in/main/moon.pkg.json | 6 + .../simple-pkg-A-004.in/moon.mod.json | 3 + .../simple-pkg-A-005.in/lib/A/lib.mbt | 3 + .../simple-pkg-A-005.in/lib/A/moon.pkg.json | 3 + .../simple-pkg-A-005.in/main/main.mbt | 4 + .../simple-pkg-A-005.in/main/moon.pkg.json | 6 + .../simple-pkg-A-005.in/moon.mod.json | 3 + .../simple-pkg-A-006.in/main/main.mbt | 3 + .../simple-pkg-A-006.in/main/moon.pkg.json | 3 + .../simple-pkg-A-006.in/moon.mod.json | 3 + .../test_cases/simple-pkg-AB-001.in/A/lib.mbt | 3 + .../simple-pkg-AB-001.in/A/moon.pkg.json | 3 + .../test_cases/simple-pkg-AB-001.in/B/lib.mbt | 3 + .../simple-pkg-AB-001.in/B/moon.pkg.json | 3 + .../simple-pkg-AB-001.in/main/main.mbt | 5 + .../simple-pkg-AB-001.in/main/moon.pkg.json | 7 + .../simple-pkg-AB-001.in/moon.mod.json | 3 + .../test_cases/simple-pkg-AB-002.in/A/lib.mbt | 3 + .../simple-pkg-AB-002.in/A/moon.pkg.json | 3 + .../test_cases/simple-pkg-AB-002.in/B/lib.mbt | 4 + .../simple-pkg-AB-002.in/B/moon.pkg.json | 5 + .../simple-pkg-AB-002.in/main/main.mbt | 4 + .../simple-pkg-AB-002.in/main/moon.pkg.json | 6 + .../simple-pkg-AB-002.in/moon.mod.json | 3 + .../test_cases/simple-pkg-AB-003.in/A/lib.mbt | 3 + .../simple-pkg-AB-003.in/A/moon.pkg.json | 3 + .../test_cases/simple-pkg-AB-003.in/B/lib.mbt | 3 + .../simple-pkg-AB-003.in/B/moon.pkg.json | 3 + .../simple-pkg-AB-003.in/main/main.mbt | 5 + .../simple-pkg-AB-003.in/main/moon.pkg.json | 7 + .../simple-pkg-AB-003.in/moon.mod.json | 3 + .../test_cases/simple-pkg-AB-004.in/A/lib.mbt | 3 + .../simple-pkg-AB-004.in/A/moon.pkg.json | 3 + .../test_cases/simple-pkg-AB-004.in/B/lib.mbt | 4 + .../simple-pkg-AB-004.in/B/moon.pkg.json | 5 + .../simple-pkg-AB-004.in/main/main.mbt | 4 + .../simple-pkg-AB-004.in/main/moon.pkg.json | 6 + .../simple-pkg-AB-004.in/moon.mod.json | 3 + .../target-backend.in/lib/hello.mbt | 4 + .../target-backend.in/lib/moon.pkg.json | 1 + .../target-backend.in/main/main.mbt | 3 + .../target-backend.in/main/moon.pkg.json | 6 + .../target-backend.in/moon.mod.json | 3 + .../test_cases/test_deny_warn.in/.gitignore | 2 + .../test_cases/test_deny_warn.in/README.md | 1 + .../test_deny_warn.in/lib/hello.mbt | 23 + .../test_deny_warn.in/lib/moon.pkg.json | 1 + .../test_deny_warn.in/main/main.mbt | 3 + .../test_deny_warn.in/main/moon.pkg.json | 6 + .../test_deny_warn.in/moon.mod.json | 9 + .../test_error_report.in/.gitignore | 2 + .../test_error_report.in/lib/hello.mbt | 3 + .../test_error_report.in/lib/hello_wbtest.mbt | 5 + .../test_error_report.in/lib/moon.pkg.json | 1 + .../test_error_report.in/main/main.mbt | 3 + .../test_error_report.in/main/moon.pkg.json | 7 + .../test_error_report.in/moon.mod.json | 4 + .../test_cases/test_filter.in/A/hello.mbt | 11 + .../test_filter.in/A/hello_wbtest.mbt | 11 + .../test_cases/test_filter.in/A/moon.pkg.json | 1 + .../test_cases/test_filter.in/A/test.mbt | 7 + .../test_cases/test_filter.in/lib/hello.mbt | 7 + .../test_filter.in/lib/hello_wbtest.mbt | 7 + .../test_filter.in/lib/moon.pkg.json | 1 + .../test_cases/test_filter.in/lib2/lib.mbt | 14 + .../test_filter.in/lib2/moon.pkg.json | 1 + .../test_cases/test_filter.in/main/main.mbt | 3 + .../test_filter.in/main/moon.pkg.json | 6 + .../test_cases/test_filter.in/moon.mod.json | 9 + .../test_filter_pkg_with_deps.in/lib/lib.mbt | 3 + .../lib/moon.pkg.json | 5 + .../test_filter_pkg_with_deps.in/lib1/lib.mbt | 10 + .../lib1/moon.pkg.json | 6 + .../test_filter_pkg_with_deps.in/lib2/lib.mbt | 9 + .../lib2/moon.pkg.json | 5 + .../test_filter_pkg_with_deps.in/lib3/lib.mbt | 9 + .../lib3/moon.pkg.json | 5 + .../test_filter_pkg_with_deps.in/lib4/lib.mbt | 7 + .../lib4/moon.pkg.json | 1 + .../main/main.mbt | 3 + .../main/moon.pkg.json | 6 + .../moon.mod.json | 9 + .../lib/_wbtest.mbt | 3 + .../lib/lib.mbt | 4 + .../lib/moon.pkg.json | 9 + .../lib1/lib.mbt | 9 + .../lib1/moon.pkg.json | 5 + .../lib2/lib.mbt | 9 + .../lib2/moon.pkg.json | 5 + .../lib3/_wbtest.mbt | 3 + .../lib3/lib.mbt | 13 + .../lib3/moon.pkg.json | 11 + .../lib4/_wbtest.mbt | 7 + .../lib4/lib.mbt | 8 + .../lib4/moon.pkg.json | 8 + .../lib5/lib.mbt | 7 + .../lib5/moon.pkg.json | 1 + .../lib6/lib.mbt | 7 + .../lib6/moon.pkg.json | 1 + .../lib7/_wbtest.mbt | 3 + .../lib7/lib.mbt | 7 + .../lib7/moon.pkg.json | 5 + .../main/main.mbt | 3 + .../main/moon.pkg.json | 6 + .../moon.mod.json | 11 + ...ilter_package_with_test_imports.drawio.png | Bin 0 -> 40274 bytes .../tests/test_cases/test_import/.gitignore | 2 + .../tests/test_cases/test_import/README.md | 11 + .../moon/tests/test_cases/test_import/a/a.mbt | 7 + .../test_cases/test_import/a/a_wbtest.mbt | 3 + .../test_cases/test_import/a/moon.pkg.json | 8 + .../moon/tests/test_cases/test_import/b/b.mbt | 3 + .../test_cases/test_import/b/moon.pkg.json | 5 + .../moon/tests/test_cases/test_import/c/c.mbt | 3 + .../test_cases/test_import/c/moon.pkg.json | 5 + .../test_cases/test_import/main/main.mbt | 4 + .../test_cases/test_import/main/moon.pkg.json | 7 + .../test_cases/test_import/moon.mod.json | 9 + .../test_cases/test_import/s/moon.pkg.json | 1 + .../moon/tests/test_cases/test_import/s/t.mbt | 3 + .../test_cases/test_import/t/moon.pkg.json | 1 + .../moon/tests/test_cases/test_import/t/t.mbt | 3 + .../test_many_targets.in/.gitignore | 2 + .../test_many_targets.in/lib/hello.mbt | 3 + .../test_many_targets.in/lib/moon.pkg.json | 1 + .../test_many_targets.in/link/hello.mbt | 3 + .../test_many_targets.in/link/moon.pkg.json | 3 + .../test_many_targets.in/moon.mod.json | 9 + .../.gitignore | 2 + .../lib/moon.pkg.json | 1 + .../lib/x.js.mbt | 3 + .../lib/x.wasm-gc.mbt | 3 + .../lib/x.wasm.mbt | 3 + .../moon.mod.json | 9 + .../.gitignore | 2 + .../lib/moon.pkg.json | 1 + .../lib/x.js.mbt | 3 + .../lib/x.wasm-gc.mbt | 3 + .../lib/x.wasm.mbt | 3 + .../moon.mod.json | 9 + .../test_cases/test_multi_process/.gitignore | 2 + .../test_cases/test_multi_process/README.md | 1 + .../test_multi_process/lib/hello.mbt | 13 + .../test_multi_process/lib/moon.pkg.json | 1 + .../test_multi_process/main/main.mbt | 3 + .../test_multi_process/main/moon.pkg.json | 6 + .../test_multi_process/moon.mod.json | 9 + .../test_cases/test_release.in/lib/hello.mbt | 7 + .../test_release.in/lib/hello_wbtest.mbt | 7 + .../test_release.in/lib/moon.pkg.json | 1 + .../test_cases/test_release.in/main/main.mbt | 3 + .../test_release.in/main/moon.pkg.json | 6 + .../test_cases/test_release.in/moon.mod.json | 9 + .../test_cases/third_party.in/.gitignore | 2 + .../tests/test_cases/third_party.in/README.md | 1 + .../third_party.in/lib/moon.pkg.json | 5 + .../test_cases/third_party.in/lib/test.mbt | 8 + .../test_cases/third_party.in/main/main.mbt | 3 + .../third_party.in/main/moon.pkg.json | 6 + .../test_cases/third_party.in/moon.mod.json | 12 + .../test_cases/unicode_demo.in/README.md | 3 + .../test_cases/unicode_demo.in/main/main.mbt | 4 + .../unicode_demo.in/main/moon.pkg.json | 4 + .../test_cases/unicode_demo.in/moon.mod.json | 3 + .../test_cases/validate_import.in/.gitignore | 2 + .../test_cases/validate_import.in/README.md | 1 + .../validate_import.in/lib/hello.mbt | 3 + .../validate_import.in/lib/hello_wbtest.mbt | 5 + .../validate_import.in/lib/moon.pkg.json | 1 + .../validate_import.in/main/main.mbt | 3 + .../validate_import.in/main/moon.pkg.json | 10 + .../validate_import.in/moon.mod.json | 9 + .../tests/test_cases/warn_list.in/.gitignore | 2 + .../tests/test_cases/warn_list.in/README.md | 1 + .../test_cases/warn_list.in/lib/hello.mbt | 4 + .../test_cases/warn_list.in/lib/moon.pkg.json | 3 + .../test_cases/warn_list.in/lib1/hello.mbt | 7 + .../warn_list.in/lib1/moon.pkg.json | 3 + .../test_cases/warn_list.in/main/main.mbt | 7 + .../warn_list.in/main/moon.pkg.json | 8 + .../test_cases/warn_list.in/moon.mod.json | 9 + .../test_cases/whitespace_test.in/.gitignore | 2 + .../test_cases/whitespace_test.in/README.md | 1 + .../whitespace_test.in/main exe/main.mbt | 3 + .../whitespace_test.in/main exe/moon.pkg.json | 9 + .../whitespace_test.in/main lib/hello.mbt | 3 + .../main lib/hello_wbtest.mbt | 5 + .../whitespace_test.in/main lib/moon.pkg.json | 1 + .../whitespace_test.in/moon.mod.json | 9 + crates/moonbuild/Cargo.toml | 47 + crates/moonbuild/src/README.md | 28 + crates/moonbuild/src/bench.rs | 173 + crates/moonbuild/src/build.rs | 73 + crates/moonbuild/src/bundle.rs | 23 + crates/moonbuild/src/check/mod.rs | 2 + crates/moonbuild/src/check/normal.rs | 75 + crates/moonbuild/src/check/watch.rs | 137 + crates/moonbuild/src/doc_http.rs | 76 + crates/moonbuild/src/dry_run.rs | 100 + crates/moonbuild/src/entry.rs | 461 ++ crates/moonbuild/src/expect.rs | 592 ++ crates/moonbuild/src/fmt.rs | 279 + crates/moonbuild/src/gen/cmd_builder.rs | 93 + crates/moonbuild/src/gen/gen_build.rs | 487 ++ crates/moonbuild/src/gen/gen_bundle.rs | 300 + crates/moonbuild/src/gen/gen_check.rs | 344 ++ crates/moonbuild/src/gen/gen_runtest.rs | 854 +++ crates/moonbuild/src/gen/mod.rs | 46 + crates/moonbuild/src/gen/util.rs | 92 + crates/moonbuild/src/lib.rs | 59 + crates/moonbuild/src/new.rs | 219 + crates/moonbuild/src/runtest.rs | 87 + crates/moonbuild/src/section_capture.rs | 164 + crates/moonbuild/src/upgrade.rs | 346 ++ crates/moonbuild/template/apache-2.0.txt | 202 + .../template/test_driver_template.mbt | 68 + crates/mooncake/Cargo.toml | 33 + crates/mooncake/src/dep_dir.rs | 429 ++ crates/mooncake/src/lib.rs | 5 + crates/mooncake/src/pkg/add.rs | 103 + crates/mooncake/src/pkg/install.rs | 36 + crates/mooncake/src/pkg/mod.rs | 5 + crates/mooncake/src/pkg/remove.rs | 42 + crates/mooncake/src/pkg/sync.rs | 22 + crates/mooncake/src/pkg/tree.rs | 57 + crates/mooncake/src/registry.rs | 121 + crates/mooncake/src/registry/mock.rs | 184 + crates/mooncake/src/registry/online.rs | 242 + crates/mooncake/src/resolver.rs | 124 + crates/mooncake/src/resolver/env.rs | 89 + crates/mooncake/src/resolver/mvs.rs | 1706 ++++++ crates/mooncake/src/update.rs | 97 + crates/moonutil/Cargo.toml | 33 + crates/moonutil/build.rs | 16 + crates/moonutil/src/cli.rs | 34 + crates/moonutil/src/common.rs | 603 ++ crates/moonutil/src/dependency.rs | 119 + crates/moonutil/src/dirs.rs | 272 + crates/moonutil/src/graph.rs | 41 + crates/moonutil/src/lib.rs | 14 + crates/moonutil/src/module.rs | 398 ++ crates/moonutil/src/moon_dir.rs | 131 + crates/moonutil/src/mooncake_bin.rs | 45 + crates/moonutil/src/mooncakes.rs | 435 ++ crates/moonutil/src/package.rs | 411 ++ crates/moonutil/src/path.rs | 221 + crates/moonutil/src/render.rs | 91 + crates/moonutil/src/scan.rs | 519 ++ crates/moonutil/src/version.rs | 25 + docs/dev/README.md | 170 + licenserc.toml | 11 + xtask/Cargo.toml | 12 + xtask/src/main.rs | 47 + 880 files changed, 27823 insertions(+) create mode 100644 .cargo/config.toml create mode 100644 .github/workflows/cd.yml create mode 100644 .github/workflows/check-merge-commit.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/test-on-main.yml create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 README.md create mode 100644 crates/moon/Cargo.toml create mode 100644 crates/moon/src/cli.rs create mode 100644 crates/moon/src/cli/build.rs create mode 100644 crates/moon/src/cli/build_matrix.rs create mode 100644 crates/moon/src/cli/bundle.rs create mode 100644 crates/moon/src/cli/check.rs create mode 100644 crates/moon/src/cli/clean.rs create mode 100644 crates/moon/src/cli/coverage.rs create mode 100644 crates/moon/src/cli/deps.rs create mode 100644 crates/moon/src/cli/doc.rs create mode 100644 crates/moon/src/cli/fmt.rs create mode 100644 crates/moon/src/cli/generate_test_driver.rs create mode 100644 crates/moon/src/cli/info.rs create mode 100644 crates/moon/src/cli/mooncake_adapter.rs create mode 100644 crates/moon/src/cli/new.rs create mode 100644 crates/moon/src/cli/run.rs create mode 100644 crates/moon/src/cli/test.rs create mode 100644 crates/moon/src/cli/update.rs create mode 100644 crates/moon/src/cli/upgrade.rs create mode 100644 crates/moon/src/cli/version.rs create mode 100644 crates/moon/src/main.rs create mode 100644 crates/moon/tests/mod.rs create mode 100644 crates/moon/tests/test_cases/alert_list.in/.gitignore create mode 100644 crates/moon/tests/test_cases/alert_list.in/README.md create mode 100644 crates/moon/tests/test_cases/alert_list.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/alert_list.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/alert_list.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/alert_list.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/alert_list.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/avl_tree.in/README.md create mode 100644 crates/moon/tests/test_cases/avl_tree.in/lib/avl.mbt create mode 100644 crates/moon/tests/test_cases/avl_tree.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/avl_tree.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/avl_tree.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/avl_tree.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/backend-flag.in/.gitignore create mode 100644 crates/moon/tests/test_cases/backend-flag.in/README.md create mode 100644 crates/moon/tests/test_cases/backend-flag.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/backend-flag.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/backend-flag.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/backend-flag.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/backend-flag.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/backend-flag.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/backend_config.in/.gitignore create mode 100644 crates/moon/tests/test_cases/backend_config.in/README.md create mode 100644 crates/moon/tests/test_cases/backend_config.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/backend_config.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/backend_config.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/backend_config.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/backend_config.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/backend_config.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/backtrace.in/.gitignore create mode 100644 crates/moon/tests/test_cases/backtrace.in/README.md create mode 100644 crates/moon/tests/test_cases/backtrace.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/backtrace.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/backtrace.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_0_0/main.mbt create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_0_0/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_0_1/main.mbt create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_0_1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_1_0/main.mbt create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_1_0/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_1_1/main.mbt create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_1_1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_0_0/main.mbt create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_0_0/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_0_1/main.mbt create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_0_1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_1_0/main.mbt create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_1_0/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_1_1/main.mbt create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_1_1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_0_0/main.mbt create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_0_0/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_0_1/main.mbt create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_0_1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_1_0/main.mbt create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_1_0/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_1_1/main.mbt create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_1_1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_0_0/main.mbt create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_0_0/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_0_1/main.mbt create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_0_1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_1_0/main.mbt create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_1_0/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_1_1/main.mbt create mode 100644 crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_1_1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/bench2_test.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/bench2_test.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/bench2_test.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/blackbox_failed_test.in/A/hello.mbt create mode 100644 crates/moon/tests/test_cases/blackbox_failed_test.in/A/hello_test.mbt create mode 100644 crates/moon/tests/test_cases/blackbox_failed_test.in/A/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/blackbox_failed_test.in/A/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/blackbox_failed_test.in/B/hello.mbt create mode 100644 crates/moon/tests/test_cases/blackbox_failed_test.in/B/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/blackbox_failed_test.in/C/hello.mbt create mode 100644 crates/moon/tests/test_cases/blackbox_failed_test.in/C/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/blackbox_failed_test.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/blackbox_failed_test.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/blackbox_failed_test.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/blackbox_success_test.in/A/hello.mbt create mode 100644 crates/moon/tests/test_cases/blackbox_success_test.in/A/hello_test.mbt create mode 100644 crates/moon/tests/test_cases/blackbox_success_test.in/A/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/blackbox_success_test.in/A/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/blackbox_success_test.in/B/hello.mbt create mode 100644 crates/moon/tests/test_cases/blackbox_success_test.in/B/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/blackbox_success_test.in/C/hello.mbt create mode 100644 crates/moon/tests/test_cases/blackbox_success_test.in/C/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/blackbox_success_test.in/D/hello.mbt create mode 100644 crates/moon/tests/test_cases/blackbox_success_test.in/D/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/blackbox_success_test.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/blackbox_success_test.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/blackbox_success_test.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/cakenew_test.in/.gitignore create mode 100644 crates/moon/tests/test_cases/cakenew_test.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/cakenew_test.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/cakenew_test.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/cakenew_test.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/cakenew_test.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/capture_abort_test.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/capture_abort_test.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/capture_abort_test.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/capture_abort_test.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/capture_abort_test.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/A/lib.mbt create mode 100644 crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/A/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/B/lib.mbt create mode 100644 crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/B/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/core_order.in/.gitignore create mode 100644 crates/moon/tests/test_cases/core_order.in/A/a.mbt create mode 100644 crates/moon/tests/test_cases/core_order.in/A/a_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/core_order.in/A/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/core_order.in/B/b.mbt create mode 100644 crates/moon/tests/test_cases/core_order.in/B/b_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/core_order.in/B/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/core_order.in/T/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/core_order.in/T/t.mbt create mode 100644 crates/moon/tests/test_cases/core_order.in/T/t_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/core_order.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/core_order.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/core_order.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/debug_flag_test.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/debug_flag_test.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/debug_flag_test.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/debug_flag_test.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/debug_flag_test.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/design.in/lib/list/lib.mbt create mode 100644 crates/moon/tests/test_cases/design.in/lib/list/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/design.in/lib/queue/lib.mbt create mode 100644 crates/moon/tests/test_cases/design.in/lib/queue/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/design.in/lib/stack/lib.mbt create mode 100644 crates/moon/tests/test_cases/design.in/lib/stack/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/design.in/lib/vec/lib.mbt create mode 100644 crates/moon/tests/test_cases/design.in/lib/vec/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/design.in/lib/vec/vec.mbt create mode 100644 crates/moon/tests/test_cases/design.in/main1/main.mbt create mode 100644 crates/moon/tests/test_cases/design.in/main1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/design.in/main2/main.mbt create mode 100644 crates/moon/tests/test_cases/design.in/main2/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/design.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-001.in/A/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-001.in/A/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-001.in/B/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-001.in/B/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-001.in/C/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-001.in/C/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-001.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-001.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-001.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/A/A0/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/A/A0/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/A/A1/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/A/A1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/A/A2/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/A/A2/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/A/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/A/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/B/B0/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/B/B0/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/B/B1/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/B/B1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/B/B2/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/B/B2/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/B/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/B/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/C/C0/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/C/C0/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/C/C1/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/C/C1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/C/C2/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/C/C2/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/C/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/C/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-002.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/A/A0/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/A/A0/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/A/A1/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/A/A1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/A/A2/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/A/A2/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/A/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/A/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/B/B0/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/B/B0/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/B/B1/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/B/B1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/B/B2/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/B/B2/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/B/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/B/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/C/C0/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/C/C0/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/C/C1/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/C/C1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/C/C2/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/C/C2/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/C/lib.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/C/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/diamond-pkg-003.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/docstring-demo.in/README.md create mode 100644 crates/moon/tests/test_cases/docstring-demo.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/docstring-demo.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/docstring-demo.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/docstring-demo.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/docstring-demo.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/dummy-core.in/0/lib.mbt create mode 100644 crates/moon/tests/test_cases/dummy-core.in/0/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/dummy-core.in/0/y.js.mbt create mode 100644 crates/moon/tests/test_cases/dummy-core.in/0/y.wasm-gc.mbt create mode 100644 crates/moon/tests/test_cases/dummy-core.in/0/y.wasm.mbt create mode 100644 crates/moon/tests/test_cases/dummy-core.in/0/y_wbtest.js.mbt create mode 100644 crates/moon/tests/test_cases/dummy-core.in/0/y_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/dummy-core.in/0/y_wbtest.wasm-gc.mbt create mode 100644 crates/moon/tests/test_cases/dummy-core.in/0/y_wbtest.wasm.mbt create mode 100644 crates/moon/tests/test_cases/dummy-core.in/1/lib.mbt create mode 100644 crates/moon/tests/test_cases/dummy-core.in/1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/dummy-core.in/1/x.js.mbt create mode 100644 crates/moon/tests/test_cases/dummy-core.in/1/x.wasm-gc.mbt create mode 100644 crates/moon/tests/test_cases/dummy-core.in/1/x.wasm.mbt create mode 100644 crates/moon/tests/test_cases/dummy-core.in/1/x_wbtest.wasm-gc.mbt create mode 100644 crates/moon/tests/test_cases/dummy-core.in/2/lib.mbt create mode 100644 crates/moon/tests/test_cases/dummy-core.in/2/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/dummy-core.in/char/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/dummy-core.in/coverage/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/dummy-core.in/iter/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/dummy-core.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/error_duplicate_alias.in/.gitignore create mode 100644 crates/moon/tests/test_cases/error_duplicate_alias.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/error_duplicate_alias.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/error_duplicate_alias.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/error_duplicate_alias.in/lib2/hello.mbt create mode 100644 crates/moon/tests/test_cases/error_duplicate_alias.in/lib2/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/error_duplicate_alias.in/lib2/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/error_duplicate_alias.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/error_duplicate_alias.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/error_duplicate_alias.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/expect_test.in/.gitignore create mode 100644 crates/moon/tests/test_cases/expect_test.in/README.md create mode 100644 crates/moon/tests/test_cases/expect_test.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/expect_test.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/expect_test.in/lib/issue_188_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/expect_test.in/lib/issue_209.mbt create mode 100644 crates/moon/tests/test_cases/expect_test.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/expect_test.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/expect_test.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/expect_test.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/export_memory.in/.gitignore create mode 100644 crates/moon/tests/test_cases/export_memory.in/README.md create mode 100644 crates/moon/tests/test_cases/export_memory.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/export_memory.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/export_memory.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/export_memory.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/export_memory.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/export_memory.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/extra_flags.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/extra_flags.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/extra_flags.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/extra_flags.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/extra_flags.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import001/.gitignore create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import001/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import001/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import001/main/main.mbt create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import001/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import001/moon.mod.json create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import002/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import002/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import002/main/main.mbt create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import002/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import002/moon.mod.json create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import003/.gitignore create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import003/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import003/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import003/lib2/hello.mbt create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import003/lib2/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import003/main/main.mbt create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import003/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import003/moon.mod.json create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import004/.gitignore create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import004/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import004/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import004/lib2/hello.mbt create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import004/lib2/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import004/lib3/hello.mbt create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import004/lib3/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import004/lib4/hello.mbt create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import004/lib4/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import004/main/main.mbt create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import004/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/fancy_import.in/import004/moon.mod.json create mode 100644 crates/moon/tests/test_cases/hello.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/hello.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/hello.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/import_memory.in/.gitignore create mode 100644 crates/moon/tests/test_cases/import_memory.in/README.md create mode 100644 crates/moon/tests/test_cases/import_memory.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/import_memory.in/lib/hello_test.mbt create mode 100644 crates/moon/tests/test_cases/import_memory.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/import_memory.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/import_memory.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/import_memory.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/internal_package.in/.gitignore create mode 100644 crates/moon/tests/test_cases/internal_package.in/README.md create mode 100644 crates/moon/tests/test_cases/internal_package.in/lib/a/lib.mbt create mode 100644 crates/moon/tests/test_cases/internal_package.in/lib/a/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/internal_package.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/internal_package.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/internal_package.in/lib/internal/b/lib.mbt create mode 100644 crates/moon/tests/test_cases/internal_package.in/lib/internal/b/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/internal_package.in/lib/internal/lib.mbt create mode 100644 crates/moon/tests/test_cases/internal_package.in/lib/internal/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/internal_package.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/internal_package.in/lib2/lib.mbt create mode 100644 crates/moon/tests/test_cases/internal_package.in/lib2/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/internal_package.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/internal_package.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/internal_package.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/js_format.in/.gitignore create mode 100644 crates/moon/tests/test_cases/js_format.in/README.md create mode 100644 crates/moon/tests/test_cases/js_format.in/lib0/hello.mbt create mode 100644 crates/moon/tests/test_cases/js_format.in/lib0/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/js_format.in/lib0/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/js_format.in/lib1/hello.mbt create mode 100644 crates/moon/tests/test_cases/js_format.in/lib1/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/js_format.in/lib1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/js_format.in/lib2/hello.mbt create mode 100644 crates/moon/tests/test_cases/js_format.in/lib2/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/js_format.in/lib2/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/js_format.in/lib3/hello.mbt create mode 100644 crates/moon/tests/test_cases/js_format.in/lib3/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/js_format.in/lib3/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/js_format.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/mbti.in/.gitignore create mode 100644 crates/moon/tests/test_cases/mbti.in/README.md create mode 100644 crates/moon/tests/test_cases/mbti.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/mbti.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/mbti.in/lib/lib.mbti create mode 100644 crates/moon/tests/test_cases/mbti.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/mbti.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/mbti.in/main/main.mbti create mode 100644 crates/moon/tests/test_cases/mbti.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/mbti.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/mod.rs create mode 100644 crates/moon/tests/test_cases/moo_run_with_cli_args.in/.gitignore create mode 100644 crates/moon/tests/test_cases/moo_run_with_cli_args.in/README.md create mode 100644 crates/moon/tests/test_cases/moo_run_with_cli_args.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/moo_run_with_cli_args.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moo_run_with_cli_args.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/moon_bundle.in/A/lib.mbt create mode 100644 crates/moon/tests/test_cases/moon_bundle.in/A/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_bundle.in/B/lib.mbt create mode 100644 crates/moon/tests/test_cases/moon_bundle.in/B/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_bundle.in/C/lib.mbt create mode 100644 crates/moon/tests/test_cases/moon_bundle.in/C/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_bundle.in/Orphan/lib.mbt create mode 100644 crates/moon/tests/test_cases/moon_bundle.in/Orphan/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_bundle.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/moon_commands.in/lib/list/lib.mbt create mode 100644 crates/moon/tests/test_cases/moon_commands.in/lib/list/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_commands.in/lib/queue/lib.mbt create mode 100644 crates/moon/tests/test_cases/moon_commands.in/lib/queue/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_commands.in/lib/stack/lib.mbt create mode 100644 crates/moon/tests/test_cases/moon_commands.in/lib/stack/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_commands.in/lib/vec/lib.mbt create mode 100644 crates/moon/tests/test_cases/moon_commands.in/lib/vec/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_commands.in/main1/main.mbt create mode 100644 crates/moon/tests/test_cases/moon_commands.in/main1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_commands.in/main2/main.mbt create mode 100644 crates/moon/tests/test_cases/moon_commands.in/main2/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_commands.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/moon_fmt.in/.gitignore create mode 100644 crates/moon/tests/test_cases/moon_fmt.in/README.md create mode 100644 crates/moon/tests/test_cases/moon_fmt.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_fmt.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_fmt.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_fmt.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/moon_fmt.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_fmt.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/moon_inline_test_001.in/.gitignore create mode 100644 crates/moon/tests/test_cases/moon_inline_test_001.in/README.md create mode 100644 crates/moon/tests/test_cases/moon_inline_test_001.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_inline_test_001.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_inline_test_001.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_inline_test_001.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/moon_inline_test_001.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_inline_test_001.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/moon_inline_test_002.in/.gitignore create mode 100644 crates/moon/tests/test_cases/moon_inline_test_002.in/README.md create mode 100644 crates/moon/tests/test_cases/moon_inline_test_002.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_inline_test_002.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_inline_test_002.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_inline_test_002.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/moon_inline_test_002.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_inline_test_002.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/moon_inline_test_003.in/.gitignore create mode 100644 crates/moon/tests/test_cases/moon_inline_test_003.in/README.md create mode 100644 crates/moon/tests/test_cases/moon_inline_test_003.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_inline_test_003.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_inline_test_003.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_inline_test_003.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/moon_inline_test_003.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_inline_test_003.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/moon_inline_test_004.in/.gitignore create mode 100644 crates/moon/tests/test_cases/moon_inline_test_004.in/README.md create mode 100644 crates/moon/tests/test_cases/moon_inline_test_004.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_inline_test_004.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_inline_test_004.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_inline_test_004.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/moon_inline_test_004.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_inline_test_004.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/moon_inline_test_order.in/.gitignore create mode 100644 crates/moon/tests/test_cases/moon_inline_test_order.in/A/A_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_inline_test_order.in/A/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_inline_test_order.in/A/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_inline_test_order.in/B/B_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_inline_test_order.in/B/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_inline_test_order.in/B/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_inline_test_order.in/README.md create mode 100644 crates/moon/tests/test_cases/moon_inline_test_order.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/moon_inline_test_order.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_inline_test_order.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/moon_new.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_new.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_new.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/moon_new.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_new.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/moon_new_and_watch/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_new_and_watch/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_new_and_watch/main/main.mbt create mode 100644 crates/moon/tests/test_cases/moon_new_and_watch/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_new_and_watch/moon.mod.json create mode 100644 crates/moon/tests/test_cases/moon_new_exist.in/.gitkeep create mode 100644 crates/moon/tests/test_cases/moon_new_new.in/.gitkeep create mode 100644 crates/moon/tests/test_cases/moon_new_snapshot.in/.gitkeep create mode 100644 crates/moon/tests/test_cases/moon_run_with_cli_args.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/moon_test.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_test.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_test.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test.in/lib2/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_test.in/lib2/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_test.in/lib2/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test.in/lib2/nested/lib.mbt create mode 100644 crates/moon/tests/test_cases/moon_test.in/lib2/nested/lib_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_test.in/lib2/nested/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test.in/lib3/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_test.in/lib3/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_test.in/lib3/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test.in/lib4/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_test.in/lib4/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_test.in/lib4/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test.in/lib5/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_test.in/lib5/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/moon_test.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/moon_test_hello_exec.in/.gitignore create mode 100644 crates/moon/tests/test_cases/moon_test_hello_exec.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_hello_exec.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_hello_exec.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test_hello_exec.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_hello_exec.in/main/main_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_hello_exec.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test_hello_exec.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/.gitignore create mode 100644 crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/moon_test_hello_lib.in/.gitignore create mode 100644 crates/moon/tests/test_cases/moon_test_hello_lib.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_hello_lib.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_hello_lib.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test_hello_lib.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/moon_test_hello_lib.in/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test_hello_lib.in/top.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_no_entry_warning.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_no_entry_warning.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test_no_entry_warning.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/moon_test_succ.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_succ.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_succ.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test_succ.in/lib2/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_succ.in/lib2/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_succ.in/lib2/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test_succ.in/lib2/nested/lib.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_succ.in/lib2/nested/lib_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_succ.in/lib2/nested/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test_succ.in/lib3/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_succ.in/lib3/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_succ.in/lib3/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test_succ.in/lib4/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_succ.in/lib4/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_succ.in/lib4/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test_succ.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_succ.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test_succ.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/moon_test_with_local_dep.in/.gitignore create mode 100644 crates/moon/tests/test_cases/moon_test_with_local_dep.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_with_local_dep.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_with_local_dep.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test_with_local_dep.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_with_local_dep.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/moon.mod.json create mode 100644 crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/top.mbt create mode 100644 crates/moon/tests/test_cases/moon_test_with_local_dep.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/multidimensional_arrays.in/README.md create mode 100644 crates/moon/tests/test_cases/multidimensional_arrays.in/lib/arrays.mbt create mode 100644 crates/moon/tests/test_cases/multidimensional_arrays.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/multidimensional_arrays.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/multidimensional_arrays.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/multidimensional_arrays.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/need_link.in/.gitignore create mode 100644 crates/moon/tests/test_cases/need_link.in/README.md create mode 100644 crates/moon/tests/test_cases/need_link.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/need_link.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/need_link.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/need_link.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/need_link.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/need_link.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/no_block_params.in/.gitignore create mode 100644 crates/moon/tests/test_cases/no_block_params.in/README.md create mode 100644 crates/moon/tests/test_cases/no_block_params.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/no_block_params.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/no_block_params.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/no_block_params.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/no_block_params.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/no_block_params.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/only_update_expect.in/.gitignore create mode 100644 crates/moon/tests/test_cases/only_update_expect.in/README.md create mode 100644 crates/moon/tests/test_cases/only_update_expect.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/only_update_expect.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/only_update_expect.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/only_update_expect.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/only_update_expect.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/output-format.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/output-format.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/output-format.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/output-format.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/output-format.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/palindrome_string.in/README.md create mode 100644 crates/moon/tests/test_cases/palindrome_string.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/palindrome_string.in/lib/str_iter.mbt create mode 100644 crates/moon/tests/test_cases/palindrome_string.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/palindrome_string.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/palindrome_string.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/panic.in/.gitignore create mode 100644 crates/moon/tests/test_cases/panic.in/README.md create mode 100644 crates/moon/tests/test_cases/panic.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/panic.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/panic.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/panic.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/panic.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/panic.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/render_no_location.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/render_no_location.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/render_no_location.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/render_no_location.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/render_no_location.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/run_single_mbt_file.in/a/b/c/.gitkeep create mode 100644 crates/moon/tests/test_cases/run_single_mbt_file.in/a/b/single.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-001.in/A/lib.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-001.in/A/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-001.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-001.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-001.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-002.in/A/lib.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-002.in/A/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-002.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-002.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-002.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-003.in/A/lib.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-003.in/A/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-003.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-003.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-003.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-004.in/lib/A/lib.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-004.in/lib/A/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-004.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-004.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-004.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-005.in/lib/A/lib.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-005.in/lib/A/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-005.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-005.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-005.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-006.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-006.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-A-006.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-001.in/A/lib.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-001.in/A/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-001.in/B/lib.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-001.in/B/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-001.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-001.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-001.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-002.in/A/lib.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-002.in/A/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-002.in/B/lib.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-002.in/B/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-002.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-002.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-002.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-003.in/A/lib.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-003.in/A/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-003.in/B/lib.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-003.in/B/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-003.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-003.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-003.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-004.in/A/lib.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-004.in/A/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-004.in/B/lib.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-004.in/B/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-004.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-004.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/simple-pkg-AB-004.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/target-backend.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/target-backend.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/target-backend.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/target-backend.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/target-backend.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/test_deny_warn.in/.gitignore create mode 100644 crates/moon/tests/test_cases/test_deny_warn.in/README.md create mode 100644 crates/moon/tests/test_cases/test_deny_warn.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/test_deny_warn.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_deny_warn.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/test_deny_warn.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_deny_warn.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/test_error_report.in/.gitignore create mode 100644 crates/moon/tests/test_cases/test_error_report.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/test_error_report.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/test_error_report.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_error_report.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/test_error_report.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_error_report.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/test_filter.in/A/hello.mbt create mode 100644 crates/moon/tests/test_cases/test_filter.in/A/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/test_filter.in/A/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_filter.in/A/test.mbt create mode 100644 crates/moon/tests/test_cases/test_filter.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/test_filter.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/test_filter.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_filter.in/lib2/lib.mbt create mode 100644 crates/moon/tests/test_cases/test_filter.in/lib2/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_filter.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/test_filter.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_filter.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib/lib.mbt create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib1/lib.mbt create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib2/lib.mbt create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib2/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib3/lib.mbt create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib3/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib4/lib.mbt create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib4/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib/_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib/lib.mbt create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib1/lib.mbt create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib2/lib.mbt create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib2/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib3/_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib3/lib.mbt create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib3/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib4/_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib4/lib.mbt create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib4/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib5/lib.mbt create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib5/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib6/lib.mbt create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib6/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib7/_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib7/lib.mbt create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib7/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/test_moon_test_filter_package_with_test_imports.drawio.png create mode 100644 crates/moon/tests/test_cases/test_import/.gitignore create mode 100644 crates/moon/tests/test_cases/test_import/README.md create mode 100644 crates/moon/tests/test_cases/test_import/a/a.mbt create mode 100644 crates/moon/tests/test_cases/test_import/a/a_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/test_import/a/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_import/b/b.mbt create mode 100644 crates/moon/tests/test_cases/test_import/b/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_import/c/c.mbt create mode 100644 crates/moon/tests/test_cases/test_import/c/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_import/main/main.mbt create mode 100644 crates/moon/tests/test_cases/test_import/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_import/moon.mod.json create mode 100644 crates/moon/tests/test_cases/test_import/s/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_import/s/t.mbt create mode 100644 crates/moon/tests/test_cases/test_import/t/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_import/t/t.mbt create mode 100644 crates/moon/tests/test_cases/test_many_targets.in/.gitignore create mode 100644 crates/moon/tests/test_cases/test_many_targets.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/test_many_targets.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_many_targets.in/link/hello.mbt create mode 100644 crates/moon/tests/test_cases/test_many_targets.in/link/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_many_targets.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/test_many_targets_auto_update.in/.gitignore create mode 100644 crates/moon/tests/test_cases/test_many_targets_auto_update.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_many_targets_auto_update.in/lib/x.js.mbt create mode 100644 crates/moon/tests/test_cases/test_many_targets_auto_update.in/lib/x.wasm-gc.mbt create mode 100644 crates/moon/tests/test_cases/test_many_targets_auto_update.in/lib/x.wasm.mbt create mode 100644 crates/moon/tests/test_cases/test_many_targets_auto_update.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/test_many_targets_expect_failed.in/.gitignore create mode 100644 crates/moon/tests/test_cases/test_many_targets_expect_failed.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_many_targets_expect_failed.in/lib/x.js.mbt create mode 100644 crates/moon/tests/test_cases/test_many_targets_expect_failed.in/lib/x.wasm-gc.mbt create mode 100644 crates/moon/tests/test_cases/test_many_targets_expect_failed.in/lib/x.wasm.mbt create mode 100644 crates/moon/tests/test_cases/test_many_targets_expect_failed.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/test_multi_process/.gitignore create mode 100644 crates/moon/tests/test_cases/test_multi_process/README.md create mode 100644 crates/moon/tests/test_cases/test_multi_process/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/test_multi_process/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_multi_process/main/main.mbt create mode 100644 crates/moon/tests/test_cases/test_multi_process/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_multi_process/moon.mod.json create mode 100644 crates/moon/tests/test_cases/test_release.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/test_release.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/test_release.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_release.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/test_release.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/test_release.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/third_party.in/.gitignore create mode 100644 crates/moon/tests/test_cases/third_party.in/README.md create mode 100644 crates/moon/tests/test_cases/third_party.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/third_party.in/lib/test.mbt create mode 100644 crates/moon/tests/test_cases/third_party.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/third_party.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/third_party.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/unicode_demo.in/README.md create mode 100644 crates/moon/tests/test_cases/unicode_demo.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/unicode_demo.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/unicode_demo.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/validate_import.in/.gitignore create mode 100644 crates/moon/tests/test_cases/validate_import.in/README.md create mode 100644 crates/moon/tests/test_cases/validate_import.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/validate_import.in/lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/validate_import.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/validate_import.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/validate_import.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/validate_import.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/warn_list.in/.gitignore create mode 100644 crates/moon/tests/test_cases/warn_list.in/README.md create mode 100644 crates/moon/tests/test_cases/warn_list.in/lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/warn_list.in/lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/warn_list.in/lib1/hello.mbt create mode 100644 crates/moon/tests/test_cases/warn_list.in/lib1/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/warn_list.in/main/main.mbt create mode 100644 crates/moon/tests/test_cases/warn_list.in/main/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/warn_list.in/moon.mod.json create mode 100644 crates/moon/tests/test_cases/whitespace_test.in/.gitignore create mode 100644 crates/moon/tests/test_cases/whitespace_test.in/README.md create mode 100644 crates/moon/tests/test_cases/whitespace_test.in/main exe/main.mbt create mode 100644 crates/moon/tests/test_cases/whitespace_test.in/main exe/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/whitespace_test.in/main lib/hello.mbt create mode 100644 crates/moon/tests/test_cases/whitespace_test.in/main lib/hello_wbtest.mbt create mode 100644 crates/moon/tests/test_cases/whitespace_test.in/main lib/moon.pkg.json create mode 100644 crates/moon/tests/test_cases/whitespace_test.in/moon.mod.json create mode 100644 crates/moonbuild/Cargo.toml create mode 100644 crates/moonbuild/src/README.md create mode 100644 crates/moonbuild/src/bench.rs create mode 100644 crates/moonbuild/src/build.rs create mode 100644 crates/moonbuild/src/bundle.rs create mode 100644 crates/moonbuild/src/check/mod.rs create mode 100644 crates/moonbuild/src/check/normal.rs create mode 100644 crates/moonbuild/src/check/watch.rs create mode 100644 crates/moonbuild/src/doc_http.rs create mode 100644 crates/moonbuild/src/dry_run.rs create mode 100644 crates/moonbuild/src/entry.rs create mode 100644 crates/moonbuild/src/expect.rs create mode 100644 crates/moonbuild/src/fmt.rs create mode 100644 crates/moonbuild/src/gen/cmd_builder.rs create mode 100644 crates/moonbuild/src/gen/gen_build.rs create mode 100644 crates/moonbuild/src/gen/gen_bundle.rs create mode 100644 crates/moonbuild/src/gen/gen_check.rs create mode 100644 crates/moonbuild/src/gen/gen_runtest.rs create mode 100644 crates/moonbuild/src/gen/mod.rs create mode 100644 crates/moonbuild/src/gen/util.rs create mode 100644 crates/moonbuild/src/lib.rs create mode 100644 crates/moonbuild/src/new.rs create mode 100644 crates/moonbuild/src/runtest.rs create mode 100644 crates/moonbuild/src/section_capture.rs create mode 100644 crates/moonbuild/src/upgrade.rs create mode 100644 crates/moonbuild/template/apache-2.0.txt create mode 100644 crates/moonbuild/template/test_driver_template.mbt create mode 100644 crates/mooncake/Cargo.toml create mode 100644 crates/mooncake/src/dep_dir.rs create mode 100644 crates/mooncake/src/lib.rs create mode 100644 crates/mooncake/src/pkg/add.rs create mode 100644 crates/mooncake/src/pkg/install.rs create mode 100644 crates/mooncake/src/pkg/mod.rs create mode 100644 crates/mooncake/src/pkg/remove.rs create mode 100644 crates/mooncake/src/pkg/sync.rs create mode 100644 crates/mooncake/src/pkg/tree.rs create mode 100644 crates/mooncake/src/registry.rs create mode 100644 crates/mooncake/src/registry/mock.rs create mode 100644 crates/mooncake/src/registry/online.rs create mode 100644 crates/mooncake/src/resolver.rs create mode 100644 crates/mooncake/src/resolver/env.rs create mode 100644 crates/mooncake/src/resolver/mvs.rs create mode 100644 crates/mooncake/src/update.rs create mode 100644 crates/moonutil/Cargo.toml create mode 100644 crates/moonutil/build.rs create mode 100644 crates/moonutil/src/cli.rs create mode 100644 crates/moonutil/src/common.rs create mode 100644 crates/moonutil/src/dependency.rs create mode 100644 crates/moonutil/src/dirs.rs create mode 100644 crates/moonutil/src/graph.rs create mode 100644 crates/moonutil/src/lib.rs create mode 100644 crates/moonutil/src/module.rs create mode 100644 crates/moonutil/src/moon_dir.rs create mode 100644 crates/moonutil/src/mooncake_bin.rs create mode 100644 crates/moonutil/src/mooncakes.rs create mode 100644 crates/moonutil/src/package.rs create mode 100644 crates/moonutil/src/path.rs create mode 100644 crates/moonutil/src/render.rs create mode 100644 crates/moonutil/src/scan.rs create mode 100644 crates/moonutil/src/version.rs create mode 100644 docs/dev/README.md create mode 100644 licenserc.toml create mode 100644 xtask/Cargo.toml create mode 100644 xtask/src/main.rs diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..35049cbc --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[alias] +xtask = "run --package xtask --" diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 00000000..1c7ab7ad --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,121 @@ +name: CD + +on: + workflow_dispatch: + push: + branches: + - main + +jobs: + build: + strategy: + matrix: + os: [macos-latest, macos-13, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.77.0 + - name: Cargo cache + uses: actions/cache@v4 + with: + key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} + path: ~/.cargo/registry + - name: Build + run: cargo build --release + + - name: Setup Rclone + uses: AnimMouse/setup-rclone@v1 + with: + rclone_config: ${{ secrets.RCLONE_CONFIG }} + + - name: Upload(Unix) + if: ${{ matrix.os != 'windows-latest' }} + run: | + version=$(echo "$GITHUB_SHA" | cut -c 1-9) + rclone copy target/release/moon "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moon/$version/$(uname -s)-$(uname -m)/" + mkdir tmp && cp target/release/moon tmp/moon + rclone copy tmp/ "aliyun:${{ secrets.ALIYUN_BUCKET_NAME }}/bleeding-moon/$version/$(uname -s)-$(uname -m)/" + + - name: Upload(Windows) + if: ${{ matrix.os == 'windows-latest' }} + run: | + $version = "$env:GITHUB_SHA".Substring(0, 9) + rclone copyto -L .\target\release\moon.exe "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moon/$version/Windows-x86_64/moon.exe" + + - name: Checkout moonc-version (macos-latest) + if: ${{ matrix.os == 'macos-latest' }} + uses: actions/checkout@v4 + with: + ref: moonc-version-dont-delete + path: moonc-version-dont-delete + + - name: Copy moonc-version file to workspace (macos-latest) + if: ${{ matrix.os == 'macos-latest' }} + run: | + cp moonc-version-dont-delete/moonc-version . + + - name: Bleeding Release (macos-latest) + if: ${{ matrix.os == 'macos-latest' }} + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + run: | + rm -rf tmp-bins + mkdir tmp-bins + mooncVersion=$(cat moonc-version | cut -c 1-9) + rclone copy "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonc/$mooncVersion/$(uname -s)-$(uname -m)/" ./tmp-bins/ + moonrunVersion=4bb74ba5f + rclone copy "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonrun/$moonrunVersion/$(uname -s)-$(uname -m)/moonrun" ./tmp-bins/ + cp -L ./target/release/moon ./tmp-bins/ + pushd tmp-bins && shasum -a 256 -- * >../moonbit-darwin-aarch64.sha256 && popd + tar czf ./moonbit-darwin-aarch64.tar.gz --directory=./tmp-bins . + aws s3 cp ./moonbit-darwin-aarch64.tar.gz s3://cli.moonbitlang.com/binaries/bleeding/moonbit-darwin-aarch64.tar.gz + aws s3 cp ./moonbit-darwin-aarch64.sha256 s3://cli.moonbitlang.com/binaries/bleeding/moonbit-darwin-aarch64.sha256 + aws cloudfront create-invalidation --distribution-id E1KQYZEVEB0TAY --paths "/*" + + ubuntu-build: + runs-on: ubuntu-latest + container: + image: ubuntu:16.04 + steps: + - name: Install dependencies + run: | + apt update && apt install -y software-properties-common curl unzip build-essential git + + - name: Checkout + run: | + git clone --depth 1 "https://${{ secrets.MOON_CLONE_PAT }}@github.com/moonbitlang/moon.git" "$GITHUB_WORKSPACE" + + - name: Install Rust + run: | + curl --proto '=https' --tlsv1.2 -sSf "https://sh.rustup.rs" | sh -s -- -y + echo ~/.cargo/bin >> $GITHUB_PATH + + - name: Rust Version + run: | + cargo version + rustc --version + + - run: | + git config --global --add safe.directory "$(pwd)" + git status + + - name: Build + run: cargo build --release + + - name: Setup Rclone + env: + RCLONE_CONFIG_PLAIN: ${{ secrets.RCLONE_CONFIG_PLAIN }} + run: | + curl https://rclone.org/install.sh | bash + mkdir -p ~/.config/rclone + echo "$RCLONE_CONFIG_PLAIN" > ~/.config/rclone/rclone.conf + + - name: Upload + run: | + version="$(echo "$GITHUB_SHA" | cut -c 1-9)" + echo "$version" + rclone copy target/release/moon "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moon/$version/$(uname -s)-$(uname -m)/" + mkdir tmp && cp target/release/moon tmp/moon + rclone copy tmp/ "aliyun:${{ secrets.ALIYUN_BUCKET_NAME }}/bleeding-moon/$version/$(uname -s)-$(uname -m)/" diff --git a/.github/workflows/check-merge-commit.yml b/.github/workflows/check-merge-commit.yml new file mode 100644 index 00000000..061148a2 --- /dev/null +++ b/.github/workflows/check-merge-commit.yml @@ -0,0 +1,35 @@ +name: Check for Merge Commits + +on: + pull_request: + branches: main + +jobs: + check-merge-commit: + runs-on: ubuntu-latest + + steps: + - name: Check out the repository + uses: actions/checkout@v4 + + - name: Get all commit messages + id: get-commit-messages + uses: actions/github-script@v7 + with: + script: | + const prNumber = context.payload.pull_request.number; + const commits = await github.rest.pulls.listCommits({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: prNumber, + per_page: 100 + }); + const commitMessages = commits.data.map(commit => commit.commit.message); + const hasMergeCommit = commitMessages.some(message => message.startsWith('Merge branch') || message.startsWith('Merge pull request')); + if (hasMergeCommit) { + core.setFailed('Pull request contains merge commit(s).'); + } + + - name: Check for merge commits + if: failure() + run: echo "This pull request contains merge commit(s) and has been marked as failed." diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..20aa0283 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,246 @@ +name: CI + +on: + push: + branches: main + pull_request: + branches: main + +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: 0 + CARGO_TARPAULIN_VERSION: 0.30.0 + +jobs: + CCAA-check: + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + outputs: + CCAA-signed: ${{ steps.CCAA-check-step.outputs.CCAA-signed }} + steps: + - uses: actions/checkout@v4 + - name: CCAA check + id: CCAA-check-step + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PR_AUTHOR=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ + https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.number }} \ + | jq -r '.user.login') + echo "The PR author is $PR_AUTHOR" + EMAIL=$(git log -1 --pretty=format:'%ae') + echo "Commit author email: $EMAIL" + CCAA_RESPONSE=$(curl -s "https://mooncakes.io/api/v0/cla/check_with_repo?gh_username=$PR_AUTHOR&repo=moon&email=$EMAIL") + echo "CCAA check response: $CCAA_RESPONSE" + SIGNED=$(echo $CCAA_RESPONSE | jq -r '.signed') + echo "CCAA-signed=$SIGNED" >> $GITHUB_ENV + echo "If you have any questions about the CCAA result, please contact us." + if [ "$SIGNED" != "true" ]; then + echo "CCAA is not signed. Please read the document at https://github.com/moonbitlang/moon/tree/main/docs/dev" + exit 1 + else + echo "CCAA is signed." + fi + + license-header-check: + name: license header check + runs-on: ubuntu-latest + env: + HAWKEYE_VERSION: v5.6.0 + steps: + - uses: actions/checkout@v4 + - name: Download HawkEye + run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/korandoru/hawkeye/releases/download/$HAWKEYE_VERSION/hawkeye-installer.sh | sh + - name: License Header Check + run: hawkeye check + + typo-check: + name: typo-check + runs-on: ubuntu-latest + timeout-minutes: 10 + env: + FORCE_COLOR: 1 + TYPOS_VERSION: v1.18.0 + steps: + - name: download typos + run: curl -LsSf https://github.com/crate-ci/typos/releases/download/$TYPOS_VERSION/typos-$TYPOS_VERSION-x86_64-unknown-linux-musl.tar.gz | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: check for typos + run: typos + + code-style: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.77.0 + with: + components: rustfmt, clippy + - name: Check formatting + run: cargo fmt -- --check + - name: Clippy + run: cargo clippy --all-targets --all-features -- -D warnings + + test: + needs: [code-style, typo-check, license-header-check] + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + # - macos-latest + # - macos-13 + - windows-latest + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Checkout moonc-version + uses: actions/checkout@v4 + with: + ref: moonc-version-dont-delete + path: moonc-version-dont-delete + - name: Copy moonc-version file to workspace + run: | + cp moonc-version-dont-delete/moonc-version . + + - uses: dtolnay/rust-toolchain@1.77.0 + - name: Cargo cache + uses: actions/cache@v4 + with: + key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} + path: ~/.cargo/registry + + - name: Setup Rclone + uses: AnimMouse/setup-rclone@v1 + with: + rclone_config: ${{ secrets.RCLONE_CONFIG }} + + - name: install MoonBit(Unix) + if: ${{ matrix.os != 'windows-latest' }} + run: | + mkdir -p ~/.moon/bin + mkdir -p ~/.moon/lib + git clone --depth 1 https://github.com/moonbitlang/core.git ~/.moon/lib/core + mooncVersion=$(cat moonc-version | cut -c 1-9) + echo "$mooncVersion" + bins=('moonc' 'mooninfo' 'moonfmt') + for bin in "${bins[@]}"; do + rclone copy "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonc/$mooncVersion/$(uname -s)-$(uname -m)/$bin" ~/.moon/bin/ + chmod +x ~/.moon/bin/"$bin" + done + moonrunVersion=4bb74ba5f + rclone copy "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonrun/$moonrunVersion/$(uname -s)-$(uname -m)/moonrun" ~/.moon/bin/ + chmod +x ~/.moon/bin/moonrun + echo "$HOME/.moon/bin" >> $GITHUB_PATH + + - name: install MoonBit(Windows) + if: ${{ matrix.os == 'windows-latest' }} + run: | + New-Item -Path "$env:USERPROFILE" -Name ".moon" -ItemType "directory" + New-Item -Path "$env:USERPROFILE\.moon" -Name "lib" -ItemType "directory" + New-Item -Path "$env:USERPROFILE\.moon" -Name "bin" -ItemType "directory" + $mooncVersion = (Get-Content moonc-version -First 1).Substring(0, 9) + $bins = @("moonc.exe", "mooninfo.exe", "moonfmt.exe") + foreach ($bin in $bins) { + rclone copy "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonc/$mooncVersion/Windows-x86_64/$bin" "$env:USERPROFILE\.moon\bin\" + } + $moonrunVersion = "4bb74ba5f" + rclone copy "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonrun/$moonrunVersion/Windows-x86_64/moonrun.exe" "$env:USERPROFILE\.moon\bin\" + git clone --depth 1 https://github.com/moonbitlang/core.git "$env:USERPROFILE\.moon\lib\core" + "$env:USERPROFILE\.moon\bin" | Out-File -FilePath $env:GITHUB_PATH -Append + + - name: Build + run: cargo build + - name: Versions + run: cargo run --bin moon version --all + - name: Bundle core (Unix) + if: ${{ matrix.os != 'windows-latest' }} + run: cargo run --bin moon bundle --source-dir ~/.moon/lib/core --all + - name: Bundle core (Windows) + if: ${{ matrix.os == 'windows-latest' }} + run: cargo run --bin moon bundle --source-dir "$env:USERPROFILE\.moon\lib\core" --all + + - name: Test core (Unix) + if: ${{ matrix.os != 'windows-latest' }} + run: | + cargo run --bin moon test --source-dir ~/.moon/lib/core --target wasm-gc + cargo run --bin moon test --source-dir ~/.moon/lib/core --target js + cargo run --bin moon test --source-dir ~/.moon/lib/core --target wasm + cargo run --bin moon test --source-dir ~/.moon/lib/core --release --target wasm-gc + cargo run --bin moon test --source-dir ~/.moon/lib/core --release --target js + cargo run --bin moon test --source-dir ~/.moon/lib/core --release --target wasm + - name: Test core (Windows) + if: ${{ matrix.os == 'windows-latest' }} + run: | + cargo run --bin moon test --source-dir "$env:USERPROFILE\.moon\lib\core" --target wasm-gc + cargo run --bin moon test --source-dir "$env:USERPROFILE\.moon\lib\core" --target js + cargo run --bin moon test --source-dir "$env:USERPROFILE\.moon\lib\core" --target wasm + cargo run --bin moon test --source-dir "$env:USERPROFILE\.moon\lib\core" --release --target wasm-gc + cargo run --bin moon test --source-dir "$env:USERPROFILE\.moon\lib\core" --release --target js + cargo run --bin moon test --source-dir "$env:USERPROFILE\.moon\lib\core" --release --target wasm + + - name: Run tests + run: cargo test + + coverage: + needs: test + runs-on: macos-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@1.77.0 + + - name: Checkout moonc-version + uses: actions/checkout@v4 + with: + ref: moonc-version-dont-delete + path: moonc-version-dont-delete + - name: Copy moonc-version file to workspace + run: | + cp moonc-version-dont-delete/moonc-version . + + - name: Setup Rclone + uses: AnimMouse/setup-rclone@v1 + with: + rclone_config: ${{ secrets.RCLONE_CONFIG }} + + - name: install MoonBit(Unix) + run: | + mkdir -p ~/.moon/bin + mkdir -p ~/.moon/lib + git clone --depth 1 https://github.com/moonbitlang/core.git ~/.moon/lib/core + mooncVersion=$(cat moonc-version | cut -c 1-9) + echo "$mooncVersion" + bins=('moonc' 'mooninfo' 'moonfmt') + for bin in "${bins[@]}"; do + rclone copy "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonc/$mooncVersion/$(uname -s)-$(uname -m)/$bin" ~/.moon/bin/ + chmod +x ~/.moon/bin/"$bin" + done + moonrunVersion=4bb74ba5f + rclone copy "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonrun/$moonrunVersion/$(uname -s)-$(uname -m)/moonrun" ~/.moon/bin/ + chmod +x ~/.moon/bin/moonrun + echo "$HOME/.moon/bin" >> $GITHUB_PATH + + - name: install cargo-tarpaulin ${{ env.CARGO_TARPAULIN_VERSION }} + run: | + cd "${CARGO_HOME}/bin" + curl -sL https://github.com/xd009642/tarpaulin/releases/download/${CARGO_TARPAULIN_VERSION}/cargo-tarpaulin-aarch64-apple-darwin.tar.gz | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin + + - name: Build + run: cargo build + - name: Versions + run: cargo run --bin moon version --all + - name: Bundle core (Unix) + run: cargo run --bin moon bundle --source-dir ~/.moon/lib/core --all + + - name: Generate code coverage + run: cargo tarpaulin --ignore-tests --out Xml + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{secrets.CODECOV_TOKEN}} + fail_ci_if_error: true diff --git a/.github/workflows/test-on-main.yml b/.github/workflows/test-on-main.yml new file mode 100644 index 00000000..0317f6fa --- /dev/null +++ b/.github/workflows/test-on-main.yml @@ -0,0 +1,134 @@ +name: Test on main + +on: + workflow_dispatch: + +jobs: + test: + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + # - macos-latest + # - macos-13 + - windows-latest + runs-on: ${{ matrix.os }} + env: + WECOM_ROBOT_KEY: ${{ secrets.WECOM_ROBOT_KEY }} + steps: + - uses: actions/checkout@v4 + + - name: Checkout moonc-version + uses: actions/checkout@v4 + with: + ref: moonc-version-dont-delete + path: moonc-version-dont-delete + - name: Copy moonc-version file to workspace + run: | + cp moonc-version-dont-delete/moonc-version . + + - uses: dtolnay/rust-toolchain@1.77.0 + - name: Cargo cache + uses: actions/cache@v4 + with: + key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} + path: ~/.cargo/registry + + - name: Setup Rclone + uses: AnimMouse/setup-rclone@v1 + with: + rclone_config: ${{ secrets.RCLONE_CONFIG }} + + - name: install MoonBit(Unix) + if: ${{ matrix.os != 'windows-latest' }} + run: | + mkdir -p ~/.moon/bin + mkdir -p ~/.moon/lib + git clone --depth 1 https://github.com/moonbitlang/core.git ~/.moon/lib/core + mooncVersion=$(cat moonc-version | cut -c 1-9) + echo "$mooncVersion" + bins=('moonc' 'mooninfo' 'moonfmt') + for bin in "${bins[@]}"; do + rclone copy "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonc/$mooncVersion/$(uname -s)-$(uname -m)/$bin" ~/.moon/bin/ + chmod +x ~/.moon/bin/"$bin" + done + moonrunVersion=4bb74ba5f + rclone copy "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonrun/$moonrunVersion/$(uname -s)-$(uname -m)/moonrun" ~/.moon/bin/ + chmod +x ~/.moon/bin/moonrun + echo "$HOME/.moon/bin" >> $GITHUB_PATH + + - name: install MoonBit(Windows) + if: ${{ matrix.os == 'windows-latest' }} + run: | + New-Item -Path "$env:USERPROFILE" -Name ".moon" -ItemType "directory" + New-Item -Path "$env:USERPROFILE\.moon" -Name "lib" -ItemType "directory" + New-Item -Path "$env:USERPROFILE\.moon" -Name "bin" -ItemType "directory" + $mooncVersion = (Get-Content moonc-version -First 1).Substring(0, 9) + $bins = @("moonc.exe", "mooninfo.exe", "moonfmt.exe") + foreach ($bin in $bins) { + rclone copy "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonc/$mooncVersion/Windows-x86_64/$bin" "$env:USERPROFILE\.moon\bin\" + } + $moonrunVersion = "4bb74ba5f" + rclone copy "aws:${{ secrets.AWS_BUCKET_NAME }}/bleeding-moonrun/$moonrunVersion/Windows-x86_64/moonrun.exe" "$env:USERPROFILE\.moon\bin\" + git clone --depth 1 https://github.com/moonbitlang/core.git "$env:USERPROFILE\.moon\lib\core" + "$env:USERPROFILE\.moon\bin" | Out-File -FilePath $env:GITHUB_PATH -Append + + - name: Build + run: cargo build + - name: Versions + run: cargo run --bin moon version --all + - name: Bundle core (Unix) + if: ${{ matrix.os != 'windows-latest' }} + run: cargo run --bin moon bundle --source-dir ~/.moon/lib/core --all + - name: Bundle core (Windows) + if: ${{ matrix.os == 'windows-latest' }} + run: cargo run --bin moon bundle --source-dir "$env:USERPROFILE\.moon\lib\core" --all + + - name: Test core (Unix) + if: ${{ matrix.os != 'windows-latest' }} + run: | + cargo run --bin moon test --source-dir ~/.moon/lib/core --target wasm-gc + cargo run --bin moon test --source-dir ~/.moon/lib/core --target js + cargo run --bin moon test --source-dir ~/.moon/lib/core --target wasm + cargo run --bin moon test --source-dir ~/.moon/lib/core --release --target wasm-gc + cargo run --bin moon test --source-dir ~/.moon/lib/core --release --target js + cargo run --bin moon test --source-dir ~/.moon/lib/core --release --target wasm + - name: Test core (Windows) + if: ${{ matrix.os == 'windows-latest' }} + run: | + cargo run --bin moon test --source-dir "$env:USERPROFILE\.moon\lib\core" --target wasm-gc + cargo run --bin moon test --source-dir "$env:USERPROFILE\.moon\lib\core" --target js + cargo run --bin moon test --source-dir "$env:USERPROFILE\.moon\lib\core" --target wasm + cargo run --bin moon test --source-dir "$env:USERPROFILE\.moon\lib\core" --release --target wasm-gc + cargo run --bin moon test --source-dir "$env:USERPROFILE\.moon\lib\core" --release --target js + cargo run --bin moon test --source-dir "$env:USERPROFILE\.moon\lib\core" --release --target wasm + + - name: Run tests + run: cargo test + + - name: Notify on fail (windows) + if: ${{ failure() && matrix.os == 'windows-latest' }} + run: | + $body = @{ + msgtype = "text" + text = @{ + content = "🤣 moon ci on windows-latest failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{github.run_id}}" + } + } | ConvertTo-Json + + Invoke-RestMethod -Uri "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=$env:WECOM_ROBOT_KEY" -Method Post -ContentType "application/json" -Body $body + + - name: notify on fail (unix) + if: ${{ failure() && matrix.os != 'windows-latest' }} + run: | + curl "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=$WECOM_ROBOT_KEY" \ + -H 'Content-Type: application/json' \ + -d @- < + +Commands: + new Create a new moonbit package + build Build the current package + check Check the current package, but don't build object files + run Run WebAssembly module + test Test the current package + clean Clean the target directory + fmt Format moonbit source code + doc Generate documentation + info Generate public interface (`.mbti`) files for all packages in the module + add Add a dependency + remove Remove a dependency + install Install dependencies + tree Display the dependency tree + login Log in to your account + register Register an account at mooncakes.io + publish Publish the current package + update Update the package registry index + coverage Code coverage utilities + generate-build-matrix Generate build matrix for benchmarking (legacy feature) + upgrade Upgrade toolchains + version Print version info and exit + help Print this message or the help of the given subcommand(s) + +Options: + --source-dir The source code directory. Defaults to the current directory + --target-dir The target directory. Defaults to `source_dir/target` + -q, --quiet Suppress output + -v, --verbose Increase verbosity + --trace Trace the execution of the program + --dry-run Do not actually run the command + -h, --help Print help +``` + +See tutorials at +[MoonBit's Build System Tutorial](https://www.moonbitlang.com/docs/build-system-tutorial) + +## Contributing + +To contribute, please read the contribution guidelines at +[docs/dev](./docs/dev/README.md). diff --git a/crates/moon/Cargo.toml b/crates/moon/Cargo.toml new file mode 100644 index 00000000..2b2ad223 --- /dev/null +++ b/crates/moon/Cargo.toml @@ -0,0 +1,46 @@ +[package] +name = "moon" +version = "0.1.0" +edition.workspace = true +exclude = [".github/*", ".vscode/*"] +readme = "README.md" +rust-version.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +moonbuild.workspace = true +mooncake.workspace = true +moonutil.workspace = true +n2.workspace = true +semver.workspace = true +clap.workspace = true +anyhow.workspace = true +colored.workspace = true +serde.workspace = true +serde_json_lenient.workspace = true +serde_json.workspace = true +dialoguer.workspace = true +dunce.workspace = true +ctrlc.workspace = true +home.workspace = true +which.workspace = true +chrono.workspace = true +env_logger.workspace = true +log.workspace = true +walkdir.workspace = true +regex.workspace = true +tokio.workspace = true +futures.workspace = true + +[target.'cfg(not(windows))'.dependencies] +openssl = { version = "0.10.60", features = ["vendored"] } + +[dev-dependencies] +tempfile = "3.6.0" +snapbox = "0.4.15" +expect-test.workspace = true + +[[bin]] +name = "moon" +bench = false diff --git a/crates/moon/src/cli.rs b/crates/moon/src/cli.rs new file mode 100644 index 00000000..58fb65b1 --- /dev/null +++ b/crates/moon/src/cli.rs @@ -0,0 +1,219 @@ +pub mod build; +pub mod build_matrix; +pub mod bundle; +pub mod check; +pub mod clean; +pub mod coverage; +pub mod deps; +pub mod doc; +pub mod fmt; +pub mod generate_test_driver; +pub mod info; +pub mod mooncake_adapter; +pub mod new; +pub mod run; +pub mod test; +pub mod update; +pub mod upgrade; +pub mod version; + +pub use build::*; +pub use build_matrix::*; +pub use bundle::*; +pub use check::*; +pub use clean::*; +pub use coverage::*; +pub use deps::*; +pub use doc::*; +pub use fmt::*; +pub use generate_test_driver::*; +pub use info::*; +pub use new::*; +pub use run::*; +pub use test::*; +pub use update::*; +pub use upgrade::*; +pub use version::*; + +use std::path::Path; + +use anyhow::bail; +use moonutil::{ + cli::UniversalFlags, + common::{ + read_module_desc_file_in_dir, BuildPackageFlags, LinkCoreFlags, MooncOpt, OutputFormat, + SurfaceTarget, TargetBackend, MOONBITLANG_CORE, MOON_MOD_JSON, + }, + mooncakes::{LoginSubcommand, PublishSubcommand, RegisterSubcommand}, +}; + +#[derive(Debug, clap::Parser)] +#[clap( + name = "moon", + about = "The build system and package manager for MoonBit." +)] +pub struct MoonBuildCli { + #[clap(subcommand)] + pub subcommand: MoonBuildSubcommands, + + #[clap(flatten)] + pub flags: UniversalFlags, +} + +#[derive(Debug, clap::Parser)] +pub enum MoonBuildSubcommands { + New(NewSubcommand), + + // Build system + Bundle(BundleSubcommand), + Build(BuildSubcommand), + Check(CheckSubcommand), + Run(RunSubcommand), + Test(TestSubcommand), + #[clap(hide = true)] + GenerateTestDriver(GeneratedTestDriverSubcommand), + Clean(CleanSubcommand), + Fmt(FmtSubcommand), + Doc(DocSubcommand), + Info(InfoSubcommand), + + // Dependencies + Add(AddSubcommand), + Remove(RemoveSubcommand), + Install(InstallSubcommand), + Tree(TreeSubcommand), + + // Mooncake + Login(LoginSubcommand), + Register(RegisterSubcommand), + Publish(PublishSubcommand), + + Update(UpdateSubcommand), + + // Misc + Coverage(CoverageSubcommand), + GenerateBuildMatrix(GenerateBuildMatrix), + /// Upgrade toolchains + Upgrade, + Version(VersionSubcommand), +} + +#[derive(Debug, clap::Parser, Clone)] +pub struct BuildFlags { + /// Enable the standard library (default) + #[clap(long)] + std: bool, + + /// Disable the standard library + #[clap(long, long = "nostd")] + no_std: bool, + + /// Emit debug information + #[clap(long, short = 'g')] + pub debug: bool, + + /// Select output target + #[clap(long, value_delimiter = ',')] + pub target: Option>, + + #[clap(skip)] + pub target_backend: Option, + + #[clap(long, requires = "target")] + pub serial: bool, + + /// Enable coverage instrumentation + #[clap(long)] + pub enable_coverage: bool, + + /// Sort input files + #[clap(long)] + pub sort_input: bool, + + /// Output WAT instead of WASM + // TODO: we need a more general name, like `--emit-asm` or even `--emit={binary,asm}` + #[clap(long)] + pub output_wat: bool, + + /// treat all warnings as errors + #[clap(long, short)] + pub deny_warn: bool, + + /// don't render diagnostics from moonc (don't pass '-error-format json' to moonc) + #[clap(long)] + pub no_render: bool, +} + +impl BuildFlags { + pub fn std(&self) -> bool { + match (self.std, self.no_std) { + (false, false) => true, + (true, false) => true, + (false, true) => false, + (true, true) => panic!("both std and no_std flags are set"), + } + } +} + +pub fn get_compiler_flags(src_dir: &Path, build_flags: &BuildFlags) -> anyhow::Result { + // read moon.mod.json + if !moonutil::common::check_moon_mod_exists(src_dir) { + bail!("could not find `{}`", MOON_MOD_JSON); + } + let moon_mod = read_module_desc_file_in_dir(src_dir)?; + let extra_build_opt = moon_mod.compile_flags.unwrap_or_default(); + let extra_link_opt = moon_mod.link_flags.unwrap_or_default(); + + let output_format = if build_flags.output_wat { + OutputFormat::Wat + } else { + OutputFormat::Wasm + }; + + let target_backend = build_flags.target_backend.unwrap_or_default(); + + if target_backend == TargetBackend::Js && output_format == OutputFormat::Wat { + bail!("--output-wat is not supported for --target js"); + } + + let output_format = if target_backend == TargetBackend::Js { + OutputFormat::Js + } else { + output_format + }; + + let debug_flag = build_flags.debug; + let enable_coverage = build_flags.enable_coverage; + let source_map = + debug_flag && matches!(target_backend, TargetBackend::WasmGC | TargetBackend::Js); + + let build_opt = BuildPackageFlags { + debug_flag, + source_map, + enable_coverage, + warn_lists: Default::default(), + alert_lists: Default::default(), + deny_warn: false, + target_backend, + }; + + let link_opt = LinkCoreFlags { + debug_flag, + source_map, + output_format, + target_backend, + }; + + let nostd = !build_flags.std() || moon_mod.name == MOONBITLANG_CORE; + let render = + !build_flags.no_render || std::env::var("MOON_NO_RENDER").unwrap_or_default() == "1"; + + Ok(MooncOpt { + build_opt, + link_opt, + extra_build_opt, + extra_link_opt, + nostd, + render, + }) +} diff --git a/crates/moon/src/cli/build.rs b/crates/moon/src/cli/build.rs new file mode 100644 index 00000000..0c00d341 --- /dev/null +++ b/crates/moon/src/cli/build.rs @@ -0,0 +1,143 @@ +use anyhow::Context; +use moonbuild::dry_run; +use moonbuild::entry; +use mooncake::pkg::sync::auto_sync; +use moonutil::common::lower_surface_targets; +use moonutil::common::FileLock; +use moonutil::common::MoonbuildOpt; +use moonutil::common::RunMode; +use moonutil::dirs::mk_arch_mode_dir; +use moonutil::dirs::PackageDirs; +use moonutil::mooncakes::sync::AutoSyncFlags; +use moonutil::mooncakes::RegistryConfig; +use n2::trace; +use std::path::Path; +use std::sync::Arc; +use std::thread; + +use super::{BuildFlags, UniversalFlags}; + +/// Build the current package +#[derive(Debug, clap::Parser, Clone)] +pub struct BuildSubcommand { + #[clap(flatten)] + pub build_flags: BuildFlags, + + #[clap(flatten)] + pub auto_sync_flags: AutoSyncFlags, +} + +pub fn run_build(cli: &UniversalFlags, cmd: &BuildSubcommand) -> anyhow::Result { + let PackageDirs { + source_dir, + target_dir, + } = cli.source_tgt_dir.try_into_package_dirs()?; + let _lock = FileLock::lock(&target_dir)?; + if cmd.build_flags.target.is_none() { + return run_build_internal(cli, cmd, &source_dir, &target_dir); + } + let surface_targets = cmd.build_flags.target.clone().unwrap(); + let targets = lower_surface_targets(&surface_targets); + + let mut ret_value = 0; + if cmd.build_flags.serial { + for t in targets { + let mut cmd = (*cmd).clone(); + cmd.build_flags.target_backend = Some(t); + let x = run_build_internal(cli, &cmd, &source_dir, &target_dir) + .context(format!("failed to run build for target {:?}", t))?; + ret_value = ret_value.max(x); + } + } else { + let cli = Arc::new(cli.clone()); + let source_dir = Arc::new(source_dir); + let target_dir = Arc::new(target_dir); + let mut handles = Vec::new(); + + for t in targets { + let cli = Arc::clone(&cli); + let mut cmd = (*cmd).clone(); + cmd.build_flags.target_backend = Some(t); + let source_dir = Arc::clone(&source_dir); + let target_dir = Arc::clone(&target_dir); + + let handle = + thread::spawn(move || run_build_internal(&cli, &cmd, &source_dir, &target_dir)); + + handles.push((t, handle)); + } + + for (backend, handle) in handles { + let x = handle + .join() + .unwrap() + .context(format!("failed to run build for target {:?}", backend))?; + ret_value = ret_value.max(x); + } + } + Ok(ret_value) +} + +fn run_build_internal( + cli: &UniversalFlags, + cmd: &BuildSubcommand, + source_dir: &Path, + target_dir: &Path, +) -> anyhow::Result { + // Run moon install before build + let (resolved_env, dir_sync_result) = auto_sync( + source_dir, + &cmd.auto_sync_flags, + &RegistryConfig::load(), + cli.quiet, + )?; + + let mut moonc_opt = super::get_compiler_flags(source_dir, &cmd.build_flags)?; + moonc_opt.build_opt.deny_warn = cmd.build_flags.deny_warn; + let run_mode = RunMode::Build; + let target_dir = mk_arch_mode_dir(source_dir, target_dir, &moonc_opt, run_mode)?; + let sort_input = cmd.build_flags.sort_input; + + let moonbuild_opt = MoonbuildOpt { + source_dir: source_dir.to_path_buf(), + target_dir, + sort_input, + run_mode, + quiet: cli.quiet, + verbose: cli.verbose, + ..Default::default() + }; + + let module = moonutil::scan::scan( + false, + &resolved_env, + &dir_sync_result, + &moonc_opt, + &moonbuild_opt, + )?; + moonc_opt.build_opt.warn_lists = module + .packages + .iter() + .map(|(name, pkg)| (name.clone(), pkg.warn_list.clone())) + .collect(); + moonc_opt.build_opt.alert_lists = module + .packages + .iter() + .map(|(name, pkg)| (name.clone(), pkg.alert_list.clone())) + .collect(); + + if cli.dry_run { + return dry_run::print_commands(&module, &moonc_opt, &moonbuild_opt); + } + + let trace_flag = cli.trace; + if trace_flag { + trace::open("trace.json").context("failed to open `trace.json`")?; + } + + let result = entry::run_build(&moonc_opt, &moonbuild_opt, &module); + if trace_flag { + trace::close(); + } + result +} diff --git a/crates/moon/src/cli/build_matrix.rs b/crates/moon/src/cli/build_matrix.rs new file mode 100644 index 00000000..1282f981 --- /dev/null +++ b/crates/moon/src/cli/build_matrix.rs @@ -0,0 +1,56 @@ +use std::path::PathBuf; + +use anyhow::bail; + +use super::UniversalFlags; + +/// Generate build matrix for benchmarking (legacy feature) +#[derive(Debug, clap::Parser)] +pub struct GenerateBuildMatrix { + /// Set all of `drow`, `dcol`, `mrow`, `mcol` to the same value + #[clap(short = 'n')] + pub number: Option, + + /// Number of directory rows + #[clap(long, long = "drow")] + pub dir_rows: Option, + + /// Number of directory columns + #[clap(long, long = "dcol")] + pub dir_cols: Option, + + /// Number of module rows + #[clap(long, long = "mrow")] + pub mod_rows: Option, + + /// Number of module columns + #[clap(long, long = "mcol")] + pub mod_cols: Option, + + #[clap(long, long = "output-dir", short, short = 'o')] + pub out_dir: PathBuf, +} + +pub fn generate_build_matrix( + _cli: &UniversalFlags, + cmd: GenerateBuildMatrix, +) -> anyhow::Result { + if _cli.dry_run { + bail!("dry-run is not implemented for bench") + } + + let n = cmd.number.unwrap_or(1); + let dir_rows = cmd.dir_rows.unwrap_or(n); + let dir_cols = cmd.dir_cols.unwrap_or(n); + let mod_rows = cmd.mod_rows.unwrap_or(n); + let mod_cols = cmd.mod_cols.unwrap_or(n); + + let mut config = moonbuild::bench::Config::new(); + config.dir_rows = dir_rows; + config.dir_cols = dir_cols; + config.mod_rows = mod_rows; + config.mod_cols = mod_cols; + + moonbuild::bench::write(&config, &cmd.out_dir); + Ok(0) +} diff --git a/crates/moon/src/cli/bundle.rs b/crates/moon/src/cli/bundle.rs new file mode 100644 index 00000000..b0c3ea74 --- /dev/null +++ b/crates/moon/src/cli/bundle.rs @@ -0,0 +1,138 @@ +use anyhow::Context; +use moonbuild::dry_run; +use mooncake::pkg::sync::auto_sync; +use moonutil::{ + cli::UniversalFlags, + common::{lower_surface_targets, FileLock, MoonbuildOpt, RunMode, SurfaceTarget}, + dirs::{mk_arch_mode_dir, PackageDirs}, + mooncakes::{sync::AutoSyncFlags, RegistryConfig}, +}; +use std::{path::Path, sync::Arc, thread}; + +use super::BuildFlags; + +/// Bundle the module +#[derive(Debug, clap::Parser, Clone)] +#[clap(hide(true))] +pub struct BundleSubcommand { + #[clap(flatten)] + pub build_flags: BuildFlags, + + /// Bundle all targets + #[clap(long)] + pub all: bool, + + #[clap(flatten)] + pub auto_sync_flags: AutoSyncFlags, +} + +pub fn run_bundle(cli: UniversalFlags, cmd: BundleSubcommand) -> anyhow::Result { + let PackageDirs { + source_dir, + target_dir, + } = cli.source_tgt_dir.try_into_package_dirs()?; + let _lock = FileLock::lock(&target_dir)?; + let target = if cmd.all { + Some(vec![SurfaceTarget::All]) + } else { + cmd.build_flags.target.clone() + }; + + if target.is_none() { + return run_bundle_internal(&cli, &cmd, &source_dir, &target_dir); + } + + let mut surface_targets = target.clone().unwrap(); + if cmd.all { + surface_targets.push(SurfaceTarget::All); + } + let targets = lower_surface_targets(&surface_targets); + + let mut ret_value = 0; + if cmd.build_flags.serial { + for t in targets { + let mut cmd = cmd.clone(); + cmd.build_flags.target_backend = Some(t); + let x = run_bundle_internal(&cli, &cmd, &source_dir, &target_dir) + .context(format!("failed to run bundle for target {:?}", t))?; + ret_value = ret_value.max(x); + } + } else { + let cli = Arc::new(cli); + let source_dir = Arc::new(source_dir); + let target_dir = Arc::new(target_dir); + let mut handles = Vec::new(); + + for t in targets { + let cli = Arc::clone(&cli); + let mut cmd = cmd.clone(); + cmd.build_flags.target_backend = Some(t); + let source_dir = Arc::clone(&source_dir); + let target_dir = Arc::clone(&target_dir); + + let handle = + thread::spawn(move || run_bundle_internal(&cli, &cmd, &source_dir, &target_dir)); + + handles.push((t, handle)); + } + + for (backend, handle) in handles { + let x = handle + .join() + .unwrap() + .context(format!("failed to run bundle for target {:?}", backend))?; + ret_value = ret_value.max(x); + } + } + Ok(ret_value) +} + +fn run_bundle_internal( + cli: &UniversalFlags, + cmd: &BundleSubcommand, + source_dir: &Path, + target_dir: &Path, +) -> anyhow::Result { + // Run moon install before build + let (resolved_env, dir_sync_result) = auto_sync( + source_dir, + &cmd.auto_sync_flags, + &RegistryConfig::load(), + cli.quiet, + )?; + + let mut moonc_opt = super::get_compiler_flags(source_dir, &cmd.build_flags)?; + let run_mode = RunMode::Bundle; + let sort_input = cmd.build_flags.sort_input; + + let target_dir = mk_arch_mode_dir(source_dir, target_dir, &moonc_opt, run_mode)?; + + let moonbuild_opt = MoonbuildOpt { + source_dir: source_dir.to_path_buf(), + target_dir, + sort_input, + run_mode, + ..Default::default() + }; + let module = moonutil::scan::scan( + false, + &resolved_env, + &dir_sync_result, + &moonc_opt, + &moonbuild_opt, + )?; + moonc_opt.build_opt.warn_lists = module + .packages + .iter() + .map(|(name, pkg)| (name.clone(), pkg.warn_list.clone())) + .collect(); + moonc_opt.build_opt.alert_lists = module + .packages + .iter() + .map(|(name, pkg)| (name.clone(), pkg.alert_list.clone())) + .collect(); + if cli.dry_run { + return dry_run::print_commands(&module, &moonc_opt, &moonbuild_opt); + } + moonbuild::entry::run_bundle(&module, &moonbuild_opt, &moonc_opt) +} diff --git a/crates/moon/src/cli/check.rs b/crates/moon/src/cli/check.rs new file mode 100644 index 00000000..960c2622 --- /dev/null +++ b/crates/moon/src/cli/check.rs @@ -0,0 +1,170 @@ +use anyhow::Context; +use moonbuild::check; +use moonbuild::dry_run; +use moonbuild::watcher_is_running; +use moonbuild::{entry, MOON_PID_NAME}; +use mooncake::pkg::sync::auto_sync; +use moonutil::cli::UniversalFlags; +use moonutil::common::lower_surface_targets; +use moonutil::common::FileLock; +use moonutil::common::MoonbuildOpt; +use moonutil::common::RunMode; +use moonutil::dirs::mk_arch_mode_dir; +use moonutil::dirs::PackageDirs; +use moonutil::mooncakes::sync::AutoSyncFlags; +use moonutil::mooncakes::RegistryConfig; +use n2::trace; +use std::path::Path; +use std::sync::Arc; +use std::thread; + +use super::{get_compiler_flags, BuildFlags}; + +/// Check the current package, but don't build object files +#[derive(Debug, clap::Parser, Clone)] +pub struct CheckSubcommand { + /// Monitor the file system and automatically check files + #[clap(long, short)] + pub watch: bool, + + #[clap(flatten)] + pub build_flags: BuildFlags, + + #[clap(flatten)] + pub auto_sync_flags: AutoSyncFlags, +} + +pub fn run_check(cli: &UniversalFlags, cmd: &CheckSubcommand) -> anyhow::Result { + let PackageDirs { + source_dir, + target_dir, + } = cli.source_tgt_dir.try_into_package_dirs()?; + let _lock = FileLock::lock(&target_dir)?; + if cmd.build_flags.target.is_none() { + return run_check_internal(cli, cmd, &source_dir, &target_dir); + } + + let surface_targets = cmd.build_flags.target.clone().unwrap(); + let targets = lower_surface_targets(&surface_targets); + + let mut ret_value = 0; + if cmd.build_flags.serial { + for t in targets { + let mut cmd = (*cmd).clone(); + cmd.build_flags.target_backend = Some(t); + let x = run_check_internal(cli, &cmd, &source_dir, &target_dir) + .context(format!("failed to run check for target {:?}", t))?; + ret_value = ret_value.max(x); + } + } else { + let cli = Arc::new(cli.clone()); + let source_dir = Arc::new(source_dir); + let target_dir = Arc::new(target_dir); + let mut handles = Vec::new(); + + for t in &targets { + let cli = Arc::clone(&cli); + let mut cmd = (*cmd).clone(); + cmd.build_flags.target_backend = Some(*t); + let source_dir = Arc::clone(&source_dir); + let target_dir = Arc::clone(&target_dir); + + let handle = + thread::spawn(move || run_check_internal(&cli, &cmd, &source_dir, &target_dir)); + + handles.push((*t, handle)); + } + + for (backend, handle) in handles { + let x = handle + .join() + .unwrap() + .context(format!("failed to run check for target {:?}", backend))?; + ret_value = ret_value.max(x); + } + } + Ok(ret_value) +} + +fn run_check_internal( + cli: &UniversalFlags, + cmd: &CheckSubcommand, + source_dir: &Path, + target_dir: &Path, +) -> anyhow::Result { + // Run moon install before build + let (resolved_modules, dir_sync_result) = auto_sync( + source_dir, + &cmd.auto_sync_flags, + &RegistryConfig::load(), + cli.quiet, + )?; + + let mut moonc_opt = get_compiler_flags(source_dir, &cmd.build_flags)?; + moonc_opt.build_opt.deny_warn = cmd.build_flags.deny_warn; + let run_mode = RunMode::Check; + let target_dir = mk_arch_mode_dir(source_dir, target_dir, &moonc_opt, run_mode)?; + + let sort_input = cmd.build_flags.sort_input; + + let moonbuild_opt = MoonbuildOpt { + source_dir: source_dir.to_path_buf(), + target_dir: target_dir.clone(), + sort_input, + run_mode, + quiet: cli.quiet, + verbose: cli.verbose, + ..Default::default() + }; + + let module = moonutil::scan::scan( + false, + &resolved_modules, + &dir_sync_result, + &moonc_opt, + &moonbuild_opt, + )?; + moonc_opt.build_opt.warn_lists = module + .packages + .iter() + .map(|(name, pkg)| (name.clone(), pkg.warn_list.clone())) + .collect(); + moonc_opt.build_opt.alert_lists = module + .packages + .iter() + .map(|(name, pkg)| (name.clone(), pkg.alert_list.clone())) + .collect(); + if cli.dry_run { + return dry_run::print_commands(&module, &moonc_opt, &moonbuild_opt); + } + + if cli.trace { + trace::open("trace.json").context("failed to open `trace.json`")?; + } + + let watch_mode = cmd.watch; + + if watch_mode { + let reg_cfg = RegistryConfig::load(); + check::watch::watch_single_thread(&moonc_opt, &moonbuild_opt, ®_cfg, &module) + } else { + let pid_path = target_dir.join(MOON_PID_NAME); + let running = watcher_is_running(&pid_path); + + if let Ok(true) = running { + let output_path = target_dir.join("check.output"); + let output = std::fs::read_to_string(&output_path) + .context(format!("failed to open `{}`", output_path.display()))?; + if !output.trim().is_empty() { + println!("{}", output.trim()); + } + Ok(if output.is_empty() { 0 } else { 1 }) + } else { + let result = entry::run_check(&moonc_opt, &moonbuild_opt, &module); + if cli.trace { + trace::close(); + } + result + } + } +} diff --git a/crates/moon/src/cli/clean.rs b/crates/moon/src/cli/clean.rs new file mode 100644 index 00000000..b79a8e93 --- /dev/null +++ b/crates/moon/src/cli/clean.rs @@ -0,0 +1,28 @@ +use anyhow::{bail, Context}; +use moonutil::{ + cli::UniversalFlags, + common::{FileLock, MOON_MOD_JSON}, +}; + +/// Clean the target directory +#[derive(Debug, clap::Parser)] +pub struct CleanSubcommand {} + +pub fn run_clean(cli: &UniversalFlags) -> anyhow::Result { + if cli.dry_run { + bail!("dry-run is not implemented for clean"); + } + + let src_tgt = cli.source_tgt_dir.try_into_package_dirs()?; + + let _lock = FileLock::lock(&src_tgt.target_dir)?; + + if !moonutil::common::check_moon_mod_exists(&src_tgt.source_dir) { + bail!("could not find `{}`", MOON_MOD_JSON); + } + + if src_tgt.target_dir.is_dir() { + std::fs::remove_dir_all(src_tgt.target_dir).context("failed to remove target directory")?; + } + Ok(0) +} diff --git a/crates/moon/src/cli/coverage.rs b/crates/moon/src/cli/coverage.rs new file mode 100644 index 00000000..e46ff654 --- /dev/null +++ b/crates/moon/src/cli/coverage.rs @@ -0,0 +1,103 @@ +//! CLI and utilities related to code coverage. + +use std::{ffi::OsStr, path::Path}; + +use anyhow::Context; +use moonutil::dirs::PackageDirs; +use walkdir::WalkDir; + +use super::UniversalFlags; + +#[derive(Debug, clap::Parser)] +#[clap( + allow_external_subcommands(true), + disable_help_flag(true), + ignore_errors(true) +)] +pub struct CoverageReportSubcommand { + /// Arguments to pass to the coverage utility + #[clap(name = "args", allow_hyphen_values(true))] + pub args: Vec, + + /// Show help for the coverage utility + #[clap(short, long)] + pub help: bool, +} + +#[derive(Debug, clap::Parser)] +pub enum CoverageSubcommands { + /// Generate code coverage report + Report(CoverageReportSubcommand), + /// Clean up coverage artifacts + Clean, +} + +/// Code coverage utilities +#[derive(Debug, clap::Parser)] +pub struct CoverageSubcommand { + #[clap(subcommand)] + pub cmd: CoverageSubcommands, +} + +pub fn run_coverage(cli: UniversalFlags, cmd: CoverageSubcommand) -> anyhow::Result { + let res = match cmd.cmd { + CoverageSubcommands::Report(args) => run_coverage_report(cli, args), + CoverageSubcommands::Clean => run_coverage_clean(cli)?, + }; + res.context("Unable to run coverage command") +} + +fn run_coverage_clean(cli: UniversalFlags) -> Result, anyhow::Error> { + let PackageDirs { + source_dir: src, + target_dir: tgt, + } = cli.source_tgt_dir.try_into_package_dirs()?; + clean_coverage_artifacts(&src, &tgt)?; + Ok(Ok(0)) +} + +fn run_coverage_report(cli: UniversalFlags, args: CoverageReportSubcommand) -> anyhow::Result { + // if help is requested, delegate to the external command + if args.help { + return run_coverage_report_command( + std::iter::once("--help"), + &std::env::current_dir().unwrap_or(".".into()), + ) + .context("Unable to get help from coverage utility")? + .code() + .ok_or_else(|| anyhow::anyhow!("Unable to get exit code")); + } + + let PackageDirs { + source_dir: src, + target_dir: _tgt, + } = cli.source_tgt_dir.try_into_package_dirs()?; + + let res = run_coverage_report_command(args.args, &src); + res.context("Unable to run coverage report")? + .code() + .ok_or_else(|| anyhow::anyhow!("Coverage report command exited without a status code")) +} + +/// Clean up coverage artifacts by removing all files with name `moonbit_coverage_*.txt` in the current directory and target +fn clean_coverage_artifacts(_src: &Path, tgt: &Path) -> anyhow::Result<()> { + for file in WalkDir::new(tgt) { + let file = file?; + let file_name = file.file_name(); + let file_name = file_name.to_string_lossy(); + if file_name.starts_with("moonbit_coverage_") && file_name.ends_with(".txt") { + std::fs::remove_file(file.path())?; + } + } + Ok(()) +} + +fn run_coverage_report_command( + args: impl IntoIterator>, + cwd: &Path, +) -> std::io::Result { + let mut cmd = std::process::Command::new("moon_cove_report"); + cmd.current_dir(cwd); + cmd.args(args); + cmd.status() +} diff --git a/crates/moon/src/cli/deps.rs b/crates/moon/src/cli/deps.rs new file mode 100644 index 00000000..9979893d --- /dev/null +++ b/crates/moon/src/cli/deps.rs @@ -0,0 +1,120 @@ +use anyhow::bail; +use moonutil::{ + dirs::PackageDirs, + mooncakes::{ModuleName, RegistryConfig}, +}; + +use super::UniversalFlags; + +/// Install dependencies +#[derive(Debug, clap::Parser)] +pub struct InstallSubcommand {} + +/// Remove a dependency +#[derive(Debug, clap::Parser)] +pub struct RemoveSubcommand { + /// The package path to remove + pub package_path: String, +} + +/// Add a dependency +#[derive(Debug, clap::Parser)] +pub struct AddSubcommand { + /// The package path to add + pub package_path: String, +} + +/// Display the dependency tree +#[derive(Debug, clap::Parser)] +pub struct TreeSubcommand {} + +pub fn install_cli(cli: UniversalFlags, _cmd: InstallSubcommand) -> anyhow::Result { + let PackageDirs { + source_dir, + target_dir, + } = cli.source_tgt_dir.try_into_package_dirs()?; + let registry_config = RegistryConfig::load(); + mooncake::pkg::install::install(&source_dir, &target_dir, ®istry_config, false) +} + +pub fn remove_cli(cli: UniversalFlags, cmd: RemoveSubcommand) -> anyhow::Result { + let PackageDirs { + source_dir, + target_dir, + } = cli.source_tgt_dir.try_into_package_dirs()?; + let package_path = cmd.package_path; + let parts: Vec<&str> = package_path.splitn(2, '/').collect(); + if parts.len() != 2 { + bail!("package path must be in the form of /"); + } + let username = parts[0]; + let pkgname = parts[1]; + let registry_config = RegistryConfig::load(); + mooncake::pkg::remove::remove( + &source_dir, + &target_dir, + username, + pkgname, + ®istry_config, + ) +} + +pub fn add_cli(cli: UniversalFlags, cmd: AddSubcommand) -> anyhow::Result { + let PackageDirs { + source_dir, + target_dir, + } = cli.source_tgt_dir.try_into_package_dirs()?; + let package_path = cmd.package_path; + + let parts: Vec<&str> = package_path.splitn(2, '@').collect(); + if parts.len() == 2 { + let version: &str = parts[1]; + let version = version.parse()?; + + let parts: Vec<&str> = parts[0].splitn(2, '/').collect(); + if parts.len() != 2 { + bail!("package path must be in the form of /[@]"); + } + let username = parts[0]; + let pkgname = parts[1]; + + let registry_config = RegistryConfig::load(); + let name = ModuleName { + username: username.to_string(), + pkgname: pkgname.to_string(), + }; + mooncake::pkg::add::add( + &source_dir, + &target_dir, + &name, + &version, + ®istry_config, + false, + ) + } else { + let parts: Vec<&str> = parts[0].splitn(2, '/').collect(); + if parts.len() < 2 { + bail!("package path must be in the form of /[@]"); + } + let username = parts[0]; + let pkgname = parts[1]; + + let registry_config = RegistryConfig::load(); + mooncake::pkg::add::add_latest( + &source_dir, + &target_dir, + username, + pkgname, + ®istry_config, + false, + ) + } +} + +pub fn tree_cli(cli: UniversalFlags, _cmd: TreeSubcommand) -> anyhow::Result { + let PackageDirs { + source_dir, + target_dir, + } = cli.source_tgt_dir.try_into_package_dirs()?; + mooncake::pkg::tree::tree(&source_dir, &target_dir) +} diff --git a/crates/moon/src/cli/doc.rs b/crates/moon/src/cli/doc.rs new file mode 100644 index 00000000..4fe75ad7 --- /dev/null +++ b/crates/moon/src/cli/doc.rs @@ -0,0 +1,107 @@ +use anyhow::bail; +use mooncake::pkg::sync::auto_sync; +use moonutil::common::{ + read_module_desc_file_in_dir, CargoPathExt, FileLock, MoonbuildOpt, MooncOpt, RunMode, + MOONBITLANG_CORE, +}; +use moonutil::dirs::{mk_arch_mode_dir, PackageDirs}; +use moonutil::mooncakes::sync::AutoSyncFlags; +use moonutil::mooncakes::RegistryConfig; + +use super::UniversalFlags; + +/// Generate documentation +#[derive(Debug, clap::Parser)] +pub struct DocSubcommand { + /// Start a web server to serve the documentation + #[clap(long)] + pub serve: bool, + + #[clap(long, short, default_value = "127.0.0.1")] + pub bind: String, + + #[clap(long, short, default_value = "3000")] + pub port: u16, + + #[clap(flatten)] + pub auto_sync_flags: AutoSyncFlags, +} + +pub fn run_doc(cli: UniversalFlags, cmd: DocSubcommand) -> anyhow::Result { + let PackageDirs { + source_dir, + target_dir, + } = cli.source_tgt_dir.try_into_package_dirs()?; + + let _lock = FileLock::lock(&target_dir)?; + + let static_dir = target_dir.join("doc"); + if static_dir.exists() { + static_dir.rm_rf(); + } + let serve = cmd.serve; + let bind = cmd.bind; + let port = cmd.port; + + if cli.dry_run { + println!( + "moondoc {} -o {}{}", + source_dir.display(), + static_dir.display(), + if serve { " -serve-mode" } else { "" } + ); + return Ok(0); + } + + let mod_desc = read_module_desc_file_in_dir(&source_dir)?; + + let mut moonc_opt = MooncOpt::default(); + if mod_desc.name == MOONBITLANG_CORE { + moonc_opt.nostd = true; + } + + let (resolved_env, dir_sync_result) = auto_sync( + &source_dir, + &cmd.auto_sync_flags, + &RegistryConfig::load(), + cli.quiet, + )?; + + let run_mode = RunMode::Check; + let target_dir = mk_arch_mode_dir(&source_dir, &target_dir, &moonc_opt, run_mode)?; + let moonbuild_opt = MoonbuildOpt { + source_dir: source_dir.clone(), + target_dir, + sort_input: false, + run_mode, + ..Default::default() + }; + + let module = moonutil::scan::scan( + false, + &resolved_env, + &dir_sync_result, + &moonc_opt, + &moonbuild_opt, + )?; + moonbuild::entry::run_check(&moonc_opt, &moonbuild_opt, &module)?; + + let mut args = vec![ + source_dir.display().to_string(), + "-o".to_string(), + static_dir.display().to_string(), + ]; + if serve { + args.push("-serve-mode".to_string()) + } + let output = std::process::Command::new("moondoc").args(&args).output()?; + if output.status.code().unwrap() != 0 { + eprintln!("{}", String::from_utf8_lossy(&output.stderr)); + bail!("failed to generate documentation"); + } + + if serve { + moonbuild::doc_http::start_server(static_dir, &mod_desc.name, bind, port)?; + } + Ok(0) +} diff --git a/crates/moon/src/cli/fmt.rs b/crates/moon/src/cli/fmt.rs new file mode 100644 index 00000000..18f59bdc --- /dev/null +++ b/crates/moon/src/cli/fmt.rs @@ -0,0 +1,61 @@ +use anyhow::bail; +use mooncake::pkg::sync::auto_sync; +use moonutil::{ + common::{FileLock, FmtOpt, MoonbuildOpt, MooncOpt, RunMode}, + dirs::{mk_arch_mode_dir, PackageDirs}, + mooncakes::{sync::AutoSyncFlags, RegistryConfig}, +}; + +use super::UniversalFlags; + +/// Format moonbit source code +#[derive(Debug, clap::Parser)] +pub struct FmtSubcommand { + #[clap(long)] + check: bool, + + #[clap(long)] + pub sort_input: bool, +} + +pub fn run_fmt(cli: &UniversalFlags, cmd: FmtSubcommand) -> anyhow::Result { + let PackageDirs { + source_dir, + target_dir, + } = cli.source_tgt_dir.try_into_package_dirs()?; + + let _lock = FileLock::lock(&target_dir)?; + + let moonc_opt = MooncOpt::default(); + let run_mode = RunMode::Format; + let target_dir = mk_arch_mode_dir(&source_dir, &target_dir, &moonc_opt, run_mode)?; + + // Resolve dependencies, but don't download anything + let (resolved_env, dir_sync_result) = auto_sync( + &source_dir, + &AutoSyncFlags { frozen: true }, + &RegistryConfig::load(), + cli.quiet, + )?; + + let moonbuild_opt = MoonbuildOpt { + source_dir, + target_dir: target_dir.clone(), + sort_input: cmd.sort_input, + run_mode, + fmt_opt: Some(FmtOpt { check: cmd.check }), + ..Default::default() + }; + + let module = moonutil::scan::scan( + false, + &resolved_env, + &dir_sync_result, + &moonc_opt, + &moonbuild_opt, + )?; + if cli.dry_run { + bail!("dry-run is not implemented for fmt"); + } + moonbuild::entry::run_fmt(&module, &moonc_opt, &moonbuild_opt) +} diff --git a/crates/moon/src/cli/generate_test_driver.rs b/crates/moon/src/cli/generate_test_driver.rs new file mode 100644 index 00000000..b9dd2121 --- /dev/null +++ b/crates/moon/src/cli/generate_test_driver.rs @@ -0,0 +1,283 @@ +use super::BuildFlags; +use anyhow::bail; +use colored::Colorize; +use mooncake::pkg::sync::auto_sync; +use moonutil::cli::UniversalFlags; +use moonutil::common::{ + lower_surface_targets, MoonbuildOpt, RunMode, TestOpt, MOONBITLANG_CORE, + MOON_TEST_DELIMITER_BEGIN, MOON_TEST_DELIMITER_END, +}; +use moonutil::dirs::PackageDirs; +use moonutil::mooncakes::sync::AutoSyncFlags; +use moonutil::mooncakes::RegistryConfig; +use regex::Regex; +use std::path::{Path, PathBuf}; + +/// Test the current package +#[derive(Debug, clap::Parser)] +pub struct GeneratedTestDriverSubcommand { + #[clap(flatten)] + pub build_flags: BuildFlags, + + #[clap(short, long, num_args(0..))] + pub package: Option>, + + #[clap(short, long, requires("package"))] + pub file: Option, + + #[clap(short, long, requires("file"))] + pub index: Option, +} + +pub fn generate_test_driver( + cli: UniversalFlags, + cmd: GeneratedTestDriverSubcommand, +) -> anyhow::Result { + let PackageDirs { + source_dir, + target_dir, + } = cli.source_tgt_dir.try_into_package_dirs()?; + + let mut cmd = cmd; + cmd.build_flags.target_backend = cmd.build_flags.target.as_ref().and_then(|surface_targets| { + if surface_targets.is_empty() { + None + } else { + Some(lower_surface_targets(surface_targets)[0]) + } + }); + + let moonc_opt = super::get_compiler_flags(&source_dir, &cmd.build_flags)?; + + let run_mode = RunMode::Test; + let sort_input = cmd.build_flags.sort_input; + let (filter_package, filter_file, filter_index) = ( + cmd.package.map(|it| it.into_iter().collect()), + cmd.file, + cmd.index, + ); + + // Resolve dependencies, but don't download anything + let (resolved_env, dir_sync_result) = auto_sync( + &source_dir, + &AutoSyncFlags { frozen: true }, + &RegistryConfig::load(), + cli.quiet, + )?; + + let moonbuild_opt = MoonbuildOpt { + source_dir, + target_dir: target_dir.clone(), + test_opt: Some(TestOpt { + filter_package: filter_package.clone(), + filter_file: filter_file.clone(), + filter_index, + }), + fmt_opt: None, + sort_input, + run_mode, + ..Default::default() + }; + + let mut module = moonutil::scan::scan( + false, + &resolved_env, + &dir_sync_result, + &moonc_opt, + &moonbuild_opt, + )?; + if cli.dry_run { + bail!("dry-run is not implemented for generate-test-driver"); + } + + for (pkgname, pkg) in module.packages.iter_mut() { + if let Some(ref package) = filter_package { + if !package.contains(Path::new(pkgname)) { + continue; + } + } + + if pkg.is_third_party { + continue; + } + + let mut testcase_internal = vec![]; + let mut testcase_underscore = vec![]; + let mut testcase_blackbox = vec![]; + let mut main_contain_test = false; + + let file: Vec = pkg + .files + .iter() + .chain(pkg.wbtest_files.iter()) + .chain(pkg.test_files.iter()) + .cloned() + .collect(); + + let backend_filtered = + moonutil::common::backend_filter(&file, moonc_opt.link_opt.target_backend); + + for file in backend_filtered.iter() { + let content = std::fs::read_to_string(file)?; + let mut counter = 0; + let pattern = + Regex::new(r#"^test[[:blank:]]*("(?P([^\\"]|\\.)*)")?.*$"#).unwrap(); + + let filename = file.file_name().unwrap().to_str().unwrap(); + if let Some(ref filter_file) = filter_file { + if filter_file != filename { + continue; + } + } + + for line in content.lines() { + let escaped_filename = base16_encode_lower(filename.as_bytes()); + + if let Some(captured) = pattern.captures(line) { + main_contain_test = true; + let test_func_name = format!("__test_{}_{}", escaped_filename, counter); + + let description = if let Some(test_name) = captured.name("name") { + if test_name.is_empty() { + format!("{:?}", counter.to_string()) + } else { + format!(r#""{}""#, test_name.as_str()) + } + } else { + format!("{:?}", counter.to_string()) + }; + + counter += 1; + if let Some(filter_index) = filter_index { + if (filter_index + 1) != counter { + continue; + } + } + + let line = format!("({:?}, {}, {}),", filename, description, test_func_name); + let file_name = &file.file_stem().unwrap().to_str().unwrap(); + if file_name.ends_with("_wbtest") { + testcase_underscore.push(line); + } else if file_name.ends_with("_test") { + testcase_blackbox.push(line); + } else { + testcase_internal.push(line); + } + } + } + } + if pkg.is_main { + if main_contain_test { + eprintln!( + "{}: tests in the main package `{}` will be ignored", + "Warning".yellow().bold(), + pkgname + ) + } + continue; + } + + { + let generated_content = generate_driver(&testcase_internal, pkgname); + let generated_file = target_dir + .join(pkg.rel.fs_full_name()) + .join("__generated_driver_for_internal_test.mbt"); + + if !generated_file.parent().unwrap().exists() { + std::fs::create_dir_all(generated_file.parent().unwrap())?; + } + std::fs::write(&generated_file, &generated_content)?; + } + + { + let generated_content = generate_driver(&testcase_underscore, pkgname); + let generated_file = target_dir + .join(pkg.rel.fs_full_name()) + .join("__generated_driver_for_underscore_test.mbt"); + + if !generated_file.parent().unwrap().exists() { + std::fs::create_dir_all(generated_file.parent().unwrap())?; + } + std::fs::write(&generated_file, &generated_content)?; + } + + { + let generated_content = generate_driver(&testcase_blackbox, pkgname); + let generated_file = target_dir + .join(pkg.rel.fs_full_name()) + .join("__generated_driver_for_blackbox_test.mbt"); + + if !generated_file.parent().unwrap().exists() { + std::fs::create_dir_all(generated_file.parent().unwrap())?; + } + std::fs::write(&generated_file, &generated_content)?; + } + } + + Ok(0) +} + +fn generate_driver(lines: &[String], pkgname: &str) -> String { + let test_driver_template = { + let template = include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/../moonbuild/template/test_driver_template.mbt" + )); + if pkgname.starts_with(MOONBITLANG_CORE) { + template.replace(&format!("@{}/builtin.", MOONBITLANG_CORE), "") + } else { + template.to_string() + } + }; + + test_driver_template + .replace("// test identifiers", &lines.join("\n ")) + .replace("{package}", pkgname) + .replace("{begin_moontest}", MOON_TEST_DELIMITER_BEGIN) + .replace("{end_moontest}", MOON_TEST_DELIMITER_END) +} + +fn base16_encode_lower(bytes: &[u8]) -> String { + fn to_char(x: u8) -> char { + if x < 10 { + (b'0' + x) as char + } else { + (b'a' + x - 10) as char + } + } + + let mut result = String::with_capacity(bytes.len() * 2); + for &b in bytes { + let high = to_char(b >> 4); + let low = to_char(b & 0xf); + result.push(high); + result.push(low); + } + result +} + +#[test] +fn test_base16() { + #[allow(unused)] + use expect_test::{expect, Expect}; + + fn check(a: &str, b: expect_test::Expect) { + let bytes = a.as_bytes(); + let b16 = base16_encode_lower(bytes); + b.assert_eq(&b16) + } + + check( + "abcdefghijklmnopqrstuvwxyz0123456789", + expect!["6162636465666768696a6b6c6d6e6f707172737475767778797a30313233343536373839"], + ); + check( + "一个中文字符串的编码", + expect!["e4b880e4b8aae4b8ade69687e5ad97e7aca6e4b8b2e79a84e7bc96e7a081"], + ); + check( + "(){}[].+-*/='\"\\|~_:", + expect!["28297b7d5b5d2e2b2d2a2f3d27225c7c7e5f3a"], + ); + check("filename.mbt", expect!["66696c656e616d652e6d6274"]); +} diff --git a/crates/moon/src/cli/info.rs b/crates/moon/src/cli/info.rs new file mode 100644 index 00000000..2d6aba37 --- /dev/null +++ b/crates/moon/src/cli/info.rs @@ -0,0 +1,133 @@ +use anyhow::{bail, Context}; +use colored::Colorize; +use futures::future::try_join_all; +use mooncake::pkg::sync::auto_sync; +use moonutil::{ + common::{ + read_module_desc_file_in_dir, FileLock, MoonbuildOpt, MooncOpt, RunMode, MOONBITLANG_CORE, + MOON_MOD_JSON, + }, + dirs::PackageDirs, + mooncakes::{sync::AutoSyncFlags, RegistryConfig}, +}; + +use super::UniversalFlags; + +/// Generate public interface (`.mbti`) files for all packages in the module +#[derive(Debug, clap::Parser)] +pub struct InfoSubcommand { + #[clap(flatten)] + pub auto_sync_flags: AutoSyncFlags, +} + +pub fn run_info(cli: UniversalFlags, cmd: InfoSubcommand) -> anyhow::Result { + if cli.dry_run { + bail!("dry-run is not implemented for info") + } + + let PackageDirs { + source_dir, + target_dir, + } = cli.source_tgt_dir.try_into_package_dirs()?; + + let _lock = FileLock::lock(&target_dir)?; + + // Run moon install before build + let (resolved_env, dir_sync_result) = auto_sync( + &source_dir, + &cmd.auto_sync_flags, + &RegistryConfig::load(), + cli.quiet, + )?; + + let mod_desc = read_module_desc_file_in_dir(&source_dir).with_context(|| { + format!( + "failed to read module description file: {}", + source_dir + .join(MOON_MOD_JSON) + .display() + .to_string() + .bold() + .red() + ) + })?; + let module_name = &mod_desc.name; + let mut moonc_opt = MooncOpt::default(); + if module_name == MOONBITLANG_CORE { + moonc_opt.nostd = true; + } + let moonbuild_opt = MoonbuildOpt { + source_dir: source_dir.clone(), + target_dir: target_dir.clone(), + sort_input: false, + run_mode: RunMode::Check, + ..Default::default() + }; + + let module = moonutil::scan::scan( + false, + &resolved_env, + &dir_sync_result, + &moonc_opt, + &moonbuild_opt, + )?; + let check_result = moonbuild::entry::run_check(&moonc_opt, &moonbuild_opt, &module); + match check_result { + Ok(0) => {} + _ => { + bail!("moon check failed"); + } + } + let mdb = moonutil::scan::scan( + false, + &resolved_env, + &dir_sync_result, + &moonc_opt, + &MoonbuildOpt { + source_dir: source_dir.clone(), + target_dir, + ..Default::default() + }, + )?; + + let runtime = tokio::runtime::Runtime::new()?; + let mut handlers = vec![]; + for (name, pkg) in mdb.packages { + // Skip if pkg is not part of the module + if pkg.is_third_party { + continue; + } + + let source_dir = std::sync::Arc::new(source_dir.clone()); + handlers.push(async move { + let mi = pkg.artifact.with_extension("mi"); + if !mi.exists() { + bail!("cannot find mi file for package {}", name); + } + + let out = tokio::process::Command::new("mooninfo") + .args(["-format=text", mi.display().to_string().as_str()]) + .output() + .await?; + + if out.status.success() { + let filename = format!("{}.mbti", pkg.last_name()); + let filepath = source_dir.join(pkg.rel.fs_full_name()).join(&filename); + + tokio::fs::write(filepath, out.stdout) + .await + .context(format!("failed to write {}", filename))?; + } else { + eprintln!("{}", String::from_utf8_lossy(&out.stderr)); + eprintln!("failed to run `mooninfo -format=text {}`", mi.display()); + } + + Ok(0) + }); + } + + // `try_join_all` will return immediately if anyone task fail + runtime.block_on(try_join_all(handlers))?; + + Ok(0) +} diff --git a/crates/moon/src/cli/mooncake_adapter.rs b/crates/moon/src/cli/mooncake_adapter.rs new file mode 100644 index 00000000..0425443a --- /dev/null +++ b/crates/moon/src/cli/mooncake_adapter.rs @@ -0,0 +1,73 @@ +use std::process::Stdio; + +use anyhow::bail; +use moonutil::{ + cli::UniversalFlags, + mooncake_bin::call_mooncake, + mooncakes::{LoginSubcommand, MooncakeSubcommands, PublishSubcommand, RegisterSubcommand}, +}; +use serde::Serialize; + +pub fn execute_cli( + cli: UniversalFlags, + cmd: T, + args: &[&str], +) -> anyhow::Result { + let mut child = call_mooncake() + .args(args) + .stdout(Stdio::inherit()) + .stdin(Stdio::piped()) + .stderr(Stdio::inherit()) + .spawn()?; + + if let Some(mut stdin) = child.stdin.take() { + let data = (cli, cmd); + serde_json::ser::to_writer(&mut stdin, &data)?; + } else { + eprintln!("failed to open stdin"); + } + + let status = child.wait()?; + if status.success() { + Ok(0) + } else { + bail!("failed to run") + } +} + +pub fn execute_cli_with_inherit_stdin( + _cli: UniversalFlags, + _cmd: T, + args: &[&str], +) -> anyhow::Result { + let mut child = call_mooncake() + .args(args) + .env("MOONCAKE_ALLOW_DIRECT", "1") + .stdout(Stdio::inherit()) + .stdin(Stdio::inherit()) + .stderr(Stdio::inherit()) + .spawn()?; + + let status = child.wait()?; + if status.success() { + Ok(0) + } else { + bail!("failed to run `moon {}`", args.join(" ")) + } +} + +pub fn login_cli(cli: UniversalFlags, cmd: LoginSubcommand) -> anyhow::Result { + execute_cli_with_inherit_stdin(cli, MooncakeSubcommands::Login(cmd), &["login"]) +} + +pub fn register_cli(cli: UniversalFlags, cmd: RegisterSubcommand) -> anyhow::Result { + execute_cli_with_inherit_stdin(cli, MooncakeSubcommands::Register(cmd), &["register"]) +} + +pub fn publish_cli(cli: UniversalFlags, cmd: PublishSubcommand) -> anyhow::Result { + execute_cli( + cli, + MooncakeSubcommands::Publish(cmd), + &["--read-args-from-stdin"], + ) +} diff --git a/crates/moon/src/cli/new.rs b/crates/moon/src/cli/new.rs new file mode 100644 index 00000000..7558fe9e --- /dev/null +++ b/crates/moon/src/cli/new.rs @@ -0,0 +1,167 @@ +use std::path::PathBuf; + +use anyhow::bail; +use colored::Colorize; +use moonutil::{common::MOON_MOD_JSON, mooncakes::validate_username}; + +use super::UniversalFlags; + +/// Create a new moonbit package +#[derive(Debug, clap::Parser)] +pub struct NewSubcommand { + /// The name of the package + pub package_name: Option, + + /// Create a library package instead of an executable + #[clap(long)] + pub lib: bool, + + #[clap(flatten)] + pub path_user_name: NewPathUserName, + + /// The license of the package + #[clap(long, default_value = "Apache-2.0")] + pub license: Option, + + /// Do not set a license for the package + #[clap(long)] + pub no_license: bool, +} + +#[derive(Debug, Clone, clap::Args)] +#[group(required(false), requires_all(["path", "user", "name"]))] +pub struct NewPathUserName { + /// Output path of the package + #[clap(long)] + pub path: Option, + + /// The user name of the package + #[clap(long)] + pub user: Option, + + /// The name part of the package + #[clap(long)] + pub name: Option, +} + +pub fn run_new(_cli: &UniversalFlags, cmd: NewSubcommand) -> anyhow::Result { + if _cli.dry_run { + bail!("dry-run is not implemented for new") + } + + let mut lib_flag = cmd.lib; + let package_name = cmd.package_name.as_ref(); + let license = if cmd.no_license { + None + } else { + match cmd.license.as_deref() { + Some("") => None, + Some("\"\"") => None, + Some("\'\'") => None, + Some(x) => Some(x), + _ => None, + } + }; + + if let Some(name) = package_name { + let target_dir = PathBuf::from(name); + if lib_flag { + return moonbuild::new::moon_new_lib( + &target_dir, + "username".into(), + "hello".into(), + license, + ); + } + + return moonbuild::new::moon_new_exec( + &target_dir, + "username".into(), + "hello".into(), + license, + ); + } + + let NewPathUserName { path, user, name } = cmd.path_user_name; + + ctrlc::set_handler(moonutil::common::dialoguer_ctrlc_handler)?; + + let (target_dir, user, name, license) = + if let (Some(path), Some(user), Some(name)) = (path, user, name) { + (path, user, name, license.map(|s| s.to_string())) + } else { + let tmp = dialoguer::Input::::new() + .with_prompt("Enter the path to create the project (. for current directory)") + .default("my-project".to_string()) + .show_default(true) + .validate_with(|input: &String| -> Result<(), String> { + let p = input.trim(); + let dot = p == "."; + + let p = PathBuf::from(p); + + if p.exists() { + if p.join(MOON_MOD_JSON).exists() { + Err(format!( + "A MoonBit project already exists in `{}`.", + p.display() + )) + } else { + if !dot { + eprintln!( + "{}: The directory is already exists.", + "Warning".yellow().bold(), + ); + }; + Ok(()) + } + } else { + Ok(()) + } + }) + .interact()?; + let path = PathBuf::from(tmp); + + let items = vec!["exec", "lib"]; + let selection = dialoguer::Select::new() + .with_prompt("Select the create mode") + .default(0) + .items(&items) + .interact()?; + lib_flag = selection == 1; + + let username = dialoguer::Input::::new() + .with_prompt("Enter your username") + .default("username".to_string()) + .validate_with(|input: &String| -> Result<(), String> { validate_username(input) }) + .show_default(true) + .interact()?; + + let package_name = dialoguer::Input::::new() + .with_prompt("Enter your project name") + .default("hello".to_string()) + .show_default(true) + .interact()?; + + let license = dialoguer::Input::::new() + .with_prompt("Enter your license") + .default("Apache-2.0".to_string()) + .show_default(true) + .interact()?; + + (path, username, package_name, Some(license)) + }; + + if target_dir.exists() && target_dir.join(MOON_MOD_JSON).exists() { + bail!( + "A MoonBit project already exists in `{}`.", + target_dir.display() + ); + } + + if !lib_flag { + moonbuild::new::moon_new_exec(&target_dir, user, name, license.as_deref()) + } else { + moonbuild::new::moon_new_lib(&target_dir, user, name, license.as_deref()) + } +} diff --git a/crates/moon/src/cli/run.rs b/crates/moon/src/cli/run.rs new file mode 100644 index 00000000..b67ff6cf --- /dev/null +++ b/crates/moon/src/cli/run.rs @@ -0,0 +1,240 @@ +use std::path::PathBuf; + +use anyhow::{bail, Context}; +use moonbuild::dry_run; +use moonbuild::entry; +use mooncake::pkg::sync::auto_sync; +use moonutil::common::lower_surface_targets; +use moonutil::common::FileLock; +use moonutil::common::RunMode; +use moonutil::common::SurfaceTarget; +use moonutil::common::TargetBackend; +use moonutil::common::{MoonbuildOpt, OutputFormat}; +use moonutil::dirs::check_moon_pkg_exist; +use moonutil::dirs::mk_arch_mode_dir; +use moonutil::dirs::PackageDirs; +use moonutil::mooncakes::sync::AutoSyncFlags; +use moonutil::mooncakes::RegistryConfig; +use n2::trace; + +use super::{BuildFlags, UniversalFlags}; + +/// Run WebAssembly module +#[derive(Debug, clap::Parser, Clone)] +pub struct RunSubcommand { + /// The package or .mbt file to run + pub package_or_mbt_file: String, + + #[clap(flatten)] + pub build_flags: BuildFlags, + + #[clap(flatten)] + pub auto_sync_flags: AutoSyncFlags, + + pub args: Vec, +} + +pub fn run_run(cli: &UniversalFlags, cmd: RunSubcommand) -> anyhow::Result { + if let Some(surface_targets) = &cmd.build_flags.target { + for st in surface_targets.iter() { + if *st == SurfaceTarget::All { + anyhow::bail!("`--target all` is not supported for `run`"); + } + } + + if surface_targets.len() > 1 { + anyhow::bail!("`--target` only supports one target for `run`") + } + + let targets = lower_surface_targets(surface_targets); + for t in targets { + let mut cmd = cmd.clone(); + cmd.build_flags.target_backend = Some(t); + run_run_internal(cli, cmd)?; + } + Ok(0) + } else { + run_run_internal(cli, cmd) + } +} + +fn run_single_mbt_file(cli: &UniversalFlags, cmd: RunSubcommand) -> anyhow::Result { + let current_dir = std::env::current_dir().unwrap(); + let mbt_file_path = current_dir.join(cmd.package_or_mbt_file); + + if !mbt_file_path.exists() || !mbt_file_path.is_file() { + bail!("{} is not exist or not a file", mbt_file_path.display()); + } + + let file_name = mbt_file_path.file_stem().unwrap().to_str().unwrap(); + + let target_backend = lower_surface_targets(&cmd.build_flags.target.unwrap_or_default()) + .first() + .map_or(TargetBackend::default(), |it| *it); + let core_bundle_path = moonutil::moon_dir::core_bundle(target_backend); + + // `parent_path` is not always same with `current_dir`, since `cmd.package_or_mbt_file` can be something like "a/b/c/single.mbt" + let parent_path = mbt_file_path.parent().unwrap(); + + // we want all output artifacts to be in the same directory as the input single .mbt file + let output_core_path = &(parent_path + .join(format!("{}.core", file_name)) + .display() + .to_string()); + let output_wasm_or_js_path = &(parent_path + .join(format!("{}.{}", file_name, target_backend.to_extension())) + .display() + .to_string()); + + let build_package_command = [ + "build-package", + &mbt_file_path.display().to_string(), + "-o", + output_core_path, + "-std-path", + core_bundle_path.to_str().unwrap(), + "-is-main", + "-target", + target_backend.to_flag(), + ]; + let link_core_command = [ + "link-core", + &core_bundle_path.join("core.core").display().to_string(), + &(parent_path + .join(format!("{}.core", file_name)) + .display() + .to_string()), + "-o", + output_wasm_or_js_path, + "-target", + target_backend.to_flag(), + ]; + + if cli.dry_run { + println!("moonc {}", build_package_command.join(" ")); + println!("moonc {}", link_core_command.join(" ")); + let runner = match target_backend { + TargetBackend::Wasm | TargetBackend::WasmGC => "moonrun", + TargetBackend::Js => "node", + }; + println!("{runner} {output_wasm_or_js_path}"); + + return Ok(0); + } + + let moonc_build_package = std::process::Command::new("moonc") + .args(build_package_command) + .stdout(std::process::Stdio::inherit()) + .stderr(std::process::Stdio::inherit()) + .spawn()? + .wait()?; + + if !moonc_build_package.success() { + bail!("failed to run: moonc {}", build_package_command.join(" ")) + } + + let moonc_link_core = std::process::Command::new("moonc") + .args(link_core_command) + .stdout(std::process::Stdio::inherit()) + .stderr(std::process::Stdio::inherit()) + .spawn()? + .wait()?; + + if !moonc_link_core.success() { + bail!("failed to run: moonc {}", link_core_command.join(" ")) + } + + trace::scope("run", || match target_backend { + TargetBackend::Wasm | TargetBackend::WasmGC => { + moonbuild::build::run_wat(&PathBuf::from(output_wasm_or_js_path), &cmd.args) + } + TargetBackend::Js => { + moonbuild::build::run_js(&PathBuf::from(output_wasm_or_js_path), &cmd.args) + } + })?; + + Ok(0) +} + +pub fn run_run_internal(cli: &UniversalFlags, cmd: RunSubcommand) -> anyhow::Result { + if cmd.package_or_mbt_file.ends_with(".mbt") { + return run_single_mbt_file(cli, cmd); + } + + let PackageDirs { + source_dir, + target_dir, + } = cli.source_tgt_dir.try_into_package_dirs()?; + let _lock = FileLock::lock(&target_dir)?; + + // Run moon install before build + let (resolved_env, dir_sync_result) = auto_sync( + &source_dir, + &cmd.auto_sync_flags, + &RegistryConfig::load(), + cli.quiet, + )?; + + let mut moonc_opt = super::get_compiler_flags(&source_dir, &cmd.build_flags)?; + let run_mode = RunMode::Run; + let target_dir = mk_arch_mode_dir(&source_dir, &target_dir, &moonc_opt, run_mode)?; + + if moonc_opt.link_opt.output_format == OutputFormat::Wat { + bail!("`--output-wat` is not supported for `run`"); + } + + let sort_input = cmd.build_flags.sort_input; + + let package_path = cmd.package_or_mbt_file.clone(); + let package = source_dir.join(&package_path); + if !check_moon_pkg_exist(&package) { + bail!("{} is not a package", package_path); + } + + let pkg = moonutil::common::read_package_desc_file_in_dir(&package)?; + if !pkg.is_main { + bail!("`{}` is not a main package", package_path); + } + let moonbuild_opt = MoonbuildOpt { + source_dir, + target_dir, + sort_input, + run_mode, + args: cmd.args.clone(), + quiet: true, + verbose: cli.verbose, + ..Default::default() + }; + + let module = moonutil::scan::scan( + false, + &resolved_env, + &dir_sync_result, + &moonc_opt, + &moonbuild_opt, + )?; + moonc_opt.build_opt.warn_lists = module + .packages + .iter() + .map(|(name, pkg)| (name.clone(), pkg.warn_list.clone())) + .collect(); + moonc_opt.build_opt.alert_lists = module + .packages + .iter() + .map(|(name, pkg)| (name.clone(), pkg.alert_list.clone())) + .collect(); + if cli.dry_run { + return dry_run::print_commands(&module, &moonc_opt, &moonbuild_opt); + } + + let trace_flag = cli.trace; + if trace_flag { + trace::open("trace.json").context("failed to open `trace.json`")?; + } + + let result = entry::run_run(Some(&package_path), &moonc_opt, &moonbuild_opt, &module); + if trace_flag { + trace::close(); + } + result +} diff --git a/crates/moon/src/cli/test.rs b/crates/moon/src/cli/test.rs new file mode 100644 index 00000000..be62e4c8 --- /dev/null +++ b/crates/moon/src/cli/test.rs @@ -0,0 +1,351 @@ +use anyhow::Context; +use colored::Colorize; +use moonbuild::dry_run; +use moonbuild::entry; +use moonbuild::entry::TestFailedStatus; +use moonbuild::entry::TestResult; +use mooncake::pkg::sync::auto_sync; +use moonutil::common::lower_surface_targets; +use moonutil::common::FileLock; +use moonutil::common::GeneratedTestDriver; +use moonutil::common::MooncOpt; +use moonutil::common::RunMode; +use moonutil::common::{MoonbuildOpt, TargetBackend, TestOpt}; +use moonutil::dirs::mk_arch_mode_dir; +use moonutil::dirs::PackageDirs; +use moonutil::module::ModuleDB; +use moonutil::mooncakes::sync::AutoSyncFlags; +use moonutil::mooncakes::RegistryConfig; +use n2::trace; +use regex::Regex; +use std::path::Path; +use std::path::PathBuf; +use std::sync::Arc; +use std::thread; + +use super::{BuildFlags, UniversalFlags}; + +/// Test the current package +#[derive(Debug, clap::Parser, Clone)] +pub struct TestSubcommand { + #[clap(flatten)] + pub build_flags: BuildFlags, + + /// run test at release compiled mode + #[clap(long)] + pub release: bool, + + /// Run test in the specified package + #[clap(short, long, num_args(0..))] + pub package: Option>, + + /// Run test in the specified file. Only valid when `--package` is also specified. + #[clap(short, long, requires("package"))] + pub file: Option, + + /// Run only the index-th test in the file. Only valid when `--file` is also specified. + #[clap(short, long, requires("file"))] + pub index: Option, + + /// Only build, do not run the tests + #[clap(long)] + pub build_only: bool, + + /// Update the test snapshot + #[clap(short, long)] + pub update: bool, + + /// Limit of expect test update passes to run, in order to avoid infinite loops + #[clap(short, long, default_value = "256", requires("update"))] + pub limit: u32, + + #[clap(flatten)] + pub auto_sync_flags: AutoSyncFlags, +} + +pub fn run_test(cli: UniversalFlags, cmd: TestSubcommand) -> anyhow::Result { + let PackageDirs { + source_dir, + target_dir, + } = cli.source_tgt_dir.try_into_package_dirs()?; + let _lock = FileLock::lock(&target_dir)?; + + if cmd.build_flags.target.is_none() { + return run_test_internal(&cli, &cmd, &source_dir, &target_dir); + } + let surface_targets = cmd.build_flags.target.clone().unwrap(); + let targets = lower_surface_targets(&surface_targets); + let cli = Arc::new(cli); + let source_dir = Arc::new(source_dir); + let target_dir = Arc::new(target_dir); + let mut handles = Vec::new(); + + let mut ret_value = 0; + if cmd.build_flags.serial { + for t in targets { + let mut cmd = cmd.clone(); + cmd.build_flags.target_backend = Some(t); + let x = run_test_internal(&cli, &cmd, &source_dir, &target_dir)?; + ret_value = ret_value.max(x); + } + } else { + for t in targets { + let cli = Arc::clone(&cli); + let mut cmd = cmd.clone(); + cmd.build_flags.target_backend = Some(t); + let source_dir = Arc::clone(&source_dir); + let target_dir = Arc::clone(&target_dir); + + let handle = + thread::spawn(move || run_test_internal(&cli, &cmd, &source_dir, &target_dir)); + + handles.push((t, handle)); + } + + for (backend, handle) in handles { + let x = handle + .join() + .unwrap() + .context(format!("failed to run test for target {:?}", backend))?; + ret_value = ret_value.max(x); + } + } + Ok(ret_value) +} + +fn run_test_internal( + cli: &UniversalFlags, + cmd: &TestSubcommand, + source_dir: &Path, + target_dir: &Path, +) -> anyhow::Result { + // Run moon install before build + let (resolved_env, dir_sync_result) = auto_sync( + source_dir, + &cmd.auto_sync_flags, + &RegistryConfig::load(), + cli.quiet, + )?; + + let mut moonc_opt = super::get_compiler_flags(source_dir, &cmd.build_flags)?; + // release is 'false' by default, so we will run test at debug mode(to gain more detailed stack trace info), unless `--release` is specified + // however, other command like build, check, run, etc, will run at release mode by default + moonc_opt.build_opt.debug_flag = !cmd.release; + moonc_opt.link_opt.debug_flag = !cmd.release; + + // TODO: remove this when we have a better way to handle this + if matches!(moonc_opt.link_opt.target_backend, TargetBackend::Js) { + moonc_opt.extra_build_opt.push("-ryu".into()); + moonc_opt.extra_link_opt.push("-ryu".into()); + } + + let run_mode = RunMode::Test; + let target_dir = mk_arch_mode_dir(source_dir, target_dir, &moonc_opt, run_mode)?; + + if cli.trace { + trace::open("trace.json").context("failed to open `trace.json`")?; + } + + let verbose = cli.verbose; + let build_only = cmd.build_only; + let auto_update = cmd.update; + let limit = cmd.limit; + let sort_input = cmd.build_flags.sort_input; + + let filter_package = cmd.package.clone().map(|it| it.into_iter().collect()); + let filter_file = &cmd.file; + let filter_index = cmd.index; + let moonbuild_opt = MoonbuildOpt { + source_dir: source_dir.to_path_buf(), + target_dir: target_dir.clone(), + test_opt: Some(TestOpt { + filter_package: filter_package.clone(), + filter_file: filter_file.clone(), + filter_index, + }), + sort_input, + run_mode, + quiet: true, + verbose: cli.verbose, + ..Default::default() + }; + + let mut module = moonutil::scan::scan( + false, + &resolved_env, + &dir_sync_result, + &moonc_opt, + &moonbuild_opt, + )?; + + for (pkgname, pkg) in module.packages.iter_mut() { + if let Some(ref package) = filter_package { + if !package.contains(Path::new(pkgname)) { + continue; + } + } + + // test driver file will be generated via `moon generate-test-driver` command + let internal_generated_file = target_dir + .join(pkg.rel.fs_full_name()) + .join("__generated_driver_for_internal_test.mbt"); + pkg.generated_test_drivers + .push(GeneratedTestDriver::InternalTest(internal_generated_file)); + + let underscore_generated_file = target_dir + .join(pkg.rel.fs_full_name()) + .join("__generated_driver_for_underscore_test.mbt"); + pkg.generated_test_drivers + .push(GeneratedTestDriver::UnderscoreTest( + underscore_generated_file, + )); + + let blackbox_generated_file = target_dir + .join(pkg.rel.fs_full_name()) + .join("__generated_driver_for_blackbox_test.mbt"); + pkg.generated_test_drivers + .push(GeneratedTestDriver::BlackboxTest(blackbox_generated_file)); + + for file in pkg + .files + .iter() + .chain(pkg.wbtest_files.iter()) + .chain(pkg.test_files.iter()) + { + let content = std::fs::read_to_string(file)?; + let pattern = + Regex::new(r#"^test[[:blank:]]*("(?P([^\\"]|\\.)*)")?.*$"#).unwrap(); + + let filename = file.file_name().unwrap().to_str().unwrap(); + if let Some(ref filter_file) = filter_file { + if filter_file != filename { + continue; + } + } + + for line in content.lines() { + if pattern.captures(line).is_some() { + pkg.files_contain_test_block.push(file.clone()); + break; + } + } + } + } + + moonc_opt.build_opt.warn_lists = module + .packages + .iter() + .map(|(name, pkg)| (name.clone(), pkg.warn_list.clone())) + .collect(); + moonc_opt.build_opt.alert_lists = module + .packages + .iter() + .map(|(name, pkg)| (name.clone(), pkg.alert_list.clone())) + .collect(); + if cli.dry_run { + return dry_run::print_commands(&module, &moonc_opt, &moonbuild_opt).map(From::from); + } + + if cli.trace { + trace::close(); + } + + let result = do_run_test( + &moonc_opt, + &moonbuild_opt, + build_only, + auto_update, + &module, + verbose, + limit, + ); + match result { + Ok(_) => Ok(0), + Err(e) => Ok(e.into()), + } +} + +fn do_run_test( + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, + build_only: bool, + auto_update: bool, + module: &ModuleDB, + verbose: bool, + limit: u32, +) -> anyhow::Result { + let result = if !auto_update { + entry::run_test(moonc_opt, moonbuild_opt, build_only, verbose, false, module) + } else { + let mut result = + entry::run_test(moonc_opt, moonbuild_opt, build_only, verbose, true, module); + + match result { + Err(TestFailedStatus::ExpectTestFailed(_)) => { + println!( + "\n{}\n", + "Auto updating expect tests and retesting ...".bold() + ); + + let (mut should_update, mut count) = (true, 1); + while should_update && count < limit { + result = entry::run_test( + moonc_opt, + moonbuild_opt, + build_only, + verbose, + true, + module, + ); + match result { + // only continue update when it is a ExpectTestFailed + Err(TestFailedStatus::ExpectTestFailed(_)) => {} + _ => { + should_update = false; + } + } + count += 1; + } + + result + } + _ => result, + } + }; + + print_test_res(&result); + result +} + +fn print_test_res(test_res: &anyhow::Result) { + let print = |test_res: &TestResult| { + let (passed, failed) = (test_res.passed, test_res.failed); + println!( + "Total tests: {}, passed: {}, failed: {}.", + passed + failed, + if passed > 0 { + passed.to_string().green() + } else { + passed.to_string().normal() + }, + if failed > 0 { + failed.to_string().red() + } else { + failed.to_string().normal() + }, + ); + }; + + match test_res { + Ok(test_res) => { + print(test_res); + } + Err(e) => match e { + TestFailedStatus::ApplyExpectFailed(it) => print(it), + TestFailedStatus::ExpectTestFailed(it) => print(it), + TestFailedStatus::Failed(it) => print(it), + TestFailedStatus::RuntimeError(it) => print(it), + TestFailedStatus::Others(it) => println!("{}: {:?}", "error".bold().red(), it), + }, + } +} diff --git a/crates/moon/src/cli/update.rs b/crates/moon/src/cli/update.rs new file mode 100644 index 00000000..c251e6d5 --- /dev/null +++ b/crates/moon/src/cli/update.rs @@ -0,0 +1,17 @@ +use anyhow::bail; +use moonutil::mooncakes::RegistryConfig; + +use super::UniversalFlags; + +/// Update the package registry index +#[derive(Debug, clap::Parser)] +pub struct UpdateSubcommand {} + +pub fn update_cli(cli: UniversalFlags, _cmd: UpdateSubcommand) -> anyhow::Result { + if cli.dry_run { + bail!("dry-run is not implemented for update") + } + let registry_config = RegistryConfig::load(); + let target_dir = moonutil::moon_dir::index(); + mooncake::update::update(&target_dir, ®istry_config) +} diff --git a/crates/moon/src/cli/upgrade.rs b/crates/moon/src/cli/upgrade.rs new file mode 100644 index 00000000..14d91346 --- /dev/null +++ b/crates/moon/src/cli/upgrade.rs @@ -0,0 +1,10 @@ +use anyhow::bail; + +use super::UniversalFlags; + +pub fn run_upgrade(cli: UniversalFlags) -> anyhow::Result { + if cli.dry_run { + bail!("dry-run is not implemented for upgrade") + } + moonbuild::upgrade::upgrade() +} diff --git a/crates/moon/src/cli/version.rs b/crates/moon/src/cli/version.rs new file mode 100644 index 00000000..13a718c0 --- /dev/null +++ b/crates/moon/src/cli/version.rs @@ -0,0 +1,145 @@ +use std::{env::current_exe, path::Path}; + +use anyhow::Context; +use moonutil::common::{get_moon_version, get_moonc_version, get_moonrun_version}; + +/// Print version info and exit +#[derive(Debug, clap::Parser)] +pub struct VersionSubcommand { + /// Print all version info + #[clap(long)] + pub all: bool, + + /// Print version info in JSON format + #[clap(long)] + pub json: bool, + + /// Do not print the path + #[clap(long)] + pub no_path: bool, +} + +fn replace_home_with_tilde(p: &Path, h: &Path) -> String { + if p.starts_with(h) { + p.display() + .to_string() + .replacen(&h.display().to_string(), "~", 1) + } else { + p.display().to_string() + } +} + +fn get_moon_path() -> anyhow::Result { + let user_home = home::home_dir().context("failed to get home directory")?; + let moon_path = which::which("moon"); + let moon_path = if let Ok(moon_path) = moon_path { + moon_path + } else { + current_exe().context("failed to get current executable path")? + }; + Ok(replace_home_with_tilde(&moon_path, &user_home)) +} + +fn get_moonc_path() -> anyhow::Result { + let moonc_path = which::which("moonc").context("failed to find moonc")?; + let user_home = home::home_dir().context("failed to get home directory")?; + Ok(replace_home_with_tilde(&moonc_path, &user_home)) +} + +fn get_moonrun_path() -> anyhow::Result { + let moonrun_path = which::which("moonrun").context("failed to find moonc")?; + let user_home = home::home_dir().context("failed to get home directory")?; + Ok(replace_home_with_tilde(&moonrun_path, &user_home)) +} + +pub fn run_version(cmd: VersionSubcommand) -> anyhow::Result { + let VersionSubcommand { + all: all_flag, + json: json_flag, + no_path: nopath_flag, + } = cmd; + + let (moon_version, moonc_version, moonrun_version) = ( + get_moon_version(), + get_moonc_version(), + get_moonrun_version(), + ); + + match (all_flag, json_flag) { + (false, false) => { + println!("moon {}", moon_version); + } + (true, false) => { + if nopath_flag { + println!("moon {}", moon_version); + println!("moonc {}", moonc_version); + println!("moonc {}", moonrun_version); + } else { + println!("moon {} {}", moon_version, get_moon_path()?); + println!("moonc {} {}", moonc_version, get_moonc_path()?); + println!("{} {}", moonrun_version, get_moonrun_path()?); + } + } + (false, true) => { + let items = moonutil::common::VersionItems { + items: vec![moonutil::common::VersionItem { + name: "moon".to_string(), + version: moon_version, + path: if nopath_flag { + None + } else { + Some(get_moon_path()?) + }, + }], + }; + println!( + "{}", + serde_json_lenient::to_string(&items).context(format!( + "failed to serialize version info to JSON: {:#?}", + items + ))? + ); + } + (true, true) => { + let items = moonutil::common::VersionItems { + items: vec![ + moonutil::common::VersionItem { + name: "moon".to_string(), + version: moon_version, + path: if nopath_flag { + None + } else { + Some(get_moon_path()?) + }, + }, + moonutil::common::VersionItem { + name: "moonc".to_string(), + version: moonc_version, + path: if nopath_flag { + None + } else { + Some(get_moonc_path()?) + }, + }, + moonutil::common::VersionItem { + name: "moonrun".to_string(), + version: moonrun_version, + path: if nopath_flag { + None + } else { + Some(get_moonrun_path()?) + }, + }, + ], + }; + println!( + "{}", + serde_json_lenient::to_string(&items).context(format!( + "failed to serialize version info to JSON: {:#?}", + items + ))? + ); + } + } + Ok(0) +} diff --git a/crates/moon/src/main.rs b/crates/moon/src/main.rs new file mode 100644 index 00000000..45551fb7 --- /dev/null +++ b/crates/moon/src/main.rs @@ -0,0 +1,71 @@ +use clap::Parser; +use cli::MoonBuildSubcommands; + +mod cli; + +use colored::*; + +fn init_log() { + use std::io::Write; + // usage example: only show debug logs for moonbuild::runtest module + // env RUST_LOG=moonbuild::runtest=debug cargo run -- test --source-dir ./tests/test_cases/moon_new.in + + // log level: error > warn > info > debug > trace + env_logger::Builder::from_env(env_logger::Env::default()) + .target(env_logger::Target::Stdout) + .format(|buf, record| { + let level_style = buf.default_level_style(record.level()); + writeln!( + buf, + "{} [{}] [{}:{}] {}", + level_style.value(record.level()), + chrono::Local::now().format("%Y-%m-%dT%H:%M:%S"), + record.file().unwrap_or("unknown"), + record.line().unwrap_or(0), + record.args() + ) + }) + .init(); +} + +pub fn main() { + init_log(); + match main1() { + Ok(code) => std::process::exit(code), + Err(e) => { + eprintln!("{}: {:?}", "error".red().bold(), e); + std::process::exit(-1); + } + } +} + +fn main1() -> anyhow::Result { + let cli = cli::MoonBuildCli::parse(); + let flags = cli.flags; + use MoonBuildSubcommands::*; + match cli.subcommand { + Add(a) => cli::add_cli(flags, a), + Build(b) => cli::run_build(&flags, &b), + Bundle(b) => cli::run_bundle(flags, b), + Check(c) => cli::run_check(&flags, &c), + Clean(_) => cli::run_clean(&flags), + Coverage(c) => cli::run_coverage(flags, c), + Doc(d) => cli::run_doc(flags, d), + Fmt(f) => cli::run_fmt(&flags, f), + GenerateBuildMatrix(b) => cli::generate_build_matrix(&flags, b), + GenerateTestDriver(g) => cli::generate_test_driver(flags, g), + Info(i) => cli::run_info(flags, i), + Install(i) => cli::install_cli(flags, i), + Login(l) => cli::mooncake_adapter::login_cli(flags, l), + New(n) => cli::run_new(&flags, n), + Publish(p) => cli::mooncake_adapter::publish_cli(flags, p), + Register(r) => cli::mooncake_adapter::register_cli(flags, r), + Remove(r) => cli::remove_cli(flags, r), + Run(r) => cli::run_run(&flags, r), + Test(t) => cli::run_test(flags, t), + Tree(t) => cli::tree_cli(flags, t), + Update(u) => cli::update_cli(flags, u), + Upgrade => cli::run_upgrade(flags), + Version(v) => cli::run_version(v), + } +} diff --git a/crates/moon/tests/mod.rs b/crates/moon/tests/mod.rs new file mode 100644 index 00000000..8dc4b972 --- /dev/null +++ b/crates/moon/tests/mod.rs @@ -0,0 +1,202 @@ +mod test_cases; + +use expect_test::Expect; +use std::path::{Path, PathBuf}; + +fn check(actual: &str, expect: Expect) { + expect.assert_eq(actual) +} + +struct TestDir { + // tempfile::TempDir has a drop implementation that will remove the directory + // copy the test directory to a temporary directory to abvoid conflict with other tests when `cargo test` parallelly testing + path: tempfile::TempDir, +} + +impl TestDir { + // create a new TestDir with the test directory in tests/test_cases/ + fn new(sub: &str) -> Self { + let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests/test_cases") + .join(sub); + let tmp_dir = tempfile::TempDir::new().unwrap(); + copy(&dir, tmp_dir.path()).unwrap(); + Self { path: tmp_dir } + } + + // create a empty TestDir + fn new_empty() -> Self { + let tmp_dir = tempfile::TempDir::new().unwrap(); + Self { path: tmp_dir } + } + + fn join(&self, sub: impl AsRef) -> PathBuf { + self.path.path().join(sub.as_ref()) + } +} + +impl AsRef for TestDir { + fn as_ref(&self) -> &Path { + self.path.path() + } +} + +pub fn moon_bin() -> PathBuf { + snapbox::cmd::cargo_bin("moon") +} + +#[track_caller] +pub fn get_stdout_with_args_without_replace( + dir: &impl AsRef, + args: impl IntoIterator>, +) -> String { + let out = snapbox::cmd::Command::new(moon_bin()) + .current_dir(dir) + .args(args) + .assert() + .success() + .get_output() + .stdout + .to_owned(); + + let s = std::str::from_utf8(&out).unwrap().to_string(); + s +} + +pub fn get_stderr_with_args_without_replace( + dir: &impl AsRef, + args: impl IntoIterator>, +) -> String { + let out = snapbox::cmd::Command::new(moon_bin()) + .current_dir(dir) + .args(args) + .assert() + .failure() + .get_output() + .stderr + .to_owned(); + + let s = std::str::from_utf8(&out).unwrap().to_string(); + s +} + +#[track_caller] +pub fn get_stdout_with_args( + dir: &impl AsRef, + args: impl IntoIterator>, +) -> String { + let s = get_stdout_with_args_without_replace(dir, args); + let s = s.replace("\r\n", "\n"); + + s.replace('\\', "/") +} + +pub fn replace_dir(s: &str, dir: &impl AsRef) -> String { + let path_str1 = dunce::canonicalize(dir) + .unwrap() + .to_str() + .unwrap() + .to_string(); + println!("path_str1: {:?}", path_str1); + let s = s.replace("\\\\", "\\"); + println!("s: {:?}", s); + let s = s.replace(&path_str1, "$ROOT"); + let s = s.replace( + dunce::canonicalize(moonutil::moon_dir::home()) + .unwrap() + .to_str() + .unwrap(), + "$MOON_HOME", + ); + let s = s.replace(moon_bin().to_string_lossy().as_ref(), "moon"); + s.replace("\r\n", "\n").replace('\\', "/") +} + +#[track_caller] +pub fn get_stdout_with_args_and_replace_dir( + dir: &impl AsRef, + args: impl IntoIterator>, +) -> String { + let s = get_stdout_with_args_without_replace(dir, args); + replace_dir(&s, dir) +} + +pub fn get_stderr_with_args_and_replace_dir( + dir: &impl AsRef, + args: impl IntoIterator>, +) -> String { + let s = get_stderr_with_args_without_replace(dir, args); + replace_dir(&s, dir) +} + +pub fn get_stderr_with_args( + dir: &impl AsRef, + args: impl IntoIterator>, +) -> String { + let out = snapbox::cmd::Command::new(moon_bin()) + .current_dir(dir) + .args(args) + .assert() + .failure() + .get_output() + .stderr + .to_owned(); + + let s = std::str::from_utf8(&out).unwrap().to_string(); + let s = s.replace("\r\n", "\n"); + + s.replace('\\', "/") +} + +pub fn copy(src: &Path, dest: &Path) -> anyhow::Result<()> { + if src.is_dir() { + if !dest.exists() { + std::fs::create_dir_all(dest)?; + } + for entry in walkdir::WalkDir::new(src) { + let entry = entry?; + let path = entry.path(); + let relative_path = path.strip_prefix(src)?; + let dest_path = dest.join(relative_path); + if path.is_dir() { + if !dest_path.exists() { + std::fs::create_dir_all(dest_path)?; + } + } else { + std::fs::copy(path, dest_path)?; + } + } + } else { + std::fs::copy(src, dest)?; + } + Ok(()) +} + +pub fn replace_crlf_to_lf(s: &str) -> String { + s.replace("\r\n", "\n") +} + +pub fn get_err_stdout_with_args_without_replace( + dir: &impl AsRef, + args: impl IntoIterator>, +) -> String { + let out = snapbox::cmd::Command::new(moon_bin()) + .current_dir(dir) + .args(args) + .assert() + .failure() + .get_output() + .stdout + .to_owned(); + + let s = std::str::from_utf8(&out).unwrap().to_string(); + s +} + +pub fn get_err_stdout_with_args_and_replace_dir( + dir: &impl AsRef, + args: impl IntoIterator>, +) -> String { + let s = get_err_stdout_with_args_without_replace(dir, args); + replace_dir(&s, dir) +} diff --git a/crates/moon/tests/test_cases/alert_list.in/.gitignore b/crates/moon/tests/test_cases/alert_list.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/alert_list.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/alert_list.in/README.md b/crates/moon/tests/test_cases/alert_list.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/alert_list.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/alert_list.in/lib/hello.mbt b/crates/moon/tests/test_cases/alert_list.in/lib/hello.mbt new file mode 100644 index 00000000..5e981944 --- /dev/null +++ b/crates/moon/tests/test_cases/alert_list.in/lib/hello.mbt @@ -0,0 +1,12 @@ +test { + alert_1(); + alert_2(); +} + +/// @alert alert_1 "alert_1" +fn alert_1() -> Unit { +} + +/// @alert alert_2 "alert_2" +fn alert_2() -> Unit { +} diff --git a/crates/moon/tests/test_cases/alert_list.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/alert_list.in/lib/moon.pkg.json new file mode 100644 index 00000000..ce726eea --- /dev/null +++ b/crates/moon/tests/test_cases/alert_list.in/lib/moon.pkg.json @@ -0,0 +1,4 @@ +{ + "warn-list": "-2", + "alert-list": "-alert_1-alert_2" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/alert_list.in/main/main.mbt b/crates/moon/tests/test_cases/alert_list.in/main/main.mbt new file mode 100644 index 00000000..d7b32586 --- /dev/null +++ b/crates/moon/tests/test_cases/alert_list.in/main/main.mbt @@ -0,0 +1,13 @@ +fn main { + alert_1(); + alert_2(); +} + +/// @alert alert_1 "alert_1" +fn alert_1() -> Unit { +} + +/// @alert alert_2 "alert_2" +fn alert_2() -> Unit { + let a = 0 +} diff --git a/crates/moon/tests/test_cases/alert_list.in/main/moon.pkg.json b/crates/moon/tests/test_cases/alert_list.in/main/moon.pkg.json new file mode 100644 index 00000000..2b877d8e --- /dev/null +++ b/crates/moon/tests/test_cases/alert_list.in/main/moon.pkg.json @@ -0,0 +1,8 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ], + "warn-list": "-1-2", + "alert-list": "-alert_1" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/alert_list.in/moon.mod.json b/crates/moon/tests/test_cases/alert_list.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/alert_list.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/avl_tree.in/README.md b/crates/moon/tests/test_cases/avl_tree.in/README.md new file mode 100644 index 00000000..ec641411 --- /dev/null +++ b/crates/moon/tests/test_cases/avl_tree.in/README.md @@ -0,0 +1,3 @@ +## AVL tree + +Use Moonbit to implement an [AVL tree](https://en.wikipedia.org/wiki/AVL_tree), with printer to show its internal. diff --git a/crates/moon/tests/test_cases/avl_tree.in/lib/avl.mbt b/crates/moon/tests/test_cases/avl_tree.in/lib/avl.mbt new file mode 100644 index 00000000..caf29310 --- /dev/null +++ b/crates/moon/tests/test_cases/avl_tree.in/lib/avl.mbt @@ -0,0 +1,254 @@ +// https://en.wikipedia.org/wiki/AVL_tree +// https://zhuanlan.zhihu.com/p/430867594 + +// Empty represents an empty node in the AVL tree +// Node represents a node in the AVL tree with left child, value, right child, and height +pub enum T[U] { + Empty + Node(T[U], U, T[U], Int) +} + +/// Calculate the height of a tree-like structure using pattern matching. +/// +/// This function calculates the height of a tree-like structure represented by the +/// user-defined enum 'T[U]' using pattern matching. The height of an empty tree is 0, +/// and the height of a non-empty tree node is determined by its stored height value. +/// +/// @param {T[U]} self - A user-defined enum representing the tree-like structure. +/// @return {Int} The height of the tree-like structure. + +pub fn height[U](self : T[U]) -> Int { + match self { + Empty => 0 + Node(_, _, _, h) => h + } +} + +/// Create a new node with the given left and right subtrees, along with a value of type 'U'. +/// +/// This function constructs a new node of the user-defined enum type 'T[U]' using the provided left subtree 'l', +/// value 'v', and right subtree 'r'. The height of the node is determined by the maximum height between +/// the left and right subtrees, incremented by one. +/// +/// @param {T[U]} l - The left subtree of the node. +/// @param {U} v - The value to be stored in the node. +/// @param {T[U]} r - The right subtree of the node. +/// @return {T[U]} - A new node of type 'T[U]' with the specified left subtree, value, and right subtree. +fn create[U](l : T[U], v : U, r : T[U]) -> T[U] { + let hl = l.height() + let hr = r.height() + Node(l, v, r, if hl >= hr { hl + 1 } else { hr + 1 }) +} + +/// Perform balancing operation on a avl tree node. +/// +/// This function performs a balancing operation on a avl tree node based on the heights +/// of its left and right subtrees. It ensures that the heights of the subtrees are balanced +/// and returns a new avl tree node with appropriate restructuring if necessary. +/// +/// @param {T[U]} l - The left subtree of the node. +/// @param {U} v - The value of the node. +/// @param {T[U]} r - The right subtree of the node. +/// @return {T[U]} - A new avl tree node after balancing. +fn bal[U](l : T[U], v : U, r : T[U]) -> T[U] { + let hl = l.height() + let hr = r.height() + + // Left subtree is taller by more than 2 level + if hl > hr + 2 { + match l { + Empty => Empty // impossible + Node(ll, lv, lr, _) => + if ll.height() >= lr.height() { + create(ll, lv, create(lr, v, r)) + } else { + match lr { + Empty => Empty // impossible + Node(lrl, lrv, lrr, _) => + create(create(ll, lv, lrl), lrv, create(lrr, v, r)) + } + } + } + } else if hr > hl + 2 { + // Right subtree is taller by more than 2 level + match r { + Empty => Empty // impossible + Node(rl, rv, rr, _) => + if rr.height() >= rl.height() { + create(create(l, v, rl), rv, rr) + } else { + match rl { + Empty => Empty // impossible + Node(rll, rlv, rlr, _) => + create(create(l, v, rll), rlv, create(rlr, rv, rr)) + } + } + } + } else { + Node(l, v, r, if hl >= hr { hl + 1 } else { hr + 1 }) + } +} + +/// Adds a value to a tree node and performs balancing. +/// +/// This function adds a value 'x' to the given tree node 'self' of type 'T[U]'. The tree +/// node is expected to be of an enumerated type 'T', and the value type 'U' should implement +/// the 'Compare' interface for comparison. +/// +/// @param {T[U]} self - The tree node of type 'T[U]' to which the value will be added. +/// @param {U} x - The value of type 'U' to be added to the tree node. +/// @return {T[U]} A balanced tree node of type 'T[U]' after adding the value. +pub fn add[U : Compare](self : T[U], x : U) -> T[U] { + match self { + Empty => Node(Empty, x, Empty, 1) + Node(l, v, r, _) as t => { + let c = x.compare(v) + if c == 0 { + t + } else if c < 0 { + bal(l.add(x), v, r) + } else { + bal(l, v, r.add(x)) + } + } + } +} + +/// Find the minimum element in a tree-like data structure. +/// +/// This function operates on a tree-like data structure of type 'T[U]', where 'U' is a type parameter representing +/// the element type. The function recursively +/// navigates the tree using pattern matching to find the minimum element. +/// +/// @param {T[U]} 'self' - The tree-like data structure on which to find the minimum element. +/// @param {U} 'default' - The default value to return if the tree is empty. +/// @return {U} The minimum element found in the tree, or the 'default' value if the tree is empty. +fn min_elt[U](self : T[U], default : U) -> U { + match self { + Empty => default + Node(Empty, v, _, _) => v + Node(l, v, _, _) => l.min_elt(v) + } +} + +/// Remove the minimum element from a avl tree and rebalance the tree. +/// +/// This function takes a avl tree 'l' of type 'T[U]', an element 'v' of type 'U' to be removed, +/// and another avl tree 'r' of type 'T[U]'. It removes the minimum element from the tree 'l', +/// and then rebalances the resulting tree using the 'bal' function. +/// +/// @param {T[U]} l - A avl tree from which the minimum element is to be removed. +/// @param {U} v - An element of type 'U' to be removed from the tree. +/// @param {T[U]} r - Another avl tree to be combined with the modified 'l' after removal. +/// @return {T[U]} A avl tree resulting from the removal of the minimum element and rebalancing. +fn remove_min_elt[U](l : T[U], v : U, r : T[U]) -> T[U] { + match l { + Empty => r + Node(ll, lv, lr, _) => bal(remove_min_elt(ll, lv, lr), v, r) + } +} + +/// Merge two AVL trees of the same user-defined type 'U' into a new AVL tree. +/// +/// This function takes two AVL trees 'self' and 'other' of type 'T[U]' and merges them into a new AVL tree. +/// The result of the merge is a balanced AVL tree that contains all the elements from both input trees while +/// maintaining the AVL tree properties. +/// +/// @param {T[U]} self - The first AVL tree to merge. +/// @param {T[U]} other - The second AVL tree to merge. +/// @return {T[U]} A new AVL tree containing elements from both input trees, balanced to maintain AVL properties. +fn internal_merge[U](self : T[U], other : T[U]) -> T[U] { + match (self, other) { + (Empty, t) => t + (t, Empty) => t + (_, Node(rl, rv, rr, _)) => + bal(self, other.min_elt(rv), remove_min_elt(rl, rv, rr)) + } +} + +/// Removes a value from the AVL tree while maintaining balance. +/// +/// This function removes a value from the AVL tree while ensuring that the resulting tree +/// remains balanced according to the AVL tree balancing rules. The type 'U' represents +/// the type of values in the tree and must implement the 'Compare' interface for comparison. +/// +/// @param {T[U]} self - The AVL tree from which to remove the value. +/// @param {U} x - The value to be removed from the AVL tree. +/// @return {T[U]} - A new AVL tree with the specified value removed, maintaining balance. +pub fn remove[U : Compare](self : T[U], x : U) -> T[U] { + match self { + Empty => Empty + Node(l, v, r, _) => { + let c = x.compare(v) + if c == 0 { + l.internal_merge(r) + } else if c < 0 { + bal(l.remove(x), v, r) + } else { + bal(l, v, r.remove(x)) + } + } + } +} + +/// Repeat a given string a specified number of times. +/// +/// This function takes a string 's' and an integer 'n' as input and returns a new string +/// containing the original string repeated 'n' times. +/// +/// @param {String} s - The string to be repeated. +/// @param {Int} n - The number of times to repeat the string. +/// @return {String} A new string containing 's' repeated 'n' times. +fn repeat_str(s : String, n : Int) -> String { + let mut result = "" + let mut i = 0 + while i < n { + result = result + s + i = i + 1 + } + result +} + +/// Print the AVL tree +/// +/// This function prints the AVL tree by traversing it in an in-order manner and displaying +/// the nodes at each level with appropriate indentation. +/// +/// The value type 'U' should implement the 'to_string' interface for 'Show'. +/// +/// @param {T[U]} self - The AVL tree to be printed. +pub fn print_tree[U : Show](self : T[U]) -> Unit { + fn helper(node : T[U], level : Int) { + match node { + Empty => () + Node(l, v, r, _) => { + helper(l, level + 1) + let indent = repeat_str(" ", level) + println(indent + v.to_string()) + helper(r, level + 1) + } + } + } + + helper(self, 0) +} + +/// Check if a given element exists in an AVL tree. +/// +/// This function checks whether a specified element 'x' exists in the AVL tree. +/// Type 'U' must implement the 'Compare' interface. The function +/// recursively searches the tree's nodes for the given element. +/// +/// @param {T[U]} self - An AVL tree of type 'T' with elements of type 'U'. +/// @param {U} x - The element to search for in the AVL tree. +/// @return {Bool} - 'true' if the element exists in the tree, 'false' otherwise. +pub fn mem[U : Compare](self : T[U], x : U) -> Bool { + match self { + Empty => false + Node(l, v, r, _) => { + let c = x.compare(v) + let tree = if c < 0 { l } else { r } + c == 0 || tree.mem(x) + } + } +} diff --git a/crates/moon/tests/test_cases/avl_tree.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/avl_tree.in/lib/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/avl_tree.in/lib/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/avl_tree.in/main/main.mbt b/crates/moon/tests/test_cases/avl_tree.in/main/main.mbt new file mode 100644 index 00000000..1c9871dc --- /dev/null +++ b/crates/moon/tests/test_cases/avl_tree.in/main/main.mbt @@ -0,0 +1,36 @@ +fn main { + let mut v : @lib.T[Int] = Empty // Create an empty AVL tree with Int type + let iter = 30 + + // Add values from 0 to iter-1 to the AVL tree + let mut i = 0 + while i < iter { + v = v.add(i) + i = i + 1 + } + let height = v.height() + println("height of the tree: \(height)") + v.print_tree() + + // Check values from 0 to iter-1 in the AVL tree + let mut j = 0 + while j < iter { + if not(v.mem(j)) { + println("impossible") + } + j = j + 1 + } + + // Remove values from 0 to iter-1 from the AVL tree + let mut k = 0 + while k < iter { + v = v.remove(k) + k = k + 1 + } + + // Tree is empty, removal successful + match v { + Empty => println("success") + Node(_) => println("impossible") + } +} diff --git a/crates/moon/tests/test_cases/avl_tree.in/main/moon.pkg.json b/crates/moon/tests/test_cases/avl_tree.in/main/moon.pkg.json new file mode 100644 index 00000000..9732c503 --- /dev/null +++ b/crates/moon/tests/test_cases/avl_tree.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "avl_tree/lib": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/avl_tree.in/moon.mod.json b/crates/moon/tests/test_cases/avl_tree.in/moon.mod.json new file mode 100644 index 00000000..bbd425d3 --- /dev/null +++ b/crates/moon/tests/test_cases/avl_tree.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "avl_tree" +} diff --git a/crates/moon/tests/test_cases/backend-flag.in/.gitignore b/crates/moon/tests/test_cases/backend-flag.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/backend-flag.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/backend-flag.in/README.md b/crates/moon/tests/test_cases/backend-flag.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/backend-flag.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/backend-flag.in/lib/hello.mbt b/crates/moon/tests/test_cases/backend-flag.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/backend-flag.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/backend-flag.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/backend-flag.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..64f26429 --- /dev/null +++ b/crates/moon/tests/test_cases/backend-flag.in/lib/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test "hello" { + if hello() != "Hello, world!" { + return Err("hello() != \"Hello, world!\"") + } +} diff --git a/crates/moon/tests/test_cases/backend-flag.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/backend-flag.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/backend-flag.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/backend-flag.in/main/main.mbt b/crates/moon/tests/test_cases/backend-flag.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/backend-flag.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/backend-flag.in/main/moon.pkg.json b/crates/moon/tests/test_cases/backend-flag.in/main/moon.pkg.json new file mode 100644 index 00000000..48783525 --- /dev/null +++ b/crates/moon/tests/test_cases/backend-flag.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/backend-flag.in/moon.mod.json b/crates/moon/tests/test_cases/backend-flag.in/moon.mod.json new file mode 100644 index 00000000..5e09be76 --- /dev/null +++ b/crates/moon/tests/test_cases/backend-flag.in/moon.mod.json @@ -0,0 +1,10 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "", + "_backend": "js" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/backend_config.in/.gitignore b/crates/moon/tests/test_cases/backend_config.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/backend_config.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/backend_config.in/README.md b/crates/moon/tests/test_cases/backend_config.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/backend_config.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/backend_config.in/lib/hello.mbt b/crates/moon/tests/test_cases/backend_config.in/lib/hello.mbt new file mode 100644 index 00000000..87ad9507 --- /dev/null +++ b/crates/moon/tests/test_cases/backend_config.in/lib/hello.mbt @@ -0,0 +1,7 @@ +pub fn hello() -> String { + "Hello, world!" +} + +pub fn foo() -> String { + "foo" +} diff --git a/crates/moon/tests/test_cases/backend_config.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/backend_config.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..64f26429 --- /dev/null +++ b/crates/moon/tests/test_cases/backend_config.in/lib/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test "hello" { + if hello() != "Hello, world!" { + return Err("hello() != \"Hello, world!\"") + } +} diff --git a/crates/moon/tests/test_cases/backend_config.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/backend_config.in/lib/moon.pkg.json new file mode 100644 index 00000000..1e87f8d9 --- /dev/null +++ b/crates/moon/tests/test_cases/backend_config.in/lib/moon.pkg.json @@ -0,0 +1,20 @@ +{ + "link": { + "wasm": { + "exports": [ + "hello:hello_wasm", + "foo:bar" + ] + }, + "wasm-gc": { + "exports": [ + "hello:hello_wasm_gc" + ] + }, + "js": { + "exports": [ + "hello:hello_js" + ] + } + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/backend_config.in/main/main.mbt b/crates/moon/tests/test_cases/backend_config.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/backend_config.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/backend_config.in/main/moon.pkg.json b/crates/moon/tests/test_cases/backend_config.in/main/moon.pkg.json new file mode 100644 index 00000000..48783525 --- /dev/null +++ b/crates/moon/tests/test_cases/backend_config.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/backend_config.in/moon.mod.json b/crates/moon/tests/test_cases/backend_config.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/backend_config.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/backtrace.in/.gitignore b/crates/moon/tests/test_cases/backtrace.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/backtrace.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/backtrace.in/README.md b/crates/moon/tests/test_cases/backtrace.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/backtrace.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/backtrace.in/main/main.mbt b/crates/moon/tests/test_cases/backtrace.in/main/main.mbt new file mode 100644 index 00000000..fa07ef97 --- /dev/null +++ b/crates/moon/tests/test_cases/backtrace.in/main/main.mbt @@ -0,0 +1,11 @@ +fn foo() -> Unit { + abort("hah") +} + +fn bar() -> Unit { + foo() +} + +fn main { + bar() +} diff --git a/crates/moon/tests/test_cases/backtrace.in/main/moon.pkg.json b/crates/moon/tests/test_cases/backtrace.in/main/moon.pkg.json new file mode 100644 index 00000000..fcc86bad --- /dev/null +++ b/crates/moon/tests/test_cases/backtrace.in/main/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "is-main": true +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/backtrace.in/moon.mod.json b/crates/moon/tests/test_cases/backtrace.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/backtrace.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_0_0/main.mbt b/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_0_0/main.mbt new file mode 100644 index 00000000..2fef350e --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_0_0/main.mbt @@ -0,0 +1,3 @@ +// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // +pub fn f() -> Unit { +} diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_0_0/moon.pkg.json b/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_0_0/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_0_0/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_0_1/main.mbt b/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_0_1/main.mbt new file mode 100644 index 00000000..2fef350e --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_0_1/main.mbt @@ -0,0 +1,3 @@ +// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // +pub fn f() -> Unit { +} diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_0_1/moon.pkg.json b/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_0_1/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_0_1/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_1_0/main.mbt b/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_1_0/main.mbt new file mode 100644 index 00000000..6698d69e --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_1_0/main.mbt @@ -0,0 +1,5 @@ +// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // +pub fn f() -> Unit { + @m_0_0_0_0.f() + @m_0_0_0_1.f() +} diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_1_0/moon.pkg.json b/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_1_0/moon.pkg.json new file mode 100644 index 00000000..8c8378aa --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_1_0/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "import": { + "build_matrix/dir_0_0/m_0_0_0_0": "", + "build_matrix/dir_0_0/m_0_0_0_1": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/bench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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // +pub fn f() -> Unit { + @m_0_0_0_0.f() + @m_0_0_0_1.f() +} diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_1_1/moon.pkg.json b/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_1_1/moon.pkg.json new file mode 100644 index 00000000..8c8378aa --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_0_0/m_0_0_1_1/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "import": { + "build_matrix/dir_0_0/m_0_0_0_0": "", + "build_matrix/dir_0_0/m_0_0_0_1": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_0_0/main.mbt b/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_0_0/main.mbt new file mode 100644 index 00000000..2fef350e --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_0_0/main.mbt @@ -0,0 +1,3 @@ +// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // +pub fn f() -> Unit { +} diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_0_0/moon.pkg.json b/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_0_0/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_0_0/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_0_1/main.mbt b/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_0_1/main.mbt new file mode 100644 index 00000000..2fef350e --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_0_1/main.mbt @@ -0,0 +1,3 @@ +// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // +pub fn f() -> Unit { +} diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_0_1/moon.pkg.json b/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_0_1/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_0_1/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_1_0/main.mbt b/crates/moon/tests/test_cases/bench2_test.in/dir_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n f() -> Unit { + @m_0_1_0_0.f() + @m_0_1_0_1.f() +} diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_1_0/moon.pkg.json b/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_1_0/moon.pkg.json new file mode 100644 index 00000000..1cd4453b --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_1_0/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "import": { + "build_matrix/dir_0_1/m_0_1_0_0": "", + "build_matrix/dir_0_1/m_0_1_0_1": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_1_1/main.mbt b/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_1_1/main.mbt new file mode 100644 index 00000000..e56b6dd0 --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_1_1/main.mbt @@ -0,0 +1,5 @@ +// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // +pub fn f() -> Unit { + @m_0_1_0_0.f() + @m_0_1_0_1.f() +} diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_1_1/moon.pkg.json b/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_1_1/moon.pkg.json new file mode 100644 index 00000000..1cd4453b --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_0_1/m_0_1_1_1/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "import": { + "build_matrix/dir_0_1/m_0_1_0_0": "", + "build_matrix/dir_0_1/m_0_1_0_1": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_0_0/main.mbt b/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_0_0/main.mbt new file mode 100644 index 00000000..c2afeabf --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_0_0/main.mbt @@ -0,0 +1,7 @@ +// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // +pub fn f() -> Unit { + @m_0_0_1_0.f() + @m_0_1_1_0.f() + @m_0_0_1_1.f() + @m_0_1_1_1.f() +} diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_0_0/moon.pkg.json b/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_0_0/moon.pkg.json new file mode 100644 index 00000000..b2664e77 --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_0_0/moon.pkg.json @@ -0,0 +1,8 @@ +{ + "import": { + "build_matrix/dir_0_0/m_0_0_1_0": "", + "build_matrix/dir_0_1/m_0_1_1_0": "", + "build_matrix/dir_0_0/m_0_0_1_1": "", + "build_matrix/dir_0_1/m_0_1_1_1": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_0_1/main.mbt b/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_0_1/main.mbt new file mode 100644 index 00000000..c2afeabf --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_0_1/main.mbt @@ -0,0 +1,7 @@ +// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // +pub fn f() -> Unit { + @m_0_0_1_0.f() + @m_0_1_1_0.f() + @m_0_0_1_1.f() + @m_0_1_1_1.f() +} diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_0_1/moon.pkg.json b/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_0_1/moon.pkg.json new file mode 100644 index 00000000..b2664e77 --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_0_1/moon.pkg.json @@ -0,0 +1,8 @@ +{ + "import": { + "build_matrix/dir_0_0/m_0_0_1_0": "", + "build_matrix/dir_0_1/m_0_1_1_0": "", + "build_matrix/dir_0_0/m_0_0_1_1": "", + "build_matrix/dir_0_1/m_0_1_1_1": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_1_0/main.mbt b/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_1_0/main.mbt new file mode 100644 index 00000000..63cec707 --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_1_0/main.mbt @@ -0,0 +1,5 @@ +// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // +pub fn f() -> Unit { + @m_1_0_0_0.f() + @m_1_0_0_1.f() +} diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_1_0/moon.pkg.json b/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_1_0/moon.pkg.json new file mode 100644 index 00000000..283b4f80 --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_1_0/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "import": { + "build_matrix/dir_1_0/m_1_0_0_0": "", + "build_matrix/dir_1_0/m_1_0_0_1": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/bench2_test.in/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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // +pub fn f() -> Unit { + @m_1_0_0_0.f() + @m_1_0_0_1.f() +} diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_1_1/moon.pkg.json b/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_1_1/moon.pkg.json new file mode 100644 index 00000000..283b4f80 --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_1_0/m_1_0_1_1/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "import": { + "build_matrix/dir_1_0/m_1_0_0_0": "", + "build_matrix/dir_1_0/m_1_0_0_1": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_0_0/main.mbt b/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_0_0/main.mbt new file mode 100644 index 00000000..c2afeabf --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_0_0/main.mbt @@ -0,0 +1,7 @@ +// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // +pub fn f() -> Unit { + @m_0_0_1_0.f() + @m_0_1_1_0.f() + @m_0_0_1_1.f() + @m_0_1_1_1.f() +} diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_0_0/moon.pkg.json b/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_0_0/moon.pkg.json new file mode 100644 index 00000000..b2664e77 --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_0_0/moon.pkg.json @@ -0,0 +1,8 @@ +{ + "import": { + "build_matrix/dir_0_0/m_0_0_1_0": "", + "build_matrix/dir_0_1/m_0_1_1_0": "", + "build_matrix/dir_0_0/m_0_0_1_1": "", + "build_matrix/dir_0_1/m_0_1_1_1": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_0_1/main.mbt b/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_0_1/main.mbt new file mode 100644 index 00000000..c2afeabf --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_0_1/main.mbt @@ -0,0 +1,7 @@ +// XXXXXXXXX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/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_0_1/moon.pkg.json new file mode 100644 index 00000000..b2664e77 --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_0_1/moon.pkg.json @@ -0,0 +1,8 @@ +{ + "import": { + "build_matrix/dir_0_0/m_0_0_1_0": "", + "build_matrix/dir_0_1/m_0_1_1_0": "", + "build_matrix/dir_0_0/m_0_0_1_1": "", + "build_matrix/dir_0_1/m_0_1_1_1": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_1_0/main.mbt b/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_1_0/main.mbt new file mode 100644 index 00000000..86c926b2 --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_1_0/main.mbt @@ -0,0 +1,5 @@ +// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // +pub fn f() -> Unit { + @m_1_1_0_0.f() + @m_1_1_0_1.f() +} diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_1_0/moon.pkg.json b/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_1_0/moon.pkg.json new file mode 100644 index 00000000..d1cf3160 --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_1_0/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "import": { + "build_matrix/dir_1_1/m_1_1_0_0": "", + "build_matrix/dir_1_1/m_1_1_0_1": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_1_1/main.mbt b/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_1_1/main.mbt new file mode 100644 index 00000000..86c926b2 --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_1_1/main.mbt @@ -0,0 +1,5 @@ +// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // +pub fn f() -> Unit { + @m_1_1_0_0.f() + @m_1_1_0_1.f() +} diff --git a/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_1_1/moon.pkg.json b/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_1_1/moon.pkg.json new file mode 100644 index 00000000..d1cf3160 --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/dir_1_1/m_1_1_1_1/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "import": { + "build_matrix/dir_1_1/m_1_1_0_0": "", + "build_matrix/dir_1_1/m_1_1_0_1": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/bench2_test.in/main/main.mbt b/crates/moon/tests/test_cases/bench2_test.in/main/main.mbt new file mode 100644 index 00000000..09c56783 --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/main/main.mbt @@ -0,0 +1,19 @@ +fn main { + let _ = @m_0_0_0_0.f + let _ = @m_0_0_0_1.f + let _ = @m_0_0_1_0.f + let _ = @m_0_0_1_1.f + let _ = @m_0_1_0_0.f + let _ = @m_0_1_0_1.f + let _ = @m_0_1_1_0.f + let _ = @m_0_1_1_1.f + let _ = @m_1_0_0_0.f + let _ = @m_1_0_0_1.f + let _ = @m_1_0_1_0.f + let _ = @m_1_0_1_1.f + let _ = @m_1_1_0_0.f + let _ = @m_1_1_0_1.f + let _ = @m_1_1_1_0.f + let _ = @m_1_1_1_1.f + println("ok") +} diff --git a/crates/moon/tests/test_cases/bench2_test.in/main/moon.pkg.json b/crates/moon/tests/test_cases/bench2_test.in/main/moon.pkg.json new file mode 100644 index 00000000..6accd5c0 --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/main/moon.pkg.json @@ -0,0 +1,21 @@ +{ + "is-main": true, + "import": { + "build_matrix/dir_0_0/m_0_0_0_0": "", + "build_matrix/dir_0_0/m_0_0_0_1": "", + "build_matrix/dir_0_0/m_0_0_1_0": "", + "build_matrix/dir_0_0/m_0_0_1_1": "", + "build_matrix/dir_0_1/m_0_1_0_0": "", + "build_matrix/dir_0_1/m_0_1_0_1": "", + "build_matrix/dir_0_1/m_0_1_1_0": "", + "build_matrix/dir_0_1/m_0_1_1_1": "", + "build_matrix/dir_1_0/m_1_0_0_0": "", + "build_matrix/dir_1_0/m_1_0_0_1": "", + "build_matrix/dir_1_0/m_1_0_1_0": "", + "build_matrix/dir_1_0/m_1_0_1_1": "", + "build_matrix/dir_1_1/m_1_1_0_0": "", + "build_matrix/dir_1_1/m_1_1_0_1": "", + "build_matrix/dir_1_1/m_1_1_1_0": "", + "build_matrix/dir_1_1/m_1_1_1_1": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/bench2_test.in/moon.mod.json b/crates/moon/tests/test_cases/bench2_test.in/moon.mod.json new file mode 100644 index 00000000..6143fe76 --- /dev/null +++ b/crates/moon/tests/test_cases/bench2_test.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "build_matrix" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/blackbox_failed_test.in/A/hello.mbt b/crates/moon/tests/test_cases/blackbox_failed_test.in/A/hello.mbt new file mode 100644 index 00000000..90c8c0a9 --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_failed_test.in/A/hello.mbt @@ -0,0 +1,7 @@ +pub fn hello() -> Unit { + println("output from A/hello.mbt!") +} + +fn _private_hello() -> Unit { + println("output from A/hello.mbt::_private_hello") +} diff --git a/crates/moon/tests/test_cases/blackbox_failed_test.in/A/hello_test.mbt b/crates/moon/tests/test_cases/blackbox_failed_test.in/A/hello_test.mbt new file mode 100644 index 00000000..f06e81d2 --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_failed_test.in/A/hello_test.mbt @@ -0,0 +1,10 @@ +pub fn hello_bbtest() -> Unit { + println("output from A/hello_bbtest.mbt!") +} + +test { + let a = 1 + let mut b = 1 + // should failed + @A._private_hello() +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/blackbox_failed_test.in/A/hello_wbtest.mbt b/crates/moon/tests/test_cases/blackbox_failed_test.in/A/hello_wbtest.mbt new file mode 100644 index 00000000..d16c572a --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_failed_test.in/A/hello_wbtest.mbt @@ -0,0 +1,13 @@ +pub fn hello_test() -> Unit { + println("output from A/hello_test.mbt!") +} + +test { + // it's ok for _test.mbt to use test_import + @B.hello() +} + +test { + // should failed, bbtest_import could no be used in _test.mbt + @C.hello() +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/blackbox_failed_test.in/A/moon.pkg.json b/crates/moon/tests/test_cases/blackbox_failed_test.in/A/moon.pkg.json new file mode 100644 index 00000000..3e169cca --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_failed_test.in/A/moon.pkg.json @@ -0,0 +1,9 @@ +{ + "import": [], + "wbtest-import": [ + "username/hello/B" + ], + "test-import": [ + "username/hello/C" + ] +} diff --git a/crates/moon/tests/test_cases/blackbox_failed_test.in/B/hello.mbt b/crates/moon/tests/test_cases/blackbox_failed_test.in/B/hello.mbt new file mode 100644 index 00000000..b615d2f8 --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_failed_test.in/B/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> Unit { + println("output from B/hello.mbt!") +} + diff --git a/crates/moon/tests/test_cases/blackbox_failed_test.in/B/moon.pkg.json b/crates/moon/tests/test_cases/blackbox_failed_test.in/B/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_failed_test.in/B/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/blackbox_failed_test.in/C/hello.mbt b/crates/moon/tests/test_cases/blackbox_failed_test.in/C/hello.mbt new file mode 100644 index 00000000..5ac3ffa2 --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_failed_test.in/C/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> Unit { + println("output from C/hello.mbt!") +} + diff --git a/crates/moon/tests/test_cases/blackbox_failed_test.in/C/moon.pkg.json b/crates/moon/tests/test_cases/blackbox_failed_test.in/C/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_failed_test.in/C/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/blackbox_failed_test.in/main/main.mbt b/crates/moon/tests/test_cases/blackbox_failed_test.in/main/main.mbt new file mode 100644 index 00000000..1807db5d --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_failed_test.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println("hello from main.mbt!") +} diff --git a/crates/moon/tests/test_cases/blackbox_failed_test.in/main/moon.pkg.json b/crates/moon/tests/test_cases/blackbox_failed_test.in/main/moon.pkg.json new file mode 100644 index 00000000..fcc86bad --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_failed_test.in/main/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "is-main": true +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/blackbox_failed_test.in/moon.mod.json b/crates/moon/tests/test_cases/blackbox_failed_test.in/moon.mod.json new file mode 100644 index 00000000..ed90db93 --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_failed_test.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "username/hello" +} diff --git a/crates/moon/tests/test_cases/blackbox_success_test.in/A/hello.mbt b/crates/moon/tests/test_cases/blackbox_success_test.in/A/hello.mbt new file mode 100644 index 00000000..2f2e5656 --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_success_test.in/A/hello.mbt @@ -0,0 +1,22 @@ +pub fn hello() -> Unit { + println("output from A/hello.mbt!") +} + +fn _private_hello() -> Unit { + println("output from A/hello.mbt::_private_hello") +} + +struct StructA { + a: Int +} + +pub fn new() -> StructA { + { + a: 33 + } +} + +pub fn method(self : StructA) -> Unit { + println("self.a: " + self.a.to_string()) +} + diff --git a/crates/moon/tests/test_cases/blackbox_success_test.in/A/hello_test.mbt b/crates/moon/tests/test_cases/blackbox_success_test.in/A/hello_test.mbt new file mode 100644 index 00000000..47127717 --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_success_test.in/A/hello_test.mbt @@ -0,0 +1,17 @@ +pub fn hello_bbtest() -> Unit { + println("output from A/hello_bbtest.mbt!") +} + +test { + // current pkg + @A.hello() + // bbtest_import pkg + @C.hello() + // import pkg + @D.hello() +} + +test { + let a = @A.new() + a.method() +} diff --git a/crates/moon/tests/test_cases/blackbox_success_test.in/A/hello_wbtest.mbt b/crates/moon/tests/test_cases/blackbox_success_test.in/A/hello_wbtest.mbt new file mode 100644 index 00000000..034e32e1 --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_success_test.in/A/hello_wbtest.mbt @@ -0,0 +1,4 @@ +pub fn hello_test() -> Unit { + println("output from A/hello_test.mbt!") +} + diff --git a/crates/moon/tests/test_cases/blackbox_success_test.in/A/moon.pkg.json b/crates/moon/tests/test_cases/blackbox_success_test.in/A/moon.pkg.json new file mode 100644 index 00000000..d2a5b5f6 --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_success_test.in/A/moon.pkg.json @@ -0,0 +1,11 @@ +{ + "import": [ + "username/hello/D" + ], + "wbtest-import": [ + "username/hello/B" + ], + "test-import": [ + "username/hello/C" + ] +} diff --git a/crates/moon/tests/test_cases/blackbox_success_test.in/B/hello.mbt b/crates/moon/tests/test_cases/blackbox_success_test.in/B/hello.mbt new file mode 100644 index 00000000..b615d2f8 --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_success_test.in/B/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> Unit { + println("output from B/hello.mbt!") +} + diff --git a/crates/moon/tests/test_cases/blackbox_success_test.in/B/moon.pkg.json b/crates/moon/tests/test_cases/blackbox_success_test.in/B/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_success_test.in/B/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/blackbox_success_test.in/C/hello.mbt b/crates/moon/tests/test_cases/blackbox_success_test.in/C/hello.mbt new file mode 100644 index 00000000..5ac3ffa2 --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_success_test.in/C/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> Unit { + println("output from C/hello.mbt!") +} + diff --git a/crates/moon/tests/test_cases/blackbox_success_test.in/C/moon.pkg.json b/crates/moon/tests/test_cases/blackbox_success_test.in/C/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_success_test.in/C/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/blackbox_success_test.in/D/hello.mbt b/crates/moon/tests/test_cases/blackbox_success_test.in/D/hello.mbt new file mode 100644 index 00000000..6d7c0788 --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_success_test.in/D/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> Unit { + println("output from D/hello.mbt!") +} + diff --git a/crates/moon/tests/test_cases/blackbox_success_test.in/D/moon.pkg.json b/crates/moon/tests/test_cases/blackbox_success_test.in/D/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_success_test.in/D/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/blackbox_success_test.in/main/main.mbt b/crates/moon/tests/test_cases/blackbox_success_test.in/main/main.mbt new file mode 100644 index 00000000..1807db5d --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_success_test.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println("hello from main.mbt!") +} diff --git a/crates/moon/tests/test_cases/blackbox_success_test.in/main/moon.pkg.json b/crates/moon/tests/test_cases/blackbox_success_test.in/main/moon.pkg.json new file mode 100644 index 00000000..fcc86bad --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_success_test.in/main/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "is-main": true +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/blackbox_success_test.in/moon.mod.json b/crates/moon/tests/test_cases/blackbox_success_test.in/moon.mod.json new file mode 100644 index 00000000..ed90db93 --- /dev/null +++ b/crates/moon/tests/test_cases/blackbox_success_test.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "username/hello" +} diff --git a/crates/moon/tests/test_cases/cakenew_test.in/.gitignore b/crates/moon/tests/test_cases/cakenew_test.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/cakenew_test.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/cakenew_test.in/lib/hello.mbt b/crates/moon/tests/test_cases/cakenew_test.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/cakenew_test.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/cakenew_test.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/cakenew_test.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/cakenew_test.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/cakenew_test.in/main/main.mbt b/crates/moon/tests/test_cases/cakenew_test.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/cakenew_test.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/cakenew_test.in/main/moon.pkg.json b/crates/moon/tests/test_cases/cakenew_test.in/main/moon.pkg.json new file mode 100644 index 00000000..a2e1932e --- /dev/null +++ b/crates/moon/tests/test_cases/cakenew_test.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "test/cakenew/lib": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/cakenew_test.in/moon.mod.json b/crates/moon/tests/test_cases/cakenew_test.in/moon.mod.json new file mode 100644 index 00000000..1ad68fc9 --- /dev/null +++ b/crates/moon/tests/test_cases/cakenew_test.in/moon.mod.json @@ -0,0 +1,4 @@ +{ + "name": "test/cakenew", + "version": "0.1.0" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/capture_abort_test.in/lib/hello.mbt b/crates/moon/tests/test_cases/capture_abort_test.in/lib/hello.mbt new file mode 100644 index 00000000..a7ac2bee --- /dev/null +++ b/crates/moon/tests/test_cases/capture_abort_test.in/lib/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> String { + "Hello, world!" +} + diff --git a/crates/moon/tests/test_cases/capture_abort_test.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/capture_abort_test.in/lib/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/capture_abort_test.in/lib/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/capture_abort_test.in/main/main.mbt b/crates/moon/tests/test_cases/capture_abort_test.in/main/main.mbt new file mode 100644 index 00000000..6a1e73af --- /dev/null +++ b/crates/moon/tests/test_cases/capture_abort_test.in/main/main.mbt @@ -0,0 +1,4 @@ +fn main { + abort("test-capture-abort") + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/capture_abort_test.in/main/moon.pkg.json b/crates/moon/tests/test_cases/capture_abort_test.in/main/moon.pkg.json new file mode 100644 index 00000000..9b2dcaba --- /dev/null +++ b/crates/moon/tests/test_cases/capture_abort_test.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "capture/lib": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/capture_abort_test.in/moon.mod.json b/crates/moon/tests/test_cases/capture_abort_test.in/moon.mod.json new file mode 100644 index 00000000..cc8ed6f4 --- /dev/null +++ b/crates/moon/tests/test_cases/capture_abort_test.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "capture" +} diff --git a/crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/lib/hello.mbt b/crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/lib/hello.mbt new file mode 100644 index 00000000..b3c24a3c --- /dev/null +++ b/crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/lib/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> String { + 1 +} + diff --git a/crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/lib/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/lib/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/main/main.mbt b/crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/main/moon.pkg.json b/crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/main/moon.pkg.json new file mode 100644 index 00000000..4343a4ef --- /dev/null +++ b/crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "moon_new/lib": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/moon.mod.json b/crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/moon.mod.json new file mode 100644 index 00000000..b5d8b346 --- /dev/null +++ b/crates/moon/tests/test_cases/check_failed_should_write_pkg_json.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "moon_new" +} diff --git a/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/A/lib.mbt b/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/A/lib.mbt new file mode 100644 index 00000000..da57cded --- /dev/null +++ b/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/A/lib.mbt @@ -0,0 +1,4 @@ +pub fn f() -> Unit { + @B.f() + println("A") +} diff --git a/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/A/moon.pkg.json b/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/A/moon.pkg.json new file mode 100644 index 00000000..958f9e17 --- /dev/null +++ b/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/A/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": { + "hello/B": "" + } +} diff --git a/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/B/lib.mbt b/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/B/lib.mbt new file mode 100644 index 00000000..98f4a947 --- /dev/null +++ b/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/B/lib.mbt @@ -0,0 +1,4 @@ +pub fn f() -> Unit { + @A.f() + println("B") +} diff --git a/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/B/moon.pkg.json b/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/B/moon.pkg.json new file mode 100644 index 00000000..d83e82ab --- /dev/null +++ b/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/B/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": { + "hello/A": "" + } +} diff --git a/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/main/main.mbt b/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/main/main.mbt new file mode 100644 index 00000000..737e3785 --- /dev/null +++ b/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/main/main.mbt @@ -0,0 +1,5 @@ +fn main { + @A.f() + @B.f() + println("main") +} diff --git a/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/main/moon.pkg.json b/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/main/moon.pkg.json new file mode 100644 index 00000000..f65683f6 --- /dev/null +++ b/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/main/moon.pkg.json @@ -0,0 +1,7 @@ +{ + "is-main": true, + "import": { + "hello/B": "", + "hello/A": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/moon.mod.json b/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/moon.mod.json new file mode 100644 index 00000000..61113747 --- /dev/null +++ b/crates/moon/tests/test_cases/circle_pkg_AB_001_test.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "hello" +} diff --git a/crates/moon/tests/test_cases/core_order.in/.gitignore b/crates/moon/tests/test_cases/core_order.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/core_order.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/core_order.in/A/a.mbt b/crates/moon/tests/test_cases/core_order.in/A/a.mbt new file mode 100644 index 00000000..0e9776d8 --- /dev/null +++ b/crates/moon/tests/test_cases/core_order.in/A/a.mbt @@ -0,0 +1,11 @@ +pub fn a() -> String { + "a" +} + +test "inline test a.mbt" { + println("inline test in a.mbt") +} + +fn init { + println("init a.mbt") +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/core_order.in/A/a_wbtest.mbt b/crates/moon/tests/test_cases/core_order.in/A/a_wbtest.mbt new file mode 100644 index 00000000..965778a9 --- /dev/null +++ b/crates/moon/tests/test_cases/core_order.in/A/a_wbtest.mbt @@ -0,0 +1,7 @@ +test "inline test a_test.mbt" { + println("inline test a_test.mbt") +} + +fn init { + println("init a_test.mbt") +} diff --git a/crates/moon/tests/test_cases/core_order.in/A/moon.pkg.json b/crates/moon/tests/test_cases/core_order.in/A/moon.pkg.json new file mode 100644 index 00000000..f7e8d7a9 --- /dev/null +++ b/crates/moon/tests/test_cases/core_order.in/A/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": [ + "lijunchen/hello/T" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/core_order.in/B/b.mbt b/crates/moon/tests/test_cases/core_order.in/B/b.mbt new file mode 100644 index 00000000..51a17f10 --- /dev/null +++ b/crates/moon/tests/test_cases/core_order.in/B/b.mbt @@ -0,0 +1,11 @@ +pub fn b() -> String { + "b" +} + +test "inline test b.mbt" { + println("inline test in b.mbt") +} + +fn init { + println("init b.mbt") +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/core_order.in/B/b_wbtest.mbt b/crates/moon/tests/test_cases/core_order.in/B/b_wbtest.mbt new file mode 100644 index 00000000..aab7995d --- /dev/null +++ b/crates/moon/tests/test_cases/core_order.in/B/b_wbtest.mbt @@ -0,0 +1,7 @@ +test "inline test b_test.mbt" { + println("inline test b_test.mbt") +} + +fn init { + println("init b_test.mbt") +} diff --git a/crates/moon/tests/test_cases/core_order.in/B/moon.pkg.json b/crates/moon/tests/test_cases/core_order.in/B/moon.pkg.json new file mode 100644 index 00000000..f7e8d7a9 --- /dev/null +++ b/crates/moon/tests/test_cases/core_order.in/B/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": [ + "lijunchen/hello/T" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/core_order.in/T/moon.pkg.json b/crates/moon/tests/test_cases/core_order.in/T/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/core_order.in/T/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/core_order.in/T/t.mbt b/crates/moon/tests/test_cases/core_order.in/T/t.mbt new file mode 100644 index 00000000..16711abd --- /dev/null +++ b/crates/moon/tests/test_cases/core_order.in/T/t.mbt @@ -0,0 +1,11 @@ +pub fn t() -> String { + "T" +} + +test "inline test t.mbt" { + println("inline test in t.mbt") +} + +fn init { + println("init t.mbt") +} diff --git a/crates/moon/tests/test_cases/core_order.in/T/t_wbtest.mbt b/crates/moon/tests/test_cases/core_order.in/T/t_wbtest.mbt new file mode 100644 index 00000000..4d4f52e1 --- /dev/null +++ b/crates/moon/tests/test_cases/core_order.in/T/t_wbtest.mbt @@ -0,0 +1,8 @@ +test "inline test t_test.mbt" { + t() + println("inline test t_test.mbt") +} + +fn init { + println("init t_test.mbt") +} diff --git a/crates/moon/tests/test_cases/core_order.in/main/main.mbt b/crates/moon/tests/test_cases/core_order.in/main/main.mbt new file mode 100644 index 00000000..d72b9c5b --- /dev/null +++ b/crates/moon/tests/test_cases/core_order.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println("init main.mbt") +} diff --git a/crates/moon/tests/test_cases/core_order.in/main/moon.pkg.json b/crates/moon/tests/test_cases/core_order.in/main/moon.pkg.json new file mode 100644 index 00000000..268d794e --- /dev/null +++ b/crates/moon/tests/test_cases/core_order.in/main/moon.pkg.json @@ -0,0 +1,7 @@ +{ + "is-main": true, + "import": [ + "lijunchen/hello/A", + "lijunchen/hello/B" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/core_order.in/moon.mod.json b/crates/moon/tests/test_cases/core_order.in/moon.mod.json new file mode 100644 index 00000000..8380388a --- /dev/null +++ b/crates/moon/tests/test_cases/core_order.in/moon.mod.json @@ -0,0 +1,5 @@ +{ + "name": "lijunchen/hello", + "version": "0.1.0", + "deps": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/debug_flag_test.in/lib/hello.mbt b/crates/moon/tests/test_cases/debug_flag_test.in/lib/hello.mbt new file mode 100644 index 00000000..a7ac2bee --- /dev/null +++ b/crates/moon/tests/test_cases/debug_flag_test.in/lib/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> String { + "Hello, world!" +} + diff --git a/crates/moon/tests/test_cases/debug_flag_test.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/debug_flag_test.in/lib/moon.pkg.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/crates/moon/tests/test_cases/debug_flag_test.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} diff --git a/crates/moon/tests/test_cases/debug_flag_test.in/main/main.mbt b/crates/moon/tests/test_cases/debug_flag_test.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/debug_flag_test.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/debug_flag_test.in/main/moon.pkg.json b/crates/moon/tests/test_cases/debug_flag_test.in/main/moon.pkg.json new file mode 100644 index 00000000..0dccc0db --- /dev/null +++ b/crates/moon/tests/test_cases/debug_flag_test.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "hello/lib": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/debug_flag_test.in/moon.mod.json b/crates/moon/tests/test_cases/debug_flag_test.in/moon.mod.json new file mode 100644 index 00000000..61113747 --- /dev/null +++ b/crates/moon/tests/test_cases/debug_flag_test.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "hello" +} diff --git a/crates/moon/tests/test_cases/design.in/lib/list/lib.mbt b/crates/moon/tests/test_cases/design.in/lib/list/lib.mbt new file mode 100644 index 00000000..ae9f6590 --- /dev/null +++ b/crates/moon/tests/test_cases/design.in/lib/list/lib.mbt @@ -0,0 +1,3 @@ +pub fn new_list() -> Unit { + println("new_list") +} diff --git a/crates/moon/tests/test_cases/design.in/lib/list/moon.pkg.json b/crates/moon/tests/test_cases/design.in/lib/list/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/design.in/lib/list/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/design.in/lib/queue/lib.mbt b/crates/moon/tests/test_cases/design.in/lib/queue/lib.mbt new file mode 100644 index 00000000..9e4b781d --- /dev/null +++ b/crates/moon/tests/test_cases/design.in/lib/queue/lib.mbt @@ -0,0 +1,4 @@ +pub fn new_queue() -> Unit { + @list.new_list() + println("new_queue") +} diff --git a/crates/moon/tests/test_cases/design.in/lib/queue/moon.pkg.json b/crates/moon/tests/test_cases/design.in/lib/queue/moon.pkg.json new file mode 100644 index 00000000..e2428e71 --- /dev/null +++ b/crates/moon/tests/test_cases/design.in/lib/queue/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": { + "moonbit/design/lib/list": "" + } +} diff --git a/crates/moon/tests/test_cases/design.in/lib/stack/lib.mbt b/crates/moon/tests/test_cases/design.in/lib/stack/lib.mbt new file mode 100644 index 00000000..6b117b69 --- /dev/null +++ b/crates/moon/tests/test_cases/design.in/lib/stack/lib.mbt @@ -0,0 +1,4 @@ +pub fn new_stack() -> Unit { + @list.new_list() + println("new_stack") +} diff --git a/crates/moon/tests/test_cases/design.in/lib/stack/moon.pkg.json b/crates/moon/tests/test_cases/design.in/lib/stack/moon.pkg.json new file mode 100644 index 00000000..e2428e71 --- /dev/null +++ b/crates/moon/tests/test_cases/design.in/lib/stack/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": { + "moonbit/design/lib/list": "" + } +} diff --git a/crates/moon/tests/test_cases/design.in/lib/vec/lib.mbt b/crates/moon/tests/test_cases/design.in/lib/vec/lib.mbt new file mode 100644 index 00000000..198ee74b --- /dev/null +++ b/crates/moon/tests/test_cases/design.in/lib/vec/lib.mbt @@ -0,0 +1,3 @@ +pub fn new_vector() -> Unit { + println("new_vector") +} diff --git a/crates/moon/tests/test_cases/design.in/lib/vec/moon.pkg.json b/crates/moon/tests/test_cases/design.in/lib/vec/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/design.in/lib/vec/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/design.in/lib/vec/vec.mbt b/crates/moon/tests/test_cases/design.in/lib/vec/vec.mbt new file mode 100644 index 00000000..ce25d994 --- /dev/null +++ b/crates/moon/tests/test_cases/design.in/lib/vec/vec.mbt @@ -0,0 +1,3 @@ +fn init { + () +} diff --git a/crates/moon/tests/test_cases/design.in/main1/main.mbt b/crates/moon/tests/test_cases/design.in/main1/main.mbt new file mode 100644 index 00000000..6186bf38 --- /dev/null +++ b/crates/moon/tests/test_cases/design.in/main1/main.mbt @@ -0,0 +1,6 @@ +fn main { + @queue.new_queue() + @stack.new_stack() + @vec.new_vector() + println("main1") +} diff --git a/crates/moon/tests/test_cases/design.in/main1/moon.pkg.json b/crates/moon/tests/test_cases/design.in/main1/moon.pkg.json new file mode 100644 index 00000000..36d11645 --- /dev/null +++ b/crates/moon/tests/test_cases/design.in/main1/moon.pkg.json @@ -0,0 +1,8 @@ +{ + "is-main": true, + "import": { + "moonbit/design/lib/queue": "", + "moonbit/design/lib/stack": "", + "moonbit/design/lib/vec": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/design.in/main2/main.mbt b/crates/moon/tests/test_cases/design.in/main2/main.mbt new file mode 100644 index 00000000..8c0279c6 --- /dev/null +++ b/crates/moon/tests/test_cases/design.in/main2/main.mbt @@ -0,0 +1,4 @@ +fn main { + @queue.new_queue() + println("main2") +} diff --git a/crates/moon/tests/test_cases/design.in/main2/moon.pkg.json b/crates/moon/tests/test_cases/design.in/main2/moon.pkg.json new file mode 100644 index 00000000..bce63d40 --- /dev/null +++ b/crates/moon/tests/test_cases/design.in/main2/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "moonbit/design/lib/queue": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/design.in/moon.mod.json b/crates/moon/tests/test_cases/design.in/moon.mod.json new file mode 100644 index 00000000..9988b54f --- /dev/null +++ b/crates/moon/tests/test_cases/design.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "moonbit/design" +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-001.in/A/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-001.in/A/lib.mbt new file mode 100644 index 00000000..0c8ba57d --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-001.in/A/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("A") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-001.in/A/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-001.in/A/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-001.in/A/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-001.in/B/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-001.in/B/lib.mbt new file mode 100644 index 00000000..98f4a947 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-001.in/B/lib.mbt @@ -0,0 +1,4 @@ +pub fn f() -> Unit { + @A.f() + println("B") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-001.in/B/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-001.in/B/moon.pkg.json new file mode 100644 index 00000000..d83e82ab --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-001.in/B/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": { + "hello/A": "" + } +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-001.in/C/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-001.in/C/lib.mbt new file mode 100644 index 00000000..8695ab4c --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-001.in/C/lib.mbt @@ -0,0 +1,4 @@ +pub fn f() -> Unit { + @A.f() + println("C") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-001.in/C/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-001.in/C/moon.pkg.json new file mode 100644 index 00000000..d83e82ab --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-001.in/C/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": { + "hello/A": "" + } +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-001.in/main/main.mbt b/crates/moon/tests/test_cases/diamond-pkg-001.in/main/main.mbt new file mode 100644 index 00000000..05100981 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-001.in/main/main.mbt @@ -0,0 +1,5 @@ +fn main { + @B.f() + @C.f() + println("main") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-001.in/main/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-001.in/main/moon.pkg.json new file mode 100644 index 00000000..5de00572 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-001.in/main/moon.pkg.json @@ -0,0 +1,7 @@ +{ + "is-main": true, + "import": { + "hello/C": "", + "hello/B": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-001.in/moon.mod.json b/crates/moon/tests/test_cases/diamond-pkg-001.in/moon.mod.json new file mode 100644 index 00000000..61113747 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-001.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "hello" +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/A/A0/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-002.in/A/A0/lib.mbt new file mode 100644 index 00000000..052f418d --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/A/A0/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("A0") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/A/A0/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-002.in/A/A0/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/A/A0/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/A/A1/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-002.in/A/A1/lib.mbt new file mode 100644 index 00000000..22121685 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/A/A1/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("A1") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/A/A1/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-002.in/A/A1/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/A/A1/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/A/A2/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-002.in/A/A2/lib.mbt new file mode 100644 index 00000000..be443419 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/A/A2/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("A2") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/A/A2/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-002.in/A/A2/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/A/A2/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/A/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-002.in/A/lib.mbt new file mode 100644 index 00000000..1e03bcdf --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/A/lib.mbt @@ -0,0 +1,6 @@ +pub fn f() -> Unit { + @A0.f() + @A1.f() + @A2.f() + println("A") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/A/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-002.in/A/moon.pkg.json new file mode 100644 index 00000000..914289e1 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/A/moon.pkg.json @@ -0,0 +1,7 @@ +{ + "import": { + "hello/A/A2": "", + "hello/A/A1": "", + "hello/A/A0": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/B/B0/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-002.in/B/B0/lib.mbt new file mode 100644 index 00000000..1f6e9b99 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/B/B0/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("B0") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/B/B0/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-002.in/B/B0/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/B/B0/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/B/B1/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-002.in/B/B1/lib.mbt new file mode 100644 index 00000000..c96e7b42 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/B/B1/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("B1") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/B/B1/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-002.in/B/B1/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/B/B1/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/B/B2/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-002.in/B/B2/lib.mbt new file mode 100644 index 00000000..73ff3452 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/B/B2/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("B2") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/B/B2/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-002.in/B/B2/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/B/B2/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/B/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-002.in/B/lib.mbt new file mode 100644 index 00000000..0873543f --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/B/lib.mbt @@ -0,0 +1,7 @@ +pub fn f() -> Unit { + @A.f() + @B0.f() + @B1.f() + @B2.f() + println("B") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/B/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-002.in/B/moon.pkg.json new file mode 100644 index 00000000..5d970856 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/B/moon.pkg.json @@ -0,0 +1,8 @@ +{ + "import": { + "hello/B/B1": "", + "hello/B/B0": "", + "hello/A": "", + "hello/B/B2": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/C/C0/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-002.in/C/C0/lib.mbt new file mode 100644 index 00000000..6e4773fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/C/C0/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("C0") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/C/C0/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-002.in/C/C0/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/C/C0/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/C/C1/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-002.in/C/C1/lib.mbt new file mode 100644 index 00000000..7a299a8a --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/C/C1/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("C1") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/C/C1/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-002.in/C/C1/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/C/C1/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/C/C2/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-002.in/C/C2/lib.mbt new file mode 100644 index 00000000..22bd696b --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/C/C2/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("C2") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/C/C2/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-002.in/C/C2/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/C/C2/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/C/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-002.in/C/lib.mbt new file mode 100644 index 00000000..356abda2 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/C/lib.mbt @@ -0,0 +1,7 @@ +pub fn f() -> Unit { + @A.f() + @C0.f() + @C1.f() + @C2.f() + println("C") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/C/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-002.in/C/moon.pkg.json new file mode 100644 index 00000000..f479a60a --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/C/moon.pkg.json @@ -0,0 +1,8 @@ +{ + "import": { + "hello/A": "", + "hello/C/C2": "", + "hello/C/C1": "", + "hello/C/C0": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/main/main.mbt b/crates/moon/tests/test_cases/diamond-pkg-002.in/main/main.mbt new file mode 100644 index 00000000..05100981 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/main/main.mbt @@ -0,0 +1,5 @@ +fn main { + @B.f() + @C.f() + println("main") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/main/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-002.in/main/moon.pkg.json new file mode 100644 index 00000000..5de00572 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/main/moon.pkg.json @@ -0,0 +1,7 @@ +{ + "is-main": true, + "import": { + "hello/C": "", + "hello/B": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-002.in/moon.mod.json b/crates/moon/tests/test_cases/diamond-pkg-002.in/moon.mod.json new file mode 100644 index 00000000..61113747 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-002.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "hello" +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/A/A0/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-003.in/A/A0/lib.mbt new file mode 100644 index 00000000..052f418d --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/A/A0/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("A0") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/A/A0/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-003.in/A/A0/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/A/A0/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/A/A1/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-003.in/A/A1/lib.mbt new file mode 100644 index 00000000..22121685 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/A/A1/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("A1") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/A/A1/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-003.in/A/A1/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/A/A1/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/A/A2/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-003.in/A/A2/lib.mbt new file mode 100644 index 00000000..be443419 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/A/A2/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("A2") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/A/A2/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-003.in/A/A2/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/A/A2/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/A/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-003.in/A/lib.mbt new file mode 100644 index 00000000..1e03bcdf --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/A/lib.mbt @@ -0,0 +1,6 @@ +pub fn f() -> Unit { + @A0.f() + @A1.f() + @A2.f() + println("A") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/A/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-003.in/A/moon.pkg.json new file mode 100644 index 00000000..a91719ea --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/A/moon.pkg.json @@ -0,0 +1,7 @@ +{ + "import": { + "h/e/l/l/o/A/A2": "", + "h/e/l/l/o/A/A0": "", + "h/e/l/l/o/A/A1": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/B/B0/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-003.in/B/B0/lib.mbt new file mode 100644 index 00000000..1f6e9b99 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/B/B0/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("B0") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/B/B0/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-003.in/B/B0/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/B/B0/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/B/B1/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-003.in/B/B1/lib.mbt new file mode 100644 index 00000000..c96e7b42 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/B/B1/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("B1") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/B/B1/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-003.in/B/B1/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/B/B1/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/B/B2/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-003.in/B/B2/lib.mbt new file mode 100644 index 00000000..73ff3452 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/B/B2/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("B2") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/B/B2/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-003.in/B/B2/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/B/B2/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/B/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-003.in/B/lib.mbt new file mode 100644 index 00000000..0873543f --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/B/lib.mbt @@ -0,0 +1,7 @@ +pub fn f() -> Unit { + @A.f() + @B0.f() + @B1.f() + @B2.f() + println("B") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/B/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-003.in/B/moon.pkg.json new file mode 100644 index 00000000..cdcf8928 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/B/moon.pkg.json @@ -0,0 +1,8 @@ +{ + "import": { + "h/e/l/l/o/A": "", + "h/e/l/l/o/B/B0": "", + "h/e/l/l/o/B/B1": "", + "h/e/l/l/o/B/B2": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/C/C0/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-003.in/C/C0/lib.mbt new file mode 100644 index 00000000..6e4773fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/C/C0/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("C0") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/C/C0/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-003.in/C/C0/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/C/C0/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/C/C1/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-003.in/C/C1/lib.mbt new file mode 100644 index 00000000..7a299a8a --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/C/C1/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("C1") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/C/C1/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-003.in/C/C1/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/C/C1/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/C/C2/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-003.in/C/C2/lib.mbt new file mode 100644 index 00000000..22bd696b --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/C/C2/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("C2") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/C/C2/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-003.in/C/C2/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/C/C2/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/C/lib.mbt b/crates/moon/tests/test_cases/diamond-pkg-003.in/C/lib.mbt new file mode 100644 index 00000000..356abda2 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/C/lib.mbt @@ -0,0 +1,7 @@ +pub fn f() -> Unit { + @A.f() + @C0.f() + @C1.f() + @C2.f() + println("C") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/C/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-003.in/C/moon.pkg.json new file mode 100644 index 00000000..bbc402cb --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/C/moon.pkg.json @@ -0,0 +1,8 @@ +{ + "import": { + "h/e/l/l/o/C/C1": "", + "h/e/l/l/o/C/C2": "", + "h/e/l/l/o/C/C0": "", + "h/e/l/l/o/A": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/main/main.mbt b/crates/moon/tests/test_cases/diamond-pkg-003.in/main/main.mbt new file mode 100644 index 00000000..05100981 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/main/main.mbt @@ -0,0 +1,5 @@ +fn main { + @B.f() + @C.f() + println("main") +} diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/main/moon.pkg.json b/crates/moon/tests/test_cases/diamond-pkg-003.in/main/moon.pkg.json new file mode 100644 index 00000000..bc405362 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/main/moon.pkg.json @@ -0,0 +1,7 @@ +{ + "is-main": true, + "import": { + "h/e/l/l/o/C": "", + "h/e/l/l/o/B": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/diamond-pkg-003.in/moon.mod.json b/crates/moon/tests/test_cases/diamond-pkg-003.in/moon.mod.json new file mode 100644 index 00000000..7d9a8e31 --- /dev/null +++ b/crates/moon/tests/test_cases/diamond-pkg-003.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "h/e/l/l/o" +} diff --git a/crates/moon/tests/test_cases/docstring-demo.in/README.md b/crates/moon/tests/test_cases/docstring-demo.in/README.md new file mode 100644 index 00000000..4e4cb239 --- /dev/null +++ b/crates/moon/tests/test_cases/docstring-demo.in/README.md @@ -0,0 +1,5 @@ +## Moonbit docstring demo + +We can see the docstring display in the IDE as follows: + + \ No newline at end of file diff --git a/crates/moon/tests/test_cases/docstring-demo.in/lib/hello.mbt b/crates/moon/tests/test_cases/docstring-demo.in/lib/hello.mbt new file mode 100644 index 00000000..c4059f55 --- /dev/null +++ b/crates/moon/tests/test_cases/docstring-demo.in/lib/hello.mbt @@ -0,0 +1,9 @@ +/// Generate a friendly greeting message. +/// +/// This function return the string "Hello, world!" followed by a newline character. +/// +/// @return {String} A string containing the greeting message. +pub fn hello() -> String { + "Hello, world!" +} + diff --git a/crates/moon/tests/test_cases/docstring-demo.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/docstring-demo.in/lib/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/docstring-demo.in/lib/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/docstring-demo.in/main/main.mbt b/crates/moon/tests/test_cases/docstring-demo.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/docstring-demo.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/docstring-demo.in/main/moon.pkg.json b/crates/moon/tests/test_cases/docstring-demo.in/main/moon.pkg.json new file mode 100644 index 00000000..def7976c --- /dev/null +++ b/crates/moon/tests/test_cases/docstring-demo.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "docstring-demo/lib": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/docstring-demo.in/moon.mod.json b/crates/moon/tests/test_cases/docstring-demo.in/moon.mod.json new file mode 100644 index 00000000..6f95aac0 --- /dev/null +++ b/crates/moon/tests/test_cases/docstring-demo.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "docstring-demo" +} diff --git a/crates/moon/tests/test_cases/dummy-core.in/0/lib.mbt b/crates/moon/tests/test_cases/dummy-core.in/0/lib.mbt new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/dummy-core.in/0/moon.pkg.json b/crates/moon/tests/test_cases/dummy-core.in/0/moon.pkg.json new file mode 100644 index 00000000..280af610 --- /dev/null +++ b/crates/moon/tests/test_cases/dummy-core.in/0/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "link": true +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/dummy-core.in/0/y.js.mbt b/crates/moon/tests/test_cases/dummy-core.in/0/y.js.mbt new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/dummy-core.in/0/y.wasm-gc.mbt b/crates/moon/tests/test_cases/dummy-core.in/0/y.wasm-gc.mbt new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/dummy-core.in/0/y.wasm.mbt b/crates/moon/tests/test_cases/dummy-core.in/0/y.wasm.mbt new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/dummy-core.in/0/y_wbtest.js.mbt b/crates/moon/tests/test_cases/dummy-core.in/0/y_wbtest.js.mbt new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/dummy-core.in/0/y_wbtest.mbt b/crates/moon/tests/test_cases/dummy-core.in/0/y_wbtest.mbt new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/dummy-core.in/0/y_wbtest.wasm-gc.mbt b/crates/moon/tests/test_cases/dummy-core.in/0/y_wbtest.wasm-gc.mbt new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/dummy-core.in/0/y_wbtest.wasm.mbt b/crates/moon/tests/test_cases/dummy-core.in/0/y_wbtest.wasm.mbt new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/dummy-core.in/1/lib.mbt b/crates/moon/tests/test_cases/dummy-core.in/1/lib.mbt new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/dummy-core.in/1/moon.pkg.json b/crates/moon/tests/test_cases/dummy-core.in/1/moon.pkg.json new file mode 100644 index 00000000..280af610 --- /dev/null +++ b/crates/moon/tests/test_cases/dummy-core.in/1/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "link": true +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/dummy-core.in/1/x.js.mbt b/crates/moon/tests/test_cases/dummy-core.in/1/x.js.mbt new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/dummy-core.in/1/x.wasm-gc.mbt b/crates/moon/tests/test_cases/dummy-core.in/1/x.wasm-gc.mbt new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/dummy-core.in/1/x.wasm.mbt b/crates/moon/tests/test_cases/dummy-core.in/1/x.wasm.mbt new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/dummy-core.in/1/x_wbtest.wasm-gc.mbt b/crates/moon/tests/test_cases/dummy-core.in/1/x_wbtest.wasm-gc.mbt new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/dummy-core.in/2/lib.mbt b/crates/moon/tests/test_cases/dummy-core.in/2/lib.mbt new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/dummy-core.in/2/moon.pkg.json b/crates/moon/tests/test_cases/dummy-core.in/2/moon.pkg.json new file mode 100644 index 00000000..c4c92ba6 --- /dev/null +++ b/crates/moon/tests/test_cases/dummy-core.in/2/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "link": true, + "import": [ + "moonbitlang/core/1" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/dummy-core.in/char/moon.pkg.json b/crates/moon/tests/test_cases/dummy-core.in/char/moon.pkg.json new file mode 100644 index 00000000..5aa1c638 --- /dev/null +++ b/crates/moon/tests/test_cases/dummy-core.in/char/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": [ + "moonbitlang/core/coverage" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/dummy-core.in/coverage/moon.pkg.json b/crates/moon/tests/test_cases/dummy-core.in/coverage/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/dummy-core.in/coverage/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/dummy-core.in/iter/moon.pkg.json b/crates/moon/tests/test_cases/dummy-core.in/iter/moon.pkg.json new file mode 100644 index 00000000..5136d392 --- /dev/null +++ b/crates/moon/tests/test_cases/dummy-core.in/iter/moon.pkg.json @@ -0,0 +1,8 @@ +{ + "import": [ + "moonbitlang/core/coverage" + ], + "wbtest-import": [ + "moonbitlang/core/char" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/dummy-core.in/moon.mod.json b/crates/moon/tests/test_cases/dummy-core.in/moon.mod.json new file mode 100644 index 00000000..1bfc8d8a --- /dev/null +++ b/crates/moon/tests/test_cases/dummy-core.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "moonbitlang/core" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/error_duplicate_alias.in/.gitignore b/crates/moon/tests/test_cases/error_duplicate_alias.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/error_duplicate_alias.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/error_duplicate_alias.in/lib/hello.mbt b/crates/moon/tests/test_cases/error_duplicate_alias.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/error_duplicate_alias.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/error_duplicate_alias.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/error_duplicate_alias.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..c9a46222 --- /dev/null +++ b/crates/moon/tests/test_cases/error_duplicate_alias.in/lib/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test { + if hello() != "Hello, world!" { + abort("") + } +} diff --git a/crates/moon/tests/test_cases/error_duplicate_alias.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/error_duplicate_alias.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/error_duplicate_alias.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/error_duplicate_alias.in/lib2/hello.mbt b/crates/moon/tests/test_cases/error_duplicate_alias.in/lib2/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/error_duplicate_alias.in/lib2/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/error_duplicate_alias.in/lib2/hello_wbtest.mbt b/crates/moon/tests/test_cases/error_duplicate_alias.in/lib2/hello_wbtest.mbt new file mode 100644 index 00000000..c9a46222 --- /dev/null +++ b/crates/moon/tests/test_cases/error_duplicate_alias.in/lib2/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test { + if hello() != "Hello, world!" { + abort("") + } +} diff --git a/crates/moon/tests/test_cases/error_duplicate_alias.in/lib2/moon.pkg.json b/crates/moon/tests/test_cases/error_duplicate_alias.in/lib2/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/error_duplicate_alias.in/lib2/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/error_duplicate_alias.in/main/main.mbt b/crates/moon/tests/test_cases/error_duplicate_alias.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/error_duplicate_alias.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/error_duplicate_alias.in/main/moon.pkg.json b/crates/moon/tests/test_cases/error_duplicate_alias.in/main/moon.pkg.json new file mode 100644 index 00000000..f8b2f095 --- /dev/null +++ b/crates/moon/tests/test_cases/error_duplicate_alias.in/main/moon.pkg.json @@ -0,0 +1,7 @@ +{ + "is-main": true, + "import": { + "lijunchen/hello/lib": "", + "lijunchen/hello/lib2": "lib" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/error_duplicate_alias.in/moon.mod.json b/crates/moon/tests/test_cases/error_duplicate_alias.in/moon.mod.json new file mode 100644 index 00000000..8380388a --- /dev/null +++ b/crates/moon/tests/test_cases/error_duplicate_alias.in/moon.mod.json @@ -0,0 +1,5 @@ +{ + "name": "lijunchen/hello", + "version": "0.1.0", + "deps": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/expect_test.in/.gitignore b/crates/moon/tests/test_cases/expect_test.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/expect_test.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/expect_test.in/README.md b/crates/moon/tests/test_cases/expect_test.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/expect_test.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/expect_test.in/lib/hello.mbt b/crates/moon/tests/test_cases/expect_test.in/lib/hello.mbt new file mode 100644 index 00000000..08e48d0a --- /dev/null +++ b/crates/moon/tests/test_cases/expect_test.in/lib/hello.mbt @@ -0,0 +1,153 @@ +pub fn hello() -> String { + "Hello, world!" +} + +test "basic" { + let buf = Buffer::new() + let n = 123 + buf.write_string(n.to_string()) + buf.expect()! +} + +test "indent" { + let _ = { + let buf = Buffer::new() + let s = "haha" + buf.write_string(s) + buf.expect()! + } + () +} + +test "auto_reset" { + let buf = Buffer::new() + let s = "haha" + buf.write_string(s) + buf.expect()! + let s = "123" + buf.write_string(s) + buf.expect(content="123")! +} + +test "multiline-string" { + let buf = Buffer::new() + let s = "1\n2\n3\n" + buf.write_string(s) + buf.expect()! +} + +test "multiline-string-2" { + let buf = Buffer::new() + let s = + #|abc + #|def + buf.write_string(s) + buf.expect( + content= + #|bcd + #|defg + , + )! +} + +test "not-empty-expect" { + let buf = Buffer::new() + buf.write_string("123") + buf.expect(content="1")! +} + +test { + inspect("a")! +} + +test { + inspect("a")! +} + +test { + inspect("a", content="")! +} + +test { + inspect("a", content="b")! +} + +test { + inspect("a\nb\nc\ndc,")! +} + +test { + (123 |> inspect)! +} + +test { + (123 |> inspect(content=""))! +} + +test { + ("a\nb\nc\n" |> inspect())! +} + +test { + ("a\nb\nc\n" |> inspect(content=""))! +} + +test { + ("a\nb\nc\n" + |> inspect( + content= + #|1 + #|2 + #|3 + , + ))! +} + +test { + (("a\nb\nc\n" |> inspect(content=""))! |> inspect(content=""))! +} + +test { + inspect("ha", content="哈哈")! +} + +test { + inspect("haha", content="哈哈")! +} + +test { + inspect("hahaha", content="哈哈")! +} + +test { + inspect("哈哈", content="haha")! +} + +test { + inspect("哈哈哈", content="haha")! +} + +test { + let buf = Buffer::new() + buf.write_string("just\ntest") + buf.expect()! +} + +test "hello" { + let buf = Buffer::new() + buf.write_string("just\ntest") + buf.expect(content="")! +} + +fn actual() -> String { + "BinOp('+', BinOp('+', Num(1), Num(2)), Num(3))" +} + +test { + inspect(actual(), content="BinOp('+', Num(1), Num(2))")! +} + +test { + let xs = Array::from_fixed_array(["a", "b", "c"]) + inspect(xs)! +} diff --git a/crates/moon/tests/test_cases/expect_test.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/expect_test.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..f4cd057d --- /dev/null +++ b/crates/moon/tests/test_cases/expect_test.in/lib/hello_wbtest.mbt @@ -0,0 +1,11 @@ +test "hello" { + let buf = Buffer::new() + buf.write_string("just\ntest") + buf.expect()! +} + +test "not-buf" { + let notbuf = Buffer::new() + notbuf.write_string("haha") + notbuf.expect()! +} diff --git a/crates/moon/tests/test_cases/expect_test.in/lib/issue_188_wbtest.mbt b/crates/moon/tests/test_cases/expect_test.in/lib/issue_188_wbtest.mbt new file mode 100644 index 00000000..5751aedf --- /dev/null +++ b/crates/moon/tests/test_cases/expect_test.in/lib/issue_188_wbtest.mbt @@ -0,0 +1,21 @@ +fn actual_188() -> String { + #|State #0 (start) + #|Transitions: + #| 0.Assert(kind=BeginOfLine) -> State #1 + #|State #1 + #| + +} + +test "issue_188" { + inspect( + actual_188(), + content= + #|State #0 + #|Transitions: + #| 0.Assert(kind=BeginOfLine) -> State #1 + #|State #1 + #| + , + )! +} diff --git a/crates/moon/tests/test_cases/expect_test.in/lib/issue_209.mbt b/crates/moon/tests/test_cases/expect_test.in/lib/issue_209.mbt new file mode 100644 index 00000000..cd25f121 --- /dev/null +++ b/crates/moon/tests/test_cases/expect_test.in/lib/issue_209.mbt @@ -0,0 +1,4 @@ +test "trailing comma" { + // 🤣 + inspect(1234)! +} // ,,,,,,,,,,,,,,,,,,,, diff --git a/crates/moon/tests/test_cases/expect_test.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/expect_test.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/expect_test.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/expect_test.in/main/main.mbt b/crates/moon/tests/test_cases/expect_test.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/expect_test.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/expect_test.in/main/moon.pkg.json b/crates/moon/tests/test_cases/expect_test.in/main/moon.pkg.json new file mode 100644 index 00000000..48783525 --- /dev/null +++ b/crates/moon/tests/test_cases/expect_test.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/expect_test.in/moon.mod.json b/crates/moon/tests/test_cases/expect_test.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/expect_test.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/export_memory.in/.gitignore b/crates/moon/tests/test_cases/export_memory.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/export_memory.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/export_memory.in/README.md b/crates/moon/tests/test_cases/export_memory.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/export_memory.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/export_memory.in/lib/hello.mbt b/crates/moon/tests/test_cases/export_memory.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/export_memory.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/export_memory.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/export_memory.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..64f26429 --- /dev/null +++ b/crates/moon/tests/test_cases/export_memory.in/lib/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test "hello" { + if hello() != "Hello, world!" { + return Err("hello() != \"Hello, world!\"") + } +} diff --git a/crates/moon/tests/test_cases/export_memory.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/export_memory.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/export_memory.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/export_memory.in/main/main.mbt b/crates/moon/tests/test_cases/export_memory.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/export_memory.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/export_memory.in/main/moon.pkg.json b/crates/moon/tests/test_cases/export_memory.in/main/moon.pkg.json new file mode 100644 index 00000000..b4b020ec --- /dev/null +++ b/crates/moon/tests/test_cases/export_memory.in/main/moon.pkg.json @@ -0,0 +1,14 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ], + "link": { + "wasm": { + "export-memory-name": "awesome_memory" + }, + "wasm-gc": { + "export-memory-name": "awesome_memory" + } + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/export_memory.in/moon.mod.json b/crates/moon/tests/test_cases/export_memory.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/export_memory.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/extra_flags.in/lib/hello.mbt b/crates/moon/tests/test_cases/extra_flags.in/lib/hello.mbt new file mode 100644 index 00000000..a7ac2bee --- /dev/null +++ b/crates/moon/tests/test_cases/extra_flags.in/lib/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> String { + "Hello, world!" +} + diff --git a/crates/moon/tests/test_cases/extra_flags.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/extra_flags.in/lib/moon.pkg.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/crates/moon/tests/test_cases/extra_flags.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} diff --git a/crates/moon/tests/test_cases/extra_flags.in/main/main.mbt b/crates/moon/tests/test_cases/extra_flags.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/extra_flags.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/extra_flags.in/main/moon.pkg.json b/crates/moon/tests/test_cases/extra_flags.in/main/moon.pkg.json new file mode 100644 index 00000000..0dccc0db --- /dev/null +++ b/crates/moon/tests/test_cases/extra_flags.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "hello/lib": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/extra_flags.in/moon.mod.json b/crates/moon/tests/test_cases/extra_flags.in/moon.mod.json new file mode 100644 index 00000000..f99a9ad9 --- /dev/null +++ b/crates/moon/tests/test_cases/extra_flags.in/moon.mod.json @@ -0,0 +1,10 @@ +{ + "name": "hello", + "compile_flags": [ + "-g", + "-no-builtin" + ], + "link_flags": [ + "-no-builtin" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/fancy_import.in/import001/.gitignore b/crates/moon/tests/test_cases/fancy_import.in/import001/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import001/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/fancy_import.in/import001/lib/hello.mbt b/crates/moon/tests/test_cases/fancy_import.in/import001/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import001/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import001/lib/moon.pkg.json b/crates/moon/tests/test_cases/fancy_import.in/import001/lib/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import001/lib/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import001/main/main.mbt b/crates/moon/tests/test_cases/fancy_import.in/import001/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import001/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import001/main/moon.pkg.json b/crates/moon/tests/test_cases/fancy_import.in/import001/main/moon.pkg.json new file mode 100644 index 00000000..f5eec55a --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import001/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "moonbitlang/import001/lib": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/fancy_import.in/import001/moon.mod.json b/crates/moon/tests/test_cases/fancy_import.in/import001/moon.mod.json new file mode 100644 index 00000000..b8cbdd3a --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import001/moon.mod.json @@ -0,0 +1,4 @@ +{ + "name": "moonbitlang/import001", + "version": "0.1.0" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/fancy_import.in/import002/lib/hello.mbt b/crates/moon/tests/test_cases/fancy_import.in/import002/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import002/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import002/lib/moon.pkg.json b/crates/moon/tests/test_cases/fancy_import.in/import002/lib/moon.pkg.json new file mode 100644 index 00000000..b4cd6892 --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import002/lib/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": [] +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import002/main/main.mbt b/crates/moon/tests/test_cases/fancy_import.in/import002/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import002/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import002/main/moon.pkg.json b/crates/moon/tests/test_cases/fancy_import.in/import002/main/moon.pkg.json new file mode 100644 index 00000000..b6090256 --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import002/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "moonbitlang/import002/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/fancy_import.in/import002/moon.mod.json b/crates/moon/tests/test_cases/fancy_import.in/import002/moon.mod.json new file mode 100644 index 00000000..45a36093 --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import002/moon.mod.json @@ -0,0 +1,4 @@ +{ + "name": "moonbitlang/import002", + "version": "0.1.0" +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import003/.gitignore b/crates/moon/tests/test_cases/fancy_import.in/import003/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import003/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/fancy_import.in/import003/lib/hello.mbt b/crates/moon/tests/test_cases/fancy_import.in/import003/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import003/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import003/lib/moon.pkg.json b/crates/moon/tests/test_cases/fancy_import.in/import003/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import003/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/fancy_import.in/import003/lib2/hello.mbt b/crates/moon/tests/test_cases/fancy_import.in/import003/lib2/hello.mbt new file mode 100644 index 00000000..86f782e4 --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import003/lib2/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello2() -> String { + "Hello, world2!" +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import003/lib2/moon.pkg.json b/crates/moon/tests/test_cases/fancy_import.in/import003/lib2/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import003/lib2/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/fancy_import.in/import003/main/main.mbt b/crates/moon/tests/test_cases/fancy_import.in/import003/main/main.mbt new file mode 100644 index 00000000..d9d5027e --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import003/main/main.mbt @@ -0,0 +1,4 @@ +fn main { + println(@lib.hello()) + println(@haha.hello2()) +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import003/main/moon.pkg.json b/crates/moon/tests/test_cases/fancy_import.in/import003/main/moon.pkg.json new file mode 100644 index 00000000..0e7b484c --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import003/main/moon.pkg.json @@ -0,0 +1,10 @@ +{ + "is-main": true, + "import": [ + "moonbitlang/import003/lib", + { + "path": "moonbitlang/import003/lib2", + "alias": "haha" + } + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/fancy_import.in/import003/moon.mod.json b/crates/moon/tests/test_cases/fancy_import.in/import003/moon.mod.json new file mode 100644 index 00000000..5afd2db3 --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import003/moon.mod.json @@ -0,0 +1,4 @@ +{ + "name": "moonbitlang/import003", + "version": "0.1.0" +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import004/.gitignore b/crates/moon/tests/test_cases/fancy_import.in/import004/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import004/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/fancy_import.in/import004/lib/hello.mbt b/crates/moon/tests/test_cases/fancy_import.in/import004/lib/hello.mbt new file mode 100644 index 00000000..3d4b5891 --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import004/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn f() -> String { + "f1" +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import004/lib/moon.pkg.json b/crates/moon/tests/test_cases/fancy_import.in/import004/lib/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import004/lib/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import004/lib2/hello.mbt b/crates/moon/tests/test_cases/fancy_import.in/import004/lib2/hello.mbt new file mode 100644 index 00000000..d361e29c --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import004/lib2/hello.mbt @@ -0,0 +1,3 @@ +pub fn f() -> String { + "f2" +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import004/lib2/moon.pkg.json b/crates/moon/tests/test_cases/fancy_import.in/import004/lib2/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import004/lib2/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import004/lib3/hello.mbt b/crates/moon/tests/test_cases/fancy_import.in/import004/lib3/hello.mbt new file mode 100644 index 00000000..533926a5 --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import004/lib3/hello.mbt @@ -0,0 +1,3 @@ +pub fn f() -> String { + "f3" +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import004/lib3/moon.pkg.json b/crates/moon/tests/test_cases/fancy_import.in/import004/lib3/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import004/lib3/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import004/lib4/hello.mbt b/crates/moon/tests/test_cases/fancy_import.in/import004/lib4/hello.mbt new file mode 100644 index 00000000..c0f00acd --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import004/lib4/hello.mbt @@ -0,0 +1,3 @@ +pub fn f() -> String { + "f4" +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import004/lib4/moon.pkg.json b/crates/moon/tests/test_cases/fancy_import.in/import004/lib4/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import004/lib4/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import004/main/main.mbt b/crates/moon/tests/test_cases/fancy_import.in/import004/main/main.mbt new file mode 100644 index 00000000..18d5bc7a --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import004/main/main.mbt @@ -0,0 +1,6 @@ +fn main { + println(@lib.f()) + println(@lib2.f()) + println(@lib3.f()) + println(@lib4.f()) +} diff --git a/crates/moon/tests/test_cases/fancy_import.in/import004/main/moon.pkg.json b/crates/moon/tests/test_cases/fancy_import.in/import004/main/moon.pkg.json new file mode 100644 index 00000000..c6f47291 --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import004/main/moon.pkg.json @@ -0,0 +1,18 @@ +{ + "is-main": true, + "import": [ + { + "path": "moonbitlang/import004/lib", + "alias": "lib" + }, + "moonbitlang/import004/lib2", + { + "path": "moonbitlang/import004/lib3", + "alias": "lib3" + }, + { + "path": "moonbitlang/import004/lib4", + "alias": "" + } + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/fancy_import.in/import004/moon.mod.json b/crates/moon/tests/test_cases/fancy_import.in/import004/moon.mod.json new file mode 100644 index 00000000..dd8ee994 --- /dev/null +++ b/crates/moon/tests/test_cases/fancy_import.in/import004/moon.mod.json @@ -0,0 +1,4 @@ +{ + "name": "moonbitlang/import004", + "version": "0.1.0" +} diff --git a/crates/moon/tests/test_cases/hello.in/main/main.mbt b/crates/moon/tests/test_cases/hello.in/main/main.mbt new file mode 100644 index 00000000..e23f6650 --- /dev/null +++ b/crates/moon/tests/test_cases/hello.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println("Hello, world!") +} diff --git a/crates/moon/tests/test_cases/hello.in/main/moon.pkg.json b/crates/moon/tests/test_cases/hello.in/main/moon.pkg.json new file mode 100644 index 00000000..d48c4d24 --- /dev/null +++ b/crates/moon/tests/test_cases/hello.in/main/moon.pkg.json @@ -0,0 +1,4 @@ +{ + "is-main": true, + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/hello.in/moon.mod.json b/crates/moon/tests/test_cases/hello.in/moon.mod.json new file mode 100644 index 00000000..61113747 --- /dev/null +++ b/crates/moon/tests/test_cases/hello.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "hello" +} diff --git a/crates/moon/tests/test_cases/import_memory.in/.gitignore b/crates/moon/tests/test_cases/import_memory.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/import_memory.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/import_memory.in/README.md b/crates/moon/tests/test_cases/import_memory.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/import_memory.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/import_memory.in/lib/hello.mbt b/crates/moon/tests/test_cases/import_memory.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/import_memory.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/import_memory.in/lib/hello_test.mbt b/crates/moon/tests/test_cases/import_memory.in/lib/hello_test.mbt new file mode 100644 index 00000000..85944a2c --- /dev/null +++ b/crates/moon/tests/test_cases/import_memory.in/lib/hello_test.mbt @@ -0,0 +1,5 @@ +test "hello" { + if hello() != "Hello, world!" { + raise "hello() != \"Hello, world!\"" + } +} diff --git a/crates/moon/tests/test_cases/import_memory.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/import_memory.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/import_memory.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/import_memory.in/main/main.mbt b/crates/moon/tests/test_cases/import_memory.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/import_memory.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/import_memory.in/main/moon.pkg.json b/crates/moon/tests/test_cases/import_memory.in/main/moon.pkg.json new file mode 100644 index 00000000..ad1ab926 --- /dev/null +++ b/crates/moon/tests/test_cases/import_memory.in/main/moon.pkg.json @@ -0,0 +1,21 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ], + "link": { + "wasm": { + "heap-start-address": 65536, + "import-memory": { + "module": "xxx", + "name": "yyy" + } + }, + "wasm-gc": { + "import-memory": { + "module": "xxx", + "name": "yyy" + } + } + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/import_memory.in/moon.mod.json b/crates/moon/tests/test_cases/import_memory.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/import_memory.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/internal_package.in/.gitignore b/crates/moon/tests/test_cases/internal_package.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/internal_package.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/internal_package.in/README.md b/crates/moon/tests/test_cases/internal_package.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/internal_package.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/internal_package.in/lib/a/lib.mbt b/crates/moon/tests/test_cases/internal_package.in/lib/a/lib.mbt new file mode 100644 index 00000000..d44873fc --- /dev/null +++ b/crates/moon/tests/test_cases/internal_package.in/lib/a/lib.mbt @@ -0,0 +1,3 @@ +pub fn g() -> String { + "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/internal_package.in/lib/a/moon.pkg.json b/crates/moon/tests/test_cases/internal_package.in/lib/a/moon.pkg.json new file mode 100644 index 00000000..7c91baba --- /dev/null +++ b/crates/moon/tests/test_cases/internal_package.in/lib/a/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": [ + "username/hello/lib/internal" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/internal_package.in/lib/hello.mbt b/crates/moon/tests/test_cases/internal_package.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/internal_package.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/internal_package.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/internal_package.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..64f26429 --- /dev/null +++ b/crates/moon/tests/test_cases/internal_package.in/lib/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test "hello" { + if hello() != "Hello, world!" { + return Err("hello() != \"Hello, world!\"") + } +} diff --git a/crates/moon/tests/test_cases/internal_package.in/lib/internal/b/lib.mbt b/crates/moon/tests/test_cases/internal_package.in/lib/internal/b/lib.mbt new file mode 100644 index 00000000..d44873fc --- /dev/null +++ b/crates/moon/tests/test_cases/internal_package.in/lib/internal/b/lib.mbt @@ -0,0 +1,3 @@ +pub fn g() -> String { + "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/internal_package.in/lib/internal/b/moon.pkg.json b/crates/moon/tests/test_cases/internal_package.in/lib/internal/b/moon.pkg.json new file mode 100644 index 00000000..7c91baba --- /dev/null +++ b/crates/moon/tests/test_cases/internal_package.in/lib/internal/b/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": [ + "username/hello/lib/internal" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/internal_package.in/lib/internal/lib.mbt b/crates/moon/tests/test_cases/internal_package.in/lib/internal/lib.mbt new file mode 100644 index 00000000..d44873fc --- /dev/null +++ b/crates/moon/tests/test_cases/internal_package.in/lib/internal/lib.mbt @@ -0,0 +1,3 @@ +pub fn g() -> String { + "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/internal_package.in/lib/internal/moon.pkg.json b/crates/moon/tests/test_cases/internal_package.in/lib/internal/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/internal_package.in/lib/internal/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/internal_package.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/internal_package.in/lib/moon.pkg.json new file mode 100644 index 00000000..7c91baba --- /dev/null +++ b/crates/moon/tests/test_cases/internal_package.in/lib/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": [ + "username/hello/lib/internal" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/internal_package.in/lib2/lib.mbt b/crates/moon/tests/test_cases/internal_package.in/lib2/lib.mbt new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/internal_package.in/lib2/moon.pkg.json b/crates/moon/tests/test_cases/internal_package.in/lib2/moon.pkg.json new file mode 100644 index 00000000..2af65622 --- /dev/null +++ b/crates/moon/tests/test_cases/internal_package.in/lib2/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "import": [ + "username/hello/lib/internal", + "username/hello/lib/internal/b" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/internal_package.in/main/main.mbt b/crates/moon/tests/test_cases/internal_package.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/internal_package.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/internal_package.in/main/moon.pkg.json b/crates/moon/tests/test_cases/internal_package.in/main/moon.pkg.json new file mode 100644 index 00000000..36b1d96a --- /dev/null +++ b/crates/moon/tests/test_cases/internal_package.in/main/moon.pkg.json @@ -0,0 +1,7 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib", + "username/hello/lib/internal" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/internal_package.in/moon.mod.json b/crates/moon/tests/test_cases/internal_package.in/moon.mod.json new file mode 100644 index 00000000..07224d12 --- /dev/null +++ b/crates/moon/tests/test_cases/internal_package.in/moon.mod.json @@ -0,0 +1,10 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "deps": {}, + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/js_format.in/.gitignore b/crates/moon/tests/test_cases/js_format.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/js_format.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/js_format.in/README.md b/crates/moon/tests/test_cases/js_format.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/js_format.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/js_format.in/lib0/hello.mbt b/crates/moon/tests/test_cases/js_format.in/lib0/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/js_format.in/lib0/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/js_format.in/lib0/hello_wbtest.mbt b/crates/moon/tests/test_cases/js_format.in/lib0/hello_wbtest.mbt new file mode 100644 index 00000000..64f26429 --- /dev/null +++ b/crates/moon/tests/test_cases/js_format.in/lib0/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test "hello" { + if hello() != "Hello, world!" { + return Err("hello() != \"Hello, world!\"") + } +} diff --git a/crates/moon/tests/test_cases/js_format.in/lib0/moon.pkg.json b/crates/moon/tests/test_cases/js_format.in/lib0/moon.pkg.json new file mode 100644 index 00000000..d5988533 --- /dev/null +++ b/crates/moon/tests/test_cases/js_format.in/lib0/moon.pkg.json @@ -0,0 +1,9 @@ +{ + "link": { + "js": { + "exports": [ + "hello" + ] + } + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/js_format.in/lib1/hello.mbt b/crates/moon/tests/test_cases/js_format.in/lib1/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/js_format.in/lib1/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/js_format.in/lib1/hello_wbtest.mbt b/crates/moon/tests/test_cases/js_format.in/lib1/hello_wbtest.mbt new file mode 100644 index 00000000..64f26429 --- /dev/null +++ b/crates/moon/tests/test_cases/js_format.in/lib1/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test "hello" { + if hello() != "Hello, world!" { + return Err("hello() != \"Hello, world!\"") + } +} diff --git a/crates/moon/tests/test_cases/js_format.in/lib1/moon.pkg.json b/crates/moon/tests/test_cases/js_format.in/lib1/moon.pkg.json new file mode 100644 index 00000000..29ddeb9c --- /dev/null +++ b/crates/moon/tests/test_cases/js_format.in/lib1/moon.pkg.json @@ -0,0 +1,10 @@ +{ + "link": { + "js": { + "exports": [ + "hello" + ], + "format": "esm" + } + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/js_format.in/lib2/hello.mbt b/crates/moon/tests/test_cases/js_format.in/lib2/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/js_format.in/lib2/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/js_format.in/lib2/hello_wbtest.mbt b/crates/moon/tests/test_cases/js_format.in/lib2/hello_wbtest.mbt new file mode 100644 index 00000000..64f26429 --- /dev/null +++ b/crates/moon/tests/test_cases/js_format.in/lib2/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test "hello" { + if hello() != "Hello, world!" { + return Err("hello() != \"Hello, world!\"") + } +} diff --git a/crates/moon/tests/test_cases/js_format.in/lib2/moon.pkg.json b/crates/moon/tests/test_cases/js_format.in/lib2/moon.pkg.json new file mode 100644 index 00000000..1dd40336 --- /dev/null +++ b/crates/moon/tests/test_cases/js_format.in/lib2/moon.pkg.json @@ -0,0 +1,10 @@ +{ + "link": { + "js": { + "exports": [ + "hello" + ], + "format": "cjs" + } + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/js_format.in/lib3/hello.mbt b/crates/moon/tests/test_cases/js_format.in/lib3/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/js_format.in/lib3/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/js_format.in/lib3/hello_wbtest.mbt b/crates/moon/tests/test_cases/js_format.in/lib3/hello_wbtest.mbt new file mode 100644 index 00000000..64f26429 --- /dev/null +++ b/crates/moon/tests/test_cases/js_format.in/lib3/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test "hello" { + if hello() != "Hello, world!" { + return Err("hello() != \"Hello, world!\"") + } +} diff --git a/crates/moon/tests/test_cases/js_format.in/lib3/moon.pkg.json b/crates/moon/tests/test_cases/js_format.in/lib3/moon.pkg.json new file mode 100644 index 00000000..316fcc99 --- /dev/null +++ b/crates/moon/tests/test_cases/js_format.in/lib3/moon.pkg.json @@ -0,0 +1,10 @@ +{ + "link": { + "js": { + "exports": [ + "hello" + ], + "format": "iife" + } + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/js_format.in/moon.mod.json b/crates/moon/tests/test_cases/js_format.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/js_format.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/mbti.in/.gitignore b/crates/moon/tests/test_cases/mbti.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/mbti.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/mbti.in/README.md b/crates/moon/tests/test_cases/mbti.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/mbti.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/mbti.in/lib/hello.mbt b/crates/moon/tests/test_cases/mbti.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/mbti.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/mbti.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/mbti.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..85944a2c --- /dev/null +++ b/crates/moon/tests/test_cases/mbti.in/lib/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test "hello" { + if hello() != "Hello, world!" { + raise "hello() != \"Hello, world!\"" + } +} diff --git a/crates/moon/tests/test_cases/mbti.in/lib/lib.mbti b/crates/moon/tests/test_cases/mbti.in/lib/lib.mbti new file mode 100644 index 00000000..64108267 --- /dev/null +++ b/crates/moon/tests/test_cases/mbti.in/lib/lib.mbti @@ -0,0 +1,11 @@ +package username/hello/lib + +// Values +fn hello() -> String + +// Types and methods + +// Traits + +// Extension Methods + diff --git a/crates/moon/tests/test_cases/mbti.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/mbti.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/mbti.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/mbti.in/main/main.mbt b/crates/moon/tests/test_cases/mbti.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/mbti.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/mbti.in/main/main.mbti b/crates/moon/tests/test_cases/mbti.in/main/main.mbti new file mode 100644 index 00000000..5df9ccd7 --- /dev/null +++ b/crates/moon/tests/test_cases/mbti.in/main/main.mbti @@ -0,0 +1,10 @@ +package username/hello/main + +// Values + +// Types and methods + +// Traits + +// Extension Methods + diff --git a/crates/moon/tests/test_cases/mbti.in/main/moon.pkg.json b/crates/moon/tests/test_cases/mbti.in/main/moon.pkg.json new file mode 100644 index 00000000..48783525 --- /dev/null +++ b/crates/moon/tests/test_cases/mbti.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/mbti.in/moon.mod.json b/crates/moon/tests/test_cases/mbti.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/mbti.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/mod.rs b/crates/moon/tests/test_cases/mod.rs new file mode 100644 index 00000000..b2cff869 --- /dev/null +++ b/crates/moon/tests/test_cases/mod.rs @@ -0,0 +1,4969 @@ +use std::io::Write; + +use super::*; +use expect_test::expect; +use moonutil::common::{ + get_cargo_pkg_version, CargoPathExt, TargetBackend, DEP_PATH, MOON_MOD_JSON, +}; +use walkdir::WalkDir; + +#[test] +fn test_design() { + let dir = TestDir::new("design.in"); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["check"]) + .assert() + .success(); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["clean"]) + .assert() + .success(); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["build"]) + .assert() + .success(); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["clean"]) + .assert() + .success(); + check( + &get_stdout_with_args(&dir, ["run", "main1"]), + expect![[r#" + new_list + new_queue + new_list + new_stack + new_vector + main1 + "#]], + ); + check( + &get_stdout_with_args(&dir, ["run", "main2"]), + expect![[r#" + new_list + new_queue + main2 + "#]], + ); +} + +#[test] +fn test_diamond_pkg_001() { + let dir = TestDir::new("diamond-pkg-001.in"); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["check"]) + .assert() + .success(); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["clean"]) + .assert() + .success(); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["build"]) + .assert() + .success(); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["clean"]) + .assert() + .success(); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + A + B + A + C + main + "#]], + ); +} + +#[test] +fn test_diamond_pkg_002() { + let dir = TestDir::new("diamond-pkg-002.in"); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["check"]) + .assert() + .success(); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["clean"]) + .assert() + .success(); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["build"]) + .assert() + .success(); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["clean"]) + .assert() + .success(); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + A0 + A1 + A2 + A + B0 + B1 + B2 + B + A0 + A1 + A2 + A + C0 + C1 + C2 + C + main + "#]], + ); +} + +#[test] +fn test_diamond_pkg_003() { + let dir = TestDir::new("diamond-pkg-003.in"); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["check"]) + .assert() + .success(); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["clean"]) + .assert() + .success(); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["build"]) + .assert() + .success(); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["clean"]) + .assert() + .success(); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + A0 + A1 + A2 + A + B0 + B1 + B2 + B + A0 + A1 + A2 + A + C0 + C1 + C2 + C + main + "#]], + ); +} + +#[test] +fn test_extra_flags() { + let dir = TestDir::new("extra_flags.in"); + check( + &get_stdout_with_args(&dir, ["build", "--dry-run", "--nostd"]), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/release/build/lib/lib.core -pkg hello/lib -pkg-sources hello/lib:./lib -target wasm-gc -g -no-builtin + moonc build-package ./main/main.mbt -o ./target/wasm-gc/release/build/main/main.core -pkg hello/main -is-main -i ./target/wasm-gc/release/build/lib/lib.mi:lib -pkg-sources hello/main:./main -target wasm-gc -g -no-builtin + moonc link-core ./target/wasm-gc/release/build/lib/lib.core ./target/wasm-gc/release/build/main/main.core -main hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources hello/lib:./lib -pkg-sources hello/main:./main -target wasm-gc -no-builtin + "#]], + ); + check( + &get_stdout_with_args(&dir, ["build", "--dry-run", "--debug", "--nostd"]), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/debug/build/lib/lib.core -pkg hello/lib -pkg-sources hello/lib:./lib -target wasm-gc -g -source-map -g -no-builtin + moonc build-package ./main/main.mbt -o ./target/wasm-gc/debug/build/main/main.core -pkg hello/main -is-main -i ./target/wasm-gc/debug/build/lib/lib.mi:lib -pkg-sources hello/main:./main -target wasm-gc -g -source-map -g -no-builtin + moonc link-core ./target/wasm-gc/debug/build/lib/lib.core ./target/wasm-gc/debug/build/main/main.core -main hello/main -o ./target/wasm-gc/debug/build/main/main.wasm -pkg-sources hello/lib:./lib -pkg-sources hello/main:./main -target wasm-gc -g -source-map -no-builtin + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["run", "main", "--dry-run", "--nostd"]), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/release/build/lib/lib.core -pkg hello/lib -pkg-sources hello/lib:./lib -target wasm-gc -g -no-builtin + moonc build-package ./main/main.mbt -o ./target/wasm-gc/release/build/main/main.core -pkg hello/main -is-main -i ./target/wasm-gc/release/build/lib/lib.mi:lib -pkg-sources hello/main:./main -target wasm-gc -g -no-builtin + moonc link-core ./target/wasm-gc/release/build/lib/lib.core ./target/wasm-gc/release/build/main/main.core -main hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources hello/lib:./lib -pkg-sources hello/main:./main -target wasm-gc -no-builtin + moonrun ./target/wasm-gc/release/build/main/main.wasm + "#]], + ); + check( + &get_stdout_with_args(&dir, ["run", "main", "--dry-run", "--debug", "--nostd"]), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/debug/build/lib/lib.core -pkg hello/lib -pkg-sources hello/lib:./lib -target wasm-gc -g -source-map -g -no-builtin + moonc build-package ./main/main.mbt -o ./target/wasm-gc/debug/build/main/main.core -pkg hello/main -is-main -i ./target/wasm-gc/debug/build/lib/lib.mi:lib -pkg-sources hello/main:./main -target wasm-gc -g -source-map -g -no-builtin + moonc link-core ./target/wasm-gc/debug/build/lib/lib.core ./target/wasm-gc/debug/build/main/main.core -main hello/main -o ./target/wasm-gc/debug/build/main/main.wasm -pkg-sources hello/lib:./lib -pkg-sources hello/main:./main -target wasm-gc -g -source-map -no-builtin + moonrun ./target/wasm-gc/debug/build/main/main.wasm + "#]], + ); +} + +#[test] +fn test_fancy_import() { + let dir = TestDir::new("fancy_import.in/import001"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + Hello, world! + "#]], + ); + + let dir = TestDir::new("fancy_import.in/import002"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + Hello, world! + "#]], + ); + + let dir = TestDir::new("fancy_import.in/import003"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + Hello, world! + Hello, world2! + "#]], + ); + + let dir = TestDir::new("fancy_import.in/import004"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + f1 + f2 + f3 + f4 + "#]], + ); +} + +#[test] +fn test_hello() { + let dir = TestDir::new("hello.in"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + Hello, world! + "#]], + ); +} + +#[test] +fn test_moon_commands() { + let dir = TestDir::new("moon_commands.in"); + check( + &get_stdout_with_args(&dir, ["build", "--dry-run", "--nostd", "--sort-input"]), + expect![[r#" + moonc build-package ./lib/list/lib.mbt -o ./target/wasm-gc/release/build/lib/list/list.core -pkg design/lib/list -pkg-sources design/lib/list:./lib/list -target wasm-gc + moonc build-package ./lib/queue/lib.mbt -o ./target/wasm-gc/release/build/lib/queue/queue.core -pkg design/lib/queue -i ./target/wasm-gc/release/build/lib/list/list.mi:list -pkg-sources design/lib/queue:./lib/queue -target wasm-gc + moonc build-package ./main2/main.mbt -o ./target/wasm-gc/release/build/main2/main2.core -pkg design/main2 -is-main -i ./target/wasm-gc/release/build/lib/queue/queue.mi:queue -pkg-sources design/main2:./main2 -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/lib/list/list.core ./target/wasm-gc/release/build/lib/queue/queue.core ./target/wasm-gc/release/build/main2/main2.core -main design/main2 -o ./target/wasm-gc/release/build/main2/main2.wasm -pkg-sources design/lib/list:./lib/list -pkg-sources design/lib/queue:./lib/queue -pkg-sources design/main2:./main2 -target wasm-gc + moonc build-package ./main1/main.mbt -o ./target/wasm-gc/release/build/main1/main1.core -pkg design/main1 -is-main -i ./target/wasm-gc/release/build/lib/queue/queue.mi:queue -pkg-sources design/main1:./main1 -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/lib/list/list.core ./target/wasm-gc/release/build/lib/queue/queue.core ./target/wasm-gc/release/build/main1/main1.core -main design/main1 -o ./target/wasm-gc/release/build/main1/main1.wasm -pkg-sources design/lib/list:./lib/list -pkg-sources design/lib/queue:./lib/queue -pkg-sources design/main1:./main1 -target wasm-gc + "#]], + ); +} + +#[test] +fn test_moon_run_main() { + let dir = TestDir::new("moon_new.in"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + Hello, world! + "#]], + ); +} + +#[test] +#[cfg(unix)] +fn test_moon_new() { + let dir = TestDir::new_empty(); + get_stdout_with_args( + &dir, + [ + "new", + "--path", + "hello", + "--user", + "moonbitlang", + "--name", + "hello", + ], + ); + check( + &get_stdout_with_args( + &dir, + [ + "run", + "--source-dir", + "./hello", + "--target-dir", + "./hello/target", + "main", + ], + ), + expect![[r#" + Hello, world! + "#]], + ); +} + +#[test] +fn test_moon_help() { + let dir = TestDir::new_empty(); + check( + &get_stdout_with_args(&dir, ["help"]).replace("moon.exe", "moon"), + expect![[r#" + The build system and package manager for MoonBit. + + Usage: moon [OPTIONS] + + Commands: + new Create a new moonbit package + build Build the current package + check Check the current package, but don't build object files + run Run WebAssembly module + test Test the current package + clean Clean the target directory + fmt Format moonbit source code + doc Generate documentation + info Generate public interface (`.mbti`) files for all packages in the module + add Add a dependency + remove Remove a dependency + install Install dependencies + tree Display the dependency tree + login Log in to your account + register Register an account at mooncakes.io + publish Publish the current package + update Update the package registry index + coverage Code coverage utilities + generate-build-matrix Generate build matrix for benchmarking (legacy feature) + upgrade Upgrade toolchains + version Print version info and exit + help Print this message or the help of the given subcommand(s) + + Options: + --source-dir The source code directory. Defaults to the current directory + --target-dir The target directory. Defaults to `source_dir/target` + -q, --quiet Suppress output + -v, --verbose Increase verbosity + --trace Trace the execution of the program + --dry-run Do not actually run the command + -h, --help Print help + "#]], + ); +} + +#[test] +#[cfg(unix)] +fn test_bench4() { + let dir = TestDir::new_empty(); + get_stdout_with_args(&dir, ["generate-build-matrix", "-n", "4", "-o", "bench4"]); + check( + &get_stdout_with_args( + &dir, + [ + "run", + "--source-dir", + "./bench4", + "--target-dir", + "./bench4/target", + "main", + ], + ), + expect![[r#" + ok + "#]], + ); + + get_stdout_with_args( + &dir, + [ + "run", + "--source-dir", + "./bench4", + "--target-dir", + "./bench4/target", + "--trace", + "main", + ], + ); + + let trace_file = dunce::canonicalize(dir.join("./trace.json")).unwrap(); + let t = std::fs::read_to_string(trace_file).unwrap(); + assert!(t.contains("moonbit::build::read")); + assert!(t.contains(r#""name":"work.run""#)); + assert!(t.contains(r#""name":"run""#)); + assert!(t.contains(r#""name":"main""#)); +} + +#[test] +fn test_moon_version() { + let dir = TestDir::new_empty(); + let output = get_stdout_with_args(&dir, ["version"]); + assert!(output.contains(&format!("moon {}", get_cargo_pkg_version()))); +} + +#[test] +fn test_moon_version_json() -> anyhow::Result<()> { + let dir = TestDir::new_empty(); + + let output = get_stdout_with_args(&dir, ["version", "--json"]); + let items: moonutil::common::VersionItems = serde_json_lenient::from_str(&output)?; + assert_eq!(items.items.len(), 1); + assert_eq!(items.items[0].name, "moon"); + assert!(items.items[0].version.contains(&get_cargo_pkg_version())); + assert!(items.items[0].path.is_some()); + + let output = get_stdout_with_args(&dir, ["version", "--all", "--json"]); + let items: moonutil::common::VersionItems = serde_json_lenient::from_str(&output)?; + assert_eq!(items.items.len(), 3); + assert_eq!(items.items[0].name, "moon"); + assert!(items.items[0].version.contains(&get_cargo_pkg_version())); + assert_eq!(items.items[1].name, "moonc"); + + let output = get_stdout_with_args(&dir, ["version", "--all", "--json", "--no-path"]); + let items: moonutil::common::VersionItems = serde_json_lenient::from_str(&output)?; + assert!(items.items[0].path.is_none()); + + Ok(()) +} + +#[test] +fn test_moon_new_exist() { + let dir = TestDir::new("moon_new_exist.in"); + dir.join("hello").rm_rf(); + let res = &get_stdout_with_args( + &dir, + [ + "new", + "--path", + "hello", + "--user", + "moonbitlang", + "--name", + "hello", + ], + ); + + assert!(res.contains("Created hello")); + assert!(res.contains("Initialized empty Git repository")); + + snapbox::cmd::Command::new(moon_bin()) + .current_dir(dir.join("hello")) + .args([ + "new", + "--path", + ".", + "--user", + "moonbitlang", + "--name", + "hello", + ]) + .assert() + .failure(); + + dir.join("hello").rm_rf(); +} + +#[test] +fn test_moon_new_new() { + let dir = TestDir::new("moon_new_new.in"); + + let hello1 = dir.join("hello"); + if hello1.exists() { + hello1.rm_rf() + } + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args([ + "new", + "--path", + "hello", + "--user", + "moonbitlang", + "--name", + "hello", + ]) + .assert() + .success(); + check( + &get_stdout_with_args(&hello1, ["run", "main"]), + expect![[r#" + Hello, world! + "#]], + ); + hello1.rm_rf(); + + let hello2 = dir.join("hello2"); + std::fs::create_dir_all(&hello2).unwrap(); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&hello2) + .args([ + "new", + "--path", + ".", + "--user", + "moonbitlang", + "--name", + "hello", + ]) + .assert() + .success(); + check( + &get_stdout_with_args(&hello2, ["run", "main"]), + expect![[r#" + Hello, world! + "#]], + ); + hello2.rm_rf(); + + let hello3 = dir.join("hello3"); + if hello3.exists() { + hello3.rm_rf(); + } + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args([ + "new", + "--lib", + "--path", + "hello3", + "--user", + "moonbitlang", + "--name", + "hello", + ]) + .assert() + .success(); + check( + &get_stdout_with_args(&hello3, ["test", "-v"]), + expect![[r#" + test moonbitlang/hello/lib/hello_wbtest.mbt::hello ok + Total tests: 1, passed: 1, failed: 0. + "#]], + ); + check( + &get_stdout_with_args(&hello3, ["test"]), + expect![[r#" + Total tests: 1, passed: 1, failed: 0. + "#]], + ); + hello3.rm_rf(); + + let hello4 = dir.join("hello4"); + std::fs::create_dir_all(&hello4).unwrap(); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&hello4) + .args([ + "new", + "--lib", + "--path", + ".", + "--user", + "moonbitlang", + "--name", + "hello", + ]) + .assert() + .success(); + check( + &std::fs::read_to_string(hello4.join("moon.pkg.json")).unwrap(), + expect![[r#" + { + "import": [ + "moonbitlang/hello/lib" + ] + } + "#]], + ); + check( + &get_stdout_with_args(&hello4, ["test", "-v"]), + expect![[r#" + test moonbitlang/hello/lib/hello_wbtest.mbt::hello ok + Total tests: 1, passed: 1, failed: 0. + "#]], + ); + hello4.rm_rf(); +} + +#[test] +#[ignore = "todo"] +fn test_moon_new_interactive() { + let dir = TestDir::new("moon_new_new.in"); + + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["new"]) + .stdin("hello5\nexec\nmoonbitlang\nhello5\n\n") + .assert() + .success(); + check( + &std::fs::read_to_string(dir.join("hello5").join("moon.mod.json")).unwrap(), + expect![[r#" + { + "name": "moonbitlang/hello5", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" + }"#]], + ); + dir.join("hello5").rm_rf(); + + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["new"]) + .stdin("hello6\nlib\nmoonbitlang\nhello6\n") + .assert() + .success(); + check( + &std::fs::read_to_string(dir.join("hello6").join("moon.pkg.json")).unwrap(), + expect![[r#" + { + "import": [ + "moonbitlang/hello6/lib" + ] + } + "#]], + ); + dir.join("hello6").rm_rf(); +} + +#[test] +fn test_moon_new_snapshot() { + let dir = TestDir::new("moon_new_snapshot.in"); + + let hello = dir.join("hello"); + if hello.exists() { + hello.rm_rf(); + } + + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["new", "hello", "--no-license"]) + .assert() + .success(); + check( + &std::fs::read_to_string(hello.join("lib").join("hello.mbt")).unwrap(), + expect![[r#" + pub fn hello() -> String { + "Hello, world!" + } + "#]], + ); + assert!(!hello.join("LICENSE").exists()); + + if hello.exists() { + hello.rm_rf(); + } + + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args([ + "new", + "--path", + "hello", + "--user", + "moonbitlang", + "--name", + "hello", + ]) + .assert() + .success(); + check( + &std::fs::read_to_string(hello.join("lib").join("hello.mbt")).unwrap(), + expect![[r#" + pub fn hello() -> String { + "Hello, world!" + } + "#]], + ); + check( + &std::fs::read_to_string(hello.join("lib").join("hello_wbtest.mbt")).unwrap(), + expect![[r#" + test "hello" { + if hello() != "Hello, world!" { + raise "hello() != \"Hello, world!\"" + } + } + "#]], + ); + check( + &std::fs::read_to_string(hello.join("lib").join("moon.pkg.json")).unwrap(), + expect!["{}"], + ); + check( + &std::fs::read_to_string(hello.join("main").join("main.mbt")).unwrap(), + expect![[r#" + fn main { + println(@lib.hello()) + } + "#]], + ); + check( + &std::fs::read_to_string(hello.join("main").join("moon.pkg.json")).unwrap(), + expect![[r#" + { + "is-main": true, + "import": [ + "moonbitlang/hello/lib" + ] + }"#]], + ); + check( + &std::fs::read_to_string(hello.join("moon.mod.json")).unwrap(), + expect![[r#" + { + "name": "moonbitlang/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "Apache-2.0", + "keywords": [], + "description": "" + }"#]], + ); + let license_content = std::fs::read_to_string(hello.join("LICENSE")).unwrap(); + assert!(license_content.contains("Apache License")); + assert!(license_content.contains("Version 2.0, January 2004")); + hello.rm_rf(); +} + +#[test] +fn test_moon_new_snapshot_lib() { + let dir = TestDir::new("moon_new_snapshot.in"); + + let hello = dir.join("hello_lib"); + + if hello.exists() { + hello.rm_rf() + } + + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["new", "--lib", "hello_lib", "--no-license"]) + .assert() + .success(); + check( + &std::fs::read_to_string(hello.join("lib").join("hello.mbt")).unwrap(), + expect![[r#" + pub fn hello() -> String { + "Hello, world!" + } + "#]], + ); + + if hello.exists() { + hello.rm_rf() + } + + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args([ + "new", + "--lib", + "--path", + "hello_lib", + "--user", + "moonbitlang", + "--name", + "hello", + "--no-license", + ]) + .assert() + .success(); + check( + &std::fs::read_to_string(hello.join("lib").join("hello.mbt")).unwrap(), + expect![[r#" + pub fn hello() -> String { + "Hello, world!" + } + "#]], + ); + check( + &std::fs::read_to_string(hello.join("lib").join("hello_wbtest.mbt")).unwrap(), + expect![[r#" + test "hello" { + if hello() != "Hello, world!" { + raise "hello() != \"Hello, world!\"" + } + } + "#]], + ); + check( + &std::fs::read_to_string(hello.join("lib").join("moon.pkg.json")).unwrap(), + expect!["{}"], + ); + check( + &std::fs::read_to_string(hello.join("moon.pkg.json")).unwrap(), + expect![[r#" + { + "import": [ + "moonbitlang/hello/lib" + ] + } + "#]], + ); + check( + &std::fs::read_to_string(hello.join("moon.mod.json")).unwrap(), + expect![[r#" + { + "name": "moonbitlang/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" + }"#]], + ); + check( + &std::fs::read_to_string(hello.join("top.mbt")).unwrap(), + expect![[r#" + pub fn greeting() -> Unit { + println(@lib.hello()) + } + "#]], + ); + check( + &std::fs::read_to_string(hello.join("README.md")).unwrap(), + expect!["# moonbitlang/hello"], + ); + hello.rm_rf(); +} + +#[test] +fn test_moon_test() { + let dir = TestDir::new("moon_test.in"); + + let out = snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["test", "--sort-input"]) + .assert() + .failure() + .get_output() + .stdout + .to_owned(); + + let s = std::str::from_utf8(&out).unwrap().to_string(); + + check( + &s, + expect![[r#" + test moontest/lib2/hello_wbtest.mbt::0 failed: hello() != "Hello, World" + test moontest/lib2/nested/lib_wbtest.mbt::0 failed: add1(1) should be 2 + Total tests: 10, passed: 8, failed: 2. + "#]], + ); +} + +#[test] +fn test_moon_test_filter_package() { + let dir = TestDir::new("test_filter.in"); + + check( + &get_stdout_with_args(&dir, ["test", "-p", "username/hello/A", "--sort-input"]), + expect![[r#" + test A + test B + test C + test D + test hello_0 + test hello_1 + test hello_2 + Total tests: 7, passed: 7, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["test", "-p", "username/hello/lib", "--sort-input"]), + expect![[r#" + test A + test hello_0 + test hello_1 + Total tests: 3, passed: 3, failed: 0. + "#]], + ); +} + +#[test] +fn test_moon_test_filter_multi_package() { + let dir = TestDir::new("test_filter_pkg_with_test_imports.in"); + + check( + &get_stdout_with_args( + &dir, + [ + "test", + "-p", + "username/hello/lib", + "username/hello/lib1", + "username/hello/lib2", + "--sort-input", + ], + ), + expect![[r#" + Hello from lib1 + + Hello from lib2 + + Hello from lib7 + Hello from lib3 + + Hello from lib4 + Total tests: 4, passed: 4, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args( + &dir, + [ + "test", + "-p", + "username/hello/lib", + "username/hello/lib1", + "username/hello/lib2", + "-p", + "username/hello/lib3", + "--sort-input", + ], + ), + expect![[r#" + Hello from lib1 + + Hello from lib2 + + Hello from lib7 + Hello from lib3 + + Hello from lib4 + Hello from lib3 + + Hello from lib7 + Hello from lib6 + Total tests: 7, passed: 7, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args( + &dir, + [ + "test", + "-p", + "username/hello/lib", + "username/hello/lib1", + "username/hello/lib2", + "-f", + "lib.mbt", + "-p", + "username/hello/lib3", + "--sort-input", + ], + ), + expect![[r#" + Hello from lib1 + + Hello from lib2 + + Hello from lib3 + + Hello from lib4 + Hello from lib3 + + Hello from lib7 + Total tests: 5, passed: 5, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args( + &dir, + [ + "test", + "-p", + "username/hello/lib", + "username/hello/lib1", + "username/hello/lib2", + "-f", + "lib.mbt", + "-p", + "username/hello/lib3", + "-i", + "0", + "--sort-input", + ], + ), + expect![[r#" + Hello from lib1 + + Hello from lib2 + + Hello from lib3 + + Hello from lib4 + Hello from lib3 + + Total tests: 4, passed: 4, failed: 0. + "#]], + ); +} +#[test] +fn test_moon_test_filter_package_with_deps() { + let dir = TestDir::new("test_filter_pkg_with_deps.in"); + + check( + &get_stdout_with_args(&dir, ["test", "-p", "username/hello/lib"]), + expect![[r#" + Hello from lib1 + Hello from lib2 + Hello from lib4 + + Hello from lib3 + Hello from lib4 + + + Total tests: 1, passed: 1, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["test", "-p", "username/hello/lib2"]), + expect![[r#" + Hello from lib2 + Hello from lib4 + + Total tests: 1, passed: 1, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["test", "-p", "username/hello/lib4"]), + expect![[r#" + Hello from lib4 + Total tests: 1, passed: 1, failed: 0. + "#]], + ); +} + +#[test] +fn test_moon_test_filter_package_with_test_imports() { + let dir = TestDir::new("test_filter_pkg_with_test_imports.in"); + + check( + &get_stdout_with_args(&dir, ["test", "-p", "username/hello/lib"]), + expect![[r#" + Hello from lib1 + + Hello from lib2 + + Hello from lib7 + Total tests: 2, passed: 2, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["test", "-p", "username/hello/lib1"]), + expect![[r#" + Hello from lib3 + + Total tests: 1, passed: 1, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["test", "-p", "username/hello/lib2"]), + expect![[r#" + Hello from lib4 + Total tests: 1, passed: 1, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["test", "-p", "username/hello/lib3"]), + expect![[r#" + Hello from lib3 + + Hello from lib7 + Hello from lib6 + Total tests: 3, passed: 3, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["test", "-p", "username/hello/lib4"]), + expect![[r#" + Hello from lib5 + Hello from lib5 + Hello from lib7 + Total tests: 3, passed: 3, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["test", "-p", "username/hello/lib5"]), + expect![[r#" + Hello from lib5 + Total tests: 1, passed: 1, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["test", "-p", "username/hello/lib6"]), + expect![[r#" + Hello from lib6 + Total tests: 1, passed: 1, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["test", "-p", "username/hello/lib7"]), + expect![[r#" + Hello from lib7 + Hello from lib6 + Total tests: 2, passed: 2, failed: 0. + "#]], + ); +} + +#[test] +fn test_moon_test_filter_package_dry_run() { + let dir = TestDir::new("test_filter.in"); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + [ + "test", + "-p", + "username/hello/A", + "--dry-run", + "--sort-input", + ], + ), + expect![[r#" + moon generate-test-driver --source-dir . --target-dir ./target/wasm-gc/debug/test --package username/hello/A --sort-input --target wasm-gc + moonc build-package ./A/hello.mbt ./A/test.mbt ./A/hello_wbtest.mbt ./target/wasm-gc/debug/test/A/__generated_driver_for_underscore_test.mbt -o ./target/wasm-gc/debug/test/A/A.underscore_test.core -pkg username/hello/A -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/A:./A -target wasm-gc -g + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/debug/test/A/A.underscore_test.core -main username/hello/A -o ./target/wasm-gc/debug/test/A/A.underscore_test.wasm -test-mode -pkg-sources username/hello/A:./A -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc -g + moonc build-package ./A/hello.mbt ./A/test.mbt ./target/wasm-gc/debug/test/A/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/A/A.internal_test.core -pkg username/hello/A -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/A:./A -target wasm-gc -g + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/debug/test/A/A.internal_test.core -main username/hello/A -o ./target/wasm-gc/debug/test/A/A.internal_test.wasm -test-mode -pkg-sources username/hello/A:./A -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc -g + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["test", "--dry-run", "--sort-input"]), + expect![[r#" + moon generate-test-driver --source-dir . --target-dir ./target/wasm-gc/debug/test --sort-input --target wasm-gc + moonc build-package ./lib2/lib.mbt ./target/wasm-gc/debug/test/lib2/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/lib2/lib2.internal_test.core -pkg username/hello/lib2 -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/lib2:./lib2 -target wasm-gc -g + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/debug/test/lib2/lib2.internal_test.core -main username/hello/lib2 -o ./target/wasm-gc/debug/test/lib2/lib2.internal_test.wasm -test-mode -pkg-sources username/hello/lib2:./lib2 -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc -g + moonc build-package ./lib/hello.mbt ./lib/hello_wbtest.mbt ./target/wasm-gc/debug/test/lib/__generated_driver_for_underscore_test.mbt -o ./target/wasm-gc/debug/test/lib/lib.underscore_test.core -pkg username/hello/lib -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/lib:./lib -target wasm-gc -g + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/debug/test/lib/lib.underscore_test.core -main username/hello/lib -o ./target/wasm-gc/debug/test/lib/lib.underscore_test.wasm -test-mode -pkg-sources username/hello/lib:./lib -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc -g + moonc build-package ./lib/hello.mbt ./target/wasm-gc/debug/test/lib/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/lib/lib.internal_test.core -pkg username/hello/lib -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/lib:./lib -target wasm-gc -g + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/debug/test/lib/lib.internal_test.core -main username/hello/lib -o ./target/wasm-gc/debug/test/lib/lib.internal_test.wasm -test-mode -pkg-sources username/hello/lib:./lib -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc -g + moonc build-package ./A/hello.mbt ./A/test.mbt ./A/hello_wbtest.mbt ./target/wasm-gc/debug/test/A/__generated_driver_for_underscore_test.mbt -o ./target/wasm-gc/debug/test/A/A.underscore_test.core -pkg username/hello/A -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/A:./A -target wasm-gc -g + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/debug/test/A/A.underscore_test.core -main username/hello/A -o ./target/wasm-gc/debug/test/A/A.underscore_test.wasm -test-mode -pkg-sources username/hello/A:./A -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc -g + moonc build-package ./A/hello.mbt ./A/test.mbt ./target/wasm-gc/debug/test/A/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/A/A.internal_test.core -pkg username/hello/A -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/A:./A -target wasm-gc -g + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/debug/test/A/A.internal_test.core -main username/hello/A -o ./target/wasm-gc/debug/test/A/A.internal_test.wasm -test-mode -pkg-sources username/hello/A:./A -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc -g + "#]], + ); +} + +#[test] +fn test_moon_test_filter_file() { + let dir = TestDir::new("test_filter.in"); + + check( + &get_stdout_with_args(&dir, ["test", "-p", "username/hello/A", "-f", "hello.mbt"]), + expect![[r#" + test A + test B + Total tests: 2, passed: 2, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args( + &dir, + ["test", "-p", "username/hello/lib", "-f", "hello_wbtest.mbt"], + ), + expect![[r#" + test hello_0 + test hello_1 + Total tests: 2, passed: 2, failed: 0. + "#]], + ); +} + +#[test] +fn test_moon_test_filter_index() { + let dir = TestDir::new("test_filter.in"); + + check( + &get_stdout_with_args( + &dir, + [ + "test", + "-p", + "username/hello/A", + "-f", + "hello.mbt", + "-i", + "1", + ], + ), + expect![[r#" + test B + Total tests: 1, passed: 1, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args( + &dir, + [ + "test", + "-p", + "username/hello/lib", + "-f", + "hello_wbtest.mbt", + "-i", + "0", + ], + ), + expect![[r#" + test hello_0 + Total tests: 1, passed: 1, failed: 0. + "#]], + ); +} + +#[test] +fn test_moon_test_filter_index_with_auto_update() { + let dir = TestDir::new("test_filter.in"); + + let _ = get_stdout_with_args( + &dir, + [ + "test", + "-p", + "username/hello/lib2", + "-f", + "lib.mbt", + "-i", + "1", + "-u", + ], + ); + check( + &replace_crlf_to_lf(&std::fs::read_to_string(dir.join("lib2").join("lib.mbt")).unwrap()), + expect![[r#" + test { + println(2) + } + + test { + inspect(1, content="1")! + inspect(1 + 2, content="3")! + inspect("hello", content="hello")! + inspect([1, 2, 3], content="[1, 2, 3]")! + } + + test { + inspect(2)! + } + "#]], + ); + + let dir = TestDir::new("test_filter.in"); + let _ = get_stderr_with_args( + &dir, + [ + "test", + "-p", + "username/hello/lib2", + "-f", + "lib.mbt", + "-i", + "1", + "-u", + "-l", + "2", + ], + ); + check( + &replace_crlf_to_lf(&std::fs::read_to_string(dir.join("lib2").join("lib.mbt")).unwrap()), + expect![[r#" + test { + println(2) + } + + test { + inspect(1, content="1")! + inspect(1 + 2, content="3")! + inspect("hello")! + inspect([1, 2, 3])! + } + + test { + inspect(2)! + } + "#]], + ); + + let dir = TestDir::new("test_filter.in"); + let _ = get_stderr_with_args( + &dir, + [ + "test", + "-p", + "username/hello/lib2", + "-f", + "lib.mbt", + "-u", + "-l", + "1", + ], + ); + check( + &replace_crlf_to_lf(&std::fs::read_to_string(dir.join("lib2").join("lib.mbt")).unwrap()), + expect![[r#" + test { + println(2) + } + + test { + inspect(1, content="1")! + inspect(1 + 2)! + inspect("hello")! + inspect([1, 2, 3])! + } + + test { + inspect(2, content="2")! + } + "#]], + ); +} + +#[test] +fn test_moon_test_succ() { + std::env::set_var("NO_COLOR", "1"); + let dir = TestDir::new("moon_test_succ.in"); + check( + &get_stdout_with_args_and_replace_dir(&dir, ["test", "-v", "--sort-input"]), + expect![[r#" + [1001] Warning: Warning: Unused function 'add1' + ╭─[$ROOT/lib2/nested/lib.mbt:1:4] + │ + 1 │ fn add1(x : Int) -> Int { + │ ──┬─ + │ ╰─── Warning: Unused function 'add1' + ───╯ + test moontest/lib/hello_wbtest.mbt::0 ok + test moontest/lib2/hello_wbtest.mbt::0 ok + test moontest/lib2/nested/lib_wbtest.mbt::1 ok + test moontest/lib2/nested/lib_wbtest.mbt::0 ok + test moontest/lib3/hello_wbtest.mbt::0 ok + test moontest/lib4/hello_wbtest.mbt::0 ok + Total tests: 6, passed: 6, failed: 0. + "#]], + ); +} + +#[test] +fn test_moon_test_hello_exec() { + let dir = TestDir::new("moon_test_hello_exec.in"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + Hello, world! + "#]], + ); + check( + &get_stdout_with_args(&dir, ["test", "-v"]), + expect![[r#" + Warning: tests in the main package `moonbitlang/hello/main` will be ignored + this is lib test + test moonbitlang/hello/lib/hello_wbtest.mbt::0 ok + Total tests: 1, passed: 1, failed: 0. + "#]], + ); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["test", "--dry-run", "--debug", "--sort-input"], + ), + expect![[r#" + moon generate-test-driver --source-dir . --target-dir ./target/wasm-gc/debug/test --sort-input --target wasm-gc + moonc build-package ./lib/hello.mbt ./lib/hello_wbtest.mbt ./target/wasm-gc/debug/test/lib/__generated_driver_for_underscore_test.mbt -o ./target/wasm-gc/debug/test/lib/lib.underscore_test.core -pkg moonbitlang/hello/lib -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources moonbitlang/hello/lib:./lib -target wasm-gc -g + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/debug/test/lib/lib.underscore_test.core -main moonbitlang/hello/lib -o ./target/wasm-gc/debug/test/lib/lib.underscore_test.wasm -test-mode -pkg-sources moonbitlang/hello/lib:./lib -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc -g + moonc build-package ./lib/hello.mbt ./target/wasm-gc/debug/test/lib/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/lib/lib.internal_test.core -pkg moonbitlang/hello/lib -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources moonbitlang/hello/lib:./lib -target wasm-gc -g + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/debug/test/lib/lib.internal_test.core -main moonbitlang/hello/lib -o ./target/wasm-gc/debug/test/lib/lib.internal_test.wasm -test-mode -pkg-sources moonbitlang/hello/lib:./lib -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc -g + "#]], + ); +} + +#[test] +fn test_moon_test_hello_exec_fntest() { + let dir = TestDir::new("moon_test_hello_exec_fntest.in"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + init in main/main.mbt + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["test", "-v", "--dry-run", "--sort-input"]), + expect![[r#" + moon generate-test-driver --source-dir . --target-dir ./target/wasm-gc/debug/test --sort-input --target wasm-gc + moonc build-package ./lib/hello.mbt ./lib/hello_wbtest.mbt ./target/wasm-gc/debug/test/lib/__generated_driver_for_underscore_test.mbt -o ./target/wasm-gc/debug/test/lib/lib.underscore_test.core -pkg moonbitlang/hello/lib -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources moonbitlang/hello/lib:./lib -target wasm-gc -g + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/debug/test/lib/lib.underscore_test.core -main moonbitlang/hello/lib -o ./target/wasm-gc/debug/test/lib/lib.underscore_test.wasm -test-mode -pkg-sources moonbitlang/hello/lib:./lib -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc -g + moonc build-package ./lib/hello.mbt ./target/wasm-gc/debug/test/lib/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/lib/lib.internal_test.core -pkg moonbitlang/hello/lib -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources moonbitlang/hello/lib:./lib -target wasm-gc -g + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/debug/test/lib/lib.internal_test.core -main moonbitlang/hello/lib -o ./target/wasm-gc/debug/test/lib/lib.internal_test.wasm -test-mode -pkg-sources moonbitlang/hello/lib:./lib -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc -g + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["test", "-v", "--sort-input"]), + expect![[r#" + test in lib/hello.mbt + test moonbitlang/hello/lib/hello.mbt::0 ok + test in lib/hello_test.mbt + test moonbitlang/hello/lib/hello_wbtest.mbt::0 ok + Total tests: 2, passed: 2, failed: 0. + "#]], + ); +} + +#[test] +fn test_moon_test_hello_lib() { + let dir = TestDir::new("moon_test_hello_lib.in"); + check( + &get_stdout_with_args(&dir, ["test", "-v"]), + expect![[r#" + test moonbitlang/hello/lib/hello_wbtest.mbt::0 ok + Total tests: 1, passed: 1, failed: 0. + "#]], + ); +} + +#[test] +fn test_moon_test_with_local_dep() { + let dir = TestDir::new("moon_test_with_local_dep.in"); + check( + &get_stdout_with_args(&dir, ["test", "-v", "--frozen"]), + expect![[r#" + test hello31/lib/hello_wbtest.mbt::0 ok + Total tests: 1, passed: 1, failed: 0. + "#]], + ); + check( + &get_stdout_with_args(&dir, ["run", "main", "--frozen"]), + expect![[r#" + Hello, world! + "#]], + ); + // Run moon info + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["info", "--frozen"]) + .assert() + .success(); + // Check directory structure by listing all files + let root_dir = dir.as_ref().to_owned(); + let dir = WalkDir::new(&dir) + .sort_by_file_name() + .into_iter() + .filter_map(|e| e.ok()) + .map(|e| e.path().strip_prefix(&root_dir).unwrap().to_owned()) + // Filter out target directory + .filter(|p| !p.starts_with("target")) + // Convert to string and join with newline + .map(|p| p.to_string_lossy().to_string()) + .collect::>(); + let joined = dir.join("\n").replace('\\', "/"); // Normalize path separator + check( + &joined, + expect![[r#" + + .gitignore + lib + lib/hello.mbt + lib/hello_wbtest.mbt + lib/lib.mbti + lib/moon.pkg.json + main + main/main.mbt + main/main.mbti + main/moon.pkg.json + mods + mods/lijunchen + mods/lijunchen/mooncake + mods/lijunchen/mooncake/lib + mods/lijunchen/mooncake/lib/hello.mbt + mods/lijunchen/mooncake/lib/hello_wbtest.mbt + mods/lijunchen/mooncake/lib/moon.pkg.json + mods/lijunchen/mooncake/moon.mod.json + mods/lijunchen/mooncake/moon.pkg.json + mods/lijunchen/mooncake/top.mbt + moon.mod.json"#]], + ); +} + +#[test] +fn test_output_format() { + let dir = TestDir::new("output-format.in"); + + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["clean"]) + .assert() + .success(); + + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["build", "-q"]) + .assert() + .success(); + assert!(dir + .join(format!( + "target/{}/release/build/main/main.wasm", + TargetBackend::default().to_backend_ext() + )) + .exists()); + assert!(!dir + .join(format!( + "target/{}/release/build/main/main.wat", + TargetBackend::default().to_backend_ext() + )) + .exists()); + + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["clean"]) + .assert() + .success(); + + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["build", "-q", "--output-wat"]) + .assert() + .success(); + assert!(dir + .join(format!( + "target/{}/release/build/main/main.wat", + TargetBackend::default().to_backend_ext() + )) + .exists()); + assert!(!dir + .join(format!( + "target/{}/release/build/main/main.wasm", + TargetBackend::default().to_backend_ext() + )) + .exists()); + + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["clean"]) + .assert() + .success(); + + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["run", "main"]) + .assert() + .success(); + assert!(!dir + .join(format!( + "target/{}/release/build/main/main.wat", + TargetBackend::default().to_backend_ext() + )) + .exists()); + assert!(dir + .join(format!( + "target/{}/release/build/main/main.wasm", + TargetBackend::default().to_backend_ext() + )) + .exists()); + + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["clean"]) + .assert() + .success(); + + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["run", "main", "--output-wat"]) + .assert() + .failure(); + + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["clean"]) + .assert() + .success(); +} + +#[test] +fn test_simple_pkg() { + let dir = TestDir::new("simple-pkg-A-001.in"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + A + main + "#]], + ); + + let dir = TestDir::new("simple-pkg-A-002.in"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + A + main + "#]], + ); + + let dir = TestDir::new("simple-pkg-A-003.in"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + A + main + "#]], + ); + + let dir = TestDir::new("simple-pkg-A-004.in"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + A + main + "#]], + ); + + let dir = TestDir::new("simple-pkg-A-005.in"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + A + main + "#]], + ); + + let dir = TestDir::new("simple-pkg-A-006.in"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + main + "#]], + ); + + let dir = TestDir::new("simple-pkg-AB-001.in"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + A + B + main + "#]], + ); + + let dir = TestDir::new("simple-pkg-AB-002.in"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + A + B + main + "#]], + ); + + let dir = TestDir::new("simple-pkg-AB-003.in"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + A + B + main + "#]], + ); + + let dir = TestDir::new("simple-pkg-AB-004.in"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + A + B + main + "#]], + ); +} + +#[test] +fn test_target_backend() { + let dir = TestDir::new("target-backend.in"); + check( + &get_stdout_with_args(&dir, ["build", "--dry-run", "--nostd"]), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/release/build/lib/lib.core -pkg hello/lib -pkg-sources hello/lib:./lib -target wasm-gc + moonc build-package ./main/main.mbt -o ./target/wasm-gc/release/build/main/main.core -pkg hello/main -is-main -i ./target/wasm-gc/release/build/lib/lib.mi:lib -pkg-sources hello/main:./main -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/lib/lib.core ./target/wasm-gc/release/build/main/main.core -main hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources hello/lib:./lib -pkg-sources hello/main:./main -target wasm-gc + "#]], + ); + check( + &get_stdout_with_args( + &dir, + ["build", "--dry-run", "--target", "wasm-gc", "--nostd"], + ), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/release/build/lib/lib.core -pkg hello/lib -pkg-sources hello/lib:./lib -target wasm-gc + moonc build-package ./main/main.mbt -o ./target/wasm-gc/release/build/main/main.core -pkg hello/main -is-main -i ./target/wasm-gc/release/build/lib/lib.mi:lib -pkg-sources hello/main:./main -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/lib/lib.core ./target/wasm-gc/release/build/main/main.core -main hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources hello/lib:./lib -pkg-sources hello/main:./main -target wasm-gc + "#]], + ); + check( + &get_stdout_with_args(&dir, ["build", "--dry-run", "--target", "js", "--nostd"]), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/js/release/build/lib/lib.core -pkg hello/lib -pkg-sources hello/lib:./lib -target js + moonc build-package ./main/main.mbt -o ./target/js/release/build/main/main.core -pkg hello/main -is-main -i ./target/js/release/build/lib/lib.mi:lib -pkg-sources hello/main:./main -target js + moonc link-core ./target/js/release/build/lib/lib.core ./target/js/release/build/main/main.core -main hello/main -o ./target/js/release/build/main/main.js -pkg-sources hello/lib:./lib -pkg-sources hello/main:./main -target js + "#]], + ); + check( + &get_stdout_with_args(&dir, ["build", "--dry-run", "--nostd"]), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/release/build/lib/lib.core -pkg hello/lib -pkg-sources hello/lib:./lib -target wasm-gc + moonc build-package ./main/main.mbt -o ./target/wasm-gc/release/build/main/main.core -pkg hello/main -is-main -i ./target/wasm-gc/release/build/lib/lib.mi:lib -pkg-sources hello/main:./main -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/lib/lib.core ./target/wasm-gc/release/build/main/main.core -main hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources hello/lib:./lib -pkg-sources hello/main:./main -target wasm-gc + "#]], + ); + check( + &get_stdout_with_args(&dir, ["run", "main", "--dry-run", "--nostd"]), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/release/build/lib/lib.core -pkg hello/lib -pkg-sources hello/lib:./lib -target wasm-gc + moonc build-package ./main/main.mbt -o ./target/wasm-gc/release/build/main/main.core -pkg hello/main -is-main -i ./target/wasm-gc/release/build/lib/lib.mi:lib -pkg-sources hello/main:./main -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/lib/lib.core ./target/wasm-gc/release/build/main/main.core -main hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources hello/lib:./lib -pkg-sources hello/main:./main -target wasm-gc + moonrun ./target/wasm-gc/release/build/main/main.wasm + "#]], + ); + check( + &get_stdout_with_args( + &dir, + ["run", "main", "--dry-run", "--target", "wasm-gc", "--nostd"], + ), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/release/build/lib/lib.core -pkg hello/lib -pkg-sources hello/lib:./lib -target wasm-gc + moonc build-package ./main/main.mbt -o ./target/wasm-gc/release/build/main/main.core -pkg hello/main -is-main -i ./target/wasm-gc/release/build/lib/lib.mi:lib -pkg-sources hello/main:./main -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/lib/lib.core ./target/wasm-gc/release/build/main/main.core -main hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources hello/lib:./lib -pkg-sources hello/main:./main -target wasm-gc + moonrun ./target/wasm-gc/release/build/main/main.wasm + "#]], + ); + check( + &get_stdout_with_args( + &dir, + ["run", "main", "--dry-run", "--target", "js", "--nostd"], + ), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/js/release/build/lib/lib.core -pkg hello/lib -pkg-sources hello/lib:./lib -target js + moonc build-package ./main/main.mbt -o ./target/js/release/build/main/main.core -pkg hello/main -is-main -i ./target/js/release/build/lib/lib.mi:lib -pkg-sources hello/main:./main -target js + moonc link-core ./target/js/release/build/lib/lib.core ./target/js/release/build/main/main.core -main hello/main -o ./target/js/release/build/main/main.js -pkg-sources hello/lib:./lib -pkg-sources hello/main:./main -target js + node ./target/js/release/build/main/main.js + "#]], + ); +} + +#[test] +fn test_test_error_report() { + let dir = TestDir::new("test_error_report.in"); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["test"]) + .assert() + .failure(); +} + +#[test] +fn test_moonbit_docs_example() { + let dir = TestDir::new("unicode_demo.in"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + 3 + "#]], + ); + + let dir = TestDir::new("palindrome_string.in"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + aba + "#]], + ); + + let dir = TestDir::new("avl_tree.in"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + height of the tree: 6 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + success + "#]], + ); + + let dir = TestDir::new("docstring-demo.in"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + Hello, world! + "#]], + ); + + let dir = TestDir::new("multidimensional_arrays.in"); + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + 11 + "#]], + ); +} + +#[test] +fn test_moon_inline_test_001() { + let dir = TestDir::new("moon_inline_test_001.in"); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["test"]) + .assert() + .success(); + + let dir = TestDir::new("moon_inline_test_002.in"); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["test"]) + .assert() + .success(); + let dir = TestDir::new("moon_inline_test_003.in"); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["test"]) + .assert() + .failure(); +} + +#[test] +fn test_moon_inline_test_004() { + let dir = TestDir::new("moon_inline_test_004.in"); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["test"]) + .assert() + .failure(); +} + +#[test] +fn test_moon_inline_test_order() { + let dir = TestDir::new("moon_inline_test_order.in"); + check( + &get_stdout_with_args(&dir, ["test", "-v", "--sort-input"]), + expect![[r#" + executing A + executing A::hello.mbt::test_A + test username/hello/A/hello.mbt::1 ok + test username/hello/A/hello.mbt::0 ok + A_test.mbt::init + A_test.mbt::test_hello_A + test username/hello/A/A_wbtest.mbt::1 ok + test username/hello/A/A_wbtest.mbt::0 ok + executing B + executing B::hello.mbt::test_B + test username/hello/B/hello.mbt::1 ok + test username/hello/B/hello.mbt::0 ok + B_test.mbt::init + B_test.mbt::test_hello_B + test username/hello/B/B_wbtest.mbt::1 ok + test username/hello/B/B_wbtest.mbt::0 ok + Total tests: 8, passed: 8, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["run", "main", "--sort-input"]), + expect![[r#" + main.mbt::init + "#]], + ); +} + +#[test] +fn test_error_duplicate_alias() { + let dir = TestDir::new("error_duplicate_alias.in"); + let out = get_stderr_with_args(&dir, ["check"]); + assert!(out.contains("Duplicate alias `lib`")); +} + +#[test] +fn test_core_order() { + let dir = TestDir::new("core_order.in"); + check( + &get_stdout_with_args(&dir, ["build", "--dry-run", "--nostd"]), + expect![[r#" + moonc build-package ./T/t.mbt -o ./target/wasm-gc/release/build/T/T.core -pkg lijunchen/hello/T -pkg-sources lijunchen/hello/T:./T -target wasm-gc + moonc build-package ./A/a.mbt -o ./target/wasm-gc/release/build/A/A.core -pkg lijunchen/hello/A -i ./target/wasm-gc/release/build/T/T.mi:T -pkg-sources lijunchen/hello/A:./A -target wasm-gc + moonc build-package ./B/b.mbt -o ./target/wasm-gc/release/build/B/B.core -pkg lijunchen/hello/B -i ./target/wasm-gc/release/build/T/T.mi:T -pkg-sources lijunchen/hello/B:./B -target wasm-gc + moonc build-package ./main/main.mbt -o ./target/wasm-gc/release/build/main/main.core -pkg lijunchen/hello/main -is-main -i ./target/wasm-gc/release/build/A/A.mi:A -i ./target/wasm-gc/release/build/B/B.mi:B -pkg-sources lijunchen/hello/main:./main -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/T/T.core ./target/wasm-gc/release/build/A/A.core ./target/wasm-gc/release/build/B/B.core ./target/wasm-gc/release/build/main/main.core -main lijunchen/hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources lijunchen/hello/T:./T -pkg-sources lijunchen/hello/A:./A -pkg-sources lijunchen/hello/B:./B -pkg-sources lijunchen/hello/main:./main -target wasm-gc + "#]], + ); +} + +#[test] +fn test_moon_bundle() { + let dir = TestDir::new("moon_bundle.in"); + check( + &get_stdout_with_args(&dir, ["bundle", "--dry-run", "--sort-input"]), + expect![[r#" + moonc build-package ./A/lib.mbt -o ./target/wasm-gc/release/bundle/A/A.core -pkg moonbitlang/core/A -pkg-sources moonbitlang/core/A:./A -target wasm-gc + moonc build-package ./B/lib.mbt -o ./target/wasm-gc/release/bundle/B/B.core -pkg moonbitlang/core/B -i ./target/wasm-gc/release/bundle/A/A.mi:A -pkg-sources moonbitlang/core/B:./B -target wasm-gc + moonc build-package ./C/lib.mbt -o ./target/wasm-gc/release/bundle/C/C.core -pkg moonbitlang/core/C -i ./target/wasm-gc/release/bundle/A/A.mi:A -pkg-sources moonbitlang/core/C:./C -target wasm-gc + moonc build-package ./Orphan/lib.mbt -o ./target/wasm-gc/release/bundle/Orphan/Orphan.core -pkg moonbitlang/core/Orphan -pkg-sources moonbitlang/core/Orphan:./Orphan -target wasm-gc + moonc bundle-core ./target/wasm-gc/release/bundle/A/A.core ./target/wasm-gc/release/bundle/B/B.core ./target/wasm-gc/release/bundle/C/C.core ./target/wasm-gc/release/bundle/Orphan/Orphan.core -o ./target/wasm-gc/release/bundle/core.core + "#]], + ); +} + +#[cfg(unix)] +#[test] +fn test_expect_test() -> anyhow::Result<()> { + let tmp_dir_path = TestDir::new("expect_test.in"); + + let s = snapbox::cmd::Command::new(moon_bin()) + .current_dir(&tmp_dir_path) + .args(["test", "--update"]) + .assert() + .success() + .get_output() + .stdout + .to_owned(); + let out = std::str::from_utf8(&s).unwrap().to_string(); + + assert!(out.contains("Auto updating expect tests and retesting ...")); + assert!(out.contains("Total tests: 30, passed: 30, failed: 0.")); + let updated = + std::fs::read_to_string(tmp_dir_path.as_ref().join("lib").join("hello.mbt")).unwrap(); + assert!(updated.contains(r#"["a", "b", "c"]"#)); + + let s = snapbox::cmd::Command::new(moon_bin()) + .current_dir(&tmp_dir_path) + .args(["test", "--update"]) + .assert() + .success() + .get_output() + .stdout + .to_owned(); + + let out = std::str::from_utf8(&s).unwrap().to_string(); + assert!(out.contains("Total tests: 30, passed: 30, failed: 0.")); + let out = std::fs::read_to_string(tmp_dir_path.as_ref().join("lib").join("hello_wbtest.mbt")) + .unwrap(); + assert!(out.contains(r#"notbuf.expect(content="haha")!"#)); + Ok(()) +} + +#[test] +fn test_only_update_expect() { + let tmp_dir_path = TestDir::new("only_update_expect.in"); + + let _ = snapbox::cmd::Command::new(moon_bin()) + .current_dir(&tmp_dir_path) + .args([ + "test", + "-p", + "username/hello/lib", + "-f", + "hello.mbt", + "-i", + "0", + "--update", + ]) + .assert() + .failure() + .get_output() + .stdout + .to_owned(); +} + +#[test] +fn test_need_link() { + let dir = TestDir::new("need_link.in"); + check( + &get_stdout_with_args(&dir, ["build", "--dry-run", "--nostd", "--sort-input"]), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/release/build/lib/lib.core -pkg username/hello/lib -pkg-sources username/hello/lib:./lib -target wasm-gc + moonc build-package ./main/main.mbt -o ./target/wasm-gc/release/build/main/main.core -pkg username/hello/main -is-main -i ./target/wasm-gc/release/build/lib/lib.mi:lib -pkg-sources username/hello/main:./main -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/lib/lib.core ./target/wasm-gc/release/build/main/main.core -main username/hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources username/hello/lib:./lib -pkg-sources username/hello/main:./main -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/lib/lib.core -main username/hello/lib -o ./target/wasm-gc/release/build/lib/lib.wasm -pkg-sources username/hello/lib:./lib -target wasm-gc + "#]], + ); +} + +#[test] +fn test_backend_config() { + let dir = TestDir::new("backend_config.in"); + + let _ = get_stdout_with_args(&dir, ["build", "--output-wat"]); + let out = std::fs::read_to_string(dir.join(format!( + "target/{}/release/build/lib/lib.wat", + TargetBackend::default().to_backend_ext() + ))) + .unwrap(); + assert!(out.contains(&format!( + "(export \"hello_{}\")", + TargetBackend::default().to_backend_ext().replace('-', "_") + ))); + check( + &get_stdout_with_args_and_replace_dir(&dir, ["build", "--dry-run", "--sort-input"]), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/release/build/lib/lib.core -pkg username/hello/lib -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/lib:./lib -target wasm-gc + moonc build-package ./main/main.mbt -o ./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 ./target/wasm-gc/release/build/lib/lib.mi:lib -pkg-sources username/hello/main:./main -target wasm-gc + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/release/build/lib/lib.core ./target/wasm-gc/release/build/main/main.core -main username/hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources username/hello/lib:./lib -pkg-sources username/hello/main:./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 ./target/wasm-gc/release/build/lib/lib.core -main username/hello/lib -o ./target/wasm-gc/release/build/lib/lib.wasm -pkg-sources username/hello/lib:./lib -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc -exported_functions=hello:hello_wasm_gc + "#]], + ); + + check( + &get_stdout_with_args( + &dir, + [ + "build", + "--dry-run", + "--nostd", + "--target", + "wasm-gc", + "--sort-input", + ], + ), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/release/build/lib/lib.core -pkg username/hello/lib -pkg-sources username/hello/lib:./lib -target wasm-gc + moonc build-package ./main/main.mbt -o ./target/wasm-gc/release/build/main/main.core -pkg username/hello/main -is-main -i ./target/wasm-gc/release/build/lib/lib.mi:lib -pkg-sources username/hello/main:./main -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/lib/lib.core ./target/wasm-gc/release/build/main/main.core -main username/hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources username/hello/lib:./lib -pkg-sources username/hello/main:./main -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/lib/lib.core -main username/hello/lib -o ./target/wasm-gc/release/build/lib/lib.wasm -pkg-sources username/hello/lib:./lib -target wasm-gc -exported_functions=hello:hello_wasm_gc + "#]], + ); + + check( + &get_stdout_with_args( + &dir, + [ + "build", + "--dry-run", + "--nostd", + "--target", + "js", + "--sort-input", + ], + ), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/js/release/build/lib/lib.core -pkg username/hello/lib -pkg-sources username/hello/lib:./lib -target js + moonc build-package ./main/main.mbt -o ./target/js/release/build/main/main.core -pkg username/hello/main -is-main -i ./target/js/release/build/lib/lib.mi:lib -pkg-sources username/hello/main:./main -target js + moonc link-core ./target/js/release/build/lib/lib.core ./target/js/release/build/main/main.core -main username/hello/main -o ./target/js/release/build/main/main.js -pkg-sources username/hello/lib:./lib -pkg-sources username/hello/main:./main -target js + moonc link-core ./target/js/release/build/lib/lib.core -main username/hello/lib -o ./target/js/release/build/lib/lib.js -pkg-sources username/hello/lib:./lib -target js -exported_functions=hello:hello_js -js-format esm + "#]], + ); +} + +#[test] +#[cfg(unix)] +fn test_mbti() { + let dir = TestDir::new("mbti.in"); + let _ = get_stdout_with_args(&dir, ["info"]); + let lib_mi_out = &std::fs::read_to_string(dir.join("lib").join("lib.mbti")).unwrap(); + expect![[r#" + package username/hello/lib + + // Values + fn hello() -> String + + // Types and methods + + // Traits + + // Extension Methods + + "#]] + .assert_eq(lib_mi_out); + + let main_mi_out = &std::fs::read_to_string(dir.join("main").join("main.mbti")).unwrap(); + expect![[r#" + package username/hello/main + + // Values + + // Types and methods + + // Traits + + // Extension Methods + + "#]] + .assert_eq(main_mi_out); +} + +#[test] +fn test_dummy_core() { + let test_dir = TestDir::new("dummy-core.in"); + let dir = test_dir.as_ref().canonicalize().unwrap(); + + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["check", "--sort-input"]) + .assert() + .success(); + + #[cfg(unix)] + { + let p = dir.join(format!( + "target/{}/release/check/packages.json", + TargetBackend::default().to_backend_ext() + )); + check( + &replace_dir(&std::fs::read_to_string(p).unwrap(), &dir), + expect![[r#" + { + "source_dir": "$ROOT", + "name": "moonbitlang/core", + "packages": [ + { + "is-main": false, + "is-third-party": false, + "root": "moonbitlang/core", + "rel": "0", + "files": [ + "$ROOT/0/lib.mbt", + "$ROOT/0/y.js.mbt", + "$ROOT/0/y.wasm-gc.mbt", + "$ROOT/0/y.wasm.mbt" + ], + "wbtest-files": [ + "$ROOT/0/y_wbtest.js.mbt", + "$ROOT/0/y_wbtest.mbt", + "$ROOT/0/y_wbtest.wasm-gc.mbt", + "$ROOT/0/y_wbtest.wasm.mbt" + ], + "test-files": [], + "deps": [], + "wbtest-deps": [], + "test-deps": [], + "artifact": "$ROOT/target/wasm-gc/release/check/0/0.mi" + }, + { + "is-main": false, + "is-third-party": false, + "root": "moonbitlang/core", + "rel": "1", + "files": [ + "$ROOT/1/lib.mbt", + "$ROOT/1/x.js.mbt", + "$ROOT/1/x.wasm-gc.mbt", + "$ROOT/1/x.wasm.mbt" + ], + "wbtest-files": [ + "$ROOT/1/x_wbtest.wasm-gc.mbt" + ], + "test-files": [], + "deps": [], + "wbtest-deps": [], + "test-deps": [], + "artifact": "$ROOT/target/wasm-gc/release/check/1/1.mi" + }, + { + "is-main": false, + "is-third-party": false, + "root": "moonbitlang/core", + "rel": "2", + "files": [ + "$ROOT/2/lib.mbt" + ], + "wbtest-files": [], + "test-files": [], + "deps": [ + { + "path": "moonbitlang/core/1", + "alias": "1" + } + ], + "wbtest-deps": [], + "test-deps": [], + "artifact": "$ROOT/target/wasm-gc/release/check/2/2.mi" + }, + { + "is-main": false, + "is-third-party": false, + "root": "moonbitlang/core", + "rel": "char", + "files": [], + "wbtest-files": [], + "test-files": [], + "deps": [ + { + "path": "moonbitlang/core/coverage", + "alias": "coverage" + } + ], + "wbtest-deps": [], + "test-deps": [], + "artifact": "$ROOT/target/wasm-gc/release/check/char/char.mi" + }, + { + "is-main": false, + "is-third-party": false, + "root": "moonbitlang/core", + "rel": "coverage", + "files": [], + "wbtest-files": [], + "test-files": [], + "deps": [], + "wbtest-deps": [], + "test-deps": [], + "artifact": "$ROOT/target/wasm-gc/release/check/coverage/coverage.mi" + }, + { + "is-main": false, + "is-third-party": false, + "root": "moonbitlang/core", + "rel": "iter", + "files": [], + "wbtest-files": [], + "test-files": [], + "deps": [ + { + "path": "moonbitlang/core/coverage", + "alias": "coverage" + } + ], + "wbtest-deps": [ + { + "path": "moonbitlang/core/char", + "alias": "char" + } + ], + "test-deps": [], + "artifact": "$ROOT/target/wasm-gc/release/check/iter/iter.mi" + } + ], + "deps": [], + "backend": "wasm-gc" + }"#]], + ); + } + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["check", "--target", "js", "--sort-input"]) + .assert() + .success(); + + #[cfg(unix)] + { + let p = dir.join("target/js/release/check/packages.json"); + check( + &replace_dir(&std::fs::read_to_string(p).unwrap(), &dir), + expect![[r#" + { + "source_dir": "$ROOT", + "name": "moonbitlang/core", + "packages": [ + { + "is-main": false, + "is-third-party": false, + "root": "moonbitlang/core", + "rel": "0", + "files": [ + "$ROOT/0/lib.mbt", + "$ROOT/0/y.js.mbt", + "$ROOT/0/y.wasm-gc.mbt", + "$ROOT/0/y.wasm.mbt" + ], + "wbtest-files": [ + "$ROOT/0/y_wbtest.js.mbt", + "$ROOT/0/y_wbtest.mbt", + "$ROOT/0/y_wbtest.wasm-gc.mbt", + "$ROOT/0/y_wbtest.wasm.mbt" + ], + "test-files": [], + "deps": [], + "wbtest-deps": [], + "test-deps": [], + "artifact": "$ROOT/target/js/release/check/0/0.mi" + }, + { + "is-main": false, + "is-third-party": false, + "root": "moonbitlang/core", + "rel": "1", + "files": [ + "$ROOT/1/lib.mbt", + "$ROOT/1/x.js.mbt", + "$ROOT/1/x.wasm-gc.mbt", + "$ROOT/1/x.wasm.mbt" + ], + "wbtest-files": [ + "$ROOT/1/x_wbtest.wasm-gc.mbt" + ], + "test-files": [], + "deps": [], + "wbtest-deps": [], + "test-deps": [], + "artifact": "$ROOT/target/js/release/check/1/1.mi" + }, + { + "is-main": false, + "is-third-party": false, + "root": "moonbitlang/core", + "rel": "2", + "files": [ + "$ROOT/2/lib.mbt" + ], + "wbtest-files": [], + "test-files": [], + "deps": [ + { + "path": "moonbitlang/core/1", + "alias": "1" + } + ], + "wbtest-deps": [], + "test-deps": [], + "artifact": "$ROOT/target/js/release/check/2/2.mi" + }, + { + "is-main": false, + "is-third-party": false, + "root": "moonbitlang/core", + "rel": "char", + "files": [], + "wbtest-files": [], + "test-files": [], + "deps": [ + { + "path": "moonbitlang/core/coverage", + "alias": "coverage" + } + ], + "wbtest-deps": [], + "test-deps": [], + "artifact": "$ROOT/target/js/release/check/char/char.mi" + }, + { + "is-main": false, + "is-third-party": false, + "root": "moonbitlang/core", + "rel": "coverage", + "files": [], + "wbtest-files": [], + "test-files": [], + "deps": [], + "wbtest-deps": [], + "test-deps": [], + "artifact": "$ROOT/target/js/release/check/coverage/coverage.mi" + }, + { + "is-main": false, + "is-third-party": false, + "root": "moonbitlang/core", + "rel": "iter", + "files": [], + "wbtest-files": [], + "test-files": [], + "deps": [ + { + "path": "moonbitlang/core/coverage", + "alias": "coverage" + } + ], + "wbtest-deps": [ + { + "path": "moonbitlang/core/char", + "alias": "char" + } + ], + "test-deps": [], + "artifact": "$ROOT/target/js/release/check/iter/iter.mi" + } + ], + "deps": [], + "backend": "js" + }"#]], + ); + }; + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["check", "--dry-run", "--sort-input"]), + expect![[r#" + moonc check -o ./target/wasm-gc/release/check/coverage/coverage.mi -pkg moonbitlang/core/coverage -pkg-sources moonbitlang/core/coverage:./coverage -target wasm-gc + moonc check -o ./target/wasm-gc/release/check/iter/iter.mi -pkg moonbitlang/core/iter -i ./target/wasm-gc/release/check/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/iter:./iter -target wasm-gc + moonc check -o ./target/wasm-gc/release/check/char/char.mi -pkg moonbitlang/core/char -i ./target/wasm-gc/release/check/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/char:./char -target wasm-gc + moonc check ./1/lib.mbt ./1/x.wasm-gc.mbt -o ./target/wasm-gc/release/check/1/1.mi -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target wasm-gc + moonc check ./2/lib.mbt -o ./target/wasm-gc/release/check/2/2.mi -pkg moonbitlang/core/2 -i ./target/wasm-gc/release/check/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target wasm-gc + moonc check ./1/lib.mbt ./1/x.wasm-gc.mbt ./1/x_wbtest.wasm-gc.mbt -o ./target/wasm-gc/release/check/1/1.underscore_test.mi -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target wasm-gc + moonc check ./0/lib.mbt ./0/y.wasm-gc.mbt ./0/y_wbtest.mbt ./0/y_wbtest.wasm-gc.mbt -o ./target/wasm-gc/release/check/0/0.underscore_test.mi -pkg moonbitlang/core/0 -pkg-sources moonbitlang/core/0:./0 -target wasm-gc + moonc check ./0/lib.mbt ./0/y.wasm-gc.mbt -o ./target/wasm-gc/release/check/0/0.mi -pkg moonbitlang/core/0 -pkg-sources moonbitlang/core/0:./0 -target wasm-gc + "#]], + ); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["check", "--dry-run", "--target", "wasm", "--sort-input"], + ), + expect![[r#" + moonc check -o ./target/wasm/release/check/coverage/coverage.mi -pkg moonbitlang/core/coverage -pkg-sources moonbitlang/core/coverage:./coverage -target wasm + moonc check -o ./target/wasm/release/check/iter/iter.mi -pkg moonbitlang/core/iter -i ./target/wasm/release/check/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/iter:./iter -target wasm + moonc check -o ./target/wasm/release/check/char/char.mi -pkg moonbitlang/core/char -i ./target/wasm/release/check/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/char:./char -target wasm + moonc check ./1/lib.mbt ./1/x.wasm.mbt -o ./target/wasm/release/check/1/1.mi -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target wasm + moonc check ./2/lib.mbt -o ./target/wasm/release/check/2/2.mi -pkg moonbitlang/core/2 -i ./target/wasm/release/check/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target wasm + moonc check ./1/lib.mbt ./1/x.wasm.mbt -o ./target/wasm/release/check/1/1.underscore_test.mi -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target wasm + moonc check ./0/lib.mbt ./0/y.wasm.mbt ./0/y_wbtest.mbt ./0/y_wbtest.wasm.mbt -o ./target/wasm/release/check/0/0.underscore_test.mi -pkg moonbitlang/core/0 -pkg-sources moonbitlang/core/0:./0 -target wasm + moonc check ./0/lib.mbt ./0/y.wasm.mbt -o ./target/wasm/release/check/0/0.mi -pkg moonbitlang/core/0 -pkg-sources moonbitlang/core/0:./0 -target wasm + "#]], + ); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["check", "--dry-run", "--target", "wasm-gc", "--sort-input"], + ), + expect![[r#" + moonc check -o ./target/wasm-gc/release/check/coverage/coverage.mi -pkg moonbitlang/core/coverage -pkg-sources moonbitlang/core/coverage:./coverage -target wasm-gc + moonc check -o ./target/wasm-gc/release/check/iter/iter.mi -pkg moonbitlang/core/iter -i ./target/wasm-gc/release/check/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/iter:./iter -target wasm-gc + moonc check -o ./target/wasm-gc/release/check/char/char.mi -pkg moonbitlang/core/char -i ./target/wasm-gc/release/check/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/char:./char -target wasm-gc + moonc check ./1/lib.mbt ./1/x.wasm-gc.mbt -o ./target/wasm-gc/release/check/1/1.mi -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target wasm-gc + moonc check ./2/lib.mbt -o ./target/wasm-gc/release/check/2/2.mi -pkg moonbitlang/core/2 -i ./target/wasm-gc/release/check/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target wasm-gc + moonc check ./1/lib.mbt ./1/x.wasm-gc.mbt ./1/x_wbtest.wasm-gc.mbt -o ./target/wasm-gc/release/check/1/1.underscore_test.mi -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target wasm-gc + moonc check ./0/lib.mbt ./0/y.wasm-gc.mbt ./0/y_wbtest.mbt ./0/y_wbtest.wasm-gc.mbt -o ./target/wasm-gc/release/check/0/0.underscore_test.mi -pkg moonbitlang/core/0 -pkg-sources moonbitlang/core/0:./0 -target wasm-gc + moonc check ./0/lib.mbt ./0/y.wasm-gc.mbt -o ./target/wasm-gc/release/check/0/0.mi -pkg moonbitlang/core/0 -pkg-sources moonbitlang/core/0:./0 -target wasm-gc + "#]], + ); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["check", "--dry-run", "--target", "js", "--sort-input"], + ), + expect![[r#" + moonc check -o ./target/js/release/check/coverage/coverage.mi -pkg moonbitlang/core/coverage -pkg-sources moonbitlang/core/coverage:./coverage -target js + moonc check -o ./target/js/release/check/iter/iter.mi -pkg moonbitlang/core/iter -i ./target/js/release/check/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/iter:./iter -target js + moonc check -o ./target/js/release/check/char/char.mi -pkg moonbitlang/core/char -i ./target/js/release/check/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/char:./char -target js + moonc check ./1/lib.mbt ./1/x.js.mbt -o ./target/js/release/check/1/1.mi -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target js + moonc check ./2/lib.mbt -o ./target/js/release/check/2/2.mi -pkg moonbitlang/core/2 -i ./target/js/release/check/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target js + moonc check ./1/lib.mbt ./1/x.js.mbt -o ./target/js/release/check/1/1.underscore_test.mi -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target js + moonc check ./0/lib.mbt ./0/y.js.mbt ./0/y_wbtest.js.mbt ./0/y_wbtest.mbt -o ./target/js/release/check/0/0.underscore_test.mi -pkg moonbitlang/core/0 -pkg-sources moonbitlang/core/0:./0 -target js + moonc check ./0/lib.mbt ./0/y.js.mbt -o ./target/js/release/check/0/0.mi -pkg moonbitlang/core/0 -pkg-sources moonbitlang/core/0:./0 -target js + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["build", "--dry-run", "--sort-input"]), + expect![[r#" + moonc build-package ./1/lib.mbt ./1/x.wasm-gc.mbt -o ./target/wasm-gc/release/build/1/1.core -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target wasm-gc + moonc build-package ./2/lib.mbt -o ./target/wasm-gc/release/build/2/2.core -pkg moonbitlang/core/2 -i ./target/wasm-gc/release/build/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/1/1.core ./target/wasm-gc/release/build/2/2.core -main moonbitlang/core/2 -o ./target/wasm-gc/release/build/2/2.wasm -pkg-sources moonbitlang/core/1:./1 -pkg-sources moonbitlang/core/2:./2 -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/1/1.core -main moonbitlang/core/1 -o ./target/wasm-gc/release/build/1/1.wasm -pkg-sources moonbitlang/core/1:./1 -target wasm-gc + moonc build-package ./0/lib.mbt ./0/y.wasm-gc.mbt -o ./target/wasm-gc/release/build/0/0.core -pkg moonbitlang/core/0 -pkg-sources moonbitlang/core/0:./0 -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/0/0.core -main moonbitlang/core/0 -o ./target/wasm-gc/release/build/0/0.wasm -pkg-sources moonbitlang/core/0:./0 -target wasm-gc + "#]], + ); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["build", "--dry-run", "--target", "wasm", "--sort-input"], + ), + expect![[r#" + moonc build-package ./1/lib.mbt ./1/x.wasm.mbt -o ./target/wasm/release/build/1/1.core -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target wasm + moonc build-package ./2/lib.mbt -o ./target/wasm/release/build/2/2.core -pkg moonbitlang/core/2 -i ./target/wasm/release/build/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target wasm + moonc link-core ./target/wasm/release/build/1/1.core ./target/wasm/release/build/2/2.core -main moonbitlang/core/2 -o ./target/wasm/release/build/2/2.wasm -pkg-sources moonbitlang/core/1:./1 -pkg-sources moonbitlang/core/2:./2 -target wasm + moonc link-core ./target/wasm/release/build/1/1.core -main moonbitlang/core/1 -o ./target/wasm/release/build/1/1.wasm -pkg-sources moonbitlang/core/1:./1 -target wasm + moonc build-package ./0/lib.mbt ./0/y.wasm.mbt -o ./target/wasm/release/build/0/0.core -pkg moonbitlang/core/0 -pkg-sources moonbitlang/core/0:./0 -target wasm + moonc link-core ./target/wasm/release/build/0/0.core -main moonbitlang/core/0 -o ./target/wasm/release/build/0/0.wasm -pkg-sources moonbitlang/core/0:./0 -target wasm + "#]], + ); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["build", "--dry-run", "--target", "wasm-gc", "--sort-input"], + ), + expect![[r#" + moonc build-package ./1/lib.mbt ./1/x.wasm-gc.mbt -o ./target/wasm-gc/release/build/1/1.core -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target wasm-gc + moonc build-package ./2/lib.mbt -o ./target/wasm-gc/release/build/2/2.core -pkg moonbitlang/core/2 -i ./target/wasm-gc/release/build/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/1/1.core ./target/wasm-gc/release/build/2/2.core -main moonbitlang/core/2 -o ./target/wasm-gc/release/build/2/2.wasm -pkg-sources moonbitlang/core/1:./1 -pkg-sources moonbitlang/core/2:./2 -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/1/1.core -main moonbitlang/core/1 -o ./target/wasm-gc/release/build/1/1.wasm -pkg-sources moonbitlang/core/1:./1 -target wasm-gc + moonc build-package ./0/lib.mbt ./0/y.wasm-gc.mbt -o ./target/wasm-gc/release/build/0/0.core -pkg moonbitlang/core/0 -pkg-sources moonbitlang/core/0:./0 -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/0/0.core -main moonbitlang/core/0 -o ./target/wasm-gc/release/build/0/0.wasm -pkg-sources moonbitlang/core/0:./0 -target wasm-gc + "#]], + ); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["build", "--dry-run", "--target", "js", "--sort-input"], + ), + expect![[r#" + moonc build-package ./1/lib.mbt ./1/x.js.mbt -o ./target/js/release/build/1/1.core -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target js + moonc build-package ./2/lib.mbt -o ./target/js/release/build/2/2.core -pkg moonbitlang/core/2 -i ./target/js/release/build/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target js + moonc link-core ./target/js/release/build/1/1.core ./target/js/release/build/2/2.core -main moonbitlang/core/2 -o ./target/js/release/build/2/2.js -pkg-sources moonbitlang/core/1:./1 -pkg-sources moonbitlang/core/2:./2 -target js + moonc link-core ./target/js/release/build/1/1.core -main moonbitlang/core/1 -o ./target/js/release/build/1/1.js -pkg-sources moonbitlang/core/1:./1 -target js + moonc build-package ./0/lib.mbt ./0/y.js.mbt -o ./target/js/release/build/0/0.core -pkg moonbitlang/core/0 -pkg-sources moonbitlang/core/0:./0 -target js + moonc link-core ./target/js/release/build/0/0.core -main moonbitlang/core/0 -o ./target/js/release/build/0/0.js -pkg-sources moonbitlang/core/0:./0 -target js + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["test", "--dry-run", "--sort-input"]), + expect![[r#" + moon generate-test-driver --source-dir . --target-dir ./target/wasm-gc/debug/test --sort-input --target wasm-gc + moonc build-package -o ./target/wasm-gc/debug/test/coverage/coverage.core -pkg moonbitlang/core/coverage -pkg-sources moonbitlang/core/coverage:./coverage -target wasm-gc -g + moonc build-package ./target/wasm-gc/debug/test/iter/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/iter/iter.internal_test.core -pkg moonbitlang/core/iter -is-main -i ./target/wasm-gc/debug/test/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/iter:./iter -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/coverage/coverage.core ./target/wasm-gc/debug/test/iter/iter.internal_test.core -main moonbitlang/core/iter -o ./target/wasm-gc/debug/test/iter/iter.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/coverage:./coverage -pkg-sources moonbitlang/core/iter:./iter -target wasm-gc -g + moonc build-package ./target/wasm-gc/debug/test/coverage/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/coverage/coverage.internal_test.core -pkg moonbitlang/core/coverage -is-main -pkg-sources moonbitlang/core/coverage:./coverage -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/coverage/coverage.internal_test.core -main moonbitlang/core/coverage -o ./target/wasm-gc/debug/test/coverage/coverage.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/coverage:./coverage -target wasm-gc -g + moonc build-package ./target/wasm-gc/debug/test/char/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/char/char.internal_test.core -pkg moonbitlang/core/char -is-main -i ./target/wasm-gc/debug/test/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/char:./char -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/coverage/coverage.core ./target/wasm-gc/debug/test/char/char.internal_test.core -main moonbitlang/core/char -o ./target/wasm-gc/debug/test/char/char.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/coverage:./coverage -pkg-sources moonbitlang/core/char:./char -target wasm-gc -g + moonc build-package ./1/lib.mbt ./1/x.wasm-gc.mbt -o ./target/wasm-gc/debug/test/1/1.core -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target wasm-gc -g + moonc build-package ./2/lib.mbt ./target/wasm-gc/debug/test/2/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/2/2.internal_test.core -pkg moonbitlang/core/2 -is-main -i ./target/wasm-gc/debug/test/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/1/1.core ./target/wasm-gc/debug/test/2/2.internal_test.core -main moonbitlang/core/2 -o ./target/wasm-gc/debug/test/2/2.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/1:./1 -pkg-sources moonbitlang/core/2:./2 -target wasm-gc -g + moonc build-package ./1/lib.mbt ./1/x.wasm-gc.mbt ./1/x_wbtest.wasm-gc.mbt ./target/wasm-gc/debug/test/1/__generated_driver_for_underscore_test.mbt -o ./target/wasm-gc/debug/test/1/1.underscore_test.core -pkg moonbitlang/core/1 -is-main -pkg-sources moonbitlang/core/1:./1 -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/1/1.underscore_test.core -main moonbitlang/core/1 -o ./target/wasm-gc/debug/test/1/1.underscore_test.wasm -test-mode -pkg-sources moonbitlang/core/1:./1 -target wasm-gc -g + moonc build-package ./1/lib.mbt ./1/x.wasm-gc.mbt ./target/wasm-gc/debug/test/1/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/1/1.internal_test.core -pkg moonbitlang/core/1 -is-main -pkg-sources moonbitlang/core/1:./1 -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/1/1.internal_test.core -main moonbitlang/core/1 -o ./target/wasm-gc/debug/test/1/1.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/1:./1 -target wasm-gc -g + moonc build-package ./0/lib.mbt ./0/y.wasm-gc.mbt ./0/y_wbtest.js.mbt ./0/y_wbtest.mbt ./0/y_wbtest.wasm-gc.mbt ./0/y_wbtest.wasm.mbt ./target/wasm-gc/debug/test/0/__generated_driver_for_underscore_test.mbt -o ./target/wasm-gc/debug/test/0/0.underscore_test.core -pkg moonbitlang/core/0 -is-main -pkg-sources moonbitlang/core/0:./0 -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/0/0.underscore_test.core -main moonbitlang/core/0 -o ./target/wasm-gc/debug/test/0/0.underscore_test.wasm -test-mode -pkg-sources moonbitlang/core/0:./0 -target wasm-gc -g + moonc build-package ./0/lib.mbt ./0/y.wasm-gc.mbt ./target/wasm-gc/debug/test/0/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/0/0.internal_test.core -pkg moonbitlang/core/0 -is-main -pkg-sources moonbitlang/core/0:./0 -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/0/0.internal_test.core -main moonbitlang/core/0 -o ./target/wasm-gc/debug/test/0/0.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/0:./0 -target wasm-gc -g + "#]], + ); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["test", "--dry-run", "--target", "wasm", "--sort-input"], + ), + expect![[r#" + moon generate-test-driver --source-dir . --target-dir ./target/wasm/debug/test --sort-input --target wasm + moonc build-package -o ./target/wasm/debug/test/coverage/coverage.core -pkg moonbitlang/core/coverage -pkg-sources moonbitlang/core/coverage:./coverage -target wasm -g + moonc build-package ./target/wasm/debug/test/iter/__generated_driver_for_internal_test.mbt -o ./target/wasm/debug/test/iter/iter.internal_test.core -pkg moonbitlang/core/iter -is-main -i ./target/wasm/debug/test/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/iter:./iter -target wasm -g + moonc link-core ./target/wasm/debug/test/coverage/coverage.core ./target/wasm/debug/test/iter/iter.internal_test.core -main moonbitlang/core/iter -o ./target/wasm/debug/test/iter/iter.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/coverage:./coverage -pkg-sources moonbitlang/core/iter:./iter -target wasm -g + moonc build-package ./target/wasm/debug/test/coverage/__generated_driver_for_internal_test.mbt -o ./target/wasm/debug/test/coverage/coverage.internal_test.core -pkg moonbitlang/core/coverage -is-main -pkg-sources moonbitlang/core/coverage:./coverage -target wasm -g + moonc link-core ./target/wasm/debug/test/coverage/coverage.internal_test.core -main moonbitlang/core/coverage -o ./target/wasm/debug/test/coverage/coverage.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/coverage:./coverage -target wasm -g + moonc build-package ./target/wasm/debug/test/char/__generated_driver_for_internal_test.mbt -o ./target/wasm/debug/test/char/char.internal_test.core -pkg moonbitlang/core/char -is-main -i ./target/wasm/debug/test/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/char:./char -target wasm -g + moonc link-core ./target/wasm/debug/test/coverage/coverage.core ./target/wasm/debug/test/char/char.internal_test.core -main moonbitlang/core/char -o ./target/wasm/debug/test/char/char.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/coverage:./coverage -pkg-sources moonbitlang/core/char:./char -target wasm -g + moonc build-package ./1/lib.mbt ./1/x.wasm.mbt -o ./target/wasm/debug/test/1/1.core -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target wasm -g + moonc build-package ./2/lib.mbt ./target/wasm/debug/test/2/__generated_driver_for_internal_test.mbt -o ./target/wasm/debug/test/2/2.internal_test.core -pkg moonbitlang/core/2 -is-main -i ./target/wasm/debug/test/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target wasm -g + moonc link-core ./target/wasm/debug/test/1/1.core ./target/wasm/debug/test/2/2.internal_test.core -main moonbitlang/core/2 -o ./target/wasm/debug/test/2/2.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/1:./1 -pkg-sources moonbitlang/core/2:./2 -target wasm -g + moonc build-package ./1/lib.mbt ./1/x.wasm.mbt ./1/x_wbtest.wasm-gc.mbt ./target/wasm/debug/test/1/__generated_driver_for_underscore_test.mbt -o ./target/wasm/debug/test/1/1.underscore_test.core -pkg moonbitlang/core/1 -is-main -pkg-sources moonbitlang/core/1:./1 -target wasm -g + moonc link-core ./target/wasm/debug/test/1/1.underscore_test.core -main moonbitlang/core/1 -o ./target/wasm/debug/test/1/1.underscore_test.wasm -test-mode -pkg-sources moonbitlang/core/1:./1 -target wasm -g + moonc build-package ./1/lib.mbt ./1/x.wasm.mbt ./target/wasm/debug/test/1/__generated_driver_for_internal_test.mbt -o ./target/wasm/debug/test/1/1.internal_test.core -pkg moonbitlang/core/1 -is-main -pkg-sources moonbitlang/core/1:./1 -target wasm -g + moonc link-core ./target/wasm/debug/test/1/1.internal_test.core -main moonbitlang/core/1 -o ./target/wasm/debug/test/1/1.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/1:./1 -target wasm -g + moonc build-package ./0/lib.mbt ./0/y.wasm.mbt ./0/y_wbtest.js.mbt ./0/y_wbtest.mbt ./0/y_wbtest.wasm-gc.mbt ./0/y_wbtest.wasm.mbt ./target/wasm/debug/test/0/__generated_driver_for_underscore_test.mbt -o ./target/wasm/debug/test/0/0.underscore_test.core -pkg moonbitlang/core/0 -is-main -pkg-sources moonbitlang/core/0:./0 -target wasm -g + moonc link-core ./target/wasm/debug/test/0/0.underscore_test.core -main moonbitlang/core/0 -o ./target/wasm/debug/test/0/0.underscore_test.wasm -test-mode -pkg-sources moonbitlang/core/0:./0 -target wasm -g + moonc build-package ./0/lib.mbt ./0/y.wasm.mbt ./target/wasm/debug/test/0/__generated_driver_for_internal_test.mbt -o ./target/wasm/debug/test/0/0.internal_test.core -pkg moonbitlang/core/0 -is-main -pkg-sources moonbitlang/core/0:./0 -target wasm -g + moonc link-core ./target/wasm/debug/test/0/0.internal_test.core -main moonbitlang/core/0 -o ./target/wasm/debug/test/0/0.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/0:./0 -target wasm -g + "#]], + ); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["test", "--dry-run", "--target", "wasm-gc", "--sort-input"], + ), + expect![[r#" + moon generate-test-driver --source-dir . --target-dir ./target/wasm-gc/debug/test --sort-input --target wasm-gc + moonc build-package -o ./target/wasm-gc/debug/test/coverage/coverage.core -pkg moonbitlang/core/coverage -pkg-sources moonbitlang/core/coverage:./coverage -target wasm-gc -g + moonc build-package ./target/wasm-gc/debug/test/iter/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/iter/iter.internal_test.core -pkg moonbitlang/core/iter -is-main -i ./target/wasm-gc/debug/test/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/iter:./iter -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/coverage/coverage.core ./target/wasm-gc/debug/test/iter/iter.internal_test.core -main moonbitlang/core/iter -o ./target/wasm-gc/debug/test/iter/iter.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/coverage:./coverage -pkg-sources moonbitlang/core/iter:./iter -target wasm-gc -g + moonc build-package ./target/wasm-gc/debug/test/coverage/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/coverage/coverage.internal_test.core -pkg moonbitlang/core/coverage -is-main -pkg-sources moonbitlang/core/coverage:./coverage -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/coverage/coverage.internal_test.core -main moonbitlang/core/coverage -o ./target/wasm-gc/debug/test/coverage/coverage.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/coverage:./coverage -target wasm-gc -g + moonc build-package ./target/wasm-gc/debug/test/char/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/char/char.internal_test.core -pkg moonbitlang/core/char -is-main -i ./target/wasm-gc/debug/test/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/char:./char -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/coverage/coverage.core ./target/wasm-gc/debug/test/char/char.internal_test.core -main moonbitlang/core/char -o ./target/wasm-gc/debug/test/char/char.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/coverage:./coverage -pkg-sources moonbitlang/core/char:./char -target wasm-gc -g + moonc build-package ./1/lib.mbt ./1/x.wasm-gc.mbt -o ./target/wasm-gc/debug/test/1/1.core -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target wasm-gc -g + moonc build-package ./2/lib.mbt ./target/wasm-gc/debug/test/2/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/2/2.internal_test.core -pkg moonbitlang/core/2 -is-main -i ./target/wasm-gc/debug/test/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/1/1.core ./target/wasm-gc/debug/test/2/2.internal_test.core -main moonbitlang/core/2 -o ./target/wasm-gc/debug/test/2/2.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/1:./1 -pkg-sources moonbitlang/core/2:./2 -target wasm-gc -g + moonc build-package ./1/lib.mbt ./1/x.wasm-gc.mbt ./1/x_wbtest.wasm-gc.mbt ./target/wasm-gc/debug/test/1/__generated_driver_for_underscore_test.mbt -o ./target/wasm-gc/debug/test/1/1.underscore_test.core -pkg moonbitlang/core/1 -is-main -pkg-sources moonbitlang/core/1:./1 -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/1/1.underscore_test.core -main moonbitlang/core/1 -o ./target/wasm-gc/debug/test/1/1.underscore_test.wasm -test-mode -pkg-sources moonbitlang/core/1:./1 -target wasm-gc -g + moonc build-package ./1/lib.mbt ./1/x.wasm-gc.mbt ./target/wasm-gc/debug/test/1/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/1/1.internal_test.core -pkg moonbitlang/core/1 -is-main -pkg-sources moonbitlang/core/1:./1 -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/1/1.internal_test.core -main moonbitlang/core/1 -o ./target/wasm-gc/debug/test/1/1.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/1:./1 -target wasm-gc -g + moonc build-package ./0/lib.mbt ./0/y.wasm-gc.mbt ./0/y_wbtest.js.mbt ./0/y_wbtest.mbt ./0/y_wbtest.wasm-gc.mbt ./0/y_wbtest.wasm.mbt ./target/wasm-gc/debug/test/0/__generated_driver_for_underscore_test.mbt -o ./target/wasm-gc/debug/test/0/0.underscore_test.core -pkg moonbitlang/core/0 -is-main -pkg-sources moonbitlang/core/0:./0 -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/0/0.underscore_test.core -main moonbitlang/core/0 -o ./target/wasm-gc/debug/test/0/0.underscore_test.wasm -test-mode -pkg-sources moonbitlang/core/0:./0 -target wasm-gc -g + moonc build-package ./0/lib.mbt ./0/y.wasm-gc.mbt ./target/wasm-gc/debug/test/0/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/0/0.internal_test.core -pkg moonbitlang/core/0 -is-main -pkg-sources moonbitlang/core/0:./0 -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/0/0.internal_test.core -main moonbitlang/core/0 -o ./target/wasm-gc/debug/test/0/0.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/0:./0 -target wasm-gc -g + "#]], + ); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["test", "--dry-run", "--target", "js", "--sort-input"], + ), + expect![[r#" + moon generate-test-driver --source-dir . --target-dir ./target/js/debug/test --sort-input --target js + moonc build-package -o ./target/js/debug/test/coverage/coverage.core -pkg moonbitlang/core/coverage -pkg-sources moonbitlang/core/coverage:./coverage -target js -g -ryu + moonc build-package ./target/js/debug/test/iter/__generated_driver_for_internal_test.mbt -o ./target/js/debug/test/iter/iter.internal_test.core -pkg moonbitlang/core/iter -is-main -i ./target/js/debug/test/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/iter:./iter -target js -g -ryu + moonc link-core ./target/js/debug/test/coverage/coverage.core ./target/js/debug/test/iter/iter.internal_test.core -main moonbitlang/core/iter -o ./target/js/debug/test/iter/iter.internal_test.js -test-mode -pkg-sources moonbitlang/core/coverage:./coverage -pkg-sources moonbitlang/core/iter:./iter -target js -g -ryu + moonc build-package ./target/js/debug/test/coverage/__generated_driver_for_internal_test.mbt -o ./target/js/debug/test/coverage/coverage.internal_test.core -pkg moonbitlang/core/coverage -is-main -pkg-sources moonbitlang/core/coverage:./coverage -target js -g -ryu + moonc link-core ./target/js/debug/test/coverage/coverage.internal_test.core -main moonbitlang/core/coverage -o ./target/js/debug/test/coverage/coverage.internal_test.js -test-mode -pkg-sources moonbitlang/core/coverage:./coverage -target js -g -ryu + moonc build-package ./target/js/debug/test/char/__generated_driver_for_internal_test.mbt -o ./target/js/debug/test/char/char.internal_test.core -pkg moonbitlang/core/char -is-main -i ./target/js/debug/test/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/char:./char -target js -g -ryu + moonc link-core ./target/js/debug/test/coverage/coverage.core ./target/js/debug/test/char/char.internal_test.core -main moonbitlang/core/char -o ./target/js/debug/test/char/char.internal_test.js -test-mode -pkg-sources moonbitlang/core/coverage:./coverage -pkg-sources moonbitlang/core/char:./char -target js -g -ryu + moonc build-package ./1/lib.mbt ./1/x.js.mbt -o ./target/js/debug/test/1/1.core -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target js -g -ryu + moonc build-package ./2/lib.mbt ./target/js/debug/test/2/__generated_driver_for_internal_test.mbt -o ./target/js/debug/test/2/2.internal_test.core -pkg moonbitlang/core/2 -is-main -i ./target/js/debug/test/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target js -g -ryu + moonc link-core ./target/js/debug/test/1/1.core ./target/js/debug/test/2/2.internal_test.core -main moonbitlang/core/2 -o ./target/js/debug/test/2/2.internal_test.js -test-mode -pkg-sources moonbitlang/core/1:./1 -pkg-sources moonbitlang/core/2:./2 -target js -g -ryu + moonc build-package ./1/lib.mbt ./1/x.js.mbt ./1/x_wbtest.wasm-gc.mbt ./target/js/debug/test/1/__generated_driver_for_underscore_test.mbt -o ./target/js/debug/test/1/1.underscore_test.core -pkg moonbitlang/core/1 -is-main -pkg-sources moonbitlang/core/1:./1 -target js -g -ryu + moonc link-core ./target/js/debug/test/1/1.underscore_test.core -main moonbitlang/core/1 -o ./target/js/debug/test/1/1.underscore_test.js -test-mode -pkg-sources moonbitlang/core/1:./1 -target js -g -ryu + moonc build-package ./1/lib.mbt ./1/x.js.mbt ./target/js/debug/test/1/__generated_driver_for_internal_test.mbt -o ./target/js/debug/test/1/1.internal_test.core -pkg moonbitlang/core/1 -is-main -pkg-sources moonbitlang/core/1:./1 -target js -g -ryu + moonc link-core ./target/js/debug/test/1/1.internal_test.core -main moonbitlang/core/1 -o ./target/js/debug/test/1/1.internal_test.js -test-mode -pkg-sources moonbitlang/core/1:./1 -target js -g -ryu + moonc build-package ./0/lib.mbt ./0/y.js.mbt ./0/y_wbtest.js.mbt ./0/y_wbtest.mbt ./0/y_wbtest.wasm-gc.mbt ./0/y_wbtest.wasm.mbt ./target/js/debug/test/0/__generated_driver_for_underscore_test.mbt -o ./target/js/debug/test/0/0.underscore_test.core -pkg moonbitlang/core/0 -is-main -pkg-sources moonbitlang/core/0:./0 -target js -g -ryu + moonc link-core ./target/js/debug/test/0/0.underscore_test.core -main moonbitlang/core/0 -o ./target/js/debug/test/0/0.underscore_test.js -test-mode -pkg-sources moonbitlang/core/0:./0 -target js -g -ryu + moonc build-package ./0/lib.mbt ./0/y.js.mbt ./target/js/debug/test/0/__generated_driver_for_internal_test.mbt -o ./target/js/debug/test/0/0.internal_test.core -pkg moonbitlang/core/0 -is-main -pkg-sources moonbitlang/core/0:./0 -target js -g -ryu + moonc link-core ./target/js/debug/test/0/0.internal_test.core -main moonbitlang/core/0 -o ./target/js/debug/test/0/0.internal_test.js -test-mode -pkg-sources moonbitlang/core/0:./0 -target js -g -ryu + "#]], + ); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["test", "--dry-run", "--enable-coverage", "--sort-input"], + ), + expect![[r#" + moon generate-test-driver --source-dir . --target-dir ./target/wasm-gc/debug/test --sort-input --target wasm-gc + moonc build-package -o ./target/wasm-gc/debug/test/coverage/coverage.core -pkg moonbitlang/core/coverage -pkg-sources moonbitlang/core/coverage:./coverage -target wasm-gc -g -enable-coverage -coverage-package-override=@self + moonc build-package ./target/wasm-gc/debug/test/iter/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/iter/iter.internal_test.core -pkg moonbitlang/core/iter -is-main -i ./target/wasm-gc/debug/test/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/iter:./iter -target wasm-gc -g -enable-coverage + moonc link-core ./target/wasm-gc/debug/test/coverage/coverage.core ./target/wasm-gc/debug/test/iter/iter.internal_test.core -main moonbitlang/core/iter -o ./target/wasm-gc/debug/test/iter/iter.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/coverage:./coverage -pkg-sources moonbitlang/core/iter:./iter -target wasm-gc -g + moonc build-package ./target/wasm-gc/debug/test/coverage/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/coverage/coverage.internal_test.core -pkg moonbitlang/core/coverage -is-main -pkg-sources moonbitlang/core/coverage:./coverage -target wasm-gc -g -enable-coverage -coverage-package-override=@self + moonc link-core ./target/wasm-gc/debug/test/coverage/coverage.internal_test.core -main moonbitlang/core/coverage -o ./target/wasm-gc/debug/test/coverage/coverage.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/coverage:./coverage -target wasm-gc -g + moonc build-package ./target/wasm-gc/debug/test/char/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/char/char.internal_test.core -pkg moonbitlang/core/char -is-main -i ./target/wasm-gc/debug/test/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/char:./char -target wasm-gc -g -enable-coverage + moonc link-core ./target/wasm-gc/debug/test/coverage/coverage.core ./target/wasm-gc/debug/test/char/char.internal_test.core -main moonbitlang/core/char -o ./target/wasm-gc/debug/test/char/char.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/coverage:./coverage -pkg-sources moonbitlang/core/char:./char -target wasm-gc -g + moonc build-package ./1/lib.mbt ./1/x.wasm-gc.mbt -o ./target/wasm-gc/debug/test/1/1.core -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target wasm-gc -g -enable-coverage + moonc build-package ./2/lib.mbt ./target/wasm-gc/debug/test/2/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/2/2.internal_test.core -pkg moonbitlang/core/2 -is-main -i ./target/wasm-gc/debug/test/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target wasm-gc -g -enable-coverage + moonc link-core ./target/wasm-gc/debug/test/1/1.core ./target/wasm-gc/debug/test/2/2.internal_test.core -main moonbitlang/core/2 -o ./target/wasm-gc/debug/test/2/2.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/1:./1 -pkg-sources moonbitlang/core/2:./2 -target wasm-gc -g + moonc build-package ./1/lib.mbt ./1/x.wasm-gc.mbt ./1/x_wbtest.wasm-gc.mbt ./target/wasm-gc/debug/test/1/__generated_driver_for_underscore_test.mbt -o ./target/wasm-gc/debug/test/1/1.underscore_test.core -pkg moonbitlang/core/1 -is-main -pkg-sources moonbitlang/core/1:./1 -target wasm-gc -g -enable-coverage + moonc link-core ./target/wasm-gc/debug/test/1/1.underscore_test.core -main moonbitlang/core/1 -o ./target/wasm-gc/debug/test/1/1.underscore_test.wasm -test-mode -pkg-sources moonbitlang/core/1:./1 -target wasm-gc -g + moonc build-package ./1/lib.mbt ./1/x.wasm-gc.mbt ./target/wasm-gc/debug/test/1/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/1/1.internal_test.core -pkg moonbitlang/core/1 -is-main -pkg-sources moonbitlang/core/1:./1 -target wasm-gc -g -enable-coverage + moonc link-core ./target/wasm-gc/debug/test/1/1.internal_test.core -main moonbitlang/core/1 -o ./target/wasm-gc/debug/test/1/1.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/1:./1 -target wasm-gc -g + moonc build-package ./0/lib.mbt ./0/y.wasm-gc.mbt ./0/y_wbtest.js.mbt ./0/y_wbtest.mbt ./0/y_wbtest.wasm-gc.mbt ./0/y_wbtest.wasm.mbt ./target/wasm-gc/debug/test/0/__generated_driver_for_underscore_test.mbt -o ./target/wasm-gc/debug/test/0/0.underscore_test.core -pkg moonbitlang/core/0 -is-main -pkg-sources moonbitlang/core/0:./0 -target wasm-gc -g -enable-coverage + moonc link-core ./target/wasm-gc/debug/test/0/0.underscore_test.core -main moonbitlang/core/0 -o ./target/wasm-gc/debug/test/0/0.underscore_test.wasm -test-mode -pkg-sources moonbitlang/core/0:./0 -target wasm-gc -g + moonc build-package ./0/lib.mbt ./0/y.wasm-gc.mbt ./target/wasm-gc/debug/test/0/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/0/0.internal_test.core -pkg moonbitlang/core/0 -is-main -pkg-sources moonbitlang/core/0:./0 -target wasm-gc -g -enable-coverage + moonc link-core ./target/wasm-gc/debug/test/0/0.internal_test.core -main moonbitlang/core/0 -o ./target/wasm-gc/debug/test/0/0.internal_test.wasm -test-mode -pkg-sources moonbitlang/core/0:./0 -target wasm-gc -g + "#]], + ); + check( + &get_stdout_with_args_and_replace_dir(&dir, ["bundle", "--dry-run", "--sort-input"]), + expect![[r#" + moonc build-package ./1/lib.mbt ./1/x.wasm-gc.mbt -o ./target/wasm-gc/release/bundle/1/1.core -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target wasm-gc + moonc build-package -o ./target/wasm-gc/release/bundle/coverage/coverage.core -pkg moonbitlang/core/coverage -pkg-sources moonbitlang/core/coverage:./coverage -target wasm-gc + moonc build-package ./0/lib.mbt ./0/y.wasm-gc.mbt -o ./target/wasm-gc/release/bundle/0/0.core -pkg moonbitlang/core/0 -pkg-sources moonbitlang/core/0:./0 -target wasm-gc + moonc build-package ./2/lib.mbt -o ./target/wasm-gc/release/bundle/2/2.core -pkg moonbitlang/core/2 -i ./target/wasm-gc/release/bundle/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target wasm-gc + moonc build-package -o ./target/wasm-gc/release/bundle/char/char.core -pkg moonbitlang/core/char -i ./target/wasm-gc/release/bundle/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/char:./char -target wasm-gc + moonc build-package -o ./target/wasm-gc/release/bundle/iter/iter.core -pkg moonbitlang/core/iter -i ./target/wasm-gc/release/bundle/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/iter:./iter -target wasm-gc + moonc bundle-core ./target/wasm-gc/release/bundle/0/0.core ./target/wasm-gc/release/bundle/1/1.core ./target/wasm-gc/release/bundle/2/2.core ./target/wasm-gc/release/bundle/coverage/coverage.core ./target/wasm-gc/release/bundle/char/char.core ./target/wasm-gc/release/bundle/iter/iter.core -o ./target/wasm-gc/release/bundle/core.core + "#]], + ); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["bundle", "--dry-run", "--target", "wasm", "--sort-input"], + ), + expect![[r#" + moonc build-package ./1/lib.mbt ./1/x.wasm.mbt -o ./target/wasm/release/bundle/1/1.core -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target wasm + moonc build-package -o ./target/wasm/release/bundle/coverage/coverage.core -pkg moonbitlang/core/coverage -pkg-sources moonbitlang/core/coverage:./coverage -target wasm + moonc build-package ./0/lib.mbt ./0/y.wasm.mbt -o ./target/wasm/release/bundle/0/0.core -pkg moonbitlang/core/0 -pkg-sources moonbitlang/core/0:./0 -target wasm + moonc build-package ./2/lib.mbt -o ./target/wasm/release/bundle/2/2.core -pkg moonbitlang/core/2 -i ./target/wasm/release/bundle/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target wasm + moonc build-package -o ./target/wasm/release/bundle/char/char.core -pkg moonbitlang/core/char -i ./target/wasm/release/bundle/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/char:./char -target wasm + moonc build-package -o ./target/wasm/release/bundle/iter/iter.core -pkg moonbitlang/core/iter -i ./target/wasm/release/bundle/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/iter:./iter -target wasm + moonc bundle-core ./target/wasm/release/bundle/0/0.core ./target/wasm/release/bundle/1/1.core ./target/wasm/release/bundle/2/2.core ./target/wasm/release/bundle/coverage/coverage.core ./target/wasm/release/bundle/char/char.core ./target/wasm/release/bundle/iter/iter.core -o ./target/wasm/release/bundle/core.core + "#]], + ); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["bundle", "--dry-run", "--target", "wasm-gc", "--sort-input"], + ), + expect![[r#" + moonc build-package ./1/lib.mbt ./1/x.wasm-gc.mbt -o ./target/wasm-gc/release/bundle/1/1.core -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target wasm-gc + moonc build-package -o ./target/wasm-gc/release/bundle/coverage/coverage.core -pkg moonbitlang/core/coverage -pkg-sources moonbitlang/core/coverage:./coverage -target wasm-gc + moonc build-package ./0/lib.mbt ./0/y.wasm-gc.mbt -o ./target/wasm-gc/release/bundle/0/0.core -pkg moonbitlang/core/0 -pkg-sources moonbitlang/core/0:./0 -target wasm-gc + moonc build-package ./2/lib.mbt -o ./target/wasm-gc/release/bundle/2/2.core -pkg moonbitlang/core/2 -i ./target/wasm-gc/release/bundle/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target wasm-gc + moonc build-package -o ./target/wasm-gc/release/bundle/char/char.core -pkg moonbitlang/core/char -i ./target/wasm-gc/release/bundle/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/char:./char -target wasm-gc + moonc build-package -o ./target/wasm-gc/release/bundle/iter/iter.core -pkg moonbitlang/core/iter -i ./target/wasm-gc/release/bundle/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/iter:./iter -target wasm-gc + moonc bundle-core ./target/wasm-gc/release/bundle/0/0.core ./target/wasm-gc/release/bundle/1/1.core ./target/wasm-gc/release/bundle/2/2.core ./target/wasm-gc/release/bundle/coverage/coverage.core ./target/wasm-gc/release/bundle/char/char.core ./target/wasm-gc/release/bundle/iter/iter.core -o ./target/wasm-gc/release/bundle/core.core + "#]], + ); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["bundle", "--dry-run", "--target", "js", "--sort-input"], + ), + expect![[r#" + moonc build-package ./1/lib.mbt ./1/x.js.mbt -o ./target/js/release/bundle/1/1.core -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target js + moonc build-package -o ./target/js/release/bundle/coverage/coverage.core -pkg moonbitlang/core/coverage -pkg-sources moonbitlang/core/coverage:./coverage -target js + moonc build-package ./0/lib.mbt ./0/y.js.mbt -o ./target/js/release/bundle/0/0.core -pkg moonbitlang/core/0 -pkg-sources moonbitlang/core/0:./0 -target js + moonc build-package ./2/lib.mbt -o ./target/js/release/bundle/2/2.core -pkg moonbitlang/core/2 -i ./target/js/release/bundle/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target js + moonc build-package -o ./target/js/release/bundle/char/char.core -pkg moonbitlang/core/char -i ./target/js/release/bundle/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/char:./char -target js + moonc build-package -o ./target/js/release/bundle/iter/iter.core -pkg moonbitlang/core/iter -i ./target/js/release/bundle/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/iter:./iter -target js + moonc bundle-core ./target/js/release/bundle/0/0.core ./target/js/release/bundle/1/1.core ./target/js/release/bundle/2/2.core ./target/js/release/bundle/coverage/coverage.core ./target/js/release/bundle/char/char.core ./target/js/release/bundle/iter/iter.core -o ./target/js/release/bundle/core.core + "#]], + ); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + [ + "bundle", + "--target", + "all", + "--dry-run", + "--sort-input", + "--serial", + ], + ), + expect![[r#" + moonc build-package ./1/lib.mbt ./1/x.wasm.mbt -o ./target/wasm/release/bundle/1/1.core -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target wasm + moonc build-package -o ./target/wasm/release/bundle/coverage/coverage.core -pkg moonbitlang/core/coverage -pkg-sources moonbitlang/core/coverage:./coverage -target wasm + moonc build-package ./0/lib.mbt ./0/y.wasm.mbt -o ./target/wasm/release/bundle/0/0.core -pkg moonbitlang/core/0 -pkg-sources moonbitlang/core/0:./0 -target wasm + moonc build-package ./2/lib.mbt -o ./target/wasm/release/bundle/2/2.core -pkg moonbitlang/core/2 -i ./target/wasm/release/bundle/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target wasm + moonc build-package -o ./target/wasm/release/bundle/char/char.core -pkg moonbitlang/core/char -i ./target/wasm/release/bundle/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/char:./char -target wasm + moonc build-package -o ./target/wasm/release/bundle/iter/iter.core -pkg moonbitlang/core/iter -i ./target/wasm/release/bundle/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/iter:./iter -target wasm + moonc bundle-core ./target/wasm/release/bundle/0/0.core ./target/wasm/release/bundle/1/1.core ./target/wasm/release/bundle/2/2.core ./target/wasm/release/bundle/coverage/coverage.core ./target/wasm/release/bundle/char/char.core ./target/wasm/release/bundle/iter/iter.core -o ./target/wasm/release/bundle/core.core + moonc build-package ./1/lib.mbt ./1/x.wasm-gc.mbt -o ./target/wasm-gc/release/bundle/1/1.core -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target wasm-gc + moonc build-package -o ./target/wasm-gc/release/bundle/coverage/coverage.core -pkg moonbitlang/core/coverage -pkg-sources moonbitlang/core/coverage:./coverage -target wasm-gc + moonc build-package ./0/lib.mbt ./0/y.wasm-gc.mbt -o ./target/wasm-gc/release/bundle/0/0.core -pkg moonbitlang/core/0 -pkg-sources moonbitlang/core/0:./0 -target wasm-gc + moonc build-package ./2/lib.mbt -o ./target/wasm-gc/release/bundle/2/2.core -pkg moonbitlang/core/2 -i ./target/wasm-gc/release/bundle/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target wasm-gc + moonc build-package -o ./target/wasm-gc/release/bundle/char/char.core -pkg moonbitlang/core/char -i ./target/wasm-gc/release/bundle/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/char:./char -target wasm-gc + moonc build-package -o ./target/wasm-gc/release/bundle/iter/iter.core -pkg moonbitlang/core/iter -i ./target/wasm-gc/release/bundle/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/iter:./iter -target wasm-gc + moonc bundle-core ./target/wasm-gc/release/bundle/0/0.core ./target/wasm-gc/release/bundle/1/1.core ./target/wasm-gc/release/bundle/2/2.core ./target/wasm-gc/release/bundle/coverage/coverage.core ./target/wasm-gc/release/bundle/char/char.core ./target/wasm-gc/release/bundle/iter/iter.core -o ./target/wasm-gc/release/bundle/core.core + moonc build-package ./1/lib.mbt ./1/x.js.mbt -o ./target/js/release/bundle/1/1.core -pkg moonbitlang/core/1 -pkg-sources moonbitlang/core/1:./1 -target js + moonc build-package -o ./target/js/release/bundle/coverage/coverage.core -pkg moonbitlang/core/coverage -pkg-sources moonbitlang/core/coverage:./coverage -target js + moonc build-package ./0/lib.mbt ./0/y.js.mbt -o ./target/js/release/bundle/0/0.core -pkg moonbitlang/core/0 -pkg-sources moonbitlang/core/0:./0 -target js + moonc build-package ./2/lib.mbt -o ./target/js/release/bundle/2/2.core -pkg moonbitlang/core/2 -i ./target/js/release/bundle/1/1.mi:1 -pkg-sources moonbitlang/core/2:./2 -target js + moonc build-package -o ./target/js/release/bundle/char/char.core -pkg moonbitlang/core/char -i ./target/js/release/bundle/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/char:./char -target js + moonc build-package -o ./target/js/release/bundle/iter/iter.core -pkg moonbitlang/core/iter -i ./target/js/release/bundle/coverage/coverage.mi:coverage -pkg-sources moonbitlang/core/iter:./iter -target js + moonc bundle-core ./target/js/release/bundle/0/0.core ./target/js/release/bundle/1/1.core ./target/js/release/bundle/2/2.core ./target/js/release/bundle/coverage/coverage.core ./target/js/release/bundle/char/char.core ./target/js/release/bundle/iter/iter.core -o ./target/js/release/bundle/core.core + "#]], + ); +} + +#[test] +#[ignore = "not implemented"] +fn test_backend_flag() { + let dir = TestDir::new("backend-flag.in"); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["check", "--dry-run", "--sort-input"]), + expect![[r#" + moonc check ./lib/hello.mbt -o ./target/js/release/check/lib/lib.mi -pkg username/hello/lib -std-path $MOON_HOME/lib/core/target/js/release/bundle -pkg-sources username/hello/lib:./lib + moonc check ./main/main.mbt -o ./target/js/release/check/main/main.mi -pkg username/hello/main -is-main -std-path $MOON_HOME/lib/core/target/js/release/bundle -i ./target/js/release/check/lib/lib.mi:lib -pkg-sources username/hello/main:./main + moonc check ./lib/hello.mbt ./lib/hello_test.mbt -o ./target/js/release/check/lib/lib.underscore_test.mi -pkg username/hello/lib -std-path $MOON_HOME/lib/core/target/js/release/bundle -pkg-sources username/hello/lib:./lib + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["build", "--dry-run", "--sort-input"]), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/js/release/build/lib/lib.core -pkg username/hello/lib -std-path $MOON_HOME/lib/core/target/js/release/bundle -pkg-sources username/hello/lib:./lib + moonc build-package ./main/main.mbt -o ./target/js/release/build/main/main.core -pkg username/hello/main -is-main -std-path $MOON_HOME/lib/core/target/js/release/bundle -i ./target/js/release/build/lib/lib.mi:lib -pkg-sources username/hello/main:./main + moonc link-core $MOON_HOME/lib/core/target/js/release/bundle/core.core ./target/js/release/build/lib/lib.core ./target/js/release/build/main/main.core -main username/hello/main -o ./target/js/release/build/main/main.js -pkg-sources username/hello/lib:./lib -pkg-sources username/hello/main:./main -target js + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["test", "--dry-run", "--sort-input"]), + expect![[r#" + moon generate-test-driver --source-dir . --target-dir ./target/js/debug/test + moonc build-package ./lib/hello.mbt ./lib/hello_test.mbt ./target/js/debug/test/lib/__generated_driver_for_underscore_test.mbt -o ./target/js/debug/test/lib/lib.underscore_test.core -pkg username/hello/lib -is-main -std-path $MOON_HOME/lib/core/target/js/release/bundle -pkg-sources username/hello/lib:./lib -g -ryu + moonc link-core $MOON_HOME/lib/core/target/js/release/bundle/core.core ./target/js/debug/test/lib/lib.underscore_test.core -main username/hello/lib -o ./target/js/debug/test/lib/lib.underscore_test.js -test-mode -pkg-sources username/hello/lib:./lib -target js -ryu + moonc build-package ./lib/hello.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 -std-path $MOON_HOME/lib/core/target/js/release/bundle -pkg-sources username/hello/lib:./lib -g -ryu + moonc link-core $MOON_HOME/lib/core/target/js/release/bundle/core.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:./lib -target js -ryu + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["bundle", "--dry-run", "--sort-input"]), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/js/release/bundle/lib/lib.core -pkg username/hello/lib -pkg-sources username/hello/lib:./lib + moonc build-package ./main/main.mbt -o ./target/js/release/bundle/main/main.core -pkg username/hello/main -is-main -i ./target/js/release/bundle/lib/lib.mi:lib -pkg-sources username/hello/main:./main + moonc bundle-core ./target/js/release/bundle/lib/lib.core ./target/js/release/bundle/main/main.core -o ./target/js/release/bundle/hello.core + "#]], + ); +} + +#[test] +fn test_source_map() { + let dir = TestDir::new("hello.in"); + + // no -source-map in wasm backend + check( + &get_stdout_with_args_and_replace_dir( + &dir, + [ + "build", + "--target", + "wasm", + "--debug", + "--dry-run", + "--sort-input", + ], + ), + expect![[r#" + moonc build-package ./main/main.mbt -o ./target/wasm/debug/build/main/main.core -pkg hello/main -is-main -std-path $MOON_HOME/lib/core/target/wasm/release/bundle -pkg-sources hello/main:./main -target wasm -g + moonc link-core $MOON_HOME/lib/core/target/wasm/release/bundle/core.core ./target/wasm/debug/build/main/main.core -main hello/main -o ./target/wasm/debug/build/main/main.wasm -pkg-sources hello/main:./main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm -g + "#]], + ); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + [ + "build", + "--target", + "wasm-gc", + "--debug", + "--dry-run", + "--sort-input", + ], + ), + expect![[r#" + moonc build-package ./main/main.mbt -o ./target/wasm-gc/debug/build/main/main.core -pkg hello/main -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources hello/main:./main -target wasm-gc -g -source-map + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/debug/build/main/main.core -main hello/main -o ./target/wasm-gc/debug/build/main/main.wasm -pkg-sources hello/main:./main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc -g -source-map + "#]], + ); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + [ + "build", + "--target", + "js", + "--debug", + "--dry-run", + "--sort-input", + ], + ), + expect![[r#" + moonc build-package ./main/main.mbt -o ./target/js/debug/build/main/main.core -pkg hello/main -is-main -std-path $MOON_HOME/lib/core/target/js/release/bundle -pkg-sources hello/main:./main -target js -g -source-map + moonc link-core $MOON_HOME/lib/core/target/js/release/bundle/core.core ./target/js/debug/build/main/main.core -main hello/main -o ./target/js/debug/build/main/main.js -pkg-sources hello/main:./main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target js -g -source-map + "#]], + ); +} + +#[test] +fn test_find_ancestor_with_mod() { + let dir = TestDir::new("hello.in"); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["run", "main"]), + expect![[r#" + Hello, world! + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["run", "main"]), + expect![[r#" + Hello, world! + "#]], + ); +} + +#[test] +fn test_js_format() { + let dir = TestDir::new("js_format.in"); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + [ + "build", + "--target", + "js", + "--sort-input", + "--dry-run", + "--nostd", + ], + ), + expect![[r#" + moonc build-package ./lib3/hello.mbt -o ./target/js/release/build/lib3/lib3.core -pkg username/hello/lib3 -pkg-sources username/hello/lib3:./lib3 -target js + moonc link-core ./target/js/release/build/lib3/lib3.core -main username/hello/lib3 -o ./target/js/release/build/lib3/lib3.js -pkg-sources username/hello/lib3:./lib3 -target js -exported_functions=hello -js-format iife + moonc build-package ./lib2/hello.mbt -o ./target/js/release/build/lib2/lib2.core -pkg username/hello/lib2 -pkg-sources username/hello/lib2:./lib2 -target js + moonc link-core ./target/js/release/build/lib2/lib2.core -main username/hello/lib2 -o ./target/js/release/build/lib2/lib2.js -pkg-sources username/hello/lib2:./lib2 -target js -exported_functions=hello -js-format cjs + moonc build-package ./lib1/hello.mbt -o ./target/js/release/build/lib1/lib1.core -pkg username/hello/lib1 -pkg-sources username/hello/lib1:./lib1 -target js + moonc link-core ./target/js/release/build/lib1/lib1.core -main username/hello/lib1 -o ./target/js/release/build/lib1/lib1.js -pkg-sources username/hello/lib1:./lib1 -target js -exported_functions=hello -js-format esm + moonc build-package ./lib0/hello.mbt -o ./target/js/release/build/lib0/lib0.core -pkg username/hello/lib0 -pkg-sources username/hello/lib0:./lib0 -target js + moonc link-core ./target/js/release/build/lib0/lib0.core -main username/hello/lib0 -o ./target/js/release/build/lib0/lib0.js -pkg-sources username/hello/lib0:./lib0 -target js -exported_functions=hello -js-format esm + "#]], + ); + let _ = get_stdout_with_args_and_replace_dir(&dir, ["build", "--target", "js", "--nostd"]); + let t = dir.join("target").join("js").join("release").join("build"); + check( + &std::fs::read_to_string(t.join("lib0").join("lib0.js")) + .unwrap() + .replace("\r\n", "\n"), + expect![[r#" + function username$hello$lib0$$hello() { + return "Hello, world!"; + } + export { username$hello$lib0$$hello as hello } + "#]], + ); + check( + &std::fs::read_to_string(t.join("lib1").join("lib1.js")) + .unwrap() + .replace("\r\n", "\n"), + expect![[r#" + function username$hello$lib1$$hello() { + return "Hello, world!"; + } + export { username$hello$lib1$$hello as hello } + "#]], + ); + check( + &std::fs::read_to_string(t.join("lib2").join("lib2.js")) + .unwrap() + .replace("\r\n", "\n"), + expect![[r#" + function username$hello$lib2$$hello() { + return "Hello, world!"; + } + exports.hello = username$hello$lib2$$hello; + "#]], + ); + check( + &std::fs::read_to_string(t.join("lib3").join("lib3.js")) + .unwrap() + .replace("\r\n", "\n"), + expect![[r#" + (() => { + function username$hello$lib3$$hello() { + return "Hello, world!"; + } + globalThis.hello = username$hello$lib3$$hello; + })(); + "#]], + ); +} + +#[test] +fn test_warn_list_dry_run() { + let dir = TestDir::new("warn_list.in"); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["build", "--sort-input", "--no-render", "--dry-run"], + ), + expect![[r#" + moonc build-package ./lib/hello.mbt -w -2 -o ./target/wasm-gc/release/build/lib/lib.core -pkg username/hello/lib -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/lib:./lib -target wasm-gc + moonc build-package ./lib1/hello.mbt -w -1 -o ./target/wasm-gc/release/build/lib1/lib1.core -pkg username/hello/lib1 -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/lib1:./lib1 -target wasm-gc + moonc build-package ./main/main.mbt -w -1-2 -o ./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 ./target/wasm-gc/release/build/lib/lib.mi:lib -i ./target/wasm-gc/release/build/lib1/lib1.mi:lib1 -pkg-sources username/hello/main:./main -target wasm-gc + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/release/build/lib/lib.core ./target/wasm-gc/release/build/lib1/lib1.core ./target/wasm-gc/release/build/main/main.core -main username/hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources username/hello/lib:./lib -pkg-sources username/hello/lib1:./lib1 -pkg-sources username/hello/main:./main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["test", "--sort-input"]), + expect![[r#" + Total tests: 0, passed: 0, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["bundle", "--sort-input", "--no-render", "--dry-run"], + ), + expect![[r#" + moonc build-package ./lib/hello.mbt -w -2 -o ./target/wasm-gc/release/bundle/lib/lib.core -pkg username/hello/lib -pkg-sources username/hello/lib:./lib -target wasm-gc + moonc build-package ./lib1/hello.mbt -w -1 -o ./target/wasm-gc/release/bundle/lib1/lib1.core -pkg username/hello/lib1 -pkg-sources username/hello/lib1:./lib1 -target wasm-gc + moonc build-package ./main/main.mbt -w -1-2 -o ./target/wasm-gc/release/bundle/main/main.core -pkg username/hello/main -is-main -i ./target/wasm-gc/release/bundle/lib/lib.mi:lib -i ./target/wasm-gc/release/bundle/lib1/lib1.mi:lib1 -pkg-sources username/hello/main:./main -target wasm-gc + moonc bundle-core ./target/wasm-gc/release/bundle/lib/lib.core ./target/wasm-gc/release/bundle/lib1/lib1.core ./target/wasm-gc/release/bundle/main/main.core -o ./target/wasm-gc/release/bundle/hello.core + "#]], + ); + + // to cover `moon bundle` no work to do + get_stdout_with_args_and_replace_dir(&dir, ["bundle", "--sort-input"]); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["check", "--sort-input", "--no-render", "--dry-run"], + ), + expect![[r#" + moonc check ./lib/hello.mbt -w -2 -o ./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:./lib -target wasm-gc + moonc check ./lib1/hello.mbt -w -1 -o ./target/wasm-gc/release/check/lib1/lib1.mi -pkg username/hello/lib1 -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/lib1:./lib1 -target wasm-gc + moonc check ./main/main.mbt -w -1-2 -o ./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 ./target/wasm-gc/release/check/lib/lib.mi:lib -i ./target/wasm-gc/release/check/lib1/lib1.mi:lib1 -pkg-sources username/hello/main:./main -target wasm-gc + "#]], + ); +} + +#[test] +fn test_warn_list_real_run() { + let dir = TestDir::new("warn_list.in"); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["build", "--sort-input", "--no-render"]), + expect![[r#" + Finished. moon: ran 4 tasks, now up to date + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["test", "--sort-input"]), + expect![[r#" + Total tests: 0, passed: 0, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["bundle", "--sort-input", "--no-render"]), + expect![[r#" + Finished. moon: ran 4 tasks, now up to date + "#]], + ); + + // to cover `moon bundle` no work to do + get_stdout_with_args_and_replace_dir(&dir, ["bundle", "--sort-input"]); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["check", "--sort-input", "--no-render"]), + expect![[r#" + Finished. moon: ran 3 tasks, now up to date + "#]], + ); +} + +#[test] +fn test_alert_list() { + std::env::set_var("NO_COLOR", "1"); + let dir = TestDir::new("alert_list.in"); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["build", "--sort-input"]), + expect![[r#" + [2000] Warning: Warning (Alert alert_2): alert_2 + ╭─[$ROOT/main/main.mbt:3:3] + │ + 3 │ alert_2(); + │ ───┬─── + │ ╰───── Warning (Alert alert_2): alert_2 + ───╯ + Finished. moon: ran 3 tasks, now up to date + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["test", "--sort-input"]), + expect![[r#" + Total tests: 1, passed: 1, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["bundle", "--sort-input"]), + expect![[r#" + [2000] Warning: Warning (Alert alert_2): alert_2 + ╭─[$ROOT/main/main.mbt:3:3] + │ + 3 │ alert_2(); + │ ───┬─── + │ ╰───── Warning (Alert alert_2): alert_2 + ───╯ + Finished. moon: ran 3 tasks, now up to date + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["check", "--sort-input"]), + expect![[r#" + [2000] Warning: Warning (Alert alert_2): alert_2 + ╭─[$ROOT/main/main.mbt:3:3] + │ + 3 │ alert_2(); + │ ───┬─── + │ ╰───── Warning (Alert alert_2): alert_2 + ───╯ + Finished. moon: ran 2 tasks, now up to date + "#]], + ); +} + +#[test] +fn test_no_work_to_do() { + let dir = TestDir::new("moon_new.in"); + let out = get_stdout_with_args_and_replace_dir(&dir, ["check"]); + assert!(out.contains("now up to date")); + + let out = get_stdout_with_args_and_replace_dir(&dir, ["check"]); + assert!(out.contains("moon: no work to do")); + + let out = get_stdout_with_args_and_replace_dir(&dir, ["build"]); + assert!(out.contains("now up to date")); + let out = get_stdout_with_args_and_replace_dir(&dir, ["build"]); + assert!(out.contains("moon: no work to do")); +} + +#[test] +fn test_moon_test_release() { + let dir = TestDir::new("test_release.in"); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["test", "--dry-run", "--sort-input"]), + expect![[r#" + moon generate-test-driver --source-dir . --target-dir ./target/wasm-gc/debug/test --sort-input --target wasm-gc + moonc build-package ./lib/hello.mbt ./lib/hello_wbtest.mbt ./target/wasm-gc/debug/test/lib/__generated_driver_for_underscore_test.mbt -o ./target/wasm-gc/debug/test/lib/lib.underscore_test.core -pkg username/hello/lib -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/lib:./lib -target wasm-gc -g + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/debug/test/lib/lib.underscore_test.core -main username/hello/lib -o ./target/wasm-gc/debug/test/lib/lib.underscore_test.wasm -test-mode -pkg-sources username/hello/lib:./lib -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc -g + moonc build-package ./lib/hello.mbt ./target/wasm-gc/debug/test/lib/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/lib/lib.internal_test.core -pkg username/hello/lib -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/lib:./lib -target wasm-gc -g + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/debug/test/lib/lib.internal_test.core -main username/hello/lib -o ./target/wasm-gc/debug/test/lib/lib.internal_test.wasm -test-mode -pkg-sources username/hello/lib:./lib -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc -g + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["test", "--release", "--dry-run", "--sort-input"], + ), + expect![[r#" + moon generate-test-driver --source-dir . --target-dir ./target/wasm-gc/release/test --sort-input --target wasm-gc + moonc build-package ./lib/hello.mbt ./lib/hello_wbtest.mbt ./target/wasm-gc/release/test/lib/__generated_driver_for_underscore_test.mbt -o ./target/wasm-gc/release/test/lib/lib.underscore_test.core -pkg username/hello/lib -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/lib:./lib -target wasm-gc + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/release/test/lib/lib.underscore_test.core -main username/hello/lib -o ./target/wasm-gc/release/test/lib/lib.underscore_test.wasm -test-mode -pkg-sources username/hello/lib:./lib -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc + moonc build-package ./lib/hello.mbt ./target/wasm-gc/release/test/lib/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/release/test/lib/lib.internal_test.core -pkg username/hello/lib -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/lib:./lib -target wasm-gc + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/release/test/lib/lib.internal_test.core -main username/hello/lib -o ./target/wasm-gc/release/test/lib/lib.internal_test.wasm -test-mode -pkg-sources username/hello/lib:./lib -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["test", "--release", "--sort-input"]), + expect![[r#" + test A + test hello_0 + test hello_1 + Total tests: 3, passed: 3, failed: 0. + "#]], + ); +} + +#[test] +fn test_backtrace() { + let dir = TestDir::new("backtrace.in"); + + let out = get_stderr_with_args(&dir, ["run", "main"]); + assert!(!out.contains("main.foo.fn")); + assert!(!out.contains("main.bar.fn")); + + let out = get_stderr_with_args(&dir, ["run", "main", "--debug"]); + assert!(out.contains("main.foo.fn")); + assert!(out.contains("main.bar.fn")); +} + +#[test] +fn test_deny_warn() { + std::env::set_var("NO_COLOR", "1"); + let dir = TestDir::new("test_deny_warn.in"); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["check", "--sort-input"]), + expect![[r#" + [2000] Warning: Warning (Alert alert_2): alert_2 + ╭─[$ROOT/lib/hello.mbt:14:3] + │ + 14 │ alert_2(); + │ ───┬─── + │ ╰───── Warning (Alert alert_2): alert_2 + ────╯ + [2000] Warning: Warning (Alert alert_1): alert_1 + ╭─[$ROOT/lib/hello.mbt:13:3] + │ + 13 │ alert_1(); + │ ───┬─── + │ ╰───── Warning (Alert alert_1): alert_1 + ────╯ + [1002] Warning: Warning: Unused variable 'a' + ╭─[$ROOT/lib/hello.mbt:4:7] + │ + 4 │ let a = 1; + │ ┬ + │ ╰── Warning: Unused variable 'a' + ───╯ + [1002] Warning: Warning: Unused variable '中文' + ╭─[$ROOT/lib/hello.mbt:11:7] + │ + 11 │ let 中文 = 2 + │ ──┬─ + │ ╰─── Warning: Unused variable '中文' + ────╯ + [1002] Warning: Warning: Unused variable '🤣😭🤣😭🤣' + ╭─[$ROOT/lib/hello.mbt:12:7] + │ + 12 │ let 🤣😭🤣😭🤣 = 2 + │ ────┬───── + │ ╰─────── Warning: Unused variable '🤣😭🤣😭🤣' + ────╯ + [1002] Warning: Warning: Unused variable 'a' + ╭─[$ROOT/main/main.mbt:2:7] + │ + 2 │ let a = 0 + │ ┬ + │ ╰── Warning: Unused variable 'a' + ───╯ + Finished. moon: ran 2 tasks, now up to date + "#]], + ); + + let out = snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["check", "--deny-warn", "--sort-input"]) + .assert() + .failure() + .get_output() + .stdout + .to_owned(); + + let s = std::str::from_utf8(&out).unwrap().to_string(); + + assert!(s.contains( + "failed: moonc check -error-format json -w @a -alert @all-raise-throw-unsafe+deprecated" + )); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["build", "--sort-input"]), + expect![[r#" + [2000] Warning: Warning (Alert alert_2): alert_2 + ╭─[$ROOT/lib/hello.mbt:14:3] + │ + 14 │ alert_2(); + │ ───┬─── + │ ╰───── Warning (Alert alert_2): alert_2 + ────╯ + [2000] Warning: Warning (Alert alert_1): alert_1 + ╭─[$ROOT/lib/hello.mbt:13:3] + │ + 13 │ alert_1(); + │ ───┬─── + │ ╰───── Warning (Alert alert_1): alert_1 + ────╯ + [1002] Warning: Warning: Unused variable 'a' + ╭─[$ROOT/lib/hello.mbt:4:7] + │ + 4 │ let a = 1; + │ ┬ + │ ╰── Warning: Unused variable 'a' + ───╯ + [1002] Warning: Warning: Unused variable '中文' + ╭─[$ROOT/lib/hello.mbt:11:7] + │ + 11 │ let 中文 = 2 + │ ──┬─ + │ ╰─── Warning: Unused variable '中文' + ────╯ + [1002] Warning: Warning: Unused variable '🤣😭🤣😭🤣' + ╭─[$ROOT/lib/hello.mbt:12:7] + │ + 12 │ let 🤣😭🤣😭🤣 = 2 + │ ────┬───── + │ ╰─────── Warning: Unused variable '🤣😭🤣😭🤣' + ────╯ + [1002] Warning: Warning: Unused variable 'a' + ╭─[$ROOT/main/main.mbt:2:7] + │ + 2 │ let a = 0 + │ ┬ + │ ╰── Warning: Unused variable 'a' + ───╯ + Finished. moon: ran 3 tasks, now up to date + "#]], + ); + + let out = snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["build", "--deny-warn", "--sort-input"]) + .assert() + .failure() + .get_output() + .stdout + .to_owned(); + + let s = std::str::from_utf8(&out).unwrap().to_string(); + + assert!( + s.contains("failed: moonc build-package -error-format json -w @a -alert @all-raise-throw-unsafe+deprecated") + ); +} + +#[test] +fn test_moon_test_no_entry_warning() { + let dir = TestDir::new("moon_test_no_entry_warning.in"); + + let out = snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["test"]) + .assert() + .success() + .get_output() + .stderr + .to_owned(); + + check( + std::str::from_utf8(&out).unwrap(), + expect![[r#" + Warning: no test entry found + "#]], + ); +} + +#[test] +fn test_moon_fmt() { + fn read(p: &Path) -> String { + std::fs::read_to_string(p).unwrap().replace('\r', "") + } + + { + let dir = TestDir::new("moon_fmt.in"); + check( + &read(&dir.join("lib").join("hello.mbt")), + expect![[r#" + pub fn hello() -> String { "Hello, world!" } + "#]], + ); + check( + &read(&dir.join("main").join("main.mbt")), + expect![[r#" + fn main { println(@lib.hello()) }"#]], + ); + let _ = get_stdout_with_args_and_replace_dir(&dir, ["fmt"]); + check( + &read(&dir.join("lib").join("hello.mbt")), + expect![[r#" + pub fn hello() -> String { + "Hello, world!" + } + "#]], + ); + check( + &read(&dir.join("main").join("main.mbt")), + expect![[r#" + fn main { + println(@lib.hello()) + } + "#]], + ); + } + + { + let dir = TestDir::new("moon_fmt.in"); + let _ = snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["fmt", "--check"]) + .assert() + .failure() + .get_output() + .stdout + .to_owned(); + check( + &read(&dir.join("lib").join("hello.mbt")), + expect![[r#" + pub fn hello() -> String { "Hello, world!" } + "#]], + ); + check( + &read(&dir.join("main").join("main.mbt")), + expect![[r#" + fn main { println(@lib.hello()) }"#]], + ); + check( + &read( + &dir.join("target") + .join(TargetBackend::default().to_dir_name()) + .join("release") + .join("format") + .join("lib") + .join("hello.mbt"), + ), + expect![[r#" + pub fn hello() -> String { + "Hello, world!" + } + "#]], + ); + check( + &read( + &dir.join("target") + .join(TargetBackend::default().to_dir_name()) + .join("release") + .join("format") + .join("main") + .join("main.mbt"), + ), + expect![[r#" + fn main { + println(@lib.hello()) + } + "#]], + ); + } +} + +#[test] +fn test_export_memory_name() { + let dir = TestDir::new("export_memory.in"); + let _ = get_stdout_with_args_and_replace_dir( + &dir, + ["build", "--target", "wasm-gc", "--output-wat"], + ); + let content = std::fs::read_to_string( + dir.join("target") + .join("wasm-gc") + .join("release") + .join("build") + .join("main") + .join("main.wat"), + ) + .unwrap(); + assert!(content.contains("awesome_memory")); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["build", "--dry-run", "--sort-input"]), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/release/build/lib/lib.core -pkg username/hello/lib -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/lib:./lib -target wasm-gc + moonc build-package ./main/main.mbt -o ./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 ./target/wasm-gc/release/build/lib/lib.mi:lib -pkg-sources username/hello/main:./main -target wasm-gc + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/release/build/lib/lib.core ./target/wasm-gc/release/build/main/main.core -main username/hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources username/hello/lib:./lib -pkg-sources username/hello/main:./main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc -export-memory-name awesome_memory + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["build", "--dry-run", "--sort-input", "--target", "wasm"], + ), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm/release/build/lib/lib.core -pkg username/hello/lib -std-path $MOON_HOME/lib/core/target/wasm/release/bundle -pkg-sources username/hello/lib:./lib -target wasm + moonc build-package ./main/main.mbt -o ./target/wasm/release/build/main/main.core -pkg username/hello/main -is-main -std-path $MOON_HOME/lib/core/target/wasm/release/bundle -i ./target/wasm/release/build/lib/lib.mi:lib -pkg-sources username/hello/main:./main -target wasm + moonc link-core $MOON_HOME/lib/core/target/wasm/release/bundle/core.core ./target/wasm/release/build/lib/lib.core ./target/wasm/release/build/main/main.core -main username/hello/main -o ./target/wasm/release/build/main/main.wasm -pkg-sources username/hello/lib:./lib -pkg-sources username/hello/main:./main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm -export-memory-name awesome_memory + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["build", "--dry-run", "--sort-input", "--target", "js"], + ), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/js/release/build/lib/lib.core -pkg username/hello/lib -std-path $MOON_HOME/lib/core/target/js/release/bundle -pkg-sources username/hello/lib:./lib -target js + moonc build-package ./main/main.mbt -o ./target/js/release/build/main/main.core -pkg username/hello/main -is-main -std-path $MOON_HOME/lib/core/target/js/release/bundle -i ./target/js/release/build/lib/lib.mi:lib -pkg-sources username/hello/main:./main -target js + moonc link-core $MOON_HOME/lib/core/target/js/release/bundle/core.core ./target/js/release/build/lib/lib.core ./target/js/release/build/main/main.core -main username/hello/main -o ./target/js/release/build/main/main.js -pkg-sources username/hello/lib:./lib -pkg-sources username/hello/main:./main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target js + "#]], + ); +} + +#[test] +fn test_no_block_params() { + let dir = TestDir::new("no_block_params.in"); + check( + &get_stdout_with_args_and_replace_dir(&dir, ["build", "--dry-run", "--sort-input"]), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/release/build/lib/lib.core -pkg username/hello/lib -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/lib:./lib -target wasm-gc + moonc build-package ./main/main.mbt -o ./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 ./target/wasm-gc/release/build/lib/lib.mi:lib -pkg-sources username/hello/main:./main -target wasm-gc + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/release/build/lib/lib.core ./target/wasm-gc/release/build/main/main.core -main username/hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources username/hello/lib:./lib -pkg-sources username/hello/main:./main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc -no-block-params + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["build", "--dry-run", "--sort-input", "--target", "wasm"], + ), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm/release/build/lib/lib.core -pkg username/hello/lib -std-path $MOON_HOME/lib/core/target/wasm/release/bundle -pkg-sources username/hello/lib:./lib -target wasm + moonc build-package ./main/main.mbt -o ./target/wasm/release/build/main/main.core -pkg username/hello/main -is-main -std-path $MOON_HOME/lib/core/target/wasm/release/bundle -i ./target/wasm/release/build/lib/lib.mi:lib -pkg-sources username/hello/main:./main -target wasm + moonc link-core $MOON_HOME/lib/core/target/wasm/release/bundle/core.core ./target/wasm/release/build/lib/lib.core ./target/wasm/release/build/main/main.core -main username/hello/main -o ./target/wasm/release/build/main/main.wasm -pkg-sources username/hello/lib:./lib -pkg-sources username/hello/main:./main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm -no-block-params + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["build", "--dry-run", "--sort-input", "--target", "js"], + ), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/js/release/build/lib/lib.core -pkg username/hello/lib -std-path $MOON_HOME/lib/core/target/js/release/bundle -pkg-sources username/hello/lib:./lib -target js + moonc build-package ./main/main.mbt -o ./target/js/release/build/main/main.core -pkg username/hello/main -is-main -std-path $MOON_HOME/lib/core/target/js/release/bundle -i ./target/js/release/build/lib/lib.mi:lib -pkg-sources username/hello/main:./main -target js + moonc link-core $MOON_HOME/lib/core/target/js/release/bundle/core.core ./target/js/release/build/lib/lib.core ./target/js/release/build/main/main.core -main username/hello/main -o ./target/js/release/build/main/main.js -pkg-sources username/hello/lib:./lib -pkg-sources username/hello/main:./main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target js + "#]], + ); +} + +#[test] +fn test_panic() { + let dir = TestDir::new("panic.in"); + let data = snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["test"]) + .assert() + .failure() + .get_output() + .stdout + .to_owned(); + let out = String::from_utf8_lossy(&data).to_string(); + check( + &out, + expect![[r#" + test username/hello/lib/hello_wbtest.mbt::panic failed: panic is expected + Total tests: 2, passed: 1, failed: 1. + "#]], + ); +} + +#[test] +fn test_validate_import() { + let dir = TestDir::new("validate_import.in"); + check( + &get_stderr_with_args_and_replace_dir(&dir, ["check"]), + expect![[r#" + error: failed to read import path in "$ROOT/main/moon.pkg.json" + + Caused by: + No matching module was found for mbt/core/set + "#]], + ); + check( + &get_stderr_with_args_and_replace_dir(&dir, ["build"]), + expect![[r#" + error: failed to read import path in "$ROOT/main/moon.pkg.json" + + Caused by: + No matching module was found for mbt/core/set + "#]], + ); + check( + &get_stderr_with_args_and_replace_dir(&dir, ["test"]), + expect![[r#" + error: failed to read import path in "$ROOT/main/moon.pkg.json" + + Caused by: + No matching module was found for mbt/core/set + "#]], + ); + check( + &get_stderr_with_args_and_replace_dir(&dir, ["bundle"]), + expect![[r#" + error: failed to read import path in "$ROOT/main/moon.pkg.json" + + Caused by: + No matching module was found for mbt/core/set + "#]], + ); +} + +#[test] +fn test_multi_process() { + use std::process::Command; + use std::thread; + + let dir = TestDir::new("test_multi_process"); + let path: PathBuf = dir.as_ref().into(); + + let (num_threads, inner_loop) = (16, 10); + let mut container = vec![]; + + let success = std::sync::Arc::new(std::sync::atomic::AtomicI32::new(0)); + + for _ in 0..num_threads { + let path = path.clone(); + let success = success.clone(); + let work = thread::spawn(move || { + for _ in 0..inner_loop { + let _ = std::fs::OpenOptions::new() + .append(true) + .open(path.join("lib/hello.mbt")) + .unwrap() + .write(b"\n") + .unwrap(); + + let output = Command::new(moon_bin()) + .arg("check") + .current_dir(path.clone()) + .output() + .expect("Failed to execute command"); + + if output.status.success() { + success.fetch_add(1, std::sync::atomic::Ordering::SeqCst); + let out = String::from_utf8(output.stdout).unwrap(); + assert!(out.contains("no work to do") || out.contains("now up to date")); + } else { + println!("moon output: {:?}", String::from_utf8(output.stdout)); + let error_message = String::from_utf8_lossy(&output.stderr); + println!("{}", error_message); + } + } + }); + container.push(work); + } + + for i in container { + i.join().unwrap(); + } + + assert_eq!( + success.load(std::sync::atomic::Ordering::SeqCst), + num_threads * inner_loop + ); +} + +#[test] +fn test_internal_package() { + let dir = TestDir::new("internal_package.in"); + check( + &get_stderr_with_args_and_replace_dir(&dir, ["check", "--sort-input"]), + expect![[r#" + error: $ROOT/lib2/moon.pkg.json: cannot import internal package `username/hello/lib/internal` in `username/hello/lib2` + $ROOT/lib2/moon.pkg.json: cannot import internal package `username/hello/lib/internal/b` in `username/hello/lib2` + $ROOT/main/moon.pkg.json: cannot import internal package `username/hello/lib/internal` in `username/hello/main` + "#]], + ); +} + +#[test] +fn mooncakes_io_smoke_test() { + let dir = TestDir::new("hello.in"); + let _ = get_stdout_with_args(&dir, ["update"]); + let _ = get_stdout_with_args(&dir, ["add", "lijunchen/hello2@0.1.0"]); + check( + &std::fs::read_to_string(dir.join("moon.mod.json")).unwrap(), + expect![[r#" + { + "name": "hello", + "deps": { + "lijunchen/hello2": "0.1.0" + } + }"#]], + ); + let _ = get_stdout_with_args(&dir, ["remove", "lijunchen/hello2"]); + check( + &std::fs::read_to_string(dir.join("moon.mod.json")).unwrap(), + expect![[r#" + { + "name": "hello", + "deps": {} + }"#]], + ); + let _ = get_stdout_with_args(&dir, ["add", "lijunchen/hello2@0.1.0"]); + std::fs::write( + dir.join("main/main.mbt"), + r#"fn main { + println(@lib.hello2()) +} +"#, + ) + .unwrap(); + + assert!(dir + .join(DEP_PATH) + .join("lijunchen") + .join("hello") + .join(MOON_MOD_JSON) + .exists()); + + std::fs::remove_dir_all(dir.join(DEP_PATH)).unwrap(); + let out = get_stdout_with_args(&dir, ["install"]); + let mut lines = out.lines().collect::>(); + lines.sort(); + check( + &lines.join("\n"), + expect![[r#" + Using cached lijunchen/hello2@0.1.0 + Using cached lijunchen/hello@0.1.0"#]], + ); + + std::fs::write( + dir.join("main/moon.pkg.json"), + r#"{ + "is-main": true, + "import": [ + "lijunchen/hello2/lib" + ] + } + "#, + ) + .unwrap(); + + check( + &get_stdout_with_args(&dir, ["run", "main"]), + expect![[r#" + Hello, world!Hello, world2! + "#]], + ); +} + +#[test] +#[ignore = "where to download mooncake?"] +fn mooncake_cli_smoke_test() { + let dir = TestDir::new("hello.in"); + let out = std::process::Command::new(moon_bin()) + .env("RUST_BACKTRACE", "0") + .current_dir(&dir) + .args(["publish"]) + .output() + .unwrap(); + let s = std::str::from_utf8(&out.stderr).unwrap().to_string(); + assert!(s.contains("failed to open credentials file")); +} + +#[test] +fn bench2_test() { + let dir = TestDir::new("bench2_test.in"); + snapbox::cmd::Command::new(snapbox::cmd::cargo_bin("moon")) + .current_dir(&dir) + .args(["run", "main"]) + .assert() + .success() + .stdout_matches("ok[..]"); +} + +#[test] +fn cakenew_test() { + let dir = TestDir::new("cakenew_test.in"); + snapbox::cmd::Command::new(snapbox::cmd::cargo_bin("moon")) + .current_dir(&dir) + .args(["run", "main"]) + .assert() + .success() + .stdout_matches("Hello,[..]"); +} + +#[test] +fn capture_abort_test() { + let dir = super::TestDir::new("capture_abort_test.in"); + snapbox::cmd::Command::new(snapbox::cmd::cargo_bin("moon")) + .current_dir(&dir) + .args(["run", "main", "--nostd"]) + .assert() + .failure(); +} + +#[test] +fn whitespace_test() { + let dir = TestDir::new("whitespace_test.in"); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["clean"]) + .assert() + .success(); + + // unstable test + // check( + // &get_stdout_with_args(&dir, ["check", "--dry-run", "--nostd"]), + // expect![[r#" + // moonc check './main lib/hello.mbt' './main lib/hello_test.mbt' -o './target/check/main lib/main lib.underscore_test.mi' -pkg 'username/hello/main lib' -pkg-sources 'username/hello/main lib:./main lib' + // moonc check './main lib/hello.mbt' -o './target/check/main lib/main lib.mi' -pkg 'username/hello/main lib' -pkg-sources 'username/hello/main lib:./main lib' + // moonc check './main exe/main.mbt' -o './target/check/main exe/main exe.mi' -pkg 'username/hello/main exe' -is-main -i './target/check/main lib/main lib.mi:lib' -pkg-sources 'username/hello/main exe:./main exe' + // "#]], + // ); + + check( + &get_stdout_with_args(&dir, ["build", "--dry-run", "--nostd"]), + expect![[r#" + moonc build-package "./main lib/hello.mbt" -o "./target/wasm-gc/release/build/main lib/main lib.core" -pkg "username/hello/main lib" -pkg-sources "username/hello/main lib:./main lib" -target wasm-gc + moonc build-package "./main exe/main.mbt" -o "./target/wasm-gc/release/build/main exe/main exe.core" -pkg "username/hello/main exe" -is-main -i "./target/wasm-gc/release/build/main lib/main lib.mi:lib" -pkg-sources "username/hello/main exe:./main exe" -target wasm-gc + moonc link-core "./target/wasm-gc/release/build/main lib/main lib.core" "./target/wasm-gc/release/build/main exe/main exe.core" -main "username/hello/main exe" -o "./target/wasm-gc/release/build/main exe/main exe.wasm" -pkg-sources "username/hello/main lib:./main lib" -pkg-sources "username/hello/main exe:./main exe" -target wasm-gc + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["build", "--dry-run", "--debug", "--nostd"]), + expect![[r#" + moonc build-package "./main lib/hello.mbt" -o "./target/wasm-gc/debug/build/main lib/main lib.core" -pkg "username/hello/main lib" -pkg-sources "username/hello/main lib:./main lib" -target wasm-gc -g -source-map + moonc build-package "./main exe/main.mbt" -o "./target/wasm-gc/debug/build/main exe/main exe.core" -pkg "username/hello/main exe" -is-main -i "./target/wasm-gc/debug/build/main lib/main lib.mi:lib" -pkg-sources "username/hello/main exe:./main exe" -target wasm-gc -g -source-map + moonc link-core "./target/wasm-gc/debug/build/main lib/main lib.core" "./target/wasm-gc/debug/build/main exe/main exe.core" -main "username/hello/main exe" -o "./target/wasm-gc/debug/build/main exe/main exe.wasm" -pkg-sources "username/hello/main lib:./main lib" -pkg-sources "username/hello/main exe:./main exe" -target wasm-gc -g -source-map + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["run", "main exe", "--dry-run", "--nostd"]), + expect![[r#" + moonc build-package "./main lib/hello.mbt" -o "./target/wasm-gc/release/build/main lib/main lib.core" -pkg "username/hello/main lib" -pkg-sources "username/hello/main lib:./main lib" -target wasm-gc + moonc build-package "./main exe/main.mbt" -o "./target/wasm-gc/release/build/main exe/main exe.core" -pkg "username/hello/main exe" -is-main -i "./target/wasm-gc/release/build/main lib/main lib.mi:lib" -pkg-sources "username/hello/main exe:./main exe" -target wasm-gc + moonc link-core "./target/wasm-gc/release/build/main lib/main lib.core" "./target/wasm-gc/release/build/main exe/main exe.core" -main "username/hello/main exe" -o "./target/wasm-gc/release/build/main exe/main exe.wasm" -pkg-sources "username/hello/main lib:./main lib" -pkg-sources "username/hello/main exe:./main exe" -target wasm-gc + moonrun ./target/wasm-gc/release/build/main exe/main exe.wasm + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["run", "main exe", "--dry-run", "--debug", "--nostd"]), + expect![[r#" + moonc build-package "./main lib/hello.mbt" -o "./target/wasm-gc/debug/build/main lib/main lib.core" -pkg "username/hello/main lib" -pkg-sources "username/hello/main lib:./main lib" -target wasm-gc -g -source-map + moonc build-package "./main exe/main.mbt" -o "./target/wasm-gc/debug/build/main exe/main exe.core" -pkg "username/hello/main exe" -is-main -i "./target/wasm-gc/debug/build/main lib/main lib.mi:lib" -pkg-sources "username/hello/main exe:./main exe" -target wasm-gc -g -source-map + moonc link-core "./target/wasm-gc/debug/build/main lib/main lib.core" "./target/wasm-gc/debug/build/main exe/main exe.core" -main "username/hello/main exe" -o "./target/wasm-gc/debug/build/main exe/main exe.wasm" -pkg-sources "username/hello/main lib:./main lib" -pkg-sources "username/hello/main exe:./main exe" -target wasm-gc -g -source-map + moonrun ./target/wasm-gc/debug/build/main exe/main exe.wasm + "#]], + ); + check( + &get_stdout_with_args( + &dir, + ["build", "--target", "wasm-gc", "--dry-run", "--nostd"], + ), + expect![[r#" + moonc build-package "./main lib/hello.mbt" -o "./target/wasm-gc/release/build/main lib/main lib.core" -pkg "username/hello/main lib" -pkg-sources "username/hello/main lib:./main lib" -target wasm-gc + moonc build-package "./main exe/main.mbt" -o "./target/wasm-gc/release/build/main exe/main exe.core" -pkg "username/hello/main exe" -is-main -i "./target/wasm-gc/release/build/main lib/main lib.mi:lib" -pkg-sources "username/hello/main exe:./main exe" -target wasm-gc + moonc link-core "./target/wasm-gc/release/build/main lib/main lib.core" "./target/wasm-gc/release/build/main exe/main exe.core" -main "username/hello/main exe" -o "./target/wasm-gc/release/build/main exe/main exe.wasm" -pkg-sources "username/hello/main lib:./main lib" -pkg-sources "username/hello/main exe:./main exe" -target wasm-gc + "#]], + ); + check( + &get_stdout_with_args( + &dir, + [ + "build", + "--dry-run", + "--target", + "wasm-gc", + "--debug", + "--nostd", + ], + ), + expect![[r#" + moonc build-package "./main lib/hello.mbt" -o "./target/wasm-gc/debug/build/main lib/main lib.core" -pkg "username/hello/main lib" -pkg-sources "username/hello/main lib:./main lib" -target wasm-gc -g -source-map + moonc build-package "./main exe/main.mbt" -o "./target/wasm-gc/debug/build/main exe/main exe.core" -pkg "username/hello/main exe" -is-main -i "./target/wasm-gc/debug/build/main lib/main lib.mi:lib" -pkg-sources "username/hello/main exe:./main exe" -target wasm-gc -g -source-map + moonc link-core "./target/wasm-gc/debug/build/main lib/main lib.core" "./target/wasm-gc/debug/build/main exe/main exe.core" -main "username/hello/main exe" -o "./target/wasm-gc/debug/build/main exe/main exe.wasm" -pkg-sources "username/hello/main lib:./main lib" -pkg-sources "username/hello/main exe:./main exe" -target wasm-gc -g -source-map + "#]], + ); + + check( + &get_stdout_with_args( + &dir, + [ + "run", + "main exe", + "--target", + "wasm-gc", + "--dry-run", + "--nostd", + ], + ), + expect![[r#" + moonc build-package "./main lib/hello.mbt" -o "./target/wasm-gc/release/build/main lib/main lib.core" -pkg "username/hello/main lib" -pkg-sources "username/hello/main lib:./main lib" -target wasm-gc + moonc build-package "./main exe/main.mbt" -o "./target/wasm-gc/release/build/main exe/main exe.core" -pkg "username/hello/main exe" -is-main -i "./target/wasm-gc/release/build/main lib/main lib.mi:lib" -pkg-sources "username/hello/main exe:./main exe" -target wasm-gc + moonc link-core "./target/wasm-gc/release/build/main lib/main lib.core" "./target/wasm-gc/release/build/main exe/main exe.core" -main "username/hello/main exe" -o "./target/wasm-gc/release/build/main exe/main exe.wasm" -pkg-sources "username/hello/main lib:./main lib" -pkg-sources "username/hello/main exe:./main exe" -target wasm-gc + moonrun ./target/wasm-gc/release/build/main exe/main exe.wasm + "#]], + ); + + check( + &get_stdout_with_args( + &dir, + [ + "run", + "main exe", + "--target", + "wasm-gc", + "--dry-run", + "--debug", + "--nostd", + ], + ), + expect![[r#" + moonc build-package "./main lib/hello.mbt" -o "./target/wasm-gc/debug/build/main lib/main lib.core" -pkg "username/hello/main lib" -pkg-sources "username/hello/main lib:./main lib" -target wasm-gc -g -source-map + moonc build-package "./main exe/main.mbt" -o "./target/wasm-gc/debug/build/main exe/main exe.core" -pkg "username/hello/main exe" -is-main -i "./target/wasm-gc/debug/build/main lib/main lib.mi:lib" -pkg-sources "username/hello/main exe:./main exe" -target wasm-gc -g -source-map + moonc link-core "./target/wasm-gc/debug/build/main lib/main lib.core" "./target/wasm-gc/debug/build/main exe/main exe.core" -main "username/hello/main exe" -o "./target/wasm-gc/debug/build/main exe/main exe.wasm" -pkg-sources "username/hello/main lib:./main lib" -pkg-sources "username/hello/main exe:./main exe" -target wasm-gc -g -source-map + moonrun ./target/wasm-gc/debug/build/main exe/main exe.wasm + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["run", "main exe"]), + expect![[r#" + Hello, world! + "#]], + ); + + let out = get_stdout_with_args(&dir, ["check"]); + assert!(out.contains("moon: ran 3 tasks, now up to date")); +} + +#[test] +fn test_whitespace_parent_space() -> anyhow::Result<()> { + let tmp_dir = tempfile::TempDir::new()?; + let path_with_space = tmp_dir.path().join("with space"); + std::fs::create_dir_all(&path_with_space)?; + let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("tests/test_cases") + .join("whitespace_test.in"); + copy(&dir, &path_with_space)?; + + let canon = dunce::canonicalize(tmp_dir.path())?; + let prefix = canon.as_path().display().to_string().replace('\\', "/"); + + let out = get_stdout_with_args( + &path_with_space, + ["build", "--no-render", "--sort-input", "--dry-run"], + ); + let out = out.replace(&prefix, "."); + let out = out.replace( + &moonutil::moon_dir::home() + .to_str() + .unwrap() + .replace('\\', "/"), + "$MOON_HOME", + ); + + copy(&dir, &path_with_space)?; + check( + &out, + expect![[r#" + moonc build-package "./main lib/hello.mbt" -o "./target/wasm-gc/release/build/main lib/main lib.core" -pkg "username/hello/main lib" -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources "username/hello/main lib:./main lib" -target wasm-gc + moonc build-package "./main exe/main.mbt" -o "./target/wasm-gc/release/build/main exe/main exe.core" -pkg "username/hello/main exe" -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -i "./target/wasm-gc/release/build/main lib/main lib.mi:lib" -pkg-sources "username/hello/main exe:./main exe" -target wasm-gc + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core "./target/wasm-gc/release/build/main lib/main lib.core" "./target/wasm-gc/release/build/main exe/main exe.core" -main "username/hello/main exe" -o "./target/wasm-gc/release/build/main exe/main exe.wasm" -pkg-sources "username/hello/main lib:./main lib" -pkg-sources "username/hello/main exe:./main exe" -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc + "#]], + ); + + let out = get_stdout_with_args(&path_with_space, ["build", "--no-render"]); + let out = out.replace(&prefix, "."); + let out = out.replace( + &moonutil::moon_dir::home() + .to_str() + .unwrap() + .replace('\\', "/"), + "$MOON_HOME", + ); + + copy(&dir, &path_with_space)?; + check( + &out, + expect![[r#" + Finished. moon: ran 3 tasks, now up to date + "#]], + ); + Ok(()) +} + +#[test] +fn circle_pkg_test() { + let dir = TestDir::new("circle_pkg_AB_001_test.in"); + let stderr = get_stderr_with_args(&dir, ["run", "main", "--nostd"]); + assert!(stderr.contains("cyclic dependency"), "stderr: {}", stderr); +} + +#[test] +fn debug_flag_test() { + let dir = TestDir::new("debug_flag_test.in"); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["clean"]) + .assert() + .success(); + + check( + &get_stdout_with_args(&dir, ["check", "--dry-run", "--nostd"]), + expect![[r#" + moonc check ./lib/hello.mbt -o ./target/wasm-gc/release/check/lib/lib.mi -pkg hello/lib -pkg-sources hello/lib:./lib -target wasm-gc + moonc check ./main/main.mbt -o ./target/wasm-gc/release/check/main/main.mi -pkg hello/main -is-main -i ./target/wasm-gc/release/check/lib/lib.mi:lib -pkg-sources hello/main:./main -target wasm-gc + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["build", "--dry-run", "--nostd"]), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/release/build/lib/lib.core -pkg hello/lib -pkg-sources hello/lib:./lib -target wasm-gc + moonc build-package ./main/main.mbt -o ./target/wasm-gc/release/build/main/main.core -pkg hello/main -is-main -i ./target/wasm-gc/release/build/lib/lib.mi:lib -pkg-sources hello/main:./main -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/lib/lib.core ./target/wasm-gc/release/build/main/main.core -main hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources hello/lib:./lib -pkg-sources hello/main:./main -target wasm-gc + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["build", "--dry-run", "--debug", "--nostd"]), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/debug/build/lib/lib.core -pkg hello/lib -pkg-sources hello/lib:./lib -target wasm-gc -g -source-map + moonc build-package ./main/main.mbt -o ./target/wasm-gc/debug/build/main/main.core -pkg hello/main -is-main -i ./target/wasm-gc/debug/build/lib/lib.mi:lib -pkg-sources hello/main:./main -target wasm-gc -g -source-map + moonc link-core ./target/wasm-gc/debug/build/lib/lib.core ./target/wasm-gc/debug/build/main/main.core -main hello/main -o ./target/wasm-gc/debug/build/main/main.wasm -pkg-sources hello/lib:./lib -pkg-sources hello/main:./main -target wasm-gc -g -source-map + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["run", "main", "--dry-run", "--nostd"]), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/release/build/lib/lib.core -pkg hello/lib -pkg-sources hello/lib:./lib -target wasm-gc + moonc build-package ./main/main.mbt -o ./target/wasm-gc/release/build/main/main.core -pkg hello/main -is-main -i ./target/wasm-gc/release/build/lib/lib.mi:lib -pkg-sources hello/main:./main -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/lib/lib.core ./target/wasm-gc/release/build/main/main.core -main hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources hello/lib:./lib -pkg-sources hello/main:./main -target wasm-gc + moonrun ./target/wasm-gc/release/build/main/main.wasm + "#]], + ); + + check( + &get_stdout_with_args(&dir, ["run", "main", "--dry-run", "--debug", "--nostd"]), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/debug/build/lib/lib.core -pkg hello/lib -pkg-sources hello/lib:./lib -target wasm-gc -g -source-map + moonc build-package ./main/main.mbt -o ./target/wasm-gc/debug/build/main/main.core -pkg hello/main -is-main -i ./target/wasm-gc/debug/build/lib/lib.mi:lib -pkg-sources hello/main:./main -target wasm-gc -g -source-map + moonc link-core ./target/wasm-gc/debug/build/lib/lib.core ./target/wasm-gc/debug/build/main/main.core -main hello/main -o ./target/wasm-gc/debug/build/main/main.wasm -pkg-sources hello/lib:./lib -pkg-sources hello/main:./main -target wasm-gc -g -source-map + moonrun ./target/wasm-gc/debug/build/main/main.wasm + "#]], + ); + check( + &get_stdout_with_args( + &dir, + ["build", "--target", "wasm-gc", "--dry-run", "--nostd"], + ), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/release/build/lib/lib.core -pkg hello/lib -pkg-sources hello/lib:./lib -target wasm-gc + moonc build-package ./main/main.mbt -o ./target/wasm-gc/release/build/main/main.core -pkg hello/main -is-main -i ./target/wasm-gc/release/build/lib/lib.mi:lib -pkg-sources hello/main:./main -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/lib/lib.core ./target/wasm-gc/release/build/main/main.core -main hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources hello/lib:./lib -pkg-sources hello/main:./main -target wasm-gc + "#]], + ); + check( + &get_stdout_with_args( + &dir, + [ + "build", + "--dry-run", + "--target", + "wasm-gc", + "--debug", + "--nostd", + ], + ), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/debug/build/lib/lib.core -pkg hello/lib -pkg-sources hello/lib:./lib -target wasm-gc -g -source-map + moonc build-package ./main/main.mbt -o ./target/wasm-gc/debug/build/main/main.core -pkg hello/main -is-main -i ./target/wasm-gc/debug/build/lib/lib.mi:lib -pkg-sources hello/main:./main -target wasm-gc -g -source-map + moonc link-core ./target/wasm-gc/debug/build/lib/lib.core ./target/wasm-gc/debug/build/main/main.core -main hello/main -o ./target/wasm-gc/debug/build/main/main.wasm -pkg-sources hello/lib:./lib -pkg-sources hello/main:./main -target wasm-gc -g -source-map + "#]], + ); + + check( + &get_stdout_with_args( + &dir, + ["run", "main", "--target", "wasm-gc", "--dry-run", "--nostd"], + ), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/release/build/lib/lib.core -pkg hello/lib -pkg-sources hello/lib:./lib -target wasm-gc + moonc build-package ./main/main.mbt -o ./target/wasm-gc/release/build/main/main.core -pkg hello/main -is-main -i ./target/wasm-gc/release/build/lib/lib.mi:lib -pkg-sources hello/main:./main -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/lib/lib.core ./target/wasm-gc/release/build/main/main.core -main hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources hello/lib:./lib -pkg-sources hello/main:./main -target wasm-gc + moonrun ./target/wasm-gc/release/build/main/main.wasm + "#]], + ); + + check( + &get_stdout_with_args( + &dir, + [ + "run", + "main", + "--target", + "wasm-gc", + "--dry-run", + "--debug", + "--nostd", + ], + ), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/debug/build/lib/lib.core -pkg hello/lib -pkg-sources hello/lib:./lib -target wasm-gc -g -source-map + moonc build-package ./main/main.mbt -o ./target/wasm-gc/debug/build/main/main.core -pkg hello/main -is-main -i ./target/wasm-gc/debug/build/lib/lib.mi:lib -pkg-sources hello/main:./main -target wasm-gc -g -source-map + moonc link-core ./target/wasm-gc/debug/build/lib/lib.core ./target/wasm-gc/debug/build/main/main.core -main hello/main -o ./target/wasm-gc/debug/build/main/main.wasm -pkg-sources hello/lib:./lib -pkg-sources hello/main:./main -target wasm-gc -g -source-map + moonrun ./target/wasm-gc/debug/build/main/main.wasm + "#]], + ); +} + +#[test] +fn test_check_failed_should_write_pkg_json() { + let dir = TestDir::new("check_failed_should_write_pkg_json.in"); + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["check"]) + .assert() + .failure(); + + let pkg_json = dir.join("target/wasm-gc/release/check/packages.json"); + assert!(pkg_json.exists()); +} + +#[test] +fn test_render_no_location() { + std::env::set_var("NO_COLOR", "1"); + let dir = TestDir::new("render_no_location.in"); + + let output = snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .arg("check") + .assert() + .failure() + .get_output() + .stdout + .to_owned(); + + let output = String::from_utf8_lossy(&output); + assert!(output.contains("[4067] Error: Missing main function in the main package.")); +} + +#[test] +fn test_moon_run_with_cli_args() { + let dir = TestDir::new("moo_run_with_cli_args.in"); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["run", "main", "--dry-run"]), + expect![[r#" + moonc build-package ./main/main.mbt -o ./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 -pkg-sources username/hello/main:./main -target wasm-gc + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/release/build/main/main.core -main username/hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources username/hello/main:./main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc + moonrun ./target/wasm-gc/release/build/main/main.wasm + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + [ + "run", + "main", + "--dry-run", + "--", + "中文", + "😄👍", + "hello", + "1242", + ], + ), + expect![[r#" + moonc build-package ./main/main.mbt -o ./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 -pkg-sources username/hello/main:./main -target wasm-gc + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/release/build/main/main.core -main username/hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources username/hello/main:./main -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc + moonrun ./target/wasm-gc/release/build/main/main.wasm -- 中文 😄👍 hello 1242 + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + ["run", "main", "--", "中文", "😄👍", "hello", "1242"], + ), + expect![[r#" + ["中文", "😄👍", "hello", "1242"] + "#]], + ); +} + +#[test] +fn test_third_party() { + if std::env::var("CI").is_err() { + return; + } + let dir = TestDir::new("third_party.in"); + get_stdout_with_args_and_replace_dir(&dir, ["update"]); + get_stdout_with_args_and_replace_dir(&dir, ["build"]); + get_stdout_with_args_and_replace_dir(&dir, ["clean"]); + + let actual = &get_stdout_with_args_and_replace_dir(&dir, ["check"]); + assert!(actual.contains("moon: ran 4 tasks, now up to date")); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["test", "--dry-run", "--sort-input"]), + expect![[r#" + moon generate-test-driver --source-dir . --target-dir ./target/wasm-gc/debug/test --sort-input --target wasm-gc + moonc build-package ./.mooncakes/lijunchen/hello18/lib/hello.mbt -o ./target/wasm-gc/debug/test/.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:./.mooncakes/lijunchen/hello18/lib -target wasm-gc -g + moonc build-package ./lib/test.mbt ./target/wasm-gc/debug/test/lib/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/lib/lib.internal_test.core -pkg username/hello/lib -is-main -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -i ./target/wasm-gc/debug/test/.mooncakes/lijunchen/hello18/lib/lib.mi:lib -pkg-sources username/hello/lib:./lib -target wasm-gc -g + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core ./target/wasm-gc/debug/test/.mooncakes/lijunchen/hello18/lib/lib.core ./target/wasm-gc/debug/test/lib/lib.internal_test.core -main username/hello/lib -o ./target/wasm-gc/debug/test/lib/lib.internal_test.wasm -test-mode -pkg-sources lijunchen/hello18/lib:./lib -pkg-sources username/hello/lib:./lib -pkg-sources moonbitlang/core:$MOON_HOME/lib/core -target wasm-gc -g + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["test", "--sort-input"]), + expect![[r#" + Hello, world! + Hello, world! + Total tests: 2, passed: 2, failed: 0. + "#]], + ); + + let actual = &get_stdout_with_args_and_replace_dir(&dir, ["build"]); + assert!(actual.contains("moon: ran 5 tasks, now up to date")); + + let actual = &get_stdout_with_args_and_replace_dir(&dir, ["run", "main"]); + assert!(actual.contains("Hello, world!")); +} + +#[test] +fn test_blackbox_success() { + let dir = TestDir::new("blackbox_success_test.in"); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + [ + "test", + "-p", + "username/hello/A", + "-f", + "hello_test.mbt", + "-i", + "0", + "--nostd", + "--sort-input", + "--dry-run", + ], + ), + expect![[r#" + moonc build-package ./D/hello.mbt -o ./target/wasm-gc/debug/test/D/D.core -pkg username/hello/D -pkg-sources username/hello/D:./D -target wasm-gc -g + moon generate-test-driver --source-dir . --target-dir ./target/wasm-gc/debug/test --package username/hello/A --file hello_test.mbt --index 0 --sort-input --target wasm-gc + moonc build-package ./A/hello.mbt -o ./target/wasm-gc/debug/test/A/A.core -pkg username/hello/A -i ./target/wasm-gc/debug/test/D/D.mi:D -pkg-sources username/hello/A:./A -target wasm-gc -g + moonc build-package ./C/hello.mbt -o ./target/wasm-gc/debug/test/C/C.core -pkg username/hello/C -pkg-sources username/hello/C:./C -target wasm-gc -g + moonc build-package ./A/hello_test.mbt ./target/wasm-gc/debug/test/A/__generated_driver_for_blackbox_test.mbt -o ./target/wasm-gc/debug/test/A/A.blackbox_test.core -pkg username/hello/A_blackbox_test -is-main -i ./target/wasm-gc/debug/test/A/A.mi:A -i ./target/wasm-gc/debug/test/D/D.mi:D -i ./target/wasm-gc/debug/test/C/C.mi:C -pkg-sources username/hello/A_blackbox_test:./A -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/D/D.core ./target/wasm-gc/debug/test/C/C.core ./target/wasm-gc/debug/test/A/A.core ./target/wasm-gc/debug/test/A/A.blackbox_test.core -main username/hello/A -o ./target/wasm-gc/debug/test/A/A.blackbox_test.wasm -test-mode -pkg-sources username/hello/D:./D -pkg-sources username/hello/C:./C -pkg-sources username/hello/A:./A -target wasm-gc -g + moonc build-package ./B/hello.mbt -o ./target/wasm-gc/debug/test/B/B.core -pkg username/hello/B -pkg-sources username/hello/B:./B -target wasm-gc -g + moonc build-package ./A/hello.mbt ./A/hello_wbtest.mbt ./target/wasm-gc/debug/test/A/__generated_driver_for_underscore_test.mbt -o ./target/wasm-gc/debug/test/A/A.underscore_test.core -pkg username/hello/A -is-main -i ./target/wasm-gc/debug/test/D/D.mi:D -i ./target/wasm-gc/debug/test/B/B.mi:B -pkg-sources username/hello/A:./A -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/D/D.core ./target/wasm-gc/debug/test/B/B.core ./target/wasm-gc/debug/test/A/A.underscore_test.core -main username/hello/A -o ./target/wasm-gc/debug/test/A/A.underscore_test.wasm -test-mode -pkg-sources username/hello/D:./D -pkg-sources username/hello/B:./B -pkg-sources username/hello/A:./A -target wasm-gc -g + moonc build-package ./A/hello.mbt ./target/wasm-gc/debug/test/A/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/A/A.internal_test.core -pkg username/hello/A -is-main -i ./target/wasm-gc/debug/test/D/D.mi:D -pkg-sources username/hello/A:./A -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/D/D.core ./target/wasm-gc/debug/test/A/A.internal_test.core -main username/hello/A -o ./target/wasm-gc/debug/test/A/A.internal_test.wasm -test-mode -pkg-sources username/hello/D:./D -pkg-sources username/hello/A:./A -target wasm-gc -g + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + [ + "test", + "-p", + "username/hello/A", + "-f", + "hello_test.mbt", + "-i", + "0", + ], + ), + expect![[r#" + output from A/hello.mbt! + output from C/hello.mbt! + output from D/hello.mbt! + Total tests: 1, passed: 1, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["test"]), + expect![[r#" + output from A/hello.mbt! + output from C/hello.mbt! + output from D/hello.mbt! + self.a: 33 + Total tests: 2, passed: 2, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir(&dir, ["check", "--sort-input", "--dry-run"]), + expect![[r#" + moonc check ./main/main.mbt -o ./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 -pkg-sources username/hello/main:./main -target wasm-gc + moonc check ./D/hello.mbt -o ./target/wasm-gc/release/check/D/D.mi -pkg username/hello/D -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/D:./D -target wasm-gc + moonc check ./A/hello.mbt -o ./target/wasm-gc/release/check/A/A.mi -pkg username/hello/A -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -i ./target/wasm-gc/release/check/D/D.mi:D -pkg-sources username/hello/A:./A -target wasm-gc + moonc check ./C/hello.mbt -o ./target/wasm-gc/release/check/C/C.mi -pkg username/hello/C -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/C:./C -target wasm-gc + moonc check ./A/hello_test.mbt -o ./target/wasm-gc/release/check/A/A.blackbox_test.mi -pkg username/hello/A_blackbox_test -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -i ./target/wasm-gc/release/check/A/A.mi:A -i ./target/wasm-gc/release/check/D/D.mi:D -i ./target/wasm-gc/release/check/C/C.mi:C -pkg-sources username/hello/A_blackbox_test:./A -target wasm-gc + moonc check ./B/hello.mbt -o ./target/wasm-gc/release/check/B/B.mi -pkg username/hello/B -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -pkg-sources username/hello/B:./B -target wasm-gc + moonc check ./A/hello.mbt ./A/hello_wbtest.mbt -o ./target/wasm-gc/release/check/A/A.underscore_test.mi -pkg username/hello/A -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -i ./target/wasm-gc/release/check/D/D.mi:D -i ./target/wasm-gc/release/check/B/B.mi:B -pkg-sources username/hello/A:./A -target wasm-gc + "#]], + ); + + snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["check", "--sort-input"]) + .assert() + .success(); + + #[cfg(unix)] + { + let p = dir.join(format!( + "target/{}/release/check/packages.json", + TargetBackend::default().to_backend_ext() + )); + check( + &replace_dir(&std::fs::read_to_string(p).unwrap(), &dir), + expect![[r#" + { + "source_dir": "$ROOT", + "name": "username/hello", + "packages": [ + { + "is-main": false, + "is-third-party": false, + "root": "username/hello", + "rel": "A", + "files": [ + "$ROOT/A/hello.mbt" + ], + "wbtest-files": [ + "$ROOT/A/hello_wbtest.mbt" + ], + "test-files": [ + "$ROOT/A/hello_test.mbt" + ], + "deps": [ + { + "path": "username/hello/D", + "alias": "D" + } + ], + "wbtest-deps": [ + { + "path": "username/hello/B", + "alias": "B" + } + ], + "test-deps": [ + { + "path": "username/hello/C", + "alias": "C" + } + ], + "artifact": "$ROOT/target/wasm-gc/release/check/A/A.mi" + }, + { + "is-main": false, + "is-third-party": false, + "root": "username/hello", + "rel": "B", + "files": [ + "$ROOT/B/hello.mbt" + ], + "wbtest-files": [], + "test-files": [], + "deps": [], + "wbtest-deps": [], + "test-deps": [], + "artifact": "$ROOT/target/wasm-gc/release/check/B/B.mi" + }, + { + "is-main": false, + "is-third-party": false, + "root": "username/hello", + "rel": "C", + "files": [ + "$ROOT/C/hello.mbt" + ], + "wbtest-files": [], + "test-files": [], + "deps": [], + "wbtest-deps": [], + "test-deps": [], + "artifact": "$ROOT/target/wasm-gc/release/check/C/C.mi" + }, + { + "is-main": false, + "is-third-party": false, + "root": "username/hello", + "rel": "D", + "files": [ + "$ROOT/D/hello.mbt" + ], + "wbtest-files": [], + "test-files": [], + "deps": [], + "wbtest-deps": [], + "test-deps": [], + "artifact": "$ROOT/target/wasm-gc/release/check/D/D.mi" + }, + { + "is-main": true, + "is-third-party": false, + "root": "username/hello", + "rel": "main", + "files": [ + "$ROOT/main/main.mbt" + ], + "wbtest-files": [], + "test-files": [], + "deps": [], + "wbtest-deps": [], + "test-deps": [], + "artifact": "$ROOT/target/wasm-gc/release/check/main/main.mi" + } + ], + "deps": [], + "backend": "wasm-gc" + }"#]], + ); + } +} + +#[test] +fn test_blackbox_failed() { + let dir = TestDir::new("blackbox_failed_test.in"); + + let output = snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .arg("test") + .assert() + .failure() + .get_output() + .stdout + .to_owned(); + + let output = String::from_utf8_lossy(&output); + // bbtest can not use private function in bbtest_import + assert!(output.contains("Value _private_hello not found in package \"A\"")); + // bbtest_import could no be used in _wbtest.mbt + assert!(output.contains("Package \"C\" not found in the loaded packages.")); + + let output = snapbox::cmd::Command::new(moon_bin()) + .current_dir(&dir) + .args(["check"]) + .assert() + .failure() + .get_output() + .stdout + .to_owned(); + + let output = String::from_utf8_lossy(&output); + assert!(output.contains("Warning: Unused variable 'a'")); + assert!(output.contains("Error: Error (warning): The mutability of 'b' is never used")); + assert!(output.contains("Value _private_hello not found in package \"A\"")); + assert!(output.contains("Package \"C\" not found in the loaded packages.")); +} + +#[test] +fn test_import_memory_and_heap_start() { + let dir = TestDir::new("import_memory.in"); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + [ + "build", + "--target", + "wasm", + "--dry-run", + "--sort-input", + "--nostd", + ], + ), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm/release/build/lib/lib.core -pkg username/hello/lib -pkg-sources username/hello/lib:./lib -target wasm + moonc build-package ./main/main.mbt -o ./target/wasm/release/build/main/main.core -pkg username/hello/main -is-main -i ./target/wasm/release/build/lib/lib.mi:lib -pkg-sources username/hello/main:./main -target wasm + moonc link-core ./target/wasm/release/build/lib/lib.core ./target/wasm/release/build/main/main.core -main username/hello/main -o ./target/wasm/release/build/main/main.wasm -pkg-sources username/hello/lib:./lib -pkg-sources username/hello/main:./main -target wasm -import-memory-module xxx -import-memory-name yyy -heap-start-address 65536 + "#]], + ); + + let dir = TestDir::new("import_memory.in"); + check( + &get_stdout_with_args_and_replace_dir( + &dir, + [ + "build", + "--target", + "wasm-gc", + "--dry-run", + "--sort-input", + "--nostd", + ], + ), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm-gc/release/build/lib/lib.core -pkg username/hello/lib -pkg-sources username/hello/lib:./lib -target wasm-gc + moonc build-package ./main/main.mbt -o ./target/wasm-gc/release/build/main/main.core -pkg username/hello/main -is-main -i ./target/wasm-gc/release/build/lib/lib.mi:lib -pkg-sources username/hello/main:./main -target wasm-gc + moonc link-core ./target/wasm-gc/release/build/lib/lib.core ./target/wasm-gc/release/build/main/main.core -main username/hello/main -o ./target/wasm-gc/release/build/main/main.wasm -pkg-sources username/hello/lib:./lib -pkg-sources username/hello/main:./main -target wasm-gc -import-memory-module xxx -import-memory-name yyy + "#]], + ); +} + +#[test] +fn test_many_targets() { + let dir = TestDir::new("test_many_targets.in"); + check( + &get_stdout_with_args_and_replace_dir(&dir, ["test", "--target", "all"]), + expect![[r#" + Total tests: 0, passed: 0, failed: 0. + Total tests: 0, passed: 0, failed: 0. + Total tests: 0, passed: 0, failed: 0. + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + [ + "check", + "--target", + "js,wasm", + "--dry-run", + "--serial", + "--nostd", + "--sort-input", + ], + ), + expect![[r#" + moonc check ./link/hello.mbt -o ./target/wasm/release/check/link/link.mi -pkg username/hello/link -pkg-sources username/hello/link:./link -target wasm + moonc check ./lib/hello.mbt -o ./target/wasm/release/check/lib/lib.mi -pkg username/hello/lib -pkg-sources username/hello/lib:./lib -target wasm + moonc check ./link/hello.mbt -o ./target/js/release/check/link/link.mi -pkg username/hello/link -pkg-sources username/hello/link:./link -target js + moonc check ./lib/hello.mbt -o ./target/js/release/check/lib/lib.mi -pkg username/hello/lib -pkg-sources username/hello/lib:./lib -target js + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + [ + "build", + "--target", + "js,wasm", + "--dry-run", + "--serial", + "--nostd", + "--sort-input", + ], + ), + expect![[r#" + moonc build-package ./link/hello.mbt -o ./target/wasm/release/build/link/link.core -pkg username/hello/link -pkg-sources username/hello/link:./link -target wasm + moonc link-core ./target/wasm/release/build/link/link.core -main username/hello/link -o ./target/wasm/release/build/link/link.wasm -pkg-sources username/hello/link:./link -target wasm + moonc build-package ./link/hello.mbt -o ./target/js/release/build/link/link.core -pkg username/hello/link -pkg-sources username/hello/link:./link -target js + moonc link-core ./target/js/release/build/link/link.core -main username/hello/link -o ./target/js/release/build/link/link.js -pkg-sources username/hello/link:./link -target js + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + [ + "bundle", + "--target", + "js,wasm", + "--dry-run", + "--serial", + "--nostd", + "--sort-input", + ], + ), + expect![[r#" + moonc build-package ./lib/hello.mbt -o ./target/wasm/release/bundle/lib/lib.core -pkg username/hello/lib -pkg-sources username/hello/lib:./lib -target wasm + moonc build-package ./link/hello.mbt -o ./target/wasm/release/bundle/link/link.core -pkg username/hello/link -pkg-sources username/hello/link:./link -target wasm + moonc bundle-core ./target/wasm/release/bundle/lib/lib.core ./target/wasm/release/bundle/link/link.core -o ./target/wasm/release/bundle/hello.core + moonc build-package ./lib/hello.mbt -o ./target/js/release/bundle/lib/lib.core -pkg username/hello/lib -pkg-sources username/hello/lib:./lib -target js + moonc build-package ./link/hello.mbt -o ./target/js/release/bundle/link/link.core -pkg username/hello/link -pkg-sources username/hello/link:./link -target js + moonc bundle-core ./target/js/release/bundle/lib/lib.core ./target/js/release/bundle/link/link.core -o ./target/js/release/bundle/hello.core + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + [ + "test", + "--target", + "js,wasm", + "--dry-run", + "--serial", + "--nostd", + "--sort-input", + ], + ), + expect![[r#" + moon generate-test-driver --source-dir . --target-dir ./target/wasm/debug/test --sort-input --target wasm + moonc build-package ./link/hello.mbt ./target/wasm/debug/test/link/__generated_driver_for_internal_test.mbt -o ./target/wasm/debug/test/link/link.internal_test.core -pkg username/hello/link -is-main -pkg-sources username/hello/link:./link -target wasm -g + moonc link-core ./target/wasm/debug/test/link/link.internal_test.core -main username/hello/link -o ./target/wasm/debug/test/link/link.internal_test.wasm -test-mode -pkg-sources username/hello/link:./link -target wasm -g + moonc build-package ./lib/hello.mbt ./target/wasm/debug/test/lib/__generated_driver_for_internal_test.mbt -o ./target/wasm/debug/test/lib/lib.internal_test.core -pkg username/hello/lib -is-main -pkg-sources username/hello/lib:./lib -target wasm -g + moonc link-core ./target/wasm/debug/test/lib/lib.internal_test.core -main username/hello/lib -o ./target/wasm/debug/test/lib/lib.internal_test.wasm -test-mode -pkg-sources username/hello/lib:./lib -target wasm -g + moon generate-test-driver --source-dir . --target-dir ./target/js/debug/test --sort-input --target js + moonc build-package ./link/hello.mbt ./target/js/debug/test/link/__generated_driver_for_internal_test.mbt -o ./target/js/debug/test/link/link.internal_test.core -pkg username/hello/link -is-main -pkg-sources username/hello/link:./link -target js -g -ryu + moonc link-core ./target/js/debug/test/link/link.internal_test.core -main username/hello/link -o ./target/js/debug/test/link/link.internal_test.js -test-mode -pkg-sources username/hello/link:./link -target js -g -ryu + moonc build-package ./lib/hello.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:./lib -target js -g -ryu + 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:./lib -target js -g -ryu + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + [ + "test", + "--target", + "js,wasm", + "--dry-run", + "--serial", + "--nostd", + "--sort-input", + "-p", + "username/hello/lib", + "-f", + "hello.mbt", + "-i", + "0", + ], + ), + expect![[r#" + moon generate-test-driver --source-dir . --target-dir ./target/wasm/debug/test --package username/hello/lib --file hello.mbt --index 0 --sort-input --target wasm + moonc build-package ./lib/hello.mbt ./target/wasm/debug/test/lib/__generated_driver_for_internal_test.mbt -o ./target/wasm/debug/test/lib/lib.internal_test.core -pkg username/hello/lib -is-main -pkg-sources username/hello/lib:./lib -target wasm -g + moonc link-core ./target/wasm/debug/test/lib/lib.internal_test.core -main username/hello/lib -o ./target/wasm/debug/test/lib/lib.internal_test.wasm -test-mode -pkg-sources username/hello/lib:./lib -target wasm -g + moon generate-test-driver --source-dir . --target-dir ./target/js/debug/test --package username/hello/lib --file hello.mbt --index 0 --sort-input --target js + moonc build-package ./lib/hello.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:./lib -target js -g -ryu + 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:./lib -target js -g -ryu + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + [ + "test", + "--target", + "js,wasm,all", + "--dry-run", + "--serial", + "--nostd", + "--sort-input", + ], + ), + expect![[r#" + moon generate-test-driver --source-dir . --target-dir ./target/wasm/debug/test --sort-input --target wasm + moonc build-package ./link/hello.mbt ./target/wasm/debug/test/link/__generated_driver_for_internal_test.mbt -o ./target/wasm/debug/test/link/link.internal_test.core -pkg username/hello/link -is-main -pkg-sources username/hello/link:./link -target wasm -g + moonc link-core ./target/wasm/debug/test/link/link.internal_test.core -main username/hello/link -o ./target/wasm/debug/test/link/link.internal_test.wasm -test-mode -pkg-sources username/hello/link:./link -target wasm -g + moonc build-package ./lib/hello.mbt ./target/wasm/debug/test/lib/__generated_driver_for_internal_test.mbt -o ./target/wasm/debug/test/lib/lib.internal_test.core -pkg username/hello/lib -is-main -pkg-sources username/hello/lib:./lib -target wasm -g + moonc link-core ./target/wasm/debug/test/lib/lib.internal_test.core -main username/hello/lib -o ./target/wasm/debug/test/lib/lib.internal_test.wasm -test-mode -pkg-sources username/hello/lib:./lib -target wasm -g + moon generate-test-driver --source-dir . --target-dir ./target/wasm-gc/debug/test --sort-input --target wasm-gc + moonc build-package ./link/hello.mbt ./target/wasm-gc/debug/test/link/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/link/link.internal_test.core -pkg username/hello/link -is-main -pkg-sources username/hello/link:./link -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/link/link.internal_test.core -main username/hello/link -o ./target/wasm-gc/debug/test/link/link.internal_test.wasm -test-mode -pkg-sources username/hello/link:./link -target wasm-gc -g + moonc build-package ./lib/hello.mbt ./target/wasm-gc/debug/test/lib/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/lib/lib.internal_test.core -pkg username/hello/lib -is-main -pkg-sources username/hello/lib:./lib -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/lib/lib.internal_test.core -main username/hello/lib -o ./target/wasm-gc/debug/test/lib/lib.internal_test.wasm -test-mode -pkg-sources username/hello/lib:./lib -target wasm-gc -g + moon generate-test-driver --source-dir . --target-dir ./target/js/debug/test --sort-input --target js + moonc build-package ./link/hello.mbt ./target/js/debug/test/link/__generated_driver_for_internal_test.mbt -o ./target/js/debug/test/link/link.internal_test.core -pkg username/hello/link -is-main -pkg-sources username/hello/link:./link -target js -g -ryu + moonc link-core ./target/js/debug/test/link/link.internal_test.core -main username/hello/link -o ./target/js/debug/test/link/link.internal_test.js -test-mode -pkg-sources username/hello/link:./link -target js -g -ryu + moonc build-package ./lib/hello.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:./lib -target js -g -ryu + 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:./lib -target js -g -ryu + "#]], + ); + + check( + &get_stdout_with_args_and_replace_dir( + &dir, + [ + "test", + "--target", + "all", + "--dry-run", + "--serial", + "--nostd", + "--sort-input", + ], + ), + expect![[r#" + moon generate-test-driver --source-dir . --target-dir ./target/wasm/debug/test --sort-input --target wasm + moonc build-package ./link/hello.mbt ./target/wasm/debug/test/link/__generated_driver_for_internal_test.mbt -o ./target/wasm/debug/test/link/link.internal_test.core -pkg username/hello/link -is-main -pkg-sources username/hello/link:./link -target wasm -g + moonc link-core ./target/wasm/debug/test/link/link.internal_test.core -main username/hello/link -o ./target/wasm/debug/test/link/link.internal_test.wasm -test-mode -pkg-sources username/hello/link:./link -target wasm -g + moonc build-package ./lib/hello.mbt ./target/wasm/debug/test/lib/__generated_driver_for_internal_test.mbt -o ./target/wasm/debug/test/lib/lib.internal_test.core -pkg username/hello/lib -is-main -pkg-sources username/hello/lib:./lib -target wasm -g + moonc link-core ./target/wasm/debug/test/lib/lib.internal_test.core -main username/hello/lib -o ./target/wasm/debug/test/lib/lib.internal_test.wasm -test-mode -pkg-sources username/hello/lib:./lib -target wasm -g + moon generate-test-driver --source-dir . --target-dir ./target/wasm-gc/debug/test --sort-input --target wasm-gc + moonc build-package ./link/hello.mbt ./target/wasm-gc/debug/test/link/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/link/link.internal_test.core -pkg username/hello/link -is-main -pkg-sources username/hello/link:./link -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/link/link.internal_test.core -main username/hello/link -o ./target/wasm-gc/debug/test/link/link.internal_test.wasm -test-mode -pkg-sources username/hello/link:./link -target wasm-gc -g + moonc build-package ./lib/hello.mbt ./target/wasm-gc/debug/test/lib/__generated_driver_for_internal_test.mbt -o ./target/wasm-gc/debug/test/lib/lib.internal_test.core -pkg username/hello/lib -is-main -pkg-sources username/hello/lib:./lib -target wasm-gc -g + moonc link-core ./target/wasm-gc/debug/test/lib/lib.internal_test.core -main username/hello/lib -o ./target/wasm-gc/debug/test/lib/lib.internal_test.wasm -test-mode -pkg-sources username/hello/lib:./lib -target wasm-gc -g + moon generate-test-driver --source-dir . --target-dir ./target/js/debug/test --sort-input --target js + moonc build-package ./link/hello.mbt ./target/js/debug/test/link/__generated_driver_for_internal_test.mbt -o ./target/js/debug/test/link/link.internal_test.core -pkg username/hello/link -is-main -pkg-sources username/hello/link:./link -target js -g -ryu + moonc link-core ./target/js/debug/test/link/link.internal_test.core -main username/hello/link -o ./target/js/debug/test/link/link.internal_test.js -test-mode -pkg-sources username/hello/link:./link -target js -g -ryu + moonc build-package ./lib/hello.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:./lib -target js -g -ryu + 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:./lib -target js -g -ryu + "#]], + ); +} + +#[test] +fn test_many_targets_auto_update_001() { + let dir = TestDir::new("test_many_targets_auto_update.in"); + let _ = get_stdout_with_args_and_replace_dir(&dir, ["test", "-u"]); + check( + &replace_crlf_to_lf(&std::fs::read_to_string(dir.join("lib").join("x.wasm.mbt")).unwrap()), + expect![[r#" + test { + inspect!("wasm") + } + "#]], + ); + check( + &replace_crlf_to_lf( + &std::fs::read_to_string(dir.join("lib").join("x.wasm-gc.mbt")).unwrap(), + ), + expect![[r#" + test { + inspect!("wasm-gc", content="wasm-gc") + } + "#]], + ); + check( + &replace_crlf_to_lf(&std::fs::read_to_string(dir.join("lib").join("x.js.mbt")).unwrap()), + expect![[r#" + test { + inspect!("js") + } + "#]], + ); +} + +#[test] +fn test_many_targets_auto_update_002() { + let dir = TestDir::new("test_many_targets_auto_update.in"); + let _ = get_stdout_with_args_and_replace_dir(&dir, ["test", "--target", "js", "-u"]); + check( + &replace_crlf_to_lf(&std::fs::read_to_string(dir.join("lib").join("x.wasm.mbt")).unwrap()), + expect![[r#" + test { + inspect!("wasm") + } + "#]], + ); + check( + &replace_crlf_to_lf( + &std::fs::read_to_string(dir.join("lib").join("x.wasm-gc.mbt")).unwrap(), + ), + expect![[r#" + test { + inspect!("wasm-gc") + } + "#]], + ); + check( + &replace_crlf_to_lf(&std::fs::read_to_string(dir.join("lib").join("x.js.mbt")).unwrap()), + expect![[r#" + test { + inspect!("js", content="js") + } + "#]], + ); +} + +#[test] +fn test_many_targets_auto_update_003() { + let dir = TestDir::new("test_many_targets_auto_update.in"); + let _ = get_stdout_with_args_and_replace_dir(&dir, ["test", "--target", "js,wasm", "-u"]); + check( + &replace_crlf_to_lf(&std::fs::read_to_string(dir.join("lib").join("x.wasm.mbt")).unwrap()), + expect![[r#" + test { + inspect!("wasm", content="wasm") + } + "#]], + ); + check( + &replace_crlf_to_lf( + &std::fs::read_to_string(dir.join("lib").join("x.wasm-gc.mbt")).unwrap(), + ), + expect![[r#" + test { + inspect!("wasm-gc") + } + "#]], + ); + check( + &replace_crlf_to_lf(&std::fs::read_to_string(dir.join("lib").join("x.js.mbt")).unwrap()), + expect![[r#" + test { + inspect!("js", content="js") + } + "#]], + ); +} + +#[test] +fn test_many_targets_auto_update_004() { + let dir = TestDir::new("test_many_targets_auto_update.in"); + let _ = get_stdout_with_args_and_replace_dir(&dir, ["test", "--target", "all", "-u"]); + check( + &replace_crlf_to_lf(&std::fs::read_to_string(dir.join("lib").join("x.wasm.mbt")).unwrap()), + expect![[r#" + test { + inspect!("wasm", content="wasm") + } + "#]], + ); + check( + &replace_crlf_to_lf( + &std::fs::read_to_string(dir.join("lib").join("x.wasm-gc.mbt")).unwrap(), + ), + expect![[r#" + test { + inspect!("wasm-gc", content="wasm-gc") + } + "#]], + ); + check( + &replace_crlf_to_lf(&std::fs::read_to_string(dir.join("lib").join("x.js.mbt")).unwrap()), + expect![[r#" + test { + inspect!("js", content="js") + } + "#]], + ); +} + +#[test] +fn test_many_targets_expect_failed() { + let dir = TestDir::new("test_many_targets_expect_failed.in"); + check( + &get_err_stdout_with_args_and_replace_dir( + &dir, + ["test", "--target", "all", "--serial", "--sort-input"], + ), + expect![[r#" + test username/hello/lib/x.wasm.mbt::0 failed + expect test failed at $ROOT/lib/x.wasm.mbt:2:3-2:32 + Diff: + ---- + 0wasm + ---- + + Total tests: 1, passed: 0, failed: 1. + test username/hello/lib/x.wasm-gc.mbt::0 failed + expect test failed at $ROOT/lib/x.wasm-gc.mbt:2:3-2:35 + Diff: + ---- + 1wasm-gc + ---- + + Total tests: 1, passed: 0, failed: 1. + test username/hello/lib/x.js.mbt::0 failed + expect test failed at $ROOT/lib/x.js.mbt:2:3-2:30 + Diff: + ---- + 2js + ---- + + Total tests: 1, passed: 0, failed: 1. + "#]], + ); + check( + &get_err_stdout_with_args_and_replace_dir( + &dir, + ["test", "--target", "js,wasm", "--sort-input", "--serial"], + ), + expect![[r#" + test username/hello/lib/x.wasm.mbt::0 failed + expect test failed at $ROOT/lib/x.wasm.mbt:2:3-2:32 + Diff: + ---- + 0wasm + ---- + + Total tests: 1, passed: 0, failed: 1. + test username/hello/lib/x.js.mbt::0 failed + expect test failed at $ROOT/lib/x.js.mbt:2:3-2:30 + Diff: + ---- + 2js + ---- + + Total tests: 1, passed: 0, failed: 1. + "#]], + ); +} + +#[test] +fn test_moon_run_single_mbt_file() { + let dir = TestDir::new("run_single_mbt_file.in"); + + #[cfg(unix)] + { + let output = + get_stdout_with_args_and_replace_dir(&dir, ["run", "a/b/single.mbt", "--dry-run"]); + check( + &output, + expect![[r#" + moonc build-package $ROOT/a/b/single.mbt -o $ROOT/a/b/single.core -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -is-main -target wasm-gc + moonc link-core $MOON_HOME/lib/core/target/wasm-gc/release/bundle/core.core $ROOT/a/b/single.core -o $ROOT/a/b/single.wasm -target wasm-gc + moonrun $ROOT/a/b/single.wasm + "#]], + ); + + let output = get_stdout_with_args_and_replace_dir( + &dir, + ["run", "a/b/single.mbt", "--target", "js", "--dry-run"], + ); + check( + &output, + expect![[r#" + moonc build-package $ROOT/a/b/single.mbt -o $ROOT/a/b/single.core -std-path $MOON_HOME/lib/core/target/js/release/bundle -is-main -target js + moonc link-core $MOON_HOME/lib/core/target/js/release/bundle/core.core $ROOT/a/b/single.core -o $ROOT/a/b/single.js -target js + node $ROOT/a/b/single.js + "#]], + ); + } + + let output = get_stdout_with_args_and_replace_dir(&dir, ["run", "a/b/single.mbt"]); + check( + &output, + expect![[r#" + I am OK + "#]], + ); + let core_output_path = dir.join("a").join("b").join("single.core"); + assert!(core_output_path.exists()); + assert!(!dir.join("single.core").exists()); + + core_output_path.rm_rf(); + assert!(!core_output_path.exists()); + + let output = get_stdout_with_args_and_replace_dir( + &dir.join("a").join("b").join("c"), + ["run", "../single.mbt"], + ); + check( + &output, + expect![[r#" + I am OK + "#]], + ); + let core_output_path = dir.join("a").join("b").join("single.core"); + assert!(core_output_path.exists()); + assert!(!dir + .join("a") + .join("b") + .join("c") + .join("single.core") + .exists()); + + let output = get_stdout_with_args_and_replace_dir( + &dir.join("a").join("b"), + ["run", "single.mbt", "--target", "js"], + ); + check( + &output, + expect![[r#" + I am OK + "#]], + ); + assert!(dir.join("a").join("b").join("single.js").exists()); +} diff --git a/crates/moon/tests/test_cases/moo_run_with_cli_args.in/.gitignore b/crates/moon/tests/test_cases/moo_run_with_cli_args.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/moo_run_with_cli_args.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/moo_run_with_cli_args.in/README.md b/crates/moon/tests/test_cases/moo_run_with_cli_args.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/moo_run_with_cli_args.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moo_run_with_cli_args.in/main/main.mbt b/crates/moon/tests/test_cases/moo_run_with_cli_args.in/main/main.mbt new file mode 100644 index 00000000..c02d3958 --- /dev/null +++ b/crates/moon/tests/test_cases/moo_run_with_cli_args.in/main/main.mbt @@ -0,0 +1,89 @@ +fn main { + let args = get_args() + println(args) +} + +fn env_get_var(s : ExternString) -> ExternString = "__moonbit_fs_unstable" "env_get_var" + +fn args_get() -> JSArray = "__moonbit_fs_unstable" "args_get" + +pub fn get_env_var(name : String) -> String? { + let res = env_get_var(string_to_extern(name)) + let mbt_string = string_from_extern(res) + if mbt_string == "" { + None + } else { + Some(mbt_string) + } +} + +pub fn get_args() -> Array[String] { + let arr = args_get() + let len = array_len(arr) + let res = [] + for i = 0; i < len; i = i + 1 { + let val = arr[i] + if jsvalue_is_string(val).not() { + abort("Expected all strings in array") + } + res.push(string_from_extern(jsvalue_get_string(val))) + } + res +} + +type JSValue + +pub fn jsvalue_is_string(v : JSValue) -> Bool = "__moonbit_fs_unstable" "jsvalue_is_string" + +pub fn jsvalue_get_string(v : JSValue) -> ExternString = "%identity" + +pub type JSArray + +pub fn array_len(arr : JSArray) -> Int = "__moonbit_fs_unstable" "array_len" + +pub fn array_get(arr : JSArray, idx : Int) -> JSValue = "__moonbit_fs_unstable" "array_get" + +pub fn JSArray::op_get(self : JSArray, idx : Int) -> JSValue { + return array_get(self, idx) +} + +type StringCreateHandle + +type StringReadHandle + +pub type ExternString + +fn begin_create_string() -> StringCreateHandle = "__moonbit_fs_unstable" "begin_create_string" + +fn string_append_char(handle : StringCreateHandle, ch : Char) = "__moonbit_fs_unstable" "string_append_char" + +fn finish_create_string(handle : StringCreateHandle) -> ExternString = "__moonbit_fs_unstable" "finish_create_string" + +pub fn string_to_extern(s : String) -> ExternString { + let handle = begin_create_string() + s.iter().each(fn(ch) { string_append_char(handle, ch) }) + finish_create_string(handle) +} + +fn begin_read_string(s : ExternString) -> StringReadHandle = "__moonbit_fs_unstable" "begin_read_string" + +/// Read one char from the string, returns -1 if the end of the string is reached. +/// The number returned is the unicode codepoint of the character. +fn string_read_char(handle : StringReadHandle) -> Int = "__moonbit_fs_unstable" "string_read_char" + +fn finish_read_string(handle : StringReadHandle) = "__moonbit_fs_unstable" "finish_read_string" + +pub fn string_from_extern(e : ExternString) -> String { + let buf = Buffer::new() + let handle = begin_read_string(e) + while true { + let ch = string_read_char(handle) + if ch == -1 { + break + } else { + buf.write_char(Char::from_int(ch)) + } + } + finish_read_string(handle) + buf.to_string() +} diff --git a/crates/moon/tests/test_cases/moo_run_with_cli_args.in/main/moon.pkg.json b/crates/moon/tests/test_cases/moo_run_with_cli_args.in/main/moon.pkg.json new file mode 100644 index 00000000..fcc86bad --- /dev/null +++ b/crates/moon/tests/test_cases/moo_run_with_cli_args.in/main/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "is-main": true +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moo_run_with_cli_args.in/moon.mod.json b/crates/moon/tests/test_cases/moo_run_with_cli_args.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/moo_run_with_cli_args.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_bundle.in/A/lib.mbt b/crates/moon/tests/test_cases/moon_bundle.in/A/lib.mbt new file mode 100644 index 00000000..0c8ba57d --- /dev/null +++ b/crates/moon/tests/test_cases/moon_bundle.in/A/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("A") +} diff --git a/crates/moon/tests/test_cases/moon_bundle.in/A/moon.pkg.json b/crates/moon/tests/test_cases/moon_bundle.in/A/moon.pkg.json new file mode 100644 index 00000000..0ca2f124 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_bundle.in/A/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_bundle.in/B/lib.mbt b/crates/moon/tests/test_cases/moon_bundle.in/B/lib.mbt new file mode 100644 index 00000000..98f4a947 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_bundle.in/B/lib.mbt @@ -0,0 +1,4 @@ +pub fn f() -> Unit { + @A.f() + println("B") +} diff --git a/crates/moon/tests/test_cases/moon_bundle.in/B/moon.pkg.json b/crates/moon/tests/test_cases/moon_bundle.in/B/moon.pkg.json new file mode 100644 index 00000000..9a3516fa --- /dev/null +++ b/crates/moon/tests/test_cases/moon_bundle.in/B/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": { + "moonbitlang/core/A": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_bundle.in/C/lib.mbt b/crates/moon/tests/test_cases/moon_bundle.in/C/lib.mbt new file mode 100644 index 00000000..8695ab4c --- /dev/null +++ b/crates/moon/tests/test_cases/moon_bundle.in/C/lib.mbt @@ -0,0 +1,4 @@ +pub fn f() -> Unit { + @A.f() + println("C") +} diff --git a/crates/moon/tests/test_cases/moon_bundle.in/C/moon.pkg.json b/crates/moon/tests/test_cases/moon_bundle.in/C/moon.pkg.json new file mode 100644 index 00000000..9a3516fa --- /dev/null +++ b/crates/moon/tests/test_cases/moon_bundle.in/C/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": { + "moonbitlang/core/A": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_bundle.in/Orphan/lib.mbt b/crates/moon/tests/test_cases/moon_bundle.in/Orphan/lib.mbt new file mode 100644 index 00000000..d4bbc21a --- /dev/null +++ b/crates/moon/tests/test_cases/moon_bundle.in/Orphan/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("Orphan") +} diff --git a/crates/moon/tests/test_cases/moon_bundle.in/Orphan/moon.pkg.json b/crates/moon/tests/test_cases/moon_bundle.in/Orphan/moon.pkg.json new file mode 100644 index 00000000..0ca2f124 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_bundle.in/Orphan/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_bundle.in/moon.mod.json b/crates/moon/tests/test_cases/moon_bundle.in/moon.mod.json new file mode 100644 index 00000000..8a6e1f35 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_bundle.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "moonbitlang/core" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_commands.in/lib/list/lib.mbt b/crates/moon/tests/test_cases/moon_commands.in/lib/list/lib.mbt new file mode 100644 index 00000000..ae9f6590 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_commands.in/lib/list/lib.mbt @@ -0,0 +1,3 @@ +pub fn new_list() -> Unit { + println("new_list") +} diff --git a/crates/moon/tests/test_cases/moon_commands.in/lib/list/moon.pkg.json b/crates/moon/tests/test_cases/moon_commands.in/lib/list/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/moon_commands.in/lib/list/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_commands.in/lib/queue/lib.mbt b/crates/moon/tests/test_cases/moon_commands.in/lib/queue/lib.mbt new file mode 100644 index 00000000..1c9b2665 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_commands.in/lib/queue/lib.mbt @@ -0,0 +1,3 @@ +pub fn new_queue() -> Unit { + println("new_queue") +} diff --git a/crates/moon/tests/test_cases/moon_commands.in/lib/queue/moon.pkg.json b/crates/moon/tests/test_cases/moon_commands.in/lib/queue/moon.pkg.json new file mode 100644 index 00000000..ebb8ec26 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_commands.in/lib/queue/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": { + "design/lib/list": "" + } +} diff --git a/crates/moon/tests/test_cases/moon_commands.in/lib/stack/lib.mbt b/crates/moon/tests/test_cases/moon_commands.in/lib/stack/lib.mbt new file mode 100644 index 00000000..24535f2b --- /dev/null +++ b/crates/moon/tests/test_cases/moon_commands.in/lib/stack/lib.mbt @@ -0,0 +1,3 @@ +pub fn new_stack() -> Unit { + println("new_stack") +} diff --git a/crates/moon/tests/test_cases/moon_commands.in/lib/stack/moon.pkg.json b/crates/moon/tests/test_cases/moon_commands.in/lib/stack/moon.pkg.json new file mode 100644 index 00000000..6a134137 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_commands.in/lib/stack/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": { + "design/lib/list": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_commands.in/lib/vec/lib.mbt b/crates/moon/tests/test_cases/moon_commands.in/lib/vec/lib.mbt new file mode 100644 index 00000000..e3f9a5b2 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_commands.in/lib/vec/lib.mbt @@ -0,0 +1,3 @@ +pub fn new_vec() -> Unit { + println("new_vec") +} diff --git a/crates/moon/tests/test_cases/moon_commands.in/lib/vec/moon.pkg.json b/crates/moon/tests/test_cases/moon_commands.in/lib/vec/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_commands.in/lib/vec/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/moon_commands.in/main1/main.mbt b/crates/moon/tests/test_cases/moon_commands.in/main1/main.mbt new file mode 100644 index 00000000..b38b25de --- /dev/null +++ b/crates/moon/tests/test_cases/moon_commands.in/main1/main.mbt @@ -0,0 +1,3 @@ +fn main { + +} diff --git a/crates/moon/tests/test_cases/moon_commands.in/main1/moon.pkg.json b/crates/moon/tests/test_cases/moon_commands.in/main1/moon.pkg.json new file mode 100644 index 00000000..3573ae96 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_commands.in/main1/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "design/lib/queue": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_commands.in/main2/main.mbt b/crates/moon/tests/test_cases/moon_commands.in/main2/main.mbt new file mode 100644 index 00000000..72777741 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_commands.in/main2/main.mbt @@ -0,0 +1,3 @@ +fn main { + println("main2") +} diff --git a/crates/moon/tests/test_cases/moon_commands.in/main2/moon.pkg.json b/crates/moon/tests/test_cases/moon_commands.in/main2/moon.pkg.json new file mode 100644 index 00000000..3573ae96 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_commands.in/main2/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "design/lib/queue": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_commands.in/moon.mod.json b/crates/moon/tests/test_cases/moon_commands.in/moon.mod.json new file mode 100644 index 00000000..d3f9d801 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_commands.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "design" +} diff --git a/crates/moon/tests/test_cases/moon_fmt.in/.gitignore b/crates/moon/tests/test_cases/moon_fmt.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_fmt.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/moon_fmt.in/README.md b/crates/moon/tests/test_cases/moon_fmt.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/moon_fmt.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_fmt.in/lib/hello.mbt b/crates/moon/tests/test_cases/moon_fmt.in/lib/hello.mbt new file mode 100644 index 00000000..36574a79 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_fmt.in/lib/hello.mbt @@ -0,0 +1 @@ +pub fn hello() -> String { "Hello, world!" } diff --git a/crates/moon/tests/test_cases/moon_fmt.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/moon_fmt.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..64f26429 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_fmt.in/lib/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test "hello" { + if hello() != "Hello, world!" { + return Err("hello() != \"Hello, world!\"") + } +} diff --git a/crates/moon/tests/test_cases/moon_fmt.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/moon_fmt.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/moon_fmt.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_fmt.in/main/main.mbt b/crates/moon/tests/test_cases/moon_fmt.in/main/main.mbt new file mode 100644 index 00000000..b7eb1b8a --- /dev/null +++ b/crates/moon/tests/test_cases/moon_fmt.in/main/main.mbt @@ -0,0 +1 @@ +fn main { println(@lib.hello()) } \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_fmt.in/main/moon.pkg.json b/crates/moon/tests/test_cases/moon_fmt.in/main/moon.pkg.json new file mode 100644 index 00000000..99dc8491 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_fmt.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is_main": true, + "import": [ + "username/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_fmt.in/moon.mod.json b/crates/moon/tests/test_cases/moon_fmt.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_fmt.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_001.in/.gitignore b/crates/moon/tests/test_cases/moon_inline_test_001.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_001.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/moon_inline_test_001.in/README.md b/crates/moon/tests/test_cases/moon_inline_test_001.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_001.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_001.in/lib/hello.mbt b/crates/moon/tests/test_cases/moon_inline_test_001.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_001.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/moon_inline_test_001.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/moon_inline_test_001.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..427f5685 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_001.in/lib/hello_wbtest.mbt @@ -0,0 +1,3 @@ +test { + +} diff --git a/crates/moon/tests/test_cases/moon_inline_test_001.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/moon_inline_test_001.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_001.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_001.in/main/main.mbt b/crates/moon/tests/test_cases/moon_inline_test_001.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_001.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/moon_inline_test_001.in/main/moon.pkg.json b/crates/moon/tests/test_cases/moon_inline_test_001.in/main/moon.pkg.json new file mode 100644 index 00000000..48783525 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_001.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_001.in/moon.mod.json b/crates/moon/tests/test_cases/moon_inline_test_001.in/moon.mod.json new file mode 100644 index 00000000..da06d445 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_001.in/moon.mod.json @@ -0,0 +1,8 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_002.in/.gitignore b/crates/moon/tests/test_cases/moon_inline_test_002.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_002.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/moon_inline_test_002.in/README.md b/crates/moon/tests/test_cases/moon_inline_test_002.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_002.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_002.in/lib/hello.mbt b/crates/moon/tests/test_cases/moon_inline_test_002.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_002.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/moon_inline_test_002.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/moon_inline_test_002.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..3aab0e0c --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_002.in/lib/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test { + if hello() != "Hello, world!" { + raise "some error messages" + } +} diff --git a/crates/moon/tests/test_cases/moon_inline_test_002.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/moon_inline_test_002.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_002.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_002.in/main/main.mbt b/crates/moon/tests/test_cases/moon_inline_test_002.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_002.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/moon_inline_test_002.in/main/moon.pkg.json b/crates/moon/tests/test_cases/moon_inline_test_002.in/main/moon.pkg.json new file mode 100644 index 00000000..48783525 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_002.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_002.in/moon.mod.json b/crates/moon/tests/test_cases/moon_inline_test_002.in/moon.mod.json new file mode 100644 index 00000000..da06d445 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_002.in/moon.mod.json @@ -0,0 +1,8 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_003.in/.gitignore b/crates/moon/tests/test_cases/moon_inline_test_003.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_003.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/moon_inline_test_003.in/README.md b/crates/moon/tests/test_cases/moon_inline_test_003.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_003.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_003.in/lib/hello.mbt b/crates/moon/tests/test_cases/moon_inline_test_003.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_003.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/moon_inline_test_003.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/moon_inline_test_003.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..e82261e2 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_003.in/lib/hello_wbtest.mbt @@ -0,0 +1,3 @@ +test { + raise "some msg" +} diff --git a/crates/moon/tests/test_cases/moon_inline_test_003.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/moon_inline_test_003.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_003.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_003.in/main/main.mbt b/crates/moon/tests/test_cases/moon_inline_test_003.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_003.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/moon_inline_test_003.in/main/moon.pkg.json b/crates/moon/tests/test_cases/moon_inline_test_003.in/main/moon.pkg.json new file mode 100644 index 00000000..48783525 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_003.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_003.in/moon.mod.json b/crates/moon/tests/test_cases/moon_inline_test_003.in/moon.mod.json new file mode 100644 index 00000000..da06d445 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_003.in/moon.mod.json @@ -0,0 +1,8 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_004.in/.gitignore b/crates/moon/tests/test_cases/moon_inline_test_004.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_004.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/moon_inline_test_004.in/README.md b/crates/moon/tests/test_cases/moon_inline_test_004.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_004.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_004.in/lib/hello.mbt b/crates/moon/tests/test_cases/moon_inline_test_004.in/lib/hello.mbt new file mode 100644 index 00000000..13e8bc60 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_004.in/lib/hello.mbt @@ -0,0 +1,7 @@ +pub fn hello() -> String { + "Hello, world!" +} + +test { + return Err("some msg") +} diff --git a/crates/moon/tests/test_cases/moon_inline_test_004.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/moon_inline_test_004.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..bad4cb75 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_004.in/lib/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test { + if hello() != "Hello, world!" { + return Err("hello != world") + } +} diff --git a/crates/moon/tests/test_cases/moon_inline_test_004.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/moon_inline_test_004.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_004.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_004.in/main/main.mbt b/crates/moon/tests/test_cases/moon_inline_test_004.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_004.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/moon_inline_test_004.in/main/moon.pkg.json b/crates/moon/tests/test_cases/moon_inline_test_004.in/main/moon.pkg.json new file mode 100644 index 00000000..48783525 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_004.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_004.in/moon.mod.json b/crates/moon/tests/test_cases/moon_inline_test_004.in/moon.mod.json new file mode 100644 index 00000000..da06d445 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_004.in/moon.mod.json @@ -0,0 +1,8 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_order.in/.gitignore b/crates/moon/tests/test_cases/moon_inline_test_order.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_order.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/moon_inline_test_order.in/A/A_wbtest.mbt b/crates/moon/tests/test_cases/moon_inline_test_order.in/A/A_wbtest.mbt new file mode 100644 index 00000000..7006c4bc --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_order.in/A/A_wbtest.mbt @@ -0,0 +1,7 @@ +test { + println("A_test.mbt::init") +} + +test { + println("A_test.mbt::test_hello_A") +} diff --git a/crates/moon/tests/test_cases/moon_inline_test_order.in/A/hello.mbt b/crates/moon/tests/test_cases/moon_inline_test_order.in/A/hello.mbt new file mode 100644 index 00000000..9bb00ff7 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_order.in/A/hello.mbt @@ -0,0 +1,7 @@ +test { + println("executing A") +} + +test { + println("executing A::hello.mbt::test_A") +} diff --git a/crates/moon/tests/test_cases/moon_inline_test_order.in/A/moon.pkg.json b/crates/moon/tests/test_cases/moon_inline_test_order.in/A/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_order.in/A/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_order.in/B/B_wbtest.mbt b/crates/moon/tests/test_cases/moon_inline_test_order.in/B/B_wbtest.mbt new file mode 100644 index 00000000..d8231741 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_order.in/B/B_wbtest.mbt @@ -0,0 +1,7 @@ +test { + println("B_test.mbt::init") +} + +test { + println("B_test.mbt::test_hello_B") +} diff --git a/crates/moon/tests/test_cases/moon_inline_test_order.in/B/hello.mbt b/crates/moon/tests/test_cases/moon_inline_test_order.in/B/hello.mbt new file mode 100644 index 00000000..f56880b4 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_order.in/B/hello.mbt @@ -0,0 +1,7 @@ +test { + println("executing B") +} + +test { + println("executing B::hello.mbt::test_B") +} diff --git a/crates/moon/tests/test_cases/moon_inline_test_order.in/B/moon.pkg.json b/crates/moon/tests/test_cases/moon_inline_test_order.in/B/moon.pkg.json new file mode 100644 index 00000000..15cf122d --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_order.in/B/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": [ + "username/hello/A" + ] +} diff --git a/crates/moon/tests/test_cases/moon_inline_test_order.in/README.md b/crates/moon/tests/test_cases/moon_inline_test_order.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_order.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_order.in/main/main.mbt b/crates/moon/tests/test_cases/moon_inline_test_order.in/main/main.mbt new file mode 100644 index 00000000..61de731e --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_order.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println("main.mbt::init") +} diff --git a/crates/moon/tests/test_cases/moon_inline_test_order.in/main/moon.pkg.json b/crates/moon/tests/test_cases/moon_inline_test_order.in/main/moon.pkg.json new file mode 100644 index 00000000..255bfc6c --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_order.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "username/hello/B" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_inline_test_order.in/moon.mod.json b/crates/moon/tests/test_cases/moon_inline_test_order.in/moon.mod.json new file mode 100644 index 00000000..d26fe667 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_inline_test_order.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "deps": {}, + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_new.in/lib/hello.mbt b/crates/moon/tests/test_cases/moon_new.in/lib/hello.mbt new file mode 100644 index 00000000..a7ac2bee --- /dev/null +++ b/crates/moon/tests/test_cases/moon_new.in/lib/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> String { + "Hello, world!" +} + diff --git a/crates/moon/tests/test_cases/moon_new.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/moon_new.in/lib/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_new.in/lib/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/moon_new.in/main/main.mbt b/crates/moon/tests/test_cases/moon_new.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_new.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/moon_new.in/main/moon.pkg.json b/crates/moon/tests/test_cases/moon_new.in/main/moon.pkg.json new file mode 100644 index 00000000..4343a4ef --- /dev/null +++ b/crates/moon/tests/test_cases/moon_new.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "moon_new/lib": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_new.in/moon.mod.json b/crates/moon/tests/test_cases/moon_new.in/moon.mod.json new file mode 100644 index 00000000..b5d8b346 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_new.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "moon_new" +} diff --git a/crates/moon/tests/test_cases/moon_new_and_watch/lib/hello.mbt b/crates/moon/tests/test_cases/moon_new_and_watch/lib/hello.mbt new file mode 100644 index 00000000..a7ac2bee --- /dev/null +++ b/crates/moon/tests/test_cases/moon_new_and_watch/lib/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> String { + "Hello, world!" +} + diff --git a/crates/moon/tests/test_cases/moon_new_and_watch/lib/moon.pkg.json b/crates/moon/tests/test_cases/moon_new_and_watch/lib/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_new_and_watch/lib/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/moon_new_and_watch/main/main.mbt b/crates/moon/tests/test_cases/moon_new_and_watch/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_new_and_watch/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/moon_new_and_watch/main/moon.pkg.json b/crates/moon/tests/test_cases/moon_new_and_watch/main/moon.pkg.json new file mode 100644 index 00000000..4343a4ef --- /dev/null +++ b/crates/moon/tests/test_cases/moon_new_and_watch/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "moon_new/lib": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_new_and_watch/moon.mod.json b/crates/moon/tests/test_cases/moon_new_and_watch/moon.mod.json new file mode 100644 index 00000000..ab3f2156 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_new_and_watch/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "moon_new" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_new_exist.in/.gitkeep b/crates/moon/tests/test_cases/moon_new_exist.in/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/moon_new_new.in/.gitkeep b/crates/moon/tests/test_cases/moon_new_new.in/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/moon_new_snapshot.in/.gitkeep b/crates/moon/tests/test_cases/moon_new_snapshot.in/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/moon_run_with_cli_args.in/main/main.mbt b/crates/moon/tests/test_cases/moon_run_with_cli_args.in/main/main.mbt new file mode 100644 index 00000000..c02d3958 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_run_with_cli_args.in/main/main.mbt @@ -0,0 +1,89 @@ +fn main { + let args = get_args() + println(args) +} + +fn env_get_var(s : ExternString) -> ExternString = "__moonbit_fs_unstable" "env_get_var" + +fn args_get() -> JSArray = "__moonbit_fs_unstable" "args_get" + +pub fn get_env_var(name : String) -> String? { + let res = env_get_var(string_to_extern(name)) + let mbt_string = string_from_extern(res) + if mbt_string == "" { + None + } else { + Some(mbt_string) + } +} + +pub fn get_args() -> Array[String] { + let arr = args_get() + let len = array_len(arr) + let res = [] + for i = 0; i < len; i = i + 1 { + let val = arr[i] + if jsvalue_is_string(val).not() { + abort("Expected all strings in array") + } + res.push(string_from_extern(jsvalue_get_string(val))) + } + res +} + +type JSValue + +pub fn jsvalue_is_string(v : JSValue) -> Bool = "__moonbit_fs_unstable" "jsvalue_is_string" + +pub fn jsvalue_get_string(v : JSValue) -> ExternString = "%identity" + +pub type JSArray + +pub fn array_len(arr : JSArray) -> Int = "__moonbit_fs_unstable" "array_len" + +pub fn array_get(arr : JSArray, idx : Int) -> JSValue = "__moonbit_fs_unstable" "array_get" + +pub fn JSArray::op_get(self : JSArray, idx : Int) -> JSValue { + return array_get(self, idx) +} + +type StringCreateHandle + +type StringReadHandle + +pub type ExternString + +fn begin_create_string() -> StringCreateHandle = "__moonbit_fs_unstable" "begin_create_string" + +fn string_append_char(handle : StringCreateHandle, ch : Char) = "__moonbit_fs_unstable" "string_append_char" + +fn finish_create_string(handle : StringCreateHandle) -> ExternString = "__moonbit_fs_unstable" "finish_create_string" + +pub fn string_to_extern(s : String) -> ExternString { + let handle = begin_create_string() + s.iter().each(fn(ch) { string_append_char(handle, ch) }) + finish_create_string(handle) +} + +fn begin_read_string(s : ExternString) -> StringReadHandle = "__moonbit_fs_unstable" "begin_read_string" + +/// Read one char from the string, returns -1 if the end of the string is reached. +/// The number returned is the unicode codepoint of the character. +fn string_read_char(handle : StringReadHandle) -> Int = "__moonbit_fs_unstable" "string_read_char" + +fn finish_read_string(handle : StringReadHandle) = "__moonbit_fs_unstable" "finish_read_string" + +pub fn string_from_extern(e : ExternString) -> String { + let buf = Buffer::new() + let handle = begin_read_string(e) + while true { + let ch = string_read_char(handle) + if ch == -1 { + break + } else { + buf.write_char(Char::from_int(ch)) + } + } + finish_read_string(handle) + buf.to_string() +} diff --git a/crates/moon/tests/test_cases/moon_test.in/lib/hello.mbt b/crates/moon/tests/test_cases/moon_test.in/lib/hello.mbt new file mode 100644 index 00000000..a7ac2bee --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/lib/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> String { + "Hello, world!" +} + diff --git a/crates/moon/tests/test_cases/moon_test.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/moon_test.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..328a3a20 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/lib/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test { + if hello() != "Hello, world!" { + raise "not ok" + } +} diff --git a/crates/moon/tests/test_cases/moon_test.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/moon_test.in/lib/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/lib/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/moon_test.in/lib2/hello.mbt b/crates/moon/tests/test_cases/moon_test.in/lib2/hello.mbt new file mode 100644 index 00000000..4f92d312 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/lib2/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> String { + "hello" +} + diff --git a/crates/moon/tests/test_cases/moon_test.in/lib2/hello_wbtest.mbt b/crates/moon/tests/test_cases/moon_test.in/lib2/hello_wbtest.mbt new file mode 100644 index 00000000..c5c0506e --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/lib2/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test { + if hello() != "Hello, world!" { + raise "hello() != \"Hello, World\"" + } +} diff --git a/crates/moon/tests/test_cases/moon_test.in/lib2/moon.pkg.json b/crates/moon/tests/test_cases/moon_test.in/lib2/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/lib2/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/moon_test.in/lib2/nested/lib.mbt b/crates/moon/tests/test_cases/moon_test.in/lib2/nested/lib.mbt new file mode 100644 index 00000000..83035f21 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/lib2/nested/lib.mbt @@ -0,0 +1,3 @@ +pub fn add1(x : Int) -> Int { + x + 2 +} diff --git a/crates/moon/tests/test_cases/moon_test.in/lib2/nested/lib_wbtest.mbt b/crates/moon/tests/test_cases/moon_test.in/lib2/nested/lib_wbtest.mbt new file mode 100644 index 00000000..cb7506fe --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/lib2/nested/lib_wbtest.mbt @@ -0,0 +1,11 @@ +test { + if add1(1) != 2 { + raise "add1(1) should be 2" + } +} + +test { + if @lib2.hello() != "hello" { + raise "@lib2.hello() should be `hello`" + } +} diff --git a/crates/moon/tests/test_cases/moon_test.in/lib2/nested/moon.pkg.json b/crates/moon/tests/test_cases/moon_test.in/lib2/nested/moon.pkg.json new file mode 100644 index 00000000..b302fe77 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/lib2/nested/moon.pkg.json @@ -0,0 +1,8 @@ +{ + "import": { + "moontest/lib2": "" + }, + "wbtest-import": [ + "moontest/lib2" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test.in/lib3/hello.mbt b/crates/moon/tests/test_cases/moon_test.in/lib3/hello.mbt new file mode 100644 index 00000000..a7ac2bee --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/lib3/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> String { + "Hello, world!" +} + diff --git a/crates/moon/tests/test_cases/moon_test.in/lib3/hello_wbtest.mbt b/crates/moon/tests/test_cases/moon_test.in/lib3/hello_wbtest.mbt new file mode 100644 index 00000000..328a3a20 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/lib3/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test { + if hello() != "Hello, world!" { + raise "not ok" + } +} diff --git a/crates/moon/tests/test_cases/moon_test.in/lib3/moon.pkg.json b/crates/moon/tests/test_cases/moon_test.in/lib3/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/lib3/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/moon_test.in/lib4/hello.mbt b/crates/moon/tests/test_cases/moon_test.in/lib4/hello.mbt new file mode 100644 index 00000000..a7ac2bee --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/lib4/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> String { + "Hello, world!" +} + diff --git a/crates/moon/tests/test_cases/moon_test.in/lib4/hello_wbtest.mbt b/crates/moon/tests/test_cases/moon_test.in/lib4/hello_wbtest.mbt new file mode 100644 index 00000000..328a3a20 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/lib4/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test { + if hello() != "Hello, world!" { + raise "not ok" + } +} diff --git a/crates/moon/tests/test_cases/moon_test.in/lib4/moon.pkg.json b/crates/moon/tests/test_cases/moon_test.in/lib4/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/lib4/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/moon_test.in/lib5/hello_wbtest.mbt b/crates/moon/tests/test_cases/moon_test.in/lib5/hello_wbtest.mbt new file mode 100644 index 00000000..2d15337e --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/lib5/hello_wbtest.mbt @@ -0,0 +1,29 @@ +test { + () +} + +test "" { + +} + +test "without_space" { + () +} + +test "with space" { + () +} + +// TODO: +// the output of debug("with space and \" and \\") is not correct + +// test "with space and \"" { +// return Ok(()) +// } +// test "with space and \" and \\" { +// return Ok(()) +// } +// test "with space and \" and \\ and one line" { +// let _ = "\" \" \\" +// return Ok(()) +// } diff --git a/crates/moon/tests/test_cases/moon_test.in/lib5/moon.pkg.json b/crates/moon/tests/test_cases/moon_test.in/lib5/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/lib5/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/moon_test.in/main/main.mbt b/crates/moon/tests/test_cases/moon_test.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/moon_test.in/main/moon.pkg.json b/crates/moon/tests/test_cases/moon_test.in/main/moon.pkg.json new file mode 100644 index 00000000..66e2dc7d --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "moontest/lib": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test.in/moon.mod.json b/crates/moon/tests/test_cases/moon_test.in/moon.mod.json new file mode 100644 index 00000000..365fb995 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "moontest" +} diff --git a/crates/moon/tests/test_cases/moon_test_hello_exec.in/.gitignore b/crates/moon/tests/test_cases/moon_test_hello_exec.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_exec.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/moon_test_hello_exec.in/lib/hello.mbt b/crates/moon/tests/test_cases/moon_test_hello_exec.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_exec.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/moon_test_hello_exec.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/moon_test_hello_exec.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..5478ec1d --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_exec.in/lib/hello_wbtest.mbt @@ -0,0 +1,6 @@ +test { + println("this is lib test") + if hello() != "Hello, world!" { + abort("") + } +} diff --git a/crates/moon/tests/test_cases/moon_test_hello_exec.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/moon_test_hello_exec.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_exec.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test_hello_exec.in/main/main.mbt b/crates/moon/tests/test_cases/moon_test_hello_exec.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_exec.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/moon_test_hello_exec.in/main/main_wbtest.mbt b/crates/moon/tests/test_cases/moon_test_hello_exec.in/main/main_wbtest.mbt new file mode 100644 index 00000000..92ead011 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_exec.in/main/main_wbtest.mbt @@ -0,0 +1,3 @@ +test { + println("this is main test") +} diff --git a/crates/moon/tests/test_cases/moon_test_hello_exec.in/main/moon.pkg.json b/crates/moon/tests/test_cases/moon_test_hello_exec.in/main/moon.pkg.json new file mode 100644 index 00000000..02016c81 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_exec.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "moonbitlang/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test_hello_exec.in/moon.mod.json b/crates/moon/tests/test_cases/moon_test_hello_exec.in/moon.mod.json new file mode 100644 index 00000000..c5d41246 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_exec.in/moon.mod.json @@ -0,0 +1,4 @@ +{ + "name": "moonbitlang/hello", + "version": "0.1.0" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/.gitignore b/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/lib/hello.mbt b/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/lib/hello.mbt new file mode 100644 index 00000000..b7bd4648 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/lib/hello.mbt @@ -0,0 +1,7 @@ +pub fn hello() -> String { + "Hello, world!" +} + +test { + println("test in lib/hello.mbt") +} diff --git a/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..0f0a481a --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/lib/hello_wbtest.mbt @@ -0,0 +1,3 @@ +test { + println("test in lib/hello_test.mbt") +} diff --git a/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/main/main.mbt b/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/main/main.mbt new file mode 100644 index 00000000..3cd805d6 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println("init in main/main.mbt") +} diff --git a/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/main/moon.pkg.json b/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/main/moon.pkg.json new file mode 100644 index 00000000..02016c81 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "moonbitlang/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/moon.mod.json b/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/moon.mod.json new file mode 100644 index 00000000..c5d41246 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_exec_fntest.in/moon.mod.json @@ -0,0 +1,4 @@ +{ + "name": "moonbitlang/hello", + "version": "0.1.0" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test_hello_lib.in/.gitignore b/crates/moon/tests/test_cases/moon_test_hello_lib.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_lib.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/moon_test_hello_lib.in/lib/hello.mbt b/crates/moon/tests/test_cases/moon_test_hello_lib.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_lib.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/moon_test_hello_lib.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/moon_test_hello_lib.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..c9a46222 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_lib.in/lib/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test { + if hello() != "Hello, world!" { + abort("") + } +} diff --git a/crates/moon/tests/test_cases/moon_test_hello_lib.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/moon_test_hello_lib.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_lib.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test_hello_lib.in/moon.mod.json b/crates/moon/tests/test_cases/moon_test_hello_lib.in/moon.mod.json new file mode 100644 index 00000000..c5d41246 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_lib.in/moon.mod.json @@ -0,0 +1,4 @@ +{ + "name": "moonbitlang/hello", + "version": "0.1.0" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test_hello_lib.in/moon.pkg.json b/crates/moon/tests/test_cases/moon_test_hello_lib.in/moon.pkg.json new file mode 100644 index 00000000..321cad47 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_lib.in/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": [ + "moonbitlang/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test_hello_lib.in/top.mbt b/crates/moon/tests/test_cases/moon_test_hello_lib.in/top.mbt new file mode 100644 index 00000000..7a554d06 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_hello_lib.in/top.mbt @@ -0,0 +1,3 @@ +pub fn greeting() -> Unit { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/moon_test_no_entry_warning.in/main/main.mbt b/crates/moon/tests/test_cases/moon_test_no_entry_warning.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_no_entry_warning.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/moon_test_no_entry_warning.in/main/moon.pkg.json b/crates/moon/tests/test_cases/moon_test_no_entry_warning.in/main/moon.pkg.json new file mode 100644 index 00000000..d6a16d9e --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_no_entry_warning.in/main/moon.pkg.json @@ -0,0 +1,4 @@ +{ + "is-main": true, + "import": [] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test_no_entry_warning.in/moon.mod.json b/crates/moon/tests/test_cases/moon_test_no_entry_warning.in/moon.mod.json new file mode 100644 index 00000000..b5d8b346 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_no_entry_warning.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "moon_new" +} diff --git a/crates/moon/tests/test_cases/moon_test_succ.in/lib/hello.mbt b/crates/moon/tests/test_cases/moon_test_succ.in/lib/hello.mbt new file mode 100644 index 00000000..a7ac2bee --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_succ.in/lib/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> String { + "Hello, world!" +} + diff --git a/crates/moon/tests/test_cases/moon_test_succ.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/moon_test_succ.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..328a3a20 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_succ.in/lib/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test { + if hello() != "Hello, world!" { + raise "not ok" + } +} diff --git a/crates/moon/tests/test_cases/moon_test_succ.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/moon_test_succ.in/lib/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_succ.in/lib/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/moon_test_succ.in/lib2/hello.mbt b/crates/moon/tests/test_cases/moon_test_succ.in/lib2/hello.mbt new file mode 100644 index 00000000..4f92d312 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_succ.in/lib2/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> String { + "hello" +} + diff --git a/crates/moon/tests/test_cases/moon_test_succ.in/lib2/hello_wbtest.mbt b/crates/moon/tests/test_cases/moon_test_succ.in/lib2/hello_wbtest.mbt new file mode 100644 index 00000000..54492bb8 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_succ.in/lib2/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test { + if hello() != "hello" { + raise "failed" + } +} diff --git a/crates/moon/tests/test_cases/moon_test_succ.in/lib2/moon.pkg.json b/crates/moon/tests/test_cases/moon_test_succ.in/lib2/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_succ.in/lib2/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/moon_test_succ.in/lib2/nested/lib.mbt b/crates/moon/tests/test_cases/moon_test_succ.in/lib2/nested/lib.mbt new file mode 100644 index 00000000..f9852707 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_succ.in/lib2/nested/lib.mbt @@ -0,0 +1,4 @@ +fn add1(x : Int) -> Int { + x + 1 +} + diff --git a/crates/moon/tests/test_cases/moon_test_succ.in/lib2/nested/lib_wbtest.mbt b/crates/moon/tests/test_cases/moon_test_succ.in/lib2/nested/lib_wbtest.mbt new file mode 100644 index 00000000..cb7506fe --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_succ.in/lib2/nested/lib_wbtest.mbt @@ -0,0 +1,11 @@ +test { + if add1(1) != 2 { + raise "add1(1) should be 2" + } +} + +test { + if @lib2.hello() != "hello" { + raise "@lib2.hello() should be `hello`" + } +} diff --git a/crates/moon/tests/test_cases/moon_test_succ.in/lib2/nested/moon.pkg.json b/crates/moon/tests/test_cases/moon_test_succ.in/lib2/nested/moon.pkg.json new file mode 100644 index 00000000..4bc5e296 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_succ.in/lib2/nested/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": { + "moontest/lib2": "" + } +} diff --git a/crates/moon/tests/test_cases/moon_test_succ.in/lib3/hello.mbt b/crates/moon/tests/test_cases/moon_test_succ.in/lib3/hello.mbt new file mode 100644 index 00000000..a7ac2bee --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_succ.in/lib3/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> String { + "Hello, world!" +} + diff --git a/crates/moon/tests/test_cases/moon_test_succ.in/lib3/hello_wbtest.mbt b/crates/moon/tests/test_cases/moon_test_succ.in/lib3/hello_wbtest.mbt new file mode 100644 index 00000000..328a3a20 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_succ.in/lib3/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test { + if hello() != "Hello, world!" { + raise "not ok" + } +} diff --git a/crates/moon/tests/test_cases/moon_test_succ.in/lib3/moon.pkg.json b/crates/moon/tests/test_cases/moon_test_succ.in/lib3/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_succ.in/lib3/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/moon_test_succ.in/lib4/hello.mbt b/crates/moon/tests/test_cases/moon_test_succ.in/lib4/hello.mbt new file mode 100644 index 00000000..a7ac2bee --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_succ.in/lib4/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> String { + "Hello, world!" +} + diff --git a/crates/moon/tests/test_cases/moon_test_succ.in/lib4/hello_wbtest.mbt b/crates/moon/tests/test_cases/moon_test_succ.in/lib4/hello_wbtest.mbt new file mode 100644 index 00000000..328a3a20 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_succ.in/lib4/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test { + if hello() != "Hello, world!" { + raise "not ok" + } +} diff --git a/crates/moon/tests/test_cases/moon_test_succ.in/lib4/moon.pkg.json b/crates/moon/tests/test_cases/moon_test_succ.in/lib4/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_succ.in/lib4/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/moon_test_succ.in/main/main.mbt b/crates/moon/tests/test_cases/moon_test_succ.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_succ.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/moon_test_succ.in/main/moon.pkg.json b/crates/moon/tests/test_cases/moon_test_succ.in/main/moon.pkg.json new file mode 100644 index 00000000..66e2dc7d --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_succ.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "moontest/lib": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test_succ.in/moon.mod.json b/crates/moon/tests/test_cases/moon_test_succ.in/moon.mod.json new file mode 100644 index 00000000..365fb995 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_succ.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "moontest" +} diff --git a/crates/moon/tests/test_cases/moon_test_with_local_dep.in/.gitignore b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/.gitignore new file mode 100644 index 00000000..8bc612e2 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/.gitignore @@ -0,0 +1,2 @@ +target/ +!.mooncakes/ \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test_with_local_dep.in/lib/hello.mbt b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/moon_test_with_local_dep.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..d997755d --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/lib/hello_wbtest.mbt @@ -0,0 +1 @@ +test {} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test_with_local_dep.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test_with_local_dep.in/main/main.mbt b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/main/main.mbt new file mode 100644 index 00000000..e3171d7f --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + @mooncake.greeting() +} diff --git a/crates/moon/tests/test_cases/moon_test_with_local_dep.in/main/moon.pkg.json b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/main/moon.pkg.json new file mode 100644 index 00000000..93af9a1c --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/main/moon.pkg.json @@ -0,0 +1,7 @@ +{ + "is-main": true, + "import": { + "hello31/lib": "", + "lijunchen/mooncake": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/lib/hello.mbt b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/lib/hello_wbtest.mbt new file mode 100644 index 00000000..c9a46222 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/lib/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test { + if hello() != "Hello, world!" { + abort("") + } +} diff --git a/crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/lib/moon.pkg.json b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/moon.mod.json b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/moon.mod.json new file mode 100644 index 00000000..2b1b9ddf --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/moon.mod.json @@ -0,0 +1,4 @@ +{ + "name": "lijunchen/mooncake", + "version": "0.1.0" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/moon.pkg.json b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/moon.pkg.json new file mode 100644 index 00000000..031728e6 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": [ + "lijunchen/mooncake/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/top.mbt b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/top.mbt new file mode 100644 index 00000000..7a554d06 --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/mods/lijunchen/mooncake/top.mbt @@ -0,0 +1,3 @@ +pub fn greeting() -> Unit { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/moon_test_with_local_dep.in/moon.mod.json b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/moon.mod.json new file mode 100644 index 00000000..bf0773ce --- /dev/null +++ b/crates/moon/tests/test_cases/moon_test_with_local_dep.in/moon.mod.json @@ -0,0 +1,8 @@ +{ + "name": "hello31", + "deps": { + "lijunchen/mooncake": { + "path": "./mods/lijunchen/mooncake" + } + } +} diff --git a/crates/moon/tests/test_cases/multidimensional_arrays.in/README.md b/crates/moon/tests/test_cases/multidimensional_arrays.in/README.md new file mode 100644 index 00000000..f64e85ce --- /dev/null +++ b/crates/moon/tests/test_cases/multidimensional_arrays.in/README.md @@ -0,0 +1,3 @@ +## Multidimensional Arrays + +Use the [triangle problem](https://leetcode.com/problems/triangle/) to demonstrate how to use Moonbit's multidimensional arrays. diff --git a/crates/moon/tests/test_cases/multidimensional_arrays.in/lib/arrays.mbt b/crates/moon/tests/test_cases/multidimensional_arrays.in/lib/arrays.mbt new file mode 100644 index 00000000..1747c80e --- /dev/null +++ b/crates/moon/tests/test_cases/multidimensional_arrays.in/lib/arrays.mbt @@ -0,0 +1,40 @@ +fn min(a : Int, b : Int) -> Int { + if a > b { + return b + } else { + return a + } +} + +/// Calculate the minimum path sum through a triangle of integers. +/// +/// Given a triangle represented as a list of lists of integers, where each list +/// corresponds to a row of the triangle, this function calculates the minimum +/// path sum from the top to the bottom of the triangle by moving only to adjacent +/// numbers on the row below. +/// +/// @param {Array[Array[Int]]} triangle - A 2D array representing the triangle of integers. +/// @return {Int} - The minimum path sum through the triangle. +/// +/// The function uses a recursive approach with dynamic programming to calculate +/// the minimum path sum. It starts from the top of the triangle and recursively +/// calculates the minimum path sum for each possible path from the current position +/// to the bottom row. The `helper` function is used for the recursive calculation. +pub fn minPathSum(triangle : Array[Array[Int]]) -> Int { + fn helper(row : Int, col : Int) -> Int { + if row == triangle.length() { + return 0 + } + let next1 = helper(row + 1, col) + let next2 = if col < row { + helper(row + 1, col + 1) + } else { + 2147483647 + } + let cur = triangle[row][col] + return cur + min(next1, next2) + } + + helper(0, 0) +} + diff --git a/crates/moon/tests/test_cases/multidimensional_arrays.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/multidimensional_arrays.in/lib/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/multidimensional_arrays.in/lib/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/multidimensional_arrays.in/main/main.mbt b/crates/moon/tests/test_cases/multidimensional_arrays.in/main/main.mbt new file mode 100644 index 00000000..0797b550 --- /dev/null +++ b/crates/moon/tests/test_cases/multidimensional_arrays.in/main/main.mbt @@ -0,0 +1,5 @@ +fn main { + let triangle : Array[Array[Int]] = [[2], [3, 4], [6, 5, 7], [4, 1, 8, 3]] + let result = @lib.minPathSum(triangle) + println(result) // prints 11 +} diff --git a/crates/moon/tests/test_cases/multidimensional_arrays.in/main/moon.pkg.json b/crates/moon/tests/test_cases/multidimensional_arrays.in/main/moon.pkg.json new file mode 100644 index 00000000..94d52132 --- /dev/null +++ b/crates/moon/tests/test_cases/multidimensional_arrays.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "multidimensional_arrays/lib": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/multidimensional_arrays.in/moon.mod.json b/crates/moon/tests/test_cases/multidimensional_arrays.in/moon.mod.json new file mode 100644 index 00000000..7cc613ed --- /dev/null +++ b/crates/moon/tests/test_cases/multidimensional_arrays.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "multidimensional_arrays" +} diff --git a/crates/moon/tests/test_cases/need_link.in/.gitignore b/crates/moon/tests/test_cases/need_link.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/need_link.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/need_link.in/README.md b/crates/moon/tests/test_cases/need_link.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/need_link.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/need_link.in/lib/hello.mbt b/crates/moon/tests/test_cases/need_link.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/need_link.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/need_link.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/need_link.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..64f26429 --- /dev/null +++ b/crates/moon/tests/test_cases/need_link.in/lib/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test "hello" { + if hello() != "Hello, world!" { + return Err("hello() != \"Hello, world!\"") + } +} diff --git a/crates/moon/tests/test_cases/need_link.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/need_link.in/lib/moon.pkg.json new file mode 100644 index 00000000..280af610 --- /dev/null +++ b/crates/moon/tests/test_cases/need_link.in/lib/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "link": true +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/need_link.in/main/main.mbt b/crates/moon/tests/test_cases/need_link.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/need_link.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/need_link.in/main/moon.pkg.json b/crates/moon/tests/test_cases/need_link.in/main/moon.pkg.json new file mode 100644 index 00000000..48783525 --- /dev/null +++ b/crates/moon/tests/test_cases/need_link.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/need_link.in/moon.mod.json b/crates/moon/tests/test_cases/need_link.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/need_link.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/no_block_params.in/.gitignore b/crates/moon/tests/test_cases/no_block_params.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/no_block_params.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/no_block_params.in/README.md b/crates/moon/tests/test_cases/no_block_params.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/no_block_params.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/no_block_params.in/lib/hello.mbt b/crates/moon/tests/test_cases/no_block_params.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/no_block_params.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/no_block_params.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/no_block_params.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..64f26429 --- /dev/null +++ b/crates/moon/tests/test_cases/no_block_params.in/lib/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test "hello" { + if hello() != "Hello, world!" { + return Err("hello() != \"Hello, world!\"") + } +} diff --git a/crates/moon/tests/test_cases/no_block_params.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/no_block_params.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/no_block_params.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/no_block_params.in/main/main.mbt b/crates/moon/tests/test_cases/no_block_params.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/no_block_params.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/no_block_params.in/main/moon.pkg.json b/crates/moon/tests/test_cases/no_block_params.in/main/moon.pkg.json new file mode 100644 index 00000000..a96f0f3a --- /dev/null +++ b/crates/moon/tests/test_cases/no_block_params.in/main/moon.pkg.json @@ -0,0 +1,18 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ], + "link": { + "wasm": { + "flags": [ + "-no-block-params" + ] + }, + "wasm-gc": { + "flags": [ + "-no-block-params" + ] + } + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/no_block_params.in/moon.mod.json b/crates/moon/tests/test_cases/no_block_params.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/no_block_params.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/only_update_expect.in/.gitignore b/crates/moon/tests/test_cases/only_update_expect.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/only_update_expect.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/only_update_expect.in/README.md b/crates/moon/tests/test_cases/only_update_expect.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/only_update_expect.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/only_update_expect.in/lib/hello.mbt b/crates/moon/tests/test_cases/only_update_expect.in/lib/hello.mbt new file mode 100644 index 00000000..f649d11b --- /dev/null +++ b/crates/moon/tests/test_cases/only_update_expect.in/lib/hello.mbt @@ -0,0 +1,3 @@ +test { + abort("") +} diff --git a/crates/moon/tests/test_cases/only_update_expect.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/only_update_expect.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/only_update_expect.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/only_update_expect.in/main/main.mbt b/crates/moon/tests/test_cases/only_update_expect.in/main/main.mbt new file mode 100644 index 00000000..2442723f --- /dev/null +++ b/crates/moon/tests/test_cases/only_update_expect.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println("main") +} diff --git a/crates/moon/tests/test_cases/only_update_expect.in/main/moon.pkg.json b/crates/moon/tests/test_cases/only_update_expect.in/main/moon.pkg.json new file mode 100644 index 00000000..48783525 --- /dev/null +++ b/crates/moon/tests/test_cases/only_update_expect.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/only_update_expect.in/moon.mod.json b/crates/moon/tests/test_cases/only_update_expect.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/only_update_expect.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/output-format.in/lib/hello.mbt b/crates/moon/tests/test_cases/output-format.in/lib/hello.mbt new file mode 100644 index 00000000..a7ac2bee --- /dev/null +++ b/crates/moon/tests/test_cases/output-format.in/lib/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> String { + "Hello, world!" +} + diff --git a/crates/moon/tests/test_cases/output-format.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/output-format.in/lib/moon.pkg.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/crates/moon/tests/test_cases/output-format.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} diff --git a/crates/moon/tests/test_cases/output-format.in/main/main.mbt b/crates/moon/tests/test_cases/output-format.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/output-format.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/output-format.in/main/moon.pkg.json b/crates/moon/tests/test_cases/output-format.in/main/moon.pkg.json new file mode 100644 index 00000000..0dccc0db --- /dev/null +++ b/crates/moon/tests/test_cases/output-format.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "hello/lib": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/output-format.in/moon.mod.json b/crates/moon/tests/test_cases/output-format.in/moon.mod.json new file mode 100644 index 00000000..61113747 --- /dev/null +++ b/crates/moon/tests/test_cases/output-format.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "hello" +} diff --git a/crates/moon/tests/test_cases/palindrome_string.in/README.md b/crates/moon/tests/test_cases/palindrome_string.in/README.md new file mode 100644 index 00000000..4c3d39ee --- /dev/null +++ b/crates/moon/tests/test_cases/palindrome_string.in/README.md @@ -0,0 +1,3 @@ +## Palindrome string + +Use the palindrome question to demonstrate Moonbit's string iteration. diff --git a/crates/moon/tests/test_cases/palindrome_string.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/palindrome_string.in/lib/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/palindrome_string.in/lib/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/palindrome_string.in/lib/str_iter.mbt b/crates/moon/tests/test_cases/palindrome_string.in/lib/str_iter.mbt new file mode 100644 index 00000000..f5ad2577 --- /dev/null +++ b/crates/moon/tests/test_cases/palindrome_string.in/lib/str_iter.mbt @@ -0,0 +1,18 @@ +/// Check if a given string is a palindrome. +/// +/// This function takes a string as input and checks whether it is a palindrome or not. +/// A palindrome is a string that reads the same forwards and backwards. +/// +/// @param {String} chars - The input string to be checked for palindrome. +/// @return {Bool} Returns `true` if the input string is a palindrome, otherwise `false`. +pub fn is_palindrome(chars : String) -> Bool { + let n = chars.length() + let mut i = 0 + while i < n / 2 { + if chars[i] != chars[n - i - 1] { + return false + } + i = i + 1 + } + return true +} diff --git a/crates/moon/tests/test_cases/palindrome_string.in/main/main.mbt b/crates/moon/tests/test_cases/palindrome_string.in/main/main.mbt new file mode 100644 index 00000000..4785d042 --- /dev/null +++ b/crates/moon/tests/test_cases/palindrome_string.in/main/main.mbt @@ -0,0 +1,12 @@ +fn main { + let test1 = "abc" + let test2 = "aba" + let a = @lib.is_palindrome(test1) + let b = @lib.is_palindrome(test2) + if a { + println(test1) // not print + } + if b { + println(test2) // print "aba" + } +} diff --git a/crates/moon/tests/test_cases/palindrome_string.in/main/moon.pkg.json b/crates/moon/tests/test_cases/palindrome_string.in/main/moon.pkg.json new file mode 100644 index 00000000..6852a912 --- /dev/null +++ b/crates/moon/tests/test_cases/palindrome_string.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "palindrome_string/lib": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/palindrome_string.in/moon.mod.json b/crates/moon/tests/test_cases/palindrome_string.in/moon.mod.json new file mode 100644 index 00000000..84c360fa --- /dev/null +++ b/crates/moon/tests/test_cases/palindrome_string.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "palindrome_string" +} diff --git a/crates/moon/tests/test_cases/panic.in/.gitignore b/crates/moon/tests/test_cases/panic.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/panic.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/panic.in/README.md b/crates/moon/tests/test_cases/panic.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/panic.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/panic.in/lib/hello.mbt b/crates/moon/tests/test_cases/panic.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/panic.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/panic.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/panic.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..a3ca2b95 --- /dev/null +++ b/crates/moon/tests/test_cases/panic.in/lib/hello_wbtest.mbt @@ -0,0 +1,9 @@ +fn panic() -> Unit = "%panic" + +test "panic" { + () +} + +test "panic_xxx" { + panic() +} diff --git a/crates/moon/tests/test_cases/panic.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/panic.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/panic.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/panic.in/main/main.mbt b/crates/moon/tests/test_cases/panic.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/panic.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/panic.in/main/moon.pkg.json b/crates/moon/tests/test_cases/panic.in/main/moon.pkg.json new file mode 100644 index 00000000..48783525 --- /dev/null +++ b/crates/moon/tests/test_cases/panic.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/panic.in/moon.mod.json b/crates/moon/tests/test_cases/panic.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/panic.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/render_no_location.in/lib/hello.mbt b/crates/moon/tests/test_cases/render_no_location.in/lib/hello.mbt new file mode 100644 index 00000000..a7ac2bee --- /dev/null +++ b/crates/moon/tests/test_cases/render_no_location.in/lib/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> String { + "Hello, world!" +} + diff --git a/crates/moon/tests/test_cases/render_no_location.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/render_no_location.in/lib/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/render_no_location.in/lib/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/render_no_location.in/main/main.mbt b/crates/moon/tests/test_cases/render_no_location.in/main/main.mbt new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/render_no_location.in/main/moon.pkg.json b/crates/moon/tests/test_cases/render_no_location.in/main/moon.pkg.json new file mode 100644 index 00000000..4343a4ef --- /dev/null +++ b/crates/moon/tests/test_cases/render_no_location.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "moon_new/lib": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/render_no_location.in/moon.mod.json b/crates/moon/tests/test_cases/render_no_location.in/moon.mod.json new file mode 100644 index 00000000..b5d8b346 --- /dev/null +++ b/crates/moon/tests/test_cases/render_no_location.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "moon_new" +} diff --git a/crates/moon/tests/test_cases/run_single_mbt_file.in/a/b/c/.gitkeep b/crates/moon/tests/test_cases/run_single_mbt_file.in/a/b/c/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/crates/moon/tests/test_cases/run_single_mbt_file.in/a/b/single.mbt b/crates/moon/tests/test_cases/run_single_mbt_file.in/a/b/single.mbt new file mode 100644 index 00000000..f55f3f18 --- /dev/null +++ b/crates/moon/tests/test_cases/run_single_mbt_file.in/a/b/single.mbt @@ -0,0 +1,3 @@ +fn main { + println("I am OK") +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/simple-pkg-A-001.in/A/lib.mbt b/crates/moon/tests/test_cases/simple-pkg-A-001.in/A/lib.mbt new file mode 100644 index 00000000..0c8ba57d --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-001.in/A/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("A") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-A-001.in/A/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-A-001.in/A/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-001.in/A/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/simple-pkg-A-001.in/main/main.mbt b/crates/moon/tests/test_cases/simple-pkg-A-001.in/main/main.mbt new file mode 100644 index 00000000..d45bceaf --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-001.in/main/main.mbt @@ -0,0 +1,4 @@ +fn main { + @A.f() + println("main") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-A-001.in/main/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-A-001.in/main/moon.pkg.json new file mode 100644 index 00000000..f6aaa8fe --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-001.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "hello/A": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/simple-pkg-A-001.in/moon.mod.json b/crates/moon/tests/test_cases/simple-pkg-A-001.in/moon.mod.json new file mode 100644 index 00000000..61113747 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-001.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "hello" +} diff --git a/crates/moon/tests/test_cases/simple-pkg-A-002.in/A/lib.mbt b/crates/moon/tests/test_cases/simple-pkg-A-002.in/A/lib.mbt new file mode 100644 index 00000000..0c8ba57d --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-002.in/A/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("A") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-A-002.in/A/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-A-002.in/A/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-002.in/A/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/simple-pkg-A-002.in/main/main.mbt b/crates/moon/tests/test_cases/simple-pkg-A-002.in/main/main.mbt new file mode 100644 index 00000000..d45bceaf --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-002.in/main/main.mbt @@ -0,0 +1,4 @@ +fn main { + @A.f() + println("main") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-A-002.in/main/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-A-002.in/main/moon.pkg.json new file mode 100644 index 00000000..f6aaa8fe --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-002.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "hello/A": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/simple-pkg-A-002.in/moon.mod.json b/crates/moon/tests/test_cases/simple-pkg-A-002.in/moon.mod.json new file mode 100644 index 00000000..61113747 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-002.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "hello" +} diff --git a/crates/moon/tests/test_cases/simple-pkg-A-003.in/A/lib.mbt b/crates/moon/tests/test_cases/simple-pkg-A-003.in/A/lib.mbt new file mode 100644 index 00000000..0c8ba57d --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-003.in/A/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("A") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-A-003.in/A/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-A-003.in/A/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-003.in/A/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/simple-pkg-A-003.in/main/main.mbt b/crates/moon/tests/test_cases/simple-pkg-A-003.in/main/main.mbt new file mode 100644 index 00000000..cd80519f --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-003.in/main/main.mbt @@ -0,0 +1,4 @@ +fn main { + @B.f() + println("main") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-A-003.in/main/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-A-003.in/main/moon.pkg.json new file mode 100644 index 00000000..0c5a0512 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-003.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "hello/A": "B" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/simple-pkg-A-003.in/moon.mod.json b/crates/moon/tests/test_cases/simple-pkg-A-003.in/moon.mod.json new file mode 100644 index 00000000..61113747 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-003.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "hello" +} diff --git a/crates/moon/tests/test_cases/simple-pkg-A-004.in/lib/A/lib.mbt b/crates/moon/tests/test_cases/simple-pkg-A-004.in/lib/A/lib.mbt new file mode 100644 index 00000000..0c8ba57d --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-004.in/lib/A/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("A") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-A-004.in/lib/A/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-A-004.in/lib/A/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-004.in/lib/A/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/simple-pkg-A-004.in/main/main.mbt b/crates/moon/tests/test_cases/simple-pkg-A-004.in/main/main.mbt new file mode 100644 index 00000000..d45bceaf --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-004.in/main/main.mbt @@ -0,0 +1,4 @@ +fn main { + @A.f() + println("main") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-A-004.in/main/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-A-004.in/main/moon.pkg.json new file mode 100644 index 00000000..30bde418 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-004.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "hello/lib/A": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/simple-pkg-A-004.in/moon.mod.json b/crates/moon/tests/test_cases/simple-pkg-A-004.in/moon.mod.json new file mode 100644 index 00000000..61113747 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-004.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "hello" +} diff --git a/crates/moon/tests/test_cases/simple-pkg-A-005.in/lib/A/lib.mbt b/crates/moon/tests/test_cases/simple-pkg-A-005.in/lib/A/lib.mbt new file mode 100644 index 00000000..0c8ba57d --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-005.in/lib/A/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("A") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-A-005.in/lib/A/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-A-005.in/lib/A/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-005.in/lib/A/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/simple-pkg-A-005.in/main/main.mbt b/crates/moon/tests/test_cases/simple-pkg-A-005.in/main/main.mbt new file mode 100644 index 00000000..cd80519f --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-005.in/main/main.mbt @@ -0,0 +1,4 @@ +fn main { + @B.f() + println("main") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-A-005.in/main/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-A-005.in/main/moon.pkg.json new file mode 100644 index 00000000..820a9d00 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-005.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "hello/lib/A": "B" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/simple-pkg-A-005.in/moon.mod.json b/crates/moon/tests/test_cases/simple-pkg-A-005.in/moon.mod.json new file mode 100644 index 00000000..61113747 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-005.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "hello" +} diff --git a/crates/moon/tests/test_cases/simple-pkg-A-006.in/main/main.mbt b/crates/moon/tests/test_cases/simple-pkg-A-006.in/main/main.mbt new file mode 100644 index 00000000..2442723f --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-006.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println("main") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-A-006.in/main/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-A-006.in/main/moon.pkg.json new file mode 100644 index 00000000..fcc86bad --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-006.in/main/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "is-main": true +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/simple-pkg-A-006.in/moon.mod.json b/crates/moon/tests/test_cases/simple-pkg-A-006.in/moon.mod.json new file mode 100644 index 00000000..61113747 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-A-006.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "hello" +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-001.in/A/lib.mbt b/crates/moon/tests/test_cases/simple-pkg-AB-001.in/A/lib.mbt new file mode 100644 index 00000000..0c8ba57d --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-001.in/A/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("A") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-001.in/A/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-AB-001.in/A/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-001.in/A/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-001.in/B/lib.mbt b/crates/moon/tests/test_cases/simple-pkg-AB-001.in/B/lib.mbt new file mode 100644 index 00000000..c1721c99 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-001.in/B/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("B") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-001.in/B/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-AB-001.in/B/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-001.in/B/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-001.in/main/main.mbt b/crates/moon/tests/test_cases/simple-pkg-AB-001.in/main/main.mbt new file mode 100644 index 00000000..737e3785 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-001.in/main/main.mbt @@ -0,0 +1,5 @@ +fn main { + @A.f() + @B.f() + println("main") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-001.in/main/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-AB-001.in/main/moon.pkg.json new file mode 100644 index 00000000..f65683f6 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-001.in/main/moon.pkg.json @@ -0,0 +1,7 @@ +{ + "is-main": true, + "import": { + "hello/B": "", + "hello/A": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-001.in/moon.mod.json b/crates/moon/tests/test_cases/simple-pkg-AB-001.in/moon.mod.json new file mode 100644 index 00000000..61113747 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-001.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "hello" +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-002.in/A/lib.mbt b/crates/moon/tests/test_cases/simple-pkg-AB-002.in/A/lib.mbt new file mode 100644 index 00000000..0c8ba57d --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-002.in/A/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("A") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-002.in/A/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-AB-002.in/A/moon.pkg.json new file mode 100644 index 00000000..72eb22fe --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-002.in/A/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-002.in/B/lib.mbt b/crates/moon/tests/test_cases/simple-pkg-AB-002.in/B/lib.mbt new file mode 100644 index 00000000..98f4a947 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-002.in/B/lib.mbt @@ -0,0 +1,4 @@ +pub fn f() -> Unit { + @A.f() + println("B") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-002.in/B/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-AB-002.in/B/moon.pkg.json new file mode 100644 index 00000000..d83e82ab --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-002.in/B/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": { + "hello/A": "" + } +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-002.in/main/main.mbt b/crates/moon/tests/test_cases/simple-pkg-AB-002.in/main/main.mbt new file mode 100644 index 00000000..cd80519f --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-002.in/main/main.mbt @@ -0,0 +1,4 @@ +fn main { + @B.f() + println("main") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-002.in/main/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-AB-002.in/main/moon.pkg.json new file mode 100644 index 00000000..64810155 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-002.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "hello/B": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-002.in/moon.mod.json b/crates/moon/tests/test_cases/simple-pkg-AB-002.in/moon.mod.json new file mode 100644 index 00000000..61113747 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-002.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "hello" +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-003.in/A/lib.mbt b/crates/moon/tests/test_cases/simple-pkg-AB-003.in/A/lib.mbt new file mode 100644 index 00000000..0c8ba57d --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-003.in/A/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("A") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-003.in/A/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-AB-003.in/A/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-003.in/A/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-003.in/B/lib.mbt b/crates/moon/tests/test_cases/simple-pkg-AB-003.in/B/lib.mbt new file mode 100644 index 00000000..c1721c99 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-003.in/B/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("B") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-003.in/B/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-AB-003.in/B/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-003.in/B/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-003.in/main/main.mbt b/crates/moon/tests/test_cases/simple-pkg-AB-003.in/main/main.mbt new file mode 100644 index 00000000..6264270b --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-003.in/main/main.mbt @@ -0,0 +1,5 @@ +fn main { + @C.f() + @D.f() + println("main") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-003.in/main/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-AB-003.in/main/moon.pkg.json new file mode 100644 index 00000000..141b259b --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-003.in/main/moon.pkg.json @@ -0,0 +1,7 @@ +{ + "is-main": true, + "import": { + "hello/A": "C", + "hello/B": "D" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-003.in/moon.mod.json b/crates/moon/tests/test_cases/simple-pkg-AB-003.in/moon.mod.json new file mode 100644 index 00000000..61113747 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-003.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "hello" +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-004.in/A/lib.mbt b/crates/moon/tests/test_cases/simple-pkg-AB-004.in/A/lib.mbt new file mode 100644 index 00000000..0c8ba57d --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-004.in/A/lib.mbt @@ -0,0 +1,3 @@ +pub fn f() -> Unit { + println("A") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-004.in/A/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-AB-004.in/A/moon.pkg.json new file mode 100644 index 00000000..9585a087 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-004.in/A/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "import": {} +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-004.in/B/lib.mbt b/crates/moon/tests/test_cases/simple-pkg-AB-004.in/B/lib.mbt new file mode 100644 index 00000000..98f4a947 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-004.in/B/lib.mbt @@ -0,0 +1,4 @@ +pub fn f() -> Unit { + @A.f() + println("B") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-004.in/B/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-AB-004.in/B/moon.pkg.json new file mode 100644 index 00000000..d83e82ab --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-004.in/B/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": { + "hello/A": "" + } +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-004.in/main/main.mbt b/crates/moon/tests/test_cases/simple-pkg-AB-004.in/main/main.mbt new file mode 100644 index 00000000..18d58f4c --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-004.in/main/main.mbt @@ -0,0 +1,4 @@ +fn main { + @D.f() + println("main") +} diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-004.in/main/moon.pkg.json b/crates/moon/tests/test_cases/simple-pkg-AB-004.in/main/moon.pkg.json new file mode 100644 index 00000000..d6d6583a --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-004.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "hello/B": "D" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/simple-pkg-AB-004.in/moon.mod.json b/crates/moon/tests/test_cases/simple-pkg-AB-004.in/moon.mod.json new file mode 100644 index 00000000..61113747 --- /dev/null +++ b/crates/moon/tests/test_cases/simple-pkg-AB-004.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "hello" +} diff --git a/crates/moon/tests/test_cases/target-backend.in/lib/hello.mbt b/crates/moon/tests/test_cases/target-backend.in/lib/hello.mbt new file mode 100644 index 00000000..a7ac2bee --- /dev/null +++ b/crates/moon/tests/test_cases/target-backend.in/lib/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> String { + "Hello, world!" +} + diff --git a/crates/moon/tests/test_cases/target-backend.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/target-backend.in/lib/moon.pkg.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/crates/moon/tests/test_cases/target-backend.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} diff --git a/crates/moon/tests/test_cases/target-backend.in/main/main.mbt b/crates/moon/tests/test_cases/target-backend.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/target-backend.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/target-backend.in/main/moon.pkg.json b/crates/moon/tests/test_cases/target-backend.in/main/moon.pkg.json new file mode 100644 index 00000000..0dccc0db --- /dev/null +++ b/crates/moon/tests/test_cases/target-backend.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": { + "hello/lib": "" + } +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/target-backend.in/moon.mod.json b/crates/moon/tests/test_cases/target-backend.in/moon.mod.json new file mode 100644 index 00000000..61113747 --- /dev/null +++ b/crates/moon/tests/test_cases/target-backend.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "hello" +} diff --git a/crates/moon/tests/test_cases/test_deny_warn.in/.gitignore b/crates/moon/tests/test_cases/test_deny_warn.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/test_deny_warn.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/test_deny_warn.in/README.md b/crates/moon/tests/test_cases/test_deny_warn.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/test_deny_warn.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_deny_warn.in/lib/hello.mbt b/crates/moon/tests/test_cases/test_deny_warn.in/lib/hello.mbt new file mode 100644 index 00000000..be6fb4f8 --- /dev/null +++ b/crates/moon/tests/test_cases/test_deny_warn.in/lib/hello.mbt @@ -0,0 +1,23 @@ +// 中文中文中文中文中文中文 +// 🤣😭🤣😭🤣😭🤣😭🤣😭🤣😭🤣😭🤣😭🤣😭🤣😭🤣😭🤣😭🤣🤣😭🤣😭🤣🤣😭🤣😭🤣🤣😭🤣😭🤣🤣😭🤣😭🤣😭🤣😭🤣😭 +test { + let a = 1; + // 中文中文中文中文中文中文 + // 中文中文中文中文中文中文 + // 中文中文中文中文中文中文 + // 🤣😭🤣😭🤣😭🤣😭🤣😭 + // 🤣😭🤣😭🤣😭🤣😭🤣😭 + // 🤣😭🤣😭🤣😭🤣😭🤣😭 + let 中文 = 2 + let 🤣😭🤣😭🤣 = 2 + alert_1(); + alert_2(); +} + +/// @alert alert_1 "alert_1" +fn alert_1() -> Unit { +} + +/// @alert alert_2 "alert_2" +fn alert_2() -> Unit { +} diff --git a/crates/moon/tests/test_cases/test_deny_warn.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/test_deny_warn.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/test_deny_warn.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_deny_warn.in/main/main.mbt b/crates/moon/tests/test_cases/test_deny_warn.in/main/main.mbt new file mode 100644 index 00000000..1ff0d94b --- /dev/null +++ b/crates/moon/tests/test_cases/test_deny_warn.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + let a = 0 +} diff --git a/crates/moon/tests/test_cases/test_deny_warn.in/main/moon.pkg.json b/crates/moon/tests/test_cases/test_deny_warn.in/main/moon.pkg.json new file mode 100644 index 00000000..48783525 --- /dev/null +++ b/crates/moon/tests/test_cases/test_deny_warn.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_deny_warn.in/moon.mod.json b/crates/moon/tests/test_cases/test_deny_warn.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/test_deny_warn.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_error_report.in/.gitignore b/crates/moon/tests/test_cases/test_error_report.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/test_error_report.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/test_error_report.in/lib/hello.mbt b/crates/moon/tests/test_cases/test_error_report.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/test_error_report.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/test_error_report.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/test_error_report.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..c9a46222 --- /dev/null +++ b/crates/moon/tests/test_cases/test_error_report.in/lib/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test { + if hello() != "Hello, world!" { + abort("") + } +} diff --git a/crates/moon/tests/test_cases/test_error_report.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/test_error_report.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/test_error_report.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_error_report.in/main/main.mbt b/crates/moon/tests/test_cases/test_error_report.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/test_error_report.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/test_error_report.in/main/moon.pkg.json b/crates/moon/tests/test_cases/test_error_report.in/main/moon.pkg.json new file mode 100644 index 00000000..dc2de995 --- /dev/null +++ b/crates/moon/tests/test_cases/test_error_report.in/main/moon.pkg.json @@ -0,0 +1,7 @@ +{ + "is-main": true, + "import": [ + "moonbitlang/report/lib", + "haha" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_error_report.in/moon.mod.json b/crates/moon/tests/test_cases/test_error_report.in/moon.mod.json new file mode 100644 index 00000000..6bacbee0 --- /dev/null +++ b/crates/moon/tests/test_cases/test_error_report.in/moon.mod.json @@ -0,0 +1,4 @@ +{ + "name": "moonbitlang/report", + "version": "0.1.0" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter.in/A/hello.mbt b/crates/moon/tests/test_cases/test_filter.in/A/hello.mbt new file mode 100644 index 00000000..59d483e5 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter.in/A/hello.mbt @@ -0,0 +1,11 @@ +pub fn hello() -> String { + "Hello, world!" +} + +test "A" { + println("test A") +} + +test "B" { + println("test B") +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter.in/A/hello_wbtest.mbt b/crates/moon/tests/test_cases/test_filter.in/A/hello_wbtest.mbt new file mode 100644 index 00000000..6cfb19cc --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter.in/A/hello_wbtest.mbt @@ -0,0 +1,11 @@ +test "hello_0" { + println("test hello_0") +} + +test "hello_1" { + println("test hello_1") +} + +test "hello_2" { + println("test hello_2") +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter.in/A/moon.pkg.json b/crates/moon/tests/test_cases/test_filter.in/A/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter.in/A/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter.in/A/test.mbt b/crates/moon/tests/test_cases/test_filter.in/A/test.mbt new file mode 100644 index 00000000..2724e784 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter.in/A/test.mbt @@ -0,0 +1,7 @@ +test "C" { + println("test C") +} + +test "D" { + println("test D") +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter.in/lib/hello.mbt b/crates/moon/tests/test_cases/test_filter.in/lib/hello.mbt new file mode 100644 index 00000000..3f8d87f5 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter.in/lib/hello.mbt @@ -0,0 +1,7 @@ +pub fn hello() -> String { + "Hello, world!" +} + +test "A" { + println("test A") +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/test_filter.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..127a51c4 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter.in/lib/hello_wbtest.mbt @@ -0,0 +1,7 @@ +test "hello_0" { + println("test hello_0") +} + +test "hello_1" { + println("test hello_1") +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/test_filter.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter.in/lib2/lib.mbt b/crates/moon/tests/test_cases/test_filter.in/lib2/lib.mbt new file mode 100644 index 00000000..43c786ca --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter.in/lib2/lib.mbt @@ -0,0 +1,14 @@ +test { + println(2) +} + +test { + inspect(1)! + inspect(1 + 2)! + inspect("hello")! + inspect([1, 2, 3])! +} + +test { + inspect(2)! +} diff --git a/crates/moon/tests/test_cases/test_filter.in/lib2/moon.pkg.json b/crates/moon/tests/test_cases/test_filter.in/lib2/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter.in/lib2/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter.in/main/main.mbt b/crates/moon/tests/test_cases/test_filter.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/test_filter.in/main/moon.pkg.json b/crates/moon/tests/test_cases/test_filter.in/main/moon.pkg.json new file mode 100644 index 00000000..48783525 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter.in/moon.mod.json b/crates/moon/tests/test_cases/test_filter.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib/lib.mbt b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib/lib.mbt new file mode 100644 index 00000000..f0efadaa --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib/lib.mbt @@ -0,0 +1,3 @@ +test "hello_lib" { + println(@lib1.hello_from_lib1()) +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib/moon.pkg.json new file mode 100644 index 00000000..a2234e6f --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": [ + "username/hello/lib1" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib1/lib.mbt b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib1/lib.mbt new file mode 100644 index 00000000..23667fd7 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib1/lib.mbt @@ -0,0 +1,10 @@ +pub fn hello_from_lib1() -> String { + println("Hello from lib1") + println(@lib2.hello_from_lib2()) + println(@lib3.hello_from_lib3()) + "" +} + +test { + println(hello_from_lib1()) +} diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib1/moon.pkg.json b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib1/moon.pkg.json new file mode 100644 index 00000000..98e4a2c1 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib1/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "import": [ + "username/hello/lib2", + "username/hello/lib3" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib2/lib.mbt b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib2/lib.mbt new file mode 100644 index 00000000..d7d388b1 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib2/lib.mbt @@ -0,0 +1,9 @@ +pub fn hello_from_lib2() -> String { + println("Hello from lib2") + println(@lib4.hello_from_lib4()) + "" +} + +test { + println(hello_from_lib2()) +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib2/moon.pkg.json b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib2/moon.pkg.json new file mode 100644 index 00000000..65fc5a43 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib2/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": [ + "username/hello/lib4" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib3/lib.mbt b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib3/lib.mbt new file mode 100644 index 00000000..d027340a --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib3/lib.mbt @@ -0,0 +1,9 @@ +pub fn hello_from_lib3() -> String { + println("Hello from lib3") + println(@lib4.hello_from_lib4()) + "" +} + +test { + println(hello_from_lib3()) +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib3/moon.pkg.json b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib3/moon.pkg.json new file mode 100644 index 00000000..65fc5a43 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib3/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": [ + "username/hello/lib4" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib4/lib.mbt b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib4/lib.mbt new file mode 100644 index 00000000..90e8b5d1 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib4/lib.mbt @@ -0,0 +1,7 @@ +pub fn hello_from_lib4() -> String { + "Hello from lib4" +} + +test { + println(hello_from_lib4()) +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib4/moon.pkg.json b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib4/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/lib4/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/main/main.mbt b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/main/moon.pkg.json b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/main/moon.pkg.json new file mode 100644 index 00000000..48783525 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/moon.mod.json b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_deps.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib/_wbtest.mbt b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib/_wbtest.mbt new file mode 100644 index 00000000..e9daf1f7 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib/_wbtest.mbt @@ -0,0 +1,3 @@ +test "hello_lib" { + println(@lib7.hello_from_lib7()) +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib/lib.mbt b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib/lib.mbt new file mode 100644 index 00000000..def58d0b --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib/lib.mbt @@ -0,0 +1,4 @@ +test "hello_lib" { + println(@lib1.hello_from_lib1()) + println(@lib2.hello_from_lib2()) +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib/moon.pkg.json new file mode 100644 index 00000000..8a53af12 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib/moon.pkg.json @@ -0,0 +1,9 @@ +{ + "import": [ + "username/hello/lib1", + "username/hello/lib2" + ], + "wbtest-import": [ + "username/hello/lib7" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib1/lib.mbt b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib1/lib.mbt new file mode 100644 index 00000000..c177e326 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib1/lib.mbt @@ -0,0 +1,9 @@ +pub fn hello_from_lib1() -> String { + println("Hello from lib1") + + "" +} + +test { + println(@lib3.hello_from_lib3()) +} diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib1/moon.pkg.json b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib1/moon.pkg.json new file mode 100644 index 00000000..e01e4913 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib1/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": [ + "username/hello/lib3" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib2/lib.mbt b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib2/lib.mbt new file mode 100644 index 00000000..b9976f7d --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib2/lib.mbt @@ -0,0 +1,9 @@ +pub fn hello_from_lib2() -> String { + println("Hello from lib2") + + "" +} + +test { + println(@lib4.hello_from_lib4()) +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib2/moon.pkg.json b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib2/moon.pkg.json new file mode 100644 index 00000000..65fc5a43 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib2/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": [ + "username/hello/lib4" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib3/_wbtest.mbt b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib3/_wbtest.mbt new file mode 100644 index 00000000..e931fd42 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib3/_wbtest.mbt @@ -0,0 +1,3 @@ +test { + println(@lib6.hello_from_lib6()) +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib3/lib.mbt b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib3/lib.mbt new file mode 100644 index 00000000..f9246c55 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib3/lib.mbt @@ -0,0 +1,13 @@ +pub fn hello_from_lib3() -> String { + println("Hello from lib3") + "" +} + +test { + println(hello_from_lib3()) +} + + +test { + println(@lib7.hello_from_lib7()) +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib3/moon.pkg.json b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib3/moon.pkg.json new file mode 100644 index 00000000..737ec956 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib3/moon.pkg.json @@ -0,0 +1,11 @@ +{ + /* */ + "import": [ + "username/hello/lib7" + ], + // + "wbtest-import": [ + "username/hello/lib5", + "username/hello/lib6" + ], +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib4/_wbtest.mbt b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib4/_wbtest.mbt new file mode 100644 index 00000000..d035b5db --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib4/_wbtest.mbt @@ -0,0 +1,7 @@ +test { + println(@lib5.hello_from_lib5()) +} + +test { + println(@lib7.hello_from_lib7()) +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib4/lib.mbt b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib4/lib.mbt new file mode 100644 index 00000000..f4948367 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib4/lib.mbt @@ -0,0 +1,8 @@ +pub fn hello_from_lib4() -> String { + "Hello from lib4" +} + +test { + println(@lib5.hello_from_lib5()) +} + diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib4/moon.pkg.json b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib4/moon.pkg.json new file mode 100644 index 00000000..55a5d9d7 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib4/moon.pkg.json @@ -0,0 +1,8 @@ +{ + "import": [ + "username/hello/lib5" + ], + "wbtest-import": [ + "username/hello/lib7" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib5/lib.mbt b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib5/lib.mbt new file mode 100644 index 00000000..841f9833 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib5/lib.mbt @@ -0,0 +1,7 @@ +pub fn hello_from_lib5() -> String { + "Hello from lib5" +} + +test { + println(hello_from_lib5()) +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib5/moon.pkg.json b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib5/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib5/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib6/lib.mbt b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib6/lib.mbt new file mode 100644 index 00000000..16ac38be --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib6/lib.mbt @@ -0,0 +1,7 @@ +pub fn hello_from_lib6() -> String { + "Hello from lib6" +} + +test { + println(hello_from_lib6()) +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib6/moon.pkg.json b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib6/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib6/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib7/_wbtest.mbt b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib7/_wbtest.mbt new file mode 100644 index 00000000..e931fd42 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib7/_wbtest.mbt @@ -0,0 +1,3 @@ +test { + println(@lib6.hello_from_lib6()) +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib7/lib.mbt b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib7/lib.mbt new file mode 100644 index 00000000..d9f1296c --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib7/lib.mbt @@ -0,0 +1,7 @@ +pub fn hello_from_lib7() -> String { + "Hello from lib7" +} + +test { + println(hello_from_lib7()) +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib7/moon.pkg.json b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib7/moon.pkg.json new file mode 100644 index 00000000..3f88af0f --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/lib7/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "wbtest-import": [ + "username/hello/lib6" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/main/main.mbt b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/main/moon.pkg.json b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/main/moon.pkg.json new file mode 100644 index 00000000..48783525 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/moon.mod.json b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/moon.mod.json new file mode 100644 index 00000000..42ed3b56 --- /dev/null +++ b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/moon.mod.json @@ -0,0 +1,11 @@ +{ + "name": "username/hello", + "version": "0.1.0", + /* */ + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + // + "description": "", +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/test_moon_test_filter_package_with_test_imports.drawio.png b/crates/moon/tests/test_cases/test_filter_pkg_with_test_imports.in/test_moon_test_filter_package_with_test_imports.drawio.png new file mode 100644 index 0000000000000000000000000000000000000000..6f446c6b14ba892aff71cf4843ad8b9ac575adeb GIT binary patch literal 40274 zcmeEu1wfS9zBr7df`Sa7(h4FX(v5UThbSf89V0D+lqjNrB1oq}izrB_44??oNC*;w z0m6V7ghkITy6Gl*zZzZzCciB3D&8a-4_= zg(o5+eoe9ko>&KOX@vg~dmdMoC%WCnNFX9o*yp8q!prrPoui8_5u2dG_fKpBd=6Mo zFE+s=Yytw7Cr|R&I9l3!Sh{-hxY>HaBN%tZ+Bn)d+S+`dBfuvh#LXwfEy$W*+4C1F8P9zhX!d{A9QS5t#c zKmk6xI6B+H|CDX5ow3Lg1qTnTD?Cx+7ZBp%L;i(_I+k{p9*)0w1#&Z6FH8IHx6;wm zIeGGw^$}Ymeh23hYU-kT%J6Drj*qQ}rz6&F{qjOQf;{}+2fX}F+J1j(W9#E+4I3iU zJ*_QW)*r9Wv%-4V*m``Q2`3R?6I5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wDZ4SMxKxeSjn6i*%Cw1wCir+xcen?b}a4BZQ! z?bQdpon5j9F^Fz!NPx<;L75jmAiwX&r3;JIov`>l44pijw%Kd}y$w4JycBmF|NTOr zSKlq8X*|Y6-1DW+Er|8J&Ku*&S&Ny+wnJ8j6(l=Ky%5=_D-P;R1hKpI z>aPW)B$so4aO=h|!DZ)<1ZLQvu30haZ!+g^@t)7YF;Q#&ch^N+$}58T(t5Lvyx-Pj zv{_)bVQN!_#KjAJ#xISaIQf^IEwIP%*75r_a9bK=>VQW#ev)#X0(GuLfdX-GiLTMk jG73ubfYa9WN)Zk_mlU(Zs!mf3{;Ut#9W1ms@zdV`n*euD literal 0 HcmV?d00001 diff --git a/crates/moon/tests/test_cases/test_import/.gitignore b/crates/moon/tests/test_cases/test_import/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/test_import/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/test_import/README.md b/crates/moon/tests/test_cases/test_import/README.md new file mode 100644 index 00000000..9d26e38a --- /dev/null +++ b/crates/moon/tests/test_cases/test_import/README.md @@ -0,0 +1,11 @@ +# username/hello + +``` + s t + \ /(timport) + a + / \ +b c + \ / + main +``` diff --git a/crates/moon/tests/test_cases/test_import/a/a.mbt b/crates/moon/tests/test_cases/test_import/a/a.mbt new file mode 100644 index 00000000..ce4dddf3 --- /dev/null +++ b/crates/moon/tests/test_cases/test_import/a/a.mbt @@ -0,0 +1,7 @@ +pub fn a() -> String { + "a" +} + +test "a_import_s" { + println(@s.s()) +} diff --git a/crates/moon/tests/test_cases/test_import/a/a_wbtest.mbt b/crates/moon/tests/test_cases/test_import/a/a_wbtest.mbt new file mode 100644 index 00000000..b1039b4d --- /dev/null +++ b/crates/moon/tests/test_cases/test_import/a/a_wbtest.mbt @@ -0,0 +1,3 @@ +test "a_test_imported_t" { + println(@t.t()) +} diff --git a/crates/moon/tests/test_cases/test_import/a/moon.pkg.json b/crates/moon/tests/test_cases/test_import/a/moon.pkg.json new file mode 100644 index 00000000..00b2d78a --- /dev/null +++ b/crates/moon/tests/test_cases/test_import/a/moon.pkg.json @@ -0,0 +1,8 @@ +{ + "import": [ + "username/hello/s" + ], + "wbtest-import": [ + "username/hello/t" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_import/b/b.mbt b/crates/moon/tests/test_cases/test_import/b/b.mbt new file mode 100644 index 00000000..351d81c7 --- /dev/null +++ b/crates/moon/tests/test_cases/test_import/b/b.mbt @@ -0,0 +1,3 @@ +pub fn b() -> String { + "b" +} diff --git a/crates/moon/tests/test_cases/test_import/b/moon.pkg.json b/crates/moon/tests/test_cases/test_import/b/moon.pkg.json new file mode 100644 index 00000000..d90ce5a4 --- /dev/null +++ b/crates/moon/tests/test_cases/test_import/b/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": [ + "username/hello/a" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_import/c/c.mbt b/crates/moon/tests/test_cases/test_import/c/c.mbt new file mode 100644 index 00000000..b448aca9 --- /dev/null +++ b/crates/moon/tests/test_cases/test_import/c/c.mbt @@ -0,0 +1,3 @@ +pub fn c() -> String { + "c" +} diff --git a/crates/moon/tests/test_cases/test_import/c/moon.pkg.json b/crates/moon/tests/test_cases/test_import/c/moon.pkg.json new file mode 100644 index 00000000..d90ce5a4 --- /dev/null +++ b/crates/moon/tests/test_cases/test_import/c/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": [ + "username/hello/a" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_import/main/main.mbt b/crates/moon/tests/test_cases/test_import/main/main.mbt new file mode 100644 index 00000000..56b05088 --- /dev/null +++ b/crates/moon/tests/test_cases/test_import/main/main.mbt @@ -0,0 +1,4 @@ +fn main { + println(@b.b()) + println(@c.c()) +} diff --git a/crates/moon/tests/test_cases/test_import/main/moon.pkg.json b/crates/moon/tests/test_cases/test_import/main/moon.pkg.json new file mode 100644 index 00000000..6be56b3d --- /dev/null +++ b/crates/moon/tests/test_cases/test_import/main/moon.pkg.json @@ -0,0 +1,7 @@ +{ + "is-main": true, + "import": [ + "username/hello/b", + "username/hello/c" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_import/moon.mod.json b/crates/moon/tests/test_cases/test_import/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/test_import/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_import/s/moon.pkg.json b/crates/moon/tests/test_cases/test_import/s/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/test_import/s/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_import/s/t.mbt b/crates/moon/tests/test_cases/test_import/s/t.mbt new file mode 100644 index 00000000..bbbc1353 --- /dev/null +++ b/crates/moon/tests/test_cases/test_import/s/t.mbt @@ -0,0 +1,3 @@ +pub fn s() -> String { + "s" +} diff --git a/crates/moon/tests/test_cases/test_import/t/moon.pkg.json b/crates/moon/tests/test_cases/test_import/t/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/test_import/t/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_import/t/t.mbt b/crates/moon/tests/test_cases/test_import/t/t.mbt new file mode 100644 index 00000000..e90bc10d --- /dev/null +++ b/crates/moon/tests/test_cases/test_import/t/t.mbt @@ -0,0 +1,3 @@ +pub fn t() -> String { + "t" +} diff --git a/crates/moon/tests/test_cases/test_many_targets.in/.gitignore b/crates/moon/tests/test_cases/test_many_targets.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/test_many_targets.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/test_many_targets.in/lib/hello.mbt b/crates/moon/tests/test_cases/test_many_targets.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/test_many_targets.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/test_many_targets.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/test_many_targets.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/test_many_targets.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_many_targets.in/link/hello.mbt b/crates/moon/tests/test_cases/test_many_targets.in/link/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/test_many_targets.in/link/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/test_many_targets.in/link/moon.pkg.json b/crates/moon/tests/test_cases/test_many_targets.in/link/moon.pkg.json new file mode 100644 index 00000000..8873c9d1 --- /dev/null +++ b/crates/moon/tests/test_cases/test_many_targets.in/link/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "link": true +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_many_targets.in/moon.mod.json b/crates/moon/tests/test_cases/test_many_targets.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/test_many_targets.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_many_targets_auto_update.in/.gitignore b/crates/moon/tests/test_cases/test_many_targets_auto_update.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/test_many_targets_auto_update.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/test_many_targets_auto_update.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/test_many_targets_auto_update.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/test_many_targets_auto_update.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_many_targets_auto_update.in/lib/x.js.mbt b/crates/moon/tests/test_cases/test_many_targets_auto_update.in/lib/x.js.mbt new file mode 100644 index 00000000..5fa4c0b7 --- /dev/null +++ b/crates/moon/tests/test_cases/test_many_targets_auto_update.in/lib/x.js.mbt @@ -0,0 +1,3 @@ +test { + inspect!("js") +} diff --git a/crates/moon/tests/test_cases/test_many_targets_auto_update.in/lib/x.wasm-gc.mbt b/crates/moon/tests/test_cases/test_many_targets_auto_update.in/lib/x.wasm-gc.mbt new file mode 100644 index 00000000..78737e6e --- /dev/null +++ b/crates/moon/tests/test_cases/test_many_targets_auto_update.in/lib/x.wasm-gc.mbt @@ -0,0 +1,3 @@ +test { + inspect!("wasm-gc") +} diff --git a/crates/moon/tests/test_cases/test_many_targets_auto_update.in/lib/x.wasm.mbt b/crates/moon/tests/test_cases/test_many_targets_auto_update.in/lib/x.wasm.mbt new file mode 100644 index 00000000..70b6f829 --- /dev/null +++ b/crates/moon/tests/test_cases/test_many_targets_auto_update.in/lib/x.wasm.mbt @@ -0,0 +1,3 @@ +test { + inspect!("wasm") +} diff --git a/crates/moon/tests/test_cases/test_many_targets_auto_update.in/moon.mod.json b/crates/moon/tests/test_cases/test_many_targets_auto_update.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/test_many_targets_auto_update.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_many_targets_expect_failed.in/.gitignore b/crates/moon/tests/test_cases/test_many_targets_expect_failed.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/test_many_targets_expect_failed.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/test_many_targets_expect_failed.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/test_many_targets_expect_failed.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/test_many_targets_expect_failed.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_many_targets_expect_failed.in/lib/x.js.mbt b/crates/moon/tests/test_cases/test_many_targets_expect_failed.in/lib/x.js.mbt new file mode 100644 index 00000000..a0dd4415 --- /dev/null +++ b/crates/moon/tests/test_cases/test_many_targets_expect_failed.in/lib/x.js.mbt @@ -0,0 +1,3 @@ +test { + inspect!("js", content="2") +} diff --git a/crates/moon/tests/test_cases/test_many_targets_expect_failed.in/lib/x.wasm-gc.mbt b/crates/moon/tests/test_cases/test_many_targets_expect_failed.in/lib/x.wasm-gc.mbt new file mode 100644 index 00000000..abe9ff37 --- /dev/null +++ b/crates/moon/tests/test_cases/test_many_targets_expect_failed.in/lib/x.wasm-gc.mbt @@ -0,0 +1,3 @@ +test { + inspect!("wasm-gc", content="1") +} diff --git a/crates/moon/tests/test_cases/test_many_targets_expect_failed.in/lib/x.wasm.mbt b/crates/moon/tests/test_cases/test_many_targets_expect_failed.in/lib/x.wasm.mbt new file mode 100644 index 00000000..37ec76f5 --- /dev/null +++ b/crates/moon/tests/test_cases/test_many_targets_expect_failed.in/lib/x.wasm.mbt @@ -0,0 +1,3 @@ +test { + inspect!("wasm", content="0") +} diff --git a/crates/moon/tests/test_cases/test_many_targets_expect_failed.in/moon.mod.json b/crates/moon/tests/test_cases/test_many_targets_expect_failed.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/test_many_targets_expect_failed.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_multi_process/.gitignore b/crates/moon/tests/test_cases/test_multi_process/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/test_multi_process/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/test_multi_process/README.md b/crates/moon/tests/test_cases/test_multi_process/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/test_multi_process/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_multi_process/lib/hello.mbt b/crates/moon/tests/test_cases/test_multi_process/lib/hello.mbt new file mode 100644 index 00000000..0751c426 --- /dev/null +++ b/crates/moon/tests/test_cases/test_multi_process/lib/hello.mbt @@ -0,0 +1,13 @@ +test { + let a = 1; + alert_1(); + alert_2(); +} + +/// @alert alert_1 "alert_1" +fn alert_1() -> Unit { +} + +/// @alert alert_2 "alert_2" +fn alert_2() -> Unit { +} diff --git a/crates/moon/tests/test_cases/test_multi_process/lib/moon.pkg.json b/crates/moon/tests/test_cases/test_multi_process/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/test_multi_process/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_multi_process/main/main.mbt b/crates/moon/tests/test_cases/test_multi_process/main/main.mbt new file mode 100644 index 00000000..1ff0d94b --- /dev/null +++ b/crates/moon/tests/test_cases/test_multi_process/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + let a = 0 +} diff --git a/crates/moon/tests/test_cases/test_multi_process/main/moon.pkg.json b/crates/moon/tests/test_cases/test_multi_process/main/moon.pkg.json new file mode 100644 index 00000000..48783525 --- /dev/null +++ b/crates/moon/tests/test_cases/test_multi_process/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_multi_process/moon.mod.json b/crates/moon/tests/test_cases/test_multi_process/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/test_multi_process/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_release.in/lib/hello.mbt b/crates/moon/tests/test_cases/test_release.in/lib/hello.mbt new file mode 100644 index 00000000..3f8d87f5 --- /dev/null +++ b/crates/moon/tests/test_cases/test_release.in/lib/hello.mbt @@ -0,0 +1,7 @@ +pub fn hello() -> String { + "Hello, world!" +} + +test "A" { + println("test A") +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_release.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/test_release.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..127a51c4 --- /dev/null +++ b/crates/moon/tests/test_cases/test_release.in/lib/hello_wbtest.mbt @@ -0,0 +1,7 @@ +test "hello_0" { + println("test hello_0") +} + +test "hello_1" { + println("test hello_1") +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_release.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/test_release.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/test_release.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_release.in/main/main.mbt b/crates/moon/tests/test_cases/test_release.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/test_release.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/test_release.in/main/moon.pkg.json b/crates/moon/tests/test_cases/test_release.in/main/moon.pkg.json new file mode 100644 index 00000000..48783525 --- /dev/null +++ b/crates/moon/tests/test_cases/test_release.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_release.in/moon.mod.json b/crates/moon/tests/test_cases/test_release.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/test_release.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/third_party.in/.gitignore b/crates/moon/tests/test_cases/third_party.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/third_party.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/third_party.in/README.md b/crates/moon/tests/test_cases/third_party.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/third_party.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/third_party.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/third_party.in/lib/moon.pkg.json new file mode 100644 index 00000000..5eec2d42 --- /dev/null +++ b/crates/moon/tests/test_cases/third_party.in/lib/moon.pkg.json @@ -0,0 +1,5 @@ +{ + "import": [ + "lijunchen/hello18/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/third_party.in/lib/test.mbt b/crates/moon/tests/test_cases/third_party.in/lib/test.mbt new file mode 100644 index 00000000..32d0e7d3 --- /dev/null +++ b/crates/moon/tests/test_cases/third_party.in/lib/test.mbt @@ -0,0 +1,8 @@ + +test { + println("Hello, world!") +} + +test { + println(@lib.hello()) +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/third_party.in/main/main.mbt b/crates/moon/tests/test_cases/third_party.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/third_party.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/third_party.in/main/moon.pkg.json b/crates/moon/tests/test_cases/third_party.in/main/moon.pkg.json new file mode 100644 index 00000000..73e5b5bb --- /dev/null +++ b/crates/moon/tests/test_cases/third_party.in/main/moon.pkg.json @@ -0,0 +1,6 @@ +{ + "is-main": true, + "import": [ + "lijunchen/hello18/lib" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/third_party.in/moon.mod.json b/crates/moon/tests/test_cases/third_party.in/moon.mod.json new file mode 100644 index 00000000..53bf182f --- /dev/null +++ b/crates/moon/tests/test_cases/third_party.in/moon.mod.json @@ -0,0 +1,12 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "deps": { + "lijunchen/hello18": "0.1.30" + }, + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/unicode_demo.in/README.md b/crates/moon/tests/test_cases/unicode_demo.in/README.md new file mode 100644 index 00000000..2a12ed6d --- /dev/null +++ b/crates/moon/tests/test_cases/unicode_demo.in/README.md @@ -0,0 +1,3 @@ +## Moonbit Unicode + +We can use emoji in Moonbit now :) diff --git a/crates/moon/tests/test_cases/unicode_demo.in/main/main.mbt b/crates/moon/tests/test_cases/unicode_demo.in/main/main.mbt new file mode 100644 index 00000000..0a3643c8 --- /dev/null +++ b/crates/moon/tests/test_cases/unicode_demo.in/main/main.mbt @@ -0,0 +1,4 @@ +fn main { + let 🤣 = 3 + println(🤣) +} diff --git a/crates/moon/tests/test_cases/unicode_demo.in/main/moon.pkg.json b/crates/moon/tests/test_cases/unicode_demo.in/main/moon.pkg.json new file mode 100644 index 00000000..d48c4d24 --- /dev/null +++ b/crates/moon/tests/test_cases/unicode_demo.in/main/moon.pkg.json @@ -0,0 +1,4 @@ +{ + "is-main": true, + "import": {} +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/unicode_demo.in/moon.mod.json b/crates/moon/tests/test_cases/unicode_demo.in/moon.mod.json new file mode 100644 index 00000000..40cfbab1 --- /dev/null +++ b/crates/moon/tests/test_cases/unicode_demo.in/moon.mod.json @@ -0,0 +1,3 @@ +{ + "name": "unicode_demo" +} diff --git a/crates/moon/tests/test_cases/validate_import.in/.gitignore b/crates/moon/tests/test_cases/validate_import.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/validate_import.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/validate_import.in/README.md b/crates/moon/tests/test_cases/validate_import.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/validate_import.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/validate_import.in/lib/hello.mbt b/crates/moon/tests/test_cases/validate_import.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/validate_import.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/validate_import.in/lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/validate_import.in/lib/hello_wbtest.mbt new file mode 100644 index 00000000..64f26429 --- /dev/null +++ b/crates/moon/tests/test_cases/validate_import.in/lib/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test "hello" { + if hello() != "Hello, world!" { + return Err("hello() != \"Hello, world!\"") + } +} diff --git a/crates/moon/tests/test_cases/validate_import.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/validate_import.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/validate_import.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/validate_import.in/main/main.mbt b/crates/moon/tests/test_cases/validate_import.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/validate_import.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/validate_import.in/main/moon.pkg.json b/crates/moon/tests/test_cases/validate_import.in/main/moon.pkg.json new file mode 100644 index 00000000..229e9f06 --- /dev/null +++ b/crates/moon/tests/test_cases/validate_import.in/main/moon.pkg.json @@ -0,0 +1,10 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib", + "mbt/core/set" + ], + "wbtest-import": [ + "mbt/core/x" + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/validate_import.in/moon.mod.json b/crates/moon/tests/test_cases/validate_import.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/validate_import.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/warn_list.in/.gitignore b/crates/moon/tests/test_cases/warn_list.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/warn_list.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/warn_list.in/README.md b/crates/moon/tests/test_cases/warn_list.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/warn_list.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/warn_list.in/lib/hello.mbt b/crates/moon/tests/test_cases/warn_list.in/lib/hello.mbt new file mode 100644 index 00000000..5bc138f8 --- /dev/null +++ b/crates/moon/tests/test_cases/warn_list.in/lib/hello.mbt @@ -0,0 +1,4 @@ +pub fn hello() -> String { + let a = 0 + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/warn_list.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/warn_list.in/lib/moon.pkg.json new file mode 100644 index 00000000..39a5e4ea --- /dev/null +++ b/crates/moon/tests/test_cases/warn_list.in/lib/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "warn-list": "-2" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/warn_list.in/lib1/hello.mbt b/crates/moon/tests/test_cases/warn_list.in/lib1/hello.mbt new file mode 100644 index 00000000..774951e8 --- /dev/null +++ b/crates/moon/tests/test_cases/warn_list.in/lib1/hello.mbt @@ -0,0 +1,7 @@ +pub fn hello() -> String { + "Hello, world!" +} + +fn t() -> Unit { + +} diff --git a/crates/moon/tests/test_cases/warn_list.in/lib1/moon.pkg.json b/crates/moon/tests/test_cases/warn_list.in/lib1/moon.pkg.json new file mode 100644 index 00000000..bde61261 --- /dev/null +++ b/crates/moon/tests/test_cases/warn_list.in/lib1/moon.pkg.json @@ -0,0 +1,3 @@ +{ + "warn-list": "-1" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/warn_list.in/main/main.mbt b/crates/moon/tests/test_cases/warn_list.in/main/main.mbt new file mode 100644 index 00000000..eb801f97 --- /dev/null +++ b/crates/moon/tests/test_cases/warn_list.in/main/main.mbt @@ -0,0 +1,7 @@ +fn main { + let a = 0 +} + +fn t() -> Unit { + +} diff --git a/crates/moon/tests/test_cases/warn_list.in/main/moon.pkg.json b/crates/moon/tests/test_cases/warn_list.in/main/moon.pkg.json new file mode 100644 index 00000000..e0088814 --- /dev/null +++ b/crates/moon/tests/test_cases/warn_list.in/main/moon.pkg.json @@ -0,0 +1,8 @@ +{ + "is-main": true, + "import": [ + "username/hello/lib", + "username/hello/lib1" + ], + "warn-list": "-1-2" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/warn_list.in/moon.mod.json b/crates/moon/tests/test_cases/warn_list.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/warn_list.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/whitespace_test.in/.gitignore b/crates/moon/tests/test_cases/whitespace_test.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/whitespace_test.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/whitespace_test.in/README.md b/crates/moon/tests/test_cases/whitespace_test.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/whitespace_test.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/whitespace_test.in/main exe/main.mbt b/crates/moon/tests/test_cases/whitespace_test.in/main exe/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/whitespace_test.in/main exe/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/whitespace_test.in/main exe/moon.pkg.json b/crates/moon/tests/test_cases/whitespace_test.in/main exe/moon.pkg.json new file mode 100644 index 00000000..0ba6c360 --- /dev/null +++ b/crates/moon/tests/test_cases/whitespace_test.in/main exe/moon.pkg.json @@ -0,0 +1,9 @@ +{ + "is-main": true, + "import": [ + { + "path": "username/hello/main lib", + "alias": "lib" + } + ] +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/whitespace_test.in/main lib/hello.mbt b/crates/moon/tests/test_cases/whitespace_test.in/main lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/whitespace_test.in/main lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/whitespace_test.in/main lib/hello_wbtest.mbt b/crates/moon/tests/test_cases/whitespace_test.in/main lib/hello_wbtest.mbt new file mode 100644 index 00000000..85944a2c --- /dev/null +++ b/crates/moon/tests/test_cases/whitespace_test.in/main lib/hello_wbtest.mbt @@ -0,0 +1,5 @@ +test "hello" { + if hello() != "Hello, world!" { + raise "hello() != \"Hello, world!\"" + } +} diff --git a/crates/moon/tests/test_cases/whitespace_test.in/main lib/moon.pkg.json b/crates/moon/tests/test_cases/whitespace_test.in/main lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/whitespace_test.in/main lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/whitespace_test.in/moon.mod.json b/crates/moon/tests/test_cases/whitespace_test.in/moon.mod.json new file mode 100644 index 00000000..80554ae2 --- /dev/null +++ b/crates/moon/tests/test_cases/whitespace_test.in/moon.mod.json @@ -0,0 +1,9 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "" +} \ No newline at end of file diff --git a/crates/moonbuild/Cargo.toml b/crates/moonbuild/Cargo.toml new file mode 100644 index 00000000..929d27f6 --- /dev/null +++ b/crates/moonbuild/Cargo.toml @@ -0,0 +1,47 @@ +[package] +name = "moonbuild" +version = "0.1.0" +edition.workspace = true +rust-version.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +moonutil.workspace = true +mooncake.workspace = true +n2.workspace = true +clap.workspace = true +serde.workspace = true +serde_json_lenient.workspace = true +anyhow.workspace = true +colored.workspace = true +dunce.workspace = true +indexmap.workspace = true +notify.workspace = true +petgraph.workspace = true +walkdir.workspace = true +tempfile.workspace = true +ctrlc.workspace = true +dissimilar.workspace = true +line-index.workspace = true +home.workspace = true +tokio.workspace = true +self-replace.workspace = true +sysinfo.workspace = true +text-size.workspace = true +log.workspace = true +hyper.workspace = true +hyper-util.workspace = true +hyper-staticfile.workspace = true +http.workspace = true +dialoguer.workspace = true +futures.workspace = true +reqwest.workspace = true +console.workspace = true +semver.workspace = true +chrono.workspace = true +zip.workspace = true +thiserror.workspace = true + +[dev-dependencies] +expect-test.workspace = true diff --git a/crates/moonbuild/src/README.md b/crates/moonbuild/src/README.md new file mode 100644 index 00000000..b87d0718 --- /dev/null +++ b/crates/moonbuild/src/README.md @@ -0,0 +1,28 @@ + +## Tests + +### Running Tests + +To run all tests, use the following command: + +```bash +cargo test +``` + +### Promoting New Test Results + +If you have made changes to the code that cause test failures, you can use the following command to promote new test results: + +```bash +env UPDATE_EXPECT=1 cargo test +``` + +This command will update the expected test results to match the actual results. Use this command with caution, as it can lead to unexpected behavior if used incorrectly. + + +## Generate `lexer.rs` +`lexer.rs` is generated by re2c 3.0 by using the following command: + +```bash +re2rust ./lexer.re2c --tags --output lexer.rs +``` diff --git a/crates/moonbuild/src/bench.rs b/crates/moonbuild/src/bench.rs new file mode 100644 index 00000000..2901ed6f --- /dev/null +++ b/crates/moonbuild/src/bench.rs @@ -0,0 +1,173 @@ +use indexmap::IndexMap; +use moonutil::common::*; +use moonutil::module::MoonModJSON; +use moonutil::package::{MoonPkgJSON, PkgJSONImport}; +use std::fs; +use std::path::Path; + +#[derive(Default)] +pub struct Config { + pub dir_rows: u32, + pub dir_cols: u32, + pub mod_rows: u32, + pub mod_cols: u32, + comment_size: u32, +} + +impl Config { + pub fn new() -> Self { + Config { + dir_rows: 1, + dir_cols: 1, + mod_rows: 1, + mod_cols: 1, + comment_size: 5000, + } + } +} + +fn write_directory(config: &Config, base_dir: &Path, dr: u32, dc: u32) { + let dir_name = base_dir.join(format!("dir_{}_{}", dr, dc)); + fs::create_dir_all(&dir_name).unwrap(); + + for mr in 0..config.mod_rows { + for mc in 0..config.mod_cols { + let mut deps = Vec::new(); + if mr == 0 { + if dr == 0 { + // nothing to do + } else { + for k in 0..config.mod_cols { + for j in 0..config.dir_cols { + deps.push((dr - 1, j, config.mod_rows - 1, k)); + } + } + } + } else { + for k in 0..config.mod_rows { + deps.push((dr, dc, mr - 1, k)); + } + } + + let mut dep_str = String::new(); + for d in deps.iter() { + dep_str.push_str(&format!(" @m_{}_{}_{}_{}.f()\n", d.0, d.1, d.2, d.3)); + } + + let mod_content = format!( + r#"// {} // +pub fn f() -> Unit {{ +{}}} +"#, + "X".repeat(config.comment_size as usize), + dep_str, + ); + let mod_name = dir_name.join(format!("m_{}_{}_{}_{}", dr, dc, mr, mc)); + fs::create_dir_all(&mod_name).unwrap(); + let mod_main = mod_name.join("main.mbt"); + fs::write(&mod_main, mod_content).unwrap(); + let moon_pkg = mod_name.join(MOON_PKG_JSON); + let mut import: IndexMap> = IndexMap::new(); + for d in deps.iter() { + import.insert( + format!( + "build_matrix/dir_{}_{}/m_{}_{}_{}_{}", + d.0, d.1, d.0, d.1, d.2, d.3 + ), + Some("".into()), + ); + } + let pkg = MoonPkgJSON { + name: None, + is_main: None, + import: if import.is_empty() { + None + } else { + Some(PkgJSONImport::Map(import)) + }, + wbtest_import: None, + test_import: None, + link: None, + warn_list: None, + alert_list: None, + }; + moonutil::common::write_package_json_to_file(&pkg, &moon_pkg).unwrap(); + } + } +} + +pub fn write(config: &Config, base_dir: &Path) { + for row in 0..config.dir_rows { + for col in 0..config.dir_cols { + write_directory(config, base_dir, row, col); + } + } + + let module = MoonModJSON { + name: "build_matrix".to_string(), + version: None, + deps: None, + readme: None, + repository: None, + license: None, + keywords: None, + description: None, + + compile_flags: None, + link_flags: None, + checksum: None, + ext: Default::default(), + }; + moonutil::common::write_module_json_to_file(&module, base_dir).unwrap(); + fs::create_dir_all(base_dir.join("main")).unwrap(); + let mut main_content = String::new(); + main_content.push_str("fn main {\n"); + for dr in 0..config.dir_rows { + for dc in 0..config.dir_cols { + for mr in 0..config.mod_rows { + for mc in 0..config.mod_cols { + main_content.push_str(&format!(" let _ = @m_{dr}_{dc}_{mr}_{mc}.f\n")); + } + } + } + } + main_content.push_str(" println(\"ok\")\n"); + main_content.push_str("}\n"); + + fs::write(base_dir.join("main").join("main.mbt"), main_content).unwrap(); + + let mut import = IndexMap::new(); + for dr in 0..config.dir_rows { + for dc in 0..config.dir_cols { + for mr in 0..config.mod_rows { + for mc in 0..config.mod_cols { + import.insert( + format!( + "build_matrix/dir_{}_{}/m_{}_{}_{}_{}", + dr, dc, dr, dc, mr, mc + ), + Some("".to_string()), + ); + } + } + } + } + + let pkg = MoonPkgJSON { + name: None, + is_main: Some(true), + import: if import.is_empty() { + None + } else { + Some(PkgJSONImport::Map(import)) + }, + wbtest_import: None, + test_import: None, + link: None, + warn_list: None, + alert_list: None, + }; + + moonutil::common::write_package_json_to_file(&pkg, &base_dir.join("main").join(MOON_PKG_JSON)) + .unwrap(); +} diff --git a/crates/moonbuild/src/build.rs b/crates/moonbuild/src/build.rs new file mode 100644 index 00000000..ea56e74c --- /dev/null +++ b/crates/moonbuild/src/build.rs @@ -0,0 +1,73 @@ +use super::gen; +use anyhow::{bail, Context}; +use moonutil::common::MoonbuildOpt; +use moonutil::module::ModuleDB; +use n2::load::State; +use std::path::Path; +use std::process::{Command, Stdio}; + +use moonutil::common::MooncOpt; + +pub fn load_moon_proj( + module: &ModuleDB, + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, +) -> anyhow::Result { + let target_dir = &moonbuild_opt.target_dir; + + let mut contain_link_item = false; + for (_, pkg) in module.packages.iter() { + if pkg.is_main || pkg.need_link { + contain_link_item = true; + break; + } + } + if !contain_link_item { + anyhow::bail!("no package need to be linked in the project") + } + + log::debug!("module: {:#?}", module); + let n2_input = gen::gen_build::gen_build(module, moonc_opt, moonbuild_opt)?; + log::debug!("n2_input: {:#?}", n2_input); + gen::gen_build::gen_n2_build_state(&n2_input, target_dir, moonc_opt, moonbuild_opt) +} + +pub fn run_wat(path: &Path, args: &[String]) -> anyhow::Result<()> { + run("moonrun", path, args) +} + +pub fn run_js(path: &Path, args: &[String]) -> anyhow::Result<()> { + if !args.is_empty() { + bail!(format!( + "js backend does not support extra args for now {:?}", + args + )) + } + run("node", path, args) +} + +fn run(command: &str, path: &Path, args: &[String]) -> anyhow::Result<()> { + let mut execution = Command::new(command) + .arg(path) + .arg("--") + .args(args) + .stdout(Stdio::inherit()) + .stderr(Stdio::inherit()) + .spawn() + .context(format!( + "failed to execute: {} {} {}", + command, + path.display(), + if args.is_empty() { + "".to_string() + } else { + format!("-- {}", args.join(" ")) + } + ))?; + let status = execution.wait()?; + if status.success() { + Ok(()) + } else { + anyhow::bail!("failed to run") + } +} diff --git a/crates/moonbuild/src/bundle.rs b/crates/moonbuild/src/bundle.rs new file mode 100644 index 00000000..903b8ee9 --- /dev/null +++ b/crates/moonbuild/src/bundle.rs @@ -0,0 +1,23 @@ +use n2::load::State; + +use moonutil::{ + common::{MoonbuildOpt, MooncOpt}, + module::ModuleDB, +}; + +pub fn load_moon_proj( + module: &ModuleDB, + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, +) -> anyhow::Result { + let target_dir = &moonbuild_opt.target_dir; + if !target_dir.exists() { + std::fs::create_dir_all(target_dir)?; + } + + log::debug!("{:#?}", module); + + let input = super::gen::gen_bundle::gen_bundle(module, moonc_opt, moonbuild_opt)?; + log::debug!("{:#?}", input); + super::gen::gen_bundle::gen_n2_bundle_state(&input, target_dir, moonc_opt, moonbuild_opt) +} diff --git a/crates/moonbuild/src/check/mod.rs b/crates/moonbuild/src/check/mod.rs new file mode 100644 index 00000000..9064dda8 --- /dev/null +++ b/crates/moonbuild/src/check/mod.rs @@ -0,0 +1,2 @@ +pub mod normal; +pub mod watch; diff --git a/crates/moonbuild/src/check/normal.rs b/crates/moonbuild/src/check/normal.rs new file mode 100644 index 00000000..3b0641d7 --- /dev/null +++ b/crates/moonbuild/src/check/normal.rs @@ -0,0 +1,75 @@ +use anyhow::Context; + +use moonutil::common::{MoonbuildOpt, MooncOpt}; +use moonutil::module::{convert_mdb_to_json, ModuleDB, ModuleDBJSON}; +use n2::load::State; +use std::io::BufWriter; +use std::io::Write; +use std::path::Path; +use std::path::PathBuf; + +pub fn write_pkg_lst(module: &ModuleDB, target_dir: &Path) -> anyhow::Result<()> { + let create_and_write = + |pkg_json_path: PathBuf, new_module_db_content: &ModuleDBJSON| -> anyhow::Result<()> { + let fp = std::fs::File::create(pkg_json_path).context(format!( + "failed to create `{}/packages.json`", + target_dir.display() + ))?; + let mut writer = BufWriter::new(fp); + let data = serde_json_lenient::to_vec_pretty(new_module_db_content) + .context("failed to serialize packages list")?; + writer.write_all(&data)?; + + Ok(()) + }; + + let mj = convert_mdb_to_json(module); + let pkg_json = target_dir.join("packages.json"); + + // if the file exist and the old content is the same as the new content in `module`, don't rewrite it + // otherwise we create and write + if pkg_json.exists() { + match std::fs::File::open(&pkg_json) { + Ok(old_pkg_json_file) => { + let old_pkg_json = serde_json_lenient::from_reader::<_, ModuleDBJSON>( + std::io::BufReader::new(old_pkg_json_file), + ); + match old_pkg_json { + Ok(old_pkg_json) if old_pkg_json == mj => { + log::debug!( + "content of {} is the same, skip writing", + pkg_json.display() + ); + Ok(()) + } + _ => { + log::debug!("content of {} change, rewriting", pkg_json.display()); + create_and_write(pkg_json, &mj) + } + } + } + Err(_) => create_and_write(pkg_json, &mj), + } + } else { + log::debug!("{} don't exist, try to create it", pkg_json.display()); + create_and_write(pkg_json, &mj) + } +} + +pub fn load_moon_proj( + module: &ModuleDB, + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, +) -> anyhow::Result { + let target_dir = &moonbuild_opt.target_dir; + + log::debug!("module: {:#?}", module); + let n2_input = super::super::gen::gen_check::gen_check(module, moonc_opt, moonbuild_opt)?; + log::debug!("n2_input: {:#?}", n2_input); + super::super::gen::gen_check::gen_n2_check_state( + &n2_input, + target_dir, + moonc_opt, + moonbuild_opt, + ) +} diff --git a/crates/moonbuild/src/check/watch.rs b/crates/moonbuild/src/check/watch.rs new file mode 100644 index 00000000..0fc5f3e7 --- /dev/null +++ b/crates/moonbuild/src/check/watch.rs @@ -0,0 +1,137 @@ +use anyhow::{anyhow, Context}; +use colored::*; +use mooncake::pkg::sync::auto_sync; +use moonutil::module::ModuleDB; +use moonutil::mooncakes::sync::AutoSyncFlags; +use moonutil::mooncakes::RegistryConfig; +use notify::{Config, RecommendedWatcher, RecursiveMode, Watcher}; + +use crate::{bail_moon_check_is_running, write_current_pid, MOON_PID_NAME}; +use moonutil::common::{MoonbuildOpt, MooncOpt}; +use std::fs::remove_file; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::Arc; + +pub fn watch_single_thread( + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, + registry_config: &RegistryConfig, + module: &ModuleDB, +) -> anyhow::Result { + let (source_dir, target_dir) = (&moonbuild_opt.source_dir, &moonbuild_opt.target_dir); + + let pid_path = target_dir.join(MOON_PID_NAME); + if pid_path.exists() { + bail_moon_check_is_running(&pid_path)?; + } + write_current_pid(target_dir, &pid_path)?; + print!("{esc}[2J{esc}[1;1H", esc = 27 as char); + let result = crate::entry::run_check(moonc_opt, moonbuild_opt, module); + match result { + Ok(0) => { + println!( + "{}", + "Success, waiting for filesystem changes...".green().bold() + ); + } + Err(e) => { + println!( + "{:?}\n{}", + e, + "Had errors, waiting for filesystem changes...".red().bold(), + ); + } + _ => { + println!( + "{}", + "Had errors, waiting for filesystem changes...".red().bold(), + ); + } + } + let (tx, rx) = std::sync::mpsc::channel(); + let tx_for_exit = tx.clone(); + let mut watcher = RecommendedWatcher::new(tx, Config::default())?; + + let exit_flag = Arc::new(AtomicBool::new(false)); + { + let r = exit_flag.clone(); + ctrlc::set_handler(move || { + let exit_signal = notify::Event::new(notify::EventKind::Other); + r.store(true, Ordering::SeqCst); + let _ = tx_for_exit.send(Ok(exit_signal)); + }) + .expect("Error setting Ctrl-C handler"); + } + + { + // main thread + let exit_flag = exit_flag.clone(); + watcher.watch(source_dir, RecursiveMode::Recursive)?; + for res in rx { + match res { + Ok(event) => { + { + if event.kind == notify::EventKind::Other + && exit_flag.load(Ordering::SeqCst) + { + break; + } + } + + let all_in_target = event.paths.iter().all(|p| p.starts_with(target_dir)); + if all_in_target { + continue; + } + + if !target_dir.exists() { + std::fs::create_dir_all(target_dir) + .context("failed to create target dir")?; + } + + print!("{esc}[2J{esc}[1;1H", esc = 27 as char); + // we need to get the latest ModuleDB when we call run_check in watch mode + let (resolved_env, dir_sync_result) = auto_sync( + source_dir, + &AutoSyncFlags { frozen: false }, + registry_config, + false, + )?; + let module = &moonutil::scan::scan( + false, + &resolved_env, + &dir_sync_result, + moonc_opt, + moonbuild_opt, + )?; + let result = crate::entry::run_check(moonc_opt, moonbuild_opt, module); + match result { + Ok(0) => { + println!( + "{}", + "Success, waiting for filesystem changes...".green().bold() + ); + } + Err(e) => { + println!( + "{:?}\n{}", + e, + "Had errors, waiting for filesystem changes...".red().bold(), + ); + } + _ => { + println!( + "{}", + "Had errors, waiting for filesystem changes...".red().bold(), + ); + } + } + } + Err(e) => { + return Err(anyhow!(e)); + } + } + } + } + remove_file(&pid_path).unwrap_or_default(); + Ok(0) +} diff --git a/crates/moonbuild/src/doc_http.rs b/crates/moonbuild/src/doc_http.rs new file mode 100644 index 00000000..f2bc02ae --- /dev/null +++ b/crates/moonbuild/src/doc_http.rs @@ -0,0 +1,76 @@ +use std::io::Error as IoError; +use std::net::SocketAddr; +use std::path::PathBuf; + +use anyhow::Context; +use colored::Colorize; +use http::response::Builder as ResponseBuilder; +use http::{header, StatusCode}; +use hyper::service::service_fn; +use hyper::{Request, Response}; +use hyper_staticfile::{Body, Static}; +use hyper_util::rt::TokioIo; +use tokio::net::TcpListener; +use tokio::runtime::Runtime; + +async fn handle_request(req: Request, static_: Static) -> Result, IoError> { + if req.uri().path() == "/" { + let res = ResponseBuilder::new() + .status(StatusCode::MOVED_PERMANENTLY) + .header(header::LOCATION, "/index.html#/") + .body(Body::Empty) + .expect("unable to build response"); + Ok(res) + } else { + static_.clone().serve(req).await + } +} + +pub fn start_server( + root_dir: impl Into, + cake_full_name: &str, + bind: String, + port: u16, +) -> anyhow::Result<()> { + let runtime = Runtime::new()?; + runtime.block_on(async { + let static_ = Static::new(root_dir); + + let addr = format!("{}:{}", bind, port) + .parse::() + .context(format!("failed to parse address {}:{}", bind, port))?; + + let listener = TcpListener::bind(addr) + .await + .context(format!("failed to bind to address {}", addr))?; + + eprintln!( + "{}", + format!( + "Doc server running on http://{}/index.html#/{}/", + addr, cake_full_name + ) + .bold() + .green() + ); + loop { + let (stream, _) = listener + .accept() + .await + .expect("Failed to accept TCP connection"); + + let static_ = static_.clone(); + tokio::spawn(async move { + if let Err(err) = hyper::server::conn::http1::Builder::new() + .serve_connection( + TokioIo::new(stream), + service_fn(move |req| handle_request(req, static_.clone())), + ) + .await + { + eprintln!("Error serving connection: {:?}", err); + } + }); + } + }) +} diff --git a/crates/moonbuild/src/dry_run.rs b/crates/moonbuild/src/dry_run.rs new file mode 100644 index 00000000..0a30122a --- /dev/null +++ b/crates/moonbuild/src/dry_run.rs @@ -0,0 +1,100 @@ +use moonutil::module::ModuleDB; +use n2::densemap::Index; +use n2::graph::{BuildId, FileId, Graph}; +use std::collections::VecDeque; + +use moonutil::common::{MoonbuildOpt, MooncOpt, RunMode, TargetBackend}; + +pub fn print_commands( + module: &ModuleDB, + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, +) -> anyhow::Result { + let moonc_opt = &MooncOpt { + render: false, + ..moonc_opt.clone() + }; + + let (source_dir, target_dir) = (&moonbuild_opt.source_dir, &moonbuild_opt.target_dir); + + let in_same_dir = target_dir.starts_with(source_dir); + let mode = moonbuild_opt.run_mode; + + let state = match mode { + RunMode::Build | RunMode::Run => { + crate::build::load_moon_proj(module, moonc_opt, moonbuild_opt)? + } + RunMode::Check => crate::check::normal::load_moon_proj(module, moonc_opt, moonbuild_opt)?, + RunMode::Test => crate::runtest::load_moon_proj(module, moonc_opt, moonbuild_opt)?, + RunMode::Bundle => crate::bundle::load_moon_proj(module, moonc_opt, moonbuild_opt)?, + RunMode::Format => crate::fmt::load_moon_proj(module, moonc_opt, moonbuild_opt)?, + }; + log::debug!("{:#?}", state); + let mut builds: VecDeque = VecDeque::new(); + if !state.default.is_empty() { + let mut sorted_default = state.default.clone(); + sorted_default.sort_by_key(|a| a.index()); + let mut queue: VecDeque = VecDeque::new(); + for target in sorted_default.iter() { + queue.push_back(*target); + bfs_graph(&state.graph, &mut queue, &mut builds); + queue.clear(); + } + for b in builds.iter().rev() { + let build = &state.graph.builds[*b]; + if let Some(cmdline) = &build.cmdline { + if in_same_dir { + // TODO: this replace is not safe + println!( + "{}", + cmdline.replace(&source_dir.display().to_string(), ".") + ); + } else { + println!("{}", cmdline); + } + } + } + if mode == RunMode::Run { + for fid in sorted_default.iter() { + let mut watfile = state.graph.file(*fid).name.clone(); + let cmd = match moonc_opt.link_opt.target_backend { + TargetBackend::Wasm => "moonrun", + TargetBackend::WasmGC => "moonrun", + TargetBackend::Js => "node", + }; + if in_same_dir { + watfile = watfile.replacen(&source_dir.display().to_string(), ".", 1); + } + + let mut moonrun_command = format!("{cmd} {watfile}"); + if !moonbuild_opt.args.is_empty() { + moonrun_command = + format!("{moonrun_command} -- {}", moonbuild_opt.args.join(" ")); + } + + println!("{moonrun_command}"); + } + } + } + Ok(0) +} + +fn bfs_graph(graph: &Graph, queue: &mut VecDeque, builds: &mut VecDeque) { + while !queue.is_empty() { + let file_id = queue.pop_front().unwrap(); + if let Some(bid) = graph.file(file_id).input { + if !builds.contains(&bid) { + builds.push_back(bid); + } else { + builds.retain(|id| &bid != id); + builds.push_back(bid); + } + let build = &graph.builds[bid]; + for &fid in build.explicit_ins().iter().rev() { + if !queue.contains(&fid) { + queue.push_back(fid); + } + } + } + } +} diff --git a/crates/moonbuild/src/entry.rs b/crates/moonbuild/src/entry.rs new file mode 100644 index 00000000..642e9ea3 --- /dev/null +++ b/crates/moonbuild/src/entry.rs @@ -0,0 +1,461 @@ +use moonutil::module::ModuleDB; +use n2::progress::{DumbConsoleProgress, FancyConsoleProgress, Progress}; +use n2::terminal; +use std::io::{BufRead, Write}; +use std::path::{Path, PathBuf}; +use std::process::{Command, Stdio}; +use thiserror::Error; + +use n2::{trace, work}; + +use anyhow::{anyhow, Context}; +use colored::Colorize; + +use crate::check::normal::write_pkg_lst; + +use moonutil::common::{is_slash, MoonbuildOpt, MooncOpt, TargetBackend}; + +use std::sync::{Arc, Mutex}; + +fn default_parallelism() -> anyhow::Result { + let par = std::thread::available_parallelism()?; + Ok(usize::from(par)) +} + +#[allow(clippy::type_complexity)] +fn create_progress_console(callback: Option>) -> Box { + if terminal::use_fancy() { + Box::new(FancyConsoleProgress::new(false, callback)) + } else { + Box::new(DumbConsoleProgress::new(false, callback)) + } +} + +fn render_result(result: Option, quiet: bool, mode: &str) -> anyhow::Result { + match result { + None => { + // Don't print any summary, the failing task is enough info. + anyhow::bail!(format!("failed when {}", mode)); + } + Some(0) => { + // Special case: don't print numbers when no work done. + if !quiet { + println!("{} moon: no work to do", "Finished.".bright_green().bold()); + } + Ok(0) + } + Some(n) => { + if !quiet { + println!( + "{} moon: ran {} task{}, now up to date", + "Finished.".bright_green().bold(), + n, + if n == 1 { "" } else { "s" } + ); + } + Ok(0) + } + } +} + +pub fn n2_run_interface( + state: n2::load::State, + output_path: PathBuf, +) -> anyhow::Result> { + let logger = Arc::new(Mutex::new(vec![])); + let use_fancy = terminal::use_fancy(); + + let catcher = logger.clone(); + let render_and_catch = move |output: &str| { + output + .split('\n') + .filter(|it| !it.is_empty()) + .for_each(|content| { + catcher.lock().unwrap().push(content.to_owned()); + moonutil::render::MooncDiagnostic::render(content, use_fancy); + }); + }; + + let mut progress = create_progress_console(Some(Box::new(render_and_catch))); + let options = work::Options { + parallelism: default_parallelism()?, + failures_left: Some(10), + explain: false, + adopt: false, + }; + let mut work = work::Work::new( + state.graph, + state.hashes, + state.db, + &options, + progress.as_mut(), + state.pools, + ); + + if !state.default.is_empty() { + for target in state.default { + work.want_file(target)?; + } + } else { + anyhow::bail!("no path specified and no default"); + } + + let res = trace::scope("work.run", || work.run())?; + + if let Some(0) = res { + // if no work to do, then do not rewrite (build | check | test ...).output + // instead, read it and print + let raw_json = std::fs::read_to_string(&output_path) + .context(format!("failed to open `{}`", output_path.display()))?; + + raw_json + .split('\n') + .filter(|it| !it.is_empty()) + .for_each(|content| { + moonutil::render::MooncDiagnostic::render(content, use_fancy); + }); + } else { + let mut output_file = std::fs::File::create(output_path)?; + + for item in logger.lock().unwrap().iter() { + output_file.write_all(item.as_bytes())?; + output_file.write_all("\n".as_bytes())?; + } + } + + Ok(res) +} + +pub fn run_check( + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, + module: &ModuleDB, +) -> anyhow::Result { + let state = trace::scope("moonbit::check::read", || { + crate::check::normal::load_moon_proj(module, moonc_opt, moonbuild_opt) + })?; + + let result = n2_run_interface(state, moonbuild_opt.target_dir.join("check.output"))?; + + match result { + Some(0) => {} + _ => { + write_pkg_lst(module, &moonbuild_opt.target_dir)?; + } + } + render_result(result, moonbuild_opt.quiet, "checking") +} + +pub fn run_build( + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, + module: &ModuleDB, +) -> anyhow::Result { + let state = trace::scope("moonbit::build::read", || { + crate::build::load_moon_proj(module, moonc_opt, moonbuild_opt) + })?; + let result = n2_run_interface(state, moonbuild_opt.target_dir.join("build.output"))?; + render_result(result, moonbuild_opt.quiet, "building") +} + +pub fn run_run( + package_path: Option<&String>, + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, + module: &ModuleDB, +) -> anyhow::Result { + run_build(moonc_opt, moonbuild_opt, module)?; + let (source_dir, target_dir) = (&moonbuild_opt.source_dir, &moonbuild_opt.target_dir); + let package_path = package_path + .unwrap() + .trim_start_matches("./") + .trim_start_matches(".\\") + .trim_end_matches(is_slash); + + let (package_path, last_name): (PathBuf, String) = + if package_path.is_empty() || package_path == "." { + let module = moonutil::common::read_module_desc_file_in_dir(source_dir)?; + let p = std::path::PathBuf::from(module.name); + ( + PathBuf::from("./"), + p.file_name().unwrap().to_str().unwrap().into(), + ) + } else { + let package_path = std::path::PathBuf::from(package_path); + let last_name = package_path.file_name().unwrap().to_str().unwrap(); + (package_path.clone(), last_name.into()) + }; + + let wat_path = target_dir.join(package_path).join(format!( + "{}.{}", + last_name, + moonc_opt.link_opt.output_format.to_str() + )); + let wat_path = dunce::canonicalize(&wat_path) + .context(format!("cannot find wat file at `{:?}`", &wat_path))?; + trace::scope("run", || { + if moonc_opt.link_opt.target_backend == TargetBackend::Wasm + || moonc_opt.link_opt.target_backend == TargetBackend::WasmGC + { + crate::build::run_wat(&wat_path, &moonbuild_opt.args) + } else { + crate::build::run_js(&wat_path, &moonbuild_opt.args) + } + })?; + Ok(0) +} + +#[derive(Debug, Error)] +pub enum TestFailedStatus { + #[error("{0}")] + ApplyExpectFailed(TestResult), + + #[error("{0}")] + ExpectTestFailed(TestResult), + + #[error("{0}")] + Failed(TestResult), + + #[error("{0}")] + RuntimeError(TestResult), + + #[error("{0:?}")] + Others(#[from] anyhow::Error), +} + +impl From for i32 { + fn from(value: TestFailedStatus) -> Self { + match value { + TestFailedStatus::ApplyExpectFailed(_) => 1, + TestFailedStatus::ExpectTestFailed(_) => 2, + TestFailedStatus::Failed(_) => 3, + TestFailedStatus::RuntimeError(_) => 4, + TestFailedStatus::Others(_) => 5, + } + } +} + +#[derive(Debug, Default)] +pub struct TestResult { + pub passed: u32, + pub failed: u32, +} + +impl std::fmt::Display for TestResult { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "passed: {}, failed: {}", self.passed, self.failed) + } +} + +#[allow(clippy::too_many_arguments)] +pub fn run_test( + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, + build_only: bool, + test_verbose_output: bool, + auto_update: bool, + module: &ModuleDB, +) -> anyhow::Result { + let target_dir = &moonbuild_opt.target_dir; + let state = crate::runtest::load_moon_proj(module, moonc_opt, moonbuild_opt)?; + let result = n2_run_interface(state, moonbuild_opt.target_dir.join("test.output"))?; + render_result(result, moonbuild_opt.quiet, "testing")?; + + if build_only { + return Ok(TestResult::default()); + } + + let state = crate::runtest::load_moon_proj(module, moonc_opt, moonbuild_opt)?; + let mut defaults: Vec<&String> = state + .default + .iter() + .map(|fid| &state.graph.file(*fid).name) + .collect(); + if moonbuild_opt.sort_input { + #[cfg(unix)] + { + defaults.sort(); + } + #[cfg(windows)] + { + let normal_slash = defaults + .iter() + .enumerate() + .map(|s| (s.0, s.1.replace('\\', "/"))) + .collect::>(); + let mut new_defaults = defaults.clone(); + for (i, (j, _)) in normal_slash.iter().enumerate() { + new_defaults[i] = defaults[*j]; + } + defaults = new_defaults; + } + } + + let mut passed = 0; + let mut failed = 0; + let mut runtime_error = false; + let mut expect_failed = false; + let mut apply_expect_failed = false; + + for d in defaults.iter() { + let p = Path::new(d); + + match p.extension() { + Some(name) if name == moonc_opt.link_opt.output_format.to_str() => { + let result = trace::scope("test", || { + if moonc_opt.link_opt.target_backend == TargetBackend::Wasm + || moonc_opt.link_opt.target_backend == TargetBackend::WasmGC + { + crate::runtest::run_wat(p, target_dir) + } else { + crate::runtest::run_js(p, target_dir) + } + }); + + if result.is_err() { + let e = result.err().unwrap(); + eprintln!("Error when running {}: {}", d, e); + runtime_error = true; + } else { + let r = result.unwrap(); + if r.messages + .iter() + .any(|msg| msg.starts_with(super::expect::EXPECT_FAILED)) + { + expect_failed = true; + } + if auto_update { + if let Err(e) = crate::expect::apply_expect(&r.messages) { + eprintln!("{}: {:?}", "failed".red().bold(), e); + apply_expect_failed = true; + } + } + passed += r.passed; + failed += r.test_names.len() as u32 - r.passed; + if test_verbose_output { + for i in 0..(r.passed as usize) { + println!( + "test {}/{}::{} {}", + r.package, + r.filenames[i], + r.test_names[i], + "ok".bold().green() + ) + } + } + + for i in 0..(r.test_names.len() - r.passed as usize) { + if r.messages[i].starts_with(super::expect::EXPECT_FAILED) { + // if we failed at auto update mode, we don't show the below msg to user + if !(auto_update && failed > 0 && !apply_expect_failed) { + println!( + "test {}/{}::{} {}", + r.package, + r.filenames[i], + r.test_names[i], + "failed".bold().red(), + ); + let _ = crate::expect::render_expect_fail(&r.messages[i]); + } + } else { + println!( + "test {}/{}::{} {}: {}", + r.package, + r.filenames[i], + r.test_names[i], + "failed".bold().red(), + r.messages[i], + ); + } + } + } + } + + _ => continue, + } + } + + let test_result = TestResult { passed, failed }; + + if failed == 0 && !runtime_error { + Ok(test_result) + } else if apply_expect_failed { + Err(TestFailedStatus::ApplyExpectFailed(test_result)) + } else if expect_failed { + Err(TestFailedStatus::ExpectTestFailed(test_result)) + } else if failed != 0 { + Err(TestFailedStatus::Failed(test_result)) + } else if runtime_error { + Err(TestFailedStatus::RuntimeError(test_result)) + } else { + Err(TestFailedStatus::Others(anyhow!("unknown error"))) + } +} + +pub fn run_bundle( + module: &ModuleDB, + moonbuild_opt: &MoonbuildOpt, + moonc_opt: &MooncOpt, +) -> anyhow::Result { + let state = crate::bundle::load_moon_proj(module, moonc_opt, moonbuild_opt)?; + let result = n2_run_interface(state, moonbuild_opt.target_dir.join("bundle.output"))?; + match result { + Some(0) => {} + _ => { + write_pkg_lst(module, &moonbuild_opt.target_dir)?; + } + } + render_result(result, moonbuild_opt.quiet, "bundle") +} + +pub fn run_fmt( + module: &ModuleDB, + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, +) -> anyhow::Result { + let n2_input = super::fmt::gen_fmt(module, moonc_opt, moonbuild_opt)?; + let state = super::fmt::gen_n2_fmt_state(&n2_input, moonc_opt, moonbuild_opt)?; + let _ = n2_run_interface(state, moonbuild_opt.target_dir.join("fmt.output"))?; + let mut exit_code = 0; + if moonbuild_opt.fmt_opt.as_ref().unwrap().check { + for item in n2_input.items.iter() { + let mut execution = Command::new("git") + .args([ + "--no-pager", + "diff", + "--color=always", + "--no-index", + &item.input, + &item.output, + ]) + .stdout(Stdio::piped()) + .stderr(Stdio::inherit()) + .spawn()?; + let child_stdout = execution.stdout.take().unwrap(); + let mut buf = String::new(); + let mut bufread = std::io::BufReader::new(child_stdout); + while let Ok(n) = bufread.read_line(&mut buf) { + if n > 0 { + print!("{}", buf); + buf.clear() + } else { + break; + } + } + let status = execution.wait()?; + match status.code() { + Some(0) => {} + Some(1) => { + exit_code = 1; + } + _ => { + eprintln!( + "failed to execute `git --no-pager diff --color=always --no-index {} {}`", + item.input, item.output + ); + } + } + } + } + Ok(exit_code) +} diff --git a/crates/moonbuild/src/expect.rs b/crates/moonbuild/src/expect.rs new file mode 100644 index 00000000..f11dfe9e --- /dev/null +++ b/crates/moonbuild/src/expect.rs @@ -0,0 +1,592 @@ +use anyhow::Context; +use colored::Colorize; +use std::collections::BTreeSet; +use std::collections::HashMap; + +#[derive(Debug, Default)] +pub struct PackagePatch { + patches: HashMap>, +} + +impl PackagePatch { + pub fn add(&mut self, filename: &str, patch: BufferExpect) { + match self.patches.get_mut(filename) { + Some(vec) => vec.push(patch), + None => { + self.patches.insert(filename.to_string(), vec![patch]); + } + } + } +} + +#[derive(Debug, Default)] +pub struct BufferExpect { + range: line_index::TextRange, + left_padding: Option<&'static str>, + right_padding: Option<&'static str>, + #[allow(unused)] + expect: String, + actual: String, + kind: TargetKind, +} + +pub const EXPECT_FAILED: &str = "@EXPECT_FAILED "; + +#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord)] +pub enum TargetKind { + #[default] + Trivial, + Pipe, + Call, +} + +#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord)] +pub struct Target { + left_border_line_start: u32, + left_border_col_start: u32, + + line_start: u32, + col_start: u32, + line_end: u32, + col_end: u32, + + kind: TargetKind, + expect: String, + actual: String, +} + +#[derive(Debug, Default, serde::Serialize, serde::Deserialize)] +pub struct ExpectFailedRaw { + loc: String, + args_loc: String, + expect: String, + actual: String, +} + +#[derive(Debug)] +struct Location { + pub raw: String, + pub line_start: u32, + pub col_start: u32, + pub line_end: u32, + pub col_end: u32, +} + +impl Location { + pub fn ahead(&self, other: &Location) -> bool { + (self.line_start, self.col_start, self.line_end, self.col_end) + < ( + other.line_start, + other.col_start, + other.line_end, + other.col_end, + ) + } +} + +#[derive(Debug)] +struct Replace { + pub filename: String, + + // inspect(1234)? + // ^...........^ + pub loc: Location, + + // "1234" + pub actual: String, + // inspect(1234)? + // ^..^ + pub actual_loc: Location, + + pub expect: String, + pub expect_loc: Option, +} + +impl Replace { + fn guess_target(&self) -> anyhow::Result { + // trivial case where content is provided, we can get precise location + if let Some(loc) = &self.expect_loc { + Ok(Target { + left_border_line_start: self.loc.line_start, + left_border_col_start: self.loc.col_start, + line_start: loc.line_start, + col_start: loc.col_start, + line_end: loc.line_end, + col_end: loc.col_end, + kind: TargetKind::Trivial, + expect: self.expect.clone(), + actual: self.actual.clone(), + }) + } else { + let is_pipe = self.actual_loc.ahead(&self.loc); + if is_pipe { + Ok(Target { + left_border_line_start: self.loc.line_start, + left_border_col_start: self.loc.col_start, + line_start: self.loc.line_end, + col_start: self.loc.col_end - 1, + line_end: self.loc.line_end, + col_end: self.loc.col_end - 1, + kind: TargetKind::Pipe, + expect: self.expect.clone(), + actual: self.actual.clone(), + }) + } else { + // TODO: find comma + Ok(Target { + left_border_line_start: self.actual_loc.line_end, + left_border_col_start: self.actual_loc.col_end, + + line_start: self.loc.line_end, + col_start: self.loc.col_end - 1, + line_end: self.loc.line_end, + col_end: self.loc.col_end - 1, + kind: TargetKind::Call, + expect: self.expect.clone(), + actual: self.actual.clone(), + }) + } + } + } +} + +fn line_col_to_byte_idx(line_index: &line_index::LineIndex, line: u32, col: u32) -> Option { + let offset = line_index.offset(line_index.to_utf8( + line_index::WideEncoding::Utf32, + line_index::WideLineCol { line, col }, + )?)?; + Some(usize::from(offset)) +} + +fn parse_expect_failed_message(msg: &str) -> anyhow::Result { + let j: ExpectFailedRaw = serde_json_lenient::from_str(msg) + .context(format!("parse expect test result failed: {}", msg))?; + let locs: Vec> = serde_json_lenient::from_str(&j.args_loc)?; + if locs.len() != 4 { + anyhow::bail!( + "invalid locations {:?}, expect 4, got: {}", + locs, + locs.len() + ); + } + if locs[0].is_none() { + // impossible + anyhow::bail!("the location of first argument cannot be None"); + } + let loc = parse_loc(&j.loc)?; + let actual_loc = parse_loc(locs[0].as_ref().unwrap())?; + let expect_loc = if locs[1].is_some() { + Some(parse_loc(locs[1].as_ref().unwrap())?) + } else { + None + }; + Ok(Replace { + filename: parse_filename(&j.loc)?, + loc, + expect: j.expect, + expect_loc, + actual: j.actual, + actual_loc, + }) +} + +fn parse_filename(loc: &str) -> anyhow::Result { + let mut index = loc.len(); + let mut colon = 0; + for (i, c) in loc.char_indices().rev() { + if c == ':' { + colon += 1; + if colon == 3 { + index = i; + break; + } + } + } + Ok(loc[..index].to_string()) +} + +fn parse_loc(loc: &str) -> anyhow::Result { + // find 3rd colon from right of loc + let mut index = loc.len(); + let mut colon = 0; + for (i, c) in loc.char_indices().rev() { + if c == ':' { + colon += 1; + if colon == 3 { + index = i; + break; + } + } + } + let tmp = &loc[index + 1..]; + let rloc = tmp.replace('-', ":"); + let parts: Vec<&str> = rloc.split(':').collect(); + if parts.len() != 4 { + anyhow::bail!("invalid location: {}", rloc); + } + let line_start = parts[0].parse::()? - 1; + let col_start = parts[1].parse::()? - 1; + let line_end = parts[2].parse::()? - 1; + let col_end = parts[3].parse::()? - 1; + Ok(Location { + raw: loc.to_string(), + line_start, + col_start, + line_end, + col_end, + }) +} + +fn collect(messages: &[String]) -> anyhow::Result>> { + let mut targets: HashMap> = HashMap::new(); + + for msg in messages { + if !msg.starts_with(EXPECT_FAILED) { + continue; + } + let json_str = &msg[EXPECT_FAILED.len()..]; + let rep = parse_expect_failed_message(json_str)?; + + match targets.get_mut(&rep.filename) { + Some(st) => { + st.insert(rep.guess_target()?); + } + None => { + let mut newst = BTreeSet::new(); + newst.insert(rep.guess_target()?); + targets.insert(rep.filename.clone(), newst); + } + } + } + Ok(targets) +} + +fn gen_patch(targets: HashMap>) -> anyhow::Result { + let mut pp = PackagePatch::default(); + for (filename, targets) in targets.into_iter() { + let mut file_patches = vec![]; + let content = std::fs::read_to_string(&filename)?; + let content_chars: Vec = content.chars().collect(); + let line_index = line_index::LineIndex::new(&content); + + let charidx = content + .char_indices() + .enumerate() + .collect::>(); + let mut byte_offset_to_char_offset = HashMap::new(); + for (i, (j, _c)) in charidx.iter() { + byte_offset_to_char_offset.insert(*j, *i); + } + + let lines = content.split('\n').collect::>(); + + for t in targets.into_iter() { + let offset_start = + line_col_to_byte_idx(&line_index, t.line_start, t.col_start).unwrap(); + let offset_start = + text_size::TextSize::new(byte_offset_to_char_offset[&offset_start] as u32); + + let offset_end = line_col_to_byte_idx(&line_index, t.line_end, t.col_end).unwrap(); + let offset_end = + text_size::TextSize::new(byte_offset_to_char_offset[&offset_end] as u32); + + let mut rg = line_index::TextRange::new(offset_start, offset_end); + + let (left_padding, right_padding) = match t.kind { + TargetKind::Trivial => (None, None), + TargetKind::Pipe => { + let mut find_paren = false; + let mut i = usize::from(offset_start); + let left_border_start = line_col_to_byte_idx( + &line_index, + t.left_border_line_start, + t.left_border_col_start, + ) + .unwrap(); + let left_border_start = byte_offset_to_char_offset[&left_border_start]; + + while i >= left_border_start { + let c = content_chars[i]; + if c == ')' { + find_paren = true; + break; + } + i -= 1; + } + if find_paren { + (Some("content="), None) + } else { + let offset_start = + line_col_to_byte_idx(&line_index, t.line_start, t.col_start + 1) + .unwrap(); + + let offset_start = text_size::TextSize::new( + byte_offset_to_char_offset[&offset_start] as u32, + ); + let offset_end = + line_col_to_byte_idx(&line_index, t.line_end, t.col_end + 1).unwrap(); + + let offset_end = text_size::TextSize::new( + byte_offset_to_char_offset[&offset_end] as u32, + ); + + rg = line_index::TextRange::new(offset_start, offset_end); + (Some("(content="), Some(")")) + } + } + TargetKind::Call => { + let mut i = usize::from(offset_start); + let left_border_start = line_col_to_byte_idx( + &line_index, + t.left_border_line_start, + t.left_border_col_start, + ) + .unwrap(); + let left_border_start = byte_offset_to_char_offset[&left_border_start]; + + let mut find_comma = false; + while i >= left_border_start { + if content_chars[i] == ',' { + find_comma = true; + break; + } + i -= 1; + } + if find_comma { + (Some("content="), None) + } else { + (Some(", content="), None) + } + } + }; + + for line in lines[t.line_start as usize..].iter() { + if line.trim().ends_with(")?") && !line.trim().starts_with("#|") { + break; + } + } + file_patches.push(BufferExpect { + range: rg, + left_padding, + right_padding, + expect: t.expect, + actual: t.actual, + kind: t.kind, + }); + } + + pp.patches.insert(filename.to_string(), file_patches); + } + Ok(pp) +} + +fn push_multi_line_string( + output: &mut String, + spaces: usize, + s: &str, + prev_char: Option<&char>, + next_char: Option<&char>, +) { + let lines: Vec<&str> = s.split('\n').collect(); + for (i, line) in lines.iter().enumerate() { + if i == 0 { + match prev_char { + Some('=') | Some('(') => { + output.push('\n'); + output.push_str(" ".repeat(spaces).as_str()); + } + Some(c) if c.is_alphabetic() => { + output.push('\n'); + output.push_str(" ".repeat(spaces).as_str()); + } + _ => {} + } + output.push_str(&format!("#|{}", line)); + } else { + match prev_char { + Some(' ') => { + output.push_str(&format!( + "{}#|{}", + " ".repeat(if spaces > 2 { spaces - 2 } else { 0 }), + line + )); + } + _ => { + output.push_str(&format!("{}#|{}", " ".repeat(spaces), line)); + } + } + } + if i == lines.len() - 1 { + if let Some(')') = next_char { + output.push('\n'); + output.push_str(" ".repeat(if spaces > 2 { spaces - 2 } else { 0 }).as_str()); + } + } else { + output.push('\n'); + } + } +} + +fn apply_patch(pp: &PackagePatch) -> anyhow::Result<()> { + for (filename, patches) in pp.patches.iter() { + let content = std::fs::read_to_string(filename)?; + // TODO: share content_chars with gen_patch + let content_chars = content.chars().collect::>(); + + let charidx = content + .char_indices() + .enumerate() + .collect::>(); + let mut char_offset_to_byte_offset = HashMap::new(); + for (i, (j, _c)) in charidx.iter() { + char_offset_to_byte_offset.insert(*i, *j); + } + + let lines: Vec<&str> = content.split('\n').collect(); + let line_index = line_index::LineIndex::new(&content); + let mut output = String::new(); + let mut i = 0u32; + let mut k = 0usize; + while k < patches.len() { + let patch = &patches[k]; + let start = patch.range.start(); + let end = patch.range.end(); + #[allow(clippy::comparison_chain)] + if i < u32::from(start) { + for item in content_chars + .iter() + .take(usize::from(start)) + .skip(i as usize) + { + output.push(*item); + } + i = u32::from(start); + } else if i == u32::from(start) { + // infer indent + let utf8_start = char_offset_to_byte_offset[&usize::from(start)]; + let start_point = line_index.line_col(text_size::TextSize::new(utf8_start as u32)); + let line = lines[start_point.line as usize]; + let spaces = line.find(|c| c != ' ').unwrap_or(0); + + if let Some(padding) = patch.left_padding { + output.push_str(padding); + if patch.kind == TargetKind::Call && patch.actual.contains('\n') { + output.push('\n'); + output.push_str(" ".repeat(spaces + 2).as_str()); + } + } + + if !patch.actual.contains('\n') && !patch.actual.contains('"') { + output.push_str(&format!("{:?}", &patch.actual)); + } else { + let next_char = content_chars[usize::from(end)..].first(); + let prev_char = content_chars[..usize::from(start)].last(); + push_multi_line_string( + &mut output, + spaces + 2, + &patch.actual, + prev_char, + next_char, + ); + } + + if let Some(padding) = patch.right_padding { + output.push_str(padding); + } + + i = u32::from(end); + k += 1; + } else { + anyhow::bail!("unreachable state in expect test, please report this bug"); + } + } + if i < content_chars.len() as u32 { + for item in content_chars.into_iter().skip(i as usize) { + output.push(item); + } + } + std::fs::write(filename, output)?; + } + + Ok(()) +} + +pub fn apply_expect(messages: &[String]) -> anyhow::Result<()> { + // dbg!(&messages); + let targets = collect(messages)?; + // dbg!(&targets); + let patches = gen_patch(targets)?; + // dbg!(&patches); + apply_patch(&patches)?; + Ok(()) +} + +fn format_chunks(chunks: Vec) -> String { + let mut buf = String::new(); + for chunk in chunks { + let formatted = match chunk { + dissimilar::Chunk::Equal(text) => text.into(), + dissimilar::Chunk::Delete(text) => format!("{}", text.red().underline()), + dissimilar::Chunk::Insert(text) => format!("{}", text.green().underline()), + }; + buf.push_str(&formatted); + } + buf +} + +pub fn render_expect_fail(msg: &str) -> anyhow::Result<()> { + assert!(msg.starts_with(EXPECT_FAILED)); + let json_str = &msg[EXPECT_FAILED.len()..]; + let rep = parse_expect_failed_message(json_str)?; + + let d = dissimilar::diff(&rep.expect, &rep.actual); + println!( + r#"expect test failed at {} +{} +---- +{} +---- +"#, + rep.loc.raw, + "Diff:".bold(), + format_chunks(d) + ); + Ok(()) +} + +pub fn render_expect_fails(messages: &[String]) -> anyhow::Result<()> { + for msg in messages { + if !msg.starts_with(EXPECT_FAILED) { + continue; + } + render_expect_fail(msg)?; + } + Ok(()) +} + +#[test] +fn test_split() { + let input = "\n"; + let xs: Vec<&str> = input.split('\n').collect(); + assert_eq!(xs, ["", ""]); + + let input = "\n\n"; + let xs: Vec<&str> = input.split('\n').collect(); + assert_eq!(xs, ["", "", ""]); +} + +#[test] +fn test_x() { + let input = r#"fn actual() -> String { + "BinOp('+', BinOp('+', Num(1), Num(2)), Num(3))" +} + +test { + inspect(actual(), content="BinOp('+', Num(1), Num(2))")? +} +"#; + let chars = input.char_indices().collect::>(); + for (i, c) in chars { + println!("{}: {}", i, c); + } +} diff --git a/crates/moonbuild/src/fmt.rs b/crates/moonbuild/src/fmt.rs new file mode 100644 index 00000000..d4e672d6 --- /dev/null +++ b/crates/moonbuild/src/fmt.rs @@ -0,0 +1,279 @@ +use std::path::{Path, PathBuf}; +use std::process::Command; + +use anyhow::Context; +use moonutil::common::IGNORE_DIRS; +use moonutil::module::ModuleDB; +use walkdir::WalkDir; + +use moonutil::common::{MoonbuildOpt, MooncOpt}; + +use n2::graph::{self as n2graph, Build, BuildIns, BuildOuts, FileId, FileLoc}; +use n2::load::State; +use n2::smallmap::SmallMap; +use std::rc::Rc; + +use crate::gen::cmd_builder::CommandBuilder; + +pub fn format_package(dir: &Path) -> anyhow::Result { + let mut errors = vec![]; + let result = walk_dir(dir, &mut errors); + if result.is_ok() { + if errors.is_empty() { + return Ok(0); + } else { + for (p, e) in errors { + eprintln!("Error while formatting {}:\n{}", p.display(), e); + } + return Ok(1); + } + } + anyhow::bail!(result.err().unwrap()) +} + +fn walk_dir(dir: &Path, errors: &mut Vec<(PathBuf, String)>) -> anyhow::Result<()> { + let walker = WalkDir::new(dir).into_iter(); + for entry in walker.filter_entry(|e| !IGNORE_DIRS.contains(&e.file_name().to_str().unwrap())) { + let entry = entry.context("failed to read entry")?; + if entry.file_type().is_dir() { + continue; + } + + let p = entry.path(); + + if let Some(ext) = p.extension() { + if ext == "mbt" { + let out = Command::new("moonfmt").arg("-w").arg(p).output()?; + if !out.status.success() { + let stderr = String::from_utf8_lossy(&out.stderr).to_string(); + errors.push((p.to_path_buf(), stderr)); + } + } + } + } + Ok(()) +} + +pub fn load_moon_proj( + m: &ModuleDB, + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, +) -> anyhow::Result { + let n2_input = gen_fmt(m, moonc_opt, moonbuild_opt); + let state = gen_n2_fmt_state(&n2_input?, moonc_opt, moonbuild_opt)?; + Ok(state) +} + +#[derive(Debug)] +pub struct FmtItem { + pub input: String, + pub output: String, + pub phony_out: String, +} + +#[derive(Debug)] +pub struct N2FmtInput { + pub items: Vec, +} + +pub fn gen_fmt( + m: &ModuleDB, + _moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, +) -> anyhow::Result { + let mut items = vec![]; + for (_, pkg) in m.packages.iter() { + if pkg.is_third_party { + continue; + } + for f in pkg + .files + .iter() + .chain(pkg.wbtest_files.iter()) + .chain(pkg.test_files.iter()) + { + let item = FmtItem { + input: f.display().to_string(), + output: moonbuild_opt + .target_dir + .join(PathBuf::from_iter(pkg.rel.components.iter())) + .join(f.file_name().unwrap().to_str().unwrap()) + .display() + .to_string(), + phony_out: moonbuild_opt + .target_dir + .join(PathBuf::from_iter(pkg.rel.components.iter())) + .join(f.file_name().unwrap().to_str().unwrap()) + .with_extension("phony") + .display() + .to_string(), + }; + items.push(item); + } + } + Ok(N2FmtInput { items }) +} + +fn gen_inplace_fmt_command(graph: &mut n2graph::Graph, item: &FmtItem) -> (Build, FileId) { + let loc = FileLoc { + filename: Rc::new(PathBuf::from("format")), + line: 0, + }; + + let input_ids = vec![graph.files.id_from_canonical(item.input.clone())]; + + let output_id = graph.files.id_from_canonical(item.phony_out.clone()); + let output_ids = vec![output_id]; + + let ins = BuildIns { + ids: input_ids, + explicit: 1, + implicit: 0, + order_only: 0, + }; + + let outs = BuildOuts { + ids: output_ids, + explicit: 1, + }; + + let mut build = Build::new(loc, ins, outs); + + let command = CommandBuilder::new("moonfmt") + .arg(&item.input) + .arg("-w") + .build(); + build.cmdline = Some(command); + (build, output_id) +} + +fn gen_fmt_to_command(graph: &mut n2graph::Graph, item: &FmtItem) -> (Build, FileId) { + let loc = FileLoc { + filename: Rc::new(PathBuf::from("format")), + line: 0, + }; + + let input_ids = vec![graph.files.id_from_canonical(item.input.clone())]; + + let output_id = graph.files.id_from_canonical(item.output.clone()); + let output_ids = vec![output_id]; + + let ins = BuildIns { + ids: input_ids, + explicit: 1, + implicit: 0, + order_only: 0, + }; + + let outs = BuildOuts { + ids: output_ids, + explicit: 1, + }; + + let mut build = Build::new(loc, ins, outs); + + let command = CommandBuilder::new("moonfmt") + .arg(&item.input) + .arg("-o") + .arg(&item.output) + .build(); + build.cmdline = Some(command); + (build, output_id) +} + +pub fn gen_inplace_format_action(graph: &mut n2graph::Graph, ids: &[FileId]) -> (Build, FileId) { + let loc = FileLoc { + filename: Rc::new(PathBuf::from("format")), + line: 0, + }; + + let phony_out = graph + .files + .id_from_canonical("__inplace_format".to_string()); + + let ins = BuildIns { + ids: ids.into(), + explicit: ids.len(), + implicit: 0, + order_only: 0, + }; + + let outs = BuildOuts { + ids: vec![phony_out], + explicit: 1, + }; + + (Build::new(loc, ins, outs), phony_out) +} + +pub fn gen_format_to_action(graph: &mut n2graph::Graph, ids: &[FileId]) -> (Build, FileId) { + let loc = FileLoc { + filename: Rc::new(PathBuf::from("format")), + line: 0, + }; + + let phony_out = graph.files.id_from_canonical("__format_to".to_string()); + + let ins = BuildIns { + ids: ids.into(), + explicit: ids.len(), + implicit: 0, + order_only: 0, + }; + + let outs = BuildOuts { + ids: vec![phony_out], + explicit: 1, + }; + + (Build::new(loc, ins, outs), phony_out) +} + +pub fn gen_n2_fmt_state( + input: &N2FmtInput, + _moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, +) -> anyhow::Result { + let mut graph = n2graph::Graph::default(); + let mut default = vec![]; + let mut builds = vec![]; + + for item in input.items.iter() { + let (build, fid) = gen_inplace_fmt_command(&mut graph, item); + graph.add_build(build)?; + builds.push(fid); + } + let (all_inplace_format_build, inplace_format_action) = + gen_inplace_format_action(&mut graph, &builds); + + graph.add_build(all_inplace_format_build)?; + default.push(inplace_format_action); + + if moonbuild_opt.fmt_opt.as_ref().unwrap().check { + default.clear(); + builds.clear(); + for item in input.items.iter() { + let (build, fid) = gen_fmt_to_command(&mut graph, item); + graph.add_build(build)?; + builds.push(fid); + } + let (all_format_to_build, format_to_action) = gen_format_to_action(&mut graph, &builds); + graph.add_build(all_format_to_build)?; + default.push(format_to_action); + } + + let mut hashes = n2graph::Hashes::default(); + let db = n2::db::open( + &moonbuild_opt.target_dir.join("format.db"), + &mut graph, + &mut hashes, + )?; + + Ok(State { + graph, + db, + hashes, + default, + pools: SmallMap::default(), + }) +} diff --git a/crates/moonbuild/src/gen/cmd_builder.rs b/crates/moonbuild/src/gen/cmd_builder.rs new file mode 100644 index 00000000..66a9ce10 --- /dev/null +++ b/crates/moonbuild/src/gen/cmd_builder.rs @@ -0,0 +1,93 @@ +pub struct CommandBuilder { + command: String, + args: Vec, +} + +impl CommandBuilder { + pub fn new(command: &str) -> CommandBuilder { + CommandBuilder { + command: command.into(), + args: Vec::new(), + } + } + + pub fn arg_with_cond(&mut self, cond: bool, arg: &str) -> &mut CommandBuilder { + if cond { + self.args.push(arg.into()); + } + self + } + + pub fn lazy_args_with_cond( + &mut self, + cond: bool, + args: impl FnOnce() -> Vec, + ) -> &mut CommandBuilder { + if cond { + for arg in args().into_iter() { + self.args.push(arg); + } + } + self + } + + pub fn args_with_cond(&mut self, cond: bool, args: I) -> &mut CommandBuilder + where + I: IntoIterator, + S: Into, + { + if cond { + for arg in args { + self.args.push(arg.into()); + } + } + self + } + + pub fn arg(&mut self, arg: &str) -> &mut CommandBuilder { + self.args.push(arg.into()); + self + } + + pub fn args(&mut self, args: I) -> &mut CommandBuilder + where + I: IntoIterator, + S: Into, + { + for arg in args { + self.args.push(arg.into()); + } + self + } + + pub fn args_with_prefix_separator( + &mut self, + args: I, + separator: &str, + ) -> &mut CommandBuilder + where + I: IntoIterator, + S: Into, + { + for arg in args { + self.args.push(separator.into()); + self.args.push(arg.into()); + } + self + } + + pub fn build(&self) -> String { + let mut cmd = self.command.clone(); + for arg in self.args.iter() { + cmd.push(' '); + if arg.contains(' ') { + cmd.push('"'); + cmd.push_str(arg); + cmd.push('"'); + } else { + cmd.push_str(arg); + } + } + cmd + } +} diff --git a/crates/moonbuild/src/gen/gen_build.rs b/crates/moonbuild/src/gen/gen_build.rs new file mode 100644 index 00000000..acf9e9fb --- /dev/null +++ b/crates/moonbuild/src/gen/gen_build.rs @@ -0,0 +1,487 @@ +use anyhow::{bail, Ok}; +use moonutil::common::TargetBackend::*; +use moonutil::module::ModuleDB; +use moonutil::package::{JsFormat, Package}; + +use super::cmd_builder::CommandBuilder; +use crate::gen::MiAlias; +use std::path::{Path, PathBuf}; +use std::rc::Rc; + +use moonutil::common::{MoonbuildOpt, MooncOpt, TargetBackend, MOONBITLANG_CORE, MOON_PKG_JSON}; +use n2::graph::{self as n2graph, Build, BuildIns, BuildOuts, FileLoc}; +use n2::load::State; +use n2::smallmap::SmallMap; + +#[derive(Debug)] +pub struct BuildDepItem { + pub core_out: String, + pub mi_out: String, + pub mbt_deps: Vec, + pub mi_deps: Vec, // do not need add parent's mi files + pub package_full_name: String, + pub package_source_dir: String, + pub is_main: bool, + pub is_third_party: bool, +} + +#[derive(Debug)] +pub struct LinkDepItem { + pub out: String, + pub core_deps: Vec, // need add parent's core files recursively + pub package_full_name: String, + pub package_sources: Vec<(String, String)>, // (pkgname, source_dir) + + pub link: Option, +} + +#[derive(Debug)] +pub struct N2BuildInput { + pub build_items: Vec, + pub link_items: Vec, // entry points +} + +pub fn gen_build_build_item( + m: &ModuleDB, + pkg: &Package, + moonc_opt: &MooncOpt, +) -> anyhow::Result { + let core_out = pkg.artifact.with_extension("core"); + let mi_out = pkg.artifact.with_extension("mi"); + + let backend_filtered = + moonutil::common::backend_filter(&pkg.files, moonc_opt.link_opt.target_backend); + + let mbt_deps = backend_filtered + .iter() + .filter(|f| { + !f.file_name() + .unwrap() + .to_str() + .unwrap() + .ends_with("_test.mbt") + }) + .map(|f| f.display().to_string()) + .collect::>(); + + let mut mi_deps = vec![]; + + for dep in pkg.imports.iter() { + let full_import_name = dep.path.make_full_path(); + if !m.packages.contains_key(&full_import_name) { + bail!( + "{}: the imported package `{}` could not be located.", + m.source_dir + .join(pkg.rel.fs_full_name()) + .join(MOON_PKG_JSON) + .display(), + full_import_name, + ); + } + let cur_pkg = &m.packages[&full_import_name]; + let d = cur_pkg.artifact.with_extension("mi"); + let alias = dep.alias.clone().unwrap_or(cur_pkg.last_name().into()); + mi_deps.push(MiAlias { + name: d.display().to_string(), + alias, + }); + } + + let package_full_name = pkg.full_name(); + let package_source_dir: String = pkg.root_path.to_string_lossy().into_owned(); + + Ok(BuildDepItem { + core_out: core_out.display().to_string(), + mi_out: mi_out.display().to_string(), + mbt_deps, + mi_deps, + package_full_name, + package_source_dir, + is_main: pkg.is_main, + is_third_party: pkg.is_third_party, + }) +} + +pub fn gen_build_link_item( + m: &ModuleDB, + pkg: &Package, + _moonc_opt: &MooncOpt, +) -> anyhow::Result { + let out = pkg.artifact.with_extension("wat"); // TODO: extension is determined by build option + let package_full_name = pkg.full_name(); + + let tp = super::util::topo_from_node(m, pkg)?; + let core_deps = super::util::nodes_to_cores(m, &tp); + let package_sources = super::util::nodes_to_pkg_sources(m, &tp); + + Ok(LinkDepItem { + out: out.display().to_string(), + core_deps, + package_sources, + package_full_name, + link: pkg.link.clone(), + }) +} + +pub fn gen_build( + m: &ModuleDB, + moonc_opt: &MooncOpt, + _moonbuild_opt: &MoonbuildOpt, +) -> anyhow::Result { + let mut build_items = vec![]; + let mut link_items = vec![]; + for (i, (_, pkg)) in m.packages.iter().enumerate() { + let is_main = m.entries.contains(&i); + + if is_main { + // entry also need build + build_items.push(gen_build_build_item(m, pkg, moonc_opt)?); + // link need add *.core files recursively + link_items.push(gen_build_link_item(m, pkg, moonc_opt)?); + continue; + } + + if pkg.need_link { + build_items.push(gen_build_build_item(m, pkg, moonc_opt)?); + link_items.push(gen_build_link_item(m, pkg, moonc_opt)?); + continue; + } + + { + build_items.push(gen_build_build_item(m, pkg, moonc_opt)?); + } + } + Ok(N2BuildInput { + build_items, + link_items, + }) +} + +pub fn gen_build_command( + graph: &mut n2graph::Graph, + item: &BuildDepItem, + moonc_opt: &MooncOpt, +) -> Build { + let core_output_id = graph.files.id_from_canonical(item.core_out.clone()); + let mi_output_id = graph.files.id_from_canonical(item.mi_out.clone()); + + let loc = FileLoc { + filename: Rc::new(PathBuf::from("build")), + line: 0, + }; + + let mut inputs = item.mbt_deps.clone(); + inputs.extend(item.mi_deps.iter().map(|a| a.name.clone())); + let input_ids = inputs + .into_iter() + .map(|f| graph.files.id_from_canonical(f)) + .collect::>(); + + let mi_files_with_alias: Vec = item + .mi_deps + .iter() + .map(|a| format!("{}:{}", a.name, a.alias)) + .collect(); + + let len = input_ids.len(); + + let ins = BuildIns { + ids: input_ids, + explicit: len, + implicit: 0, + order_only: 0, + }; + + let outs = BuildOuts { + ids: vec![core_output_id, mi_output_id], + explicit: 1, + }; + + // WORKAROUND: do not test coverage on coverage library itself, because of cyclic dependency + let enable_coverage = moonc_opt.build_opt.enable_coverage + && !super::is_skip_coverage_lib(&item.package_full_name) + && !item.is_third_party; + // WORKAROUND: lang core/builtin and core/coverage should be able to cover themselves + let self_coverage = enable_coverage && super::is_self_coverage_lib(&item.package_full_name); + + let mut build = Build::new(loc, ins, outs); + + let cur_pkg_warn_list = match moonc_opt.build_opt.warn_lists.get(&item.package_full_name) { + Some(Some(warn_list)) => warn_list, + _ => "", + }; + let cur_pkg_alert_list = match moonc_opt.build_opt.alert_lists.get(&item.package_full_name) { + Some(Some(alert_list)) => alert_list, + _ => "", + }; + + let command = CommandBuilder::new("moonc") + .arg("build-package") + .args_with_cond(moonc_opt.render, vec!["-error-format", "json"]) + .args_with_cond( + moonc_opt.build_opt.deny_warn, + // the default strategy for warn and alert is +a and +all-raise-throw-unsafe+deprecated + // we replace + with @ to tell moonc treat warning as error + ["-w", "@a", "-alert", "@all-raise-throw-unsafe+deprecated"], + ) + .args(&item.mbt_deps) + .args_with_cond(!cur_pkg_warn_list.is_empty(), ["-w", cur_pkg_warn_list]) + .args_with_cond( + !cur_pkg_alert_list.is_empty(), + ["-alert", cur_pkg_alert_list], + ) + .arg("-o") + .arg(&item.core_out) + .arg("-pkg") + .arg(&item.package_full_name) + .arg_with_cond(item.is_main, "-is-main") + .args_with_cond( + !moonc_opt.nostd, + [ + "-std-path", + moonutil::moon_dir::core_bundle(moonc_opt.link_opt.target_backend) + .to_str() + .unwrap(), + ], + ) + .args_with_prefix_separator(mi_files_with_alias, "-i") + .arg("-pkg-sources") + .arg(&format!( + "{}:{}", + &item.package_full_name, &item.package_source_dir + )) + .args(["-target", moonc_opt.build_opt.target_backend.to_flag()]) + .arg_with_cond(moonc_opt.build_opt.debug_flag, "-g") + .arg_with_cond(moonc_opt.link_opt.source_map, "-source-map") + .arg_with_cond(enable_coverage, "-enable-coverage") + .arg_with_cond(self_coverage, "-coverage-package-override=@self") + .args(moonc_opt.extra_build_opt.iter()) + .build(); + log::debug!("Command: {}", command); + build.cmdline = Some(command); + build +} + +pub fn gen_link_command( + graph: &mut n2graph::Graph, + item: &LinkDepItem, + moonc_opt: &MooncOpt, +) -> (Build, n2graph::FileId) { + let artifact_output_path = PathBuf::from(&item.out) + .with_extension(moonc_opt.link_opt.output_format.to_str()) + .display() + .to_string(); + + let artifact_id = graph.files.id_from_canonical(artifact_output_path.clone()); + + let loc = FileLoc { + filename: Rc::new(PathBuf::from("build")), + line: 0, + }; + + let input_ids = item + .core_deps + .iter() + .map(|f| graph.files.id_from_canonical(f.clone())) + .collect::>(); + let len = input_ids.len(); + + let ins = BuildIns { + ids: input_ids, + explicit: len, + implicit: 0, + order_only: 0, + }; + + let outs = BuildOuts { + ids: vec![artifact_id], + explicit: 1, + }; + + let mut build = Build::new(loc, ins, outs); + + let exports = item.exports(moonc_opt.link_opt.target_backend); + let export_memory_name = item.export_memory_name(moonc_opt.link_opt.target_backend); + let heap_start_address = item.heap_start_address(moonc_opt.link_opt.target_backend); + let import_memory = item.import_memory(moonc_opt.link_opt.target_backend); + let link_flags = item.link_flags(moonc_opt.link_opt.target_backend); + + let command = CommandBuilder::new("moonc") + .arg("link-core") + .arg_with_cond( + !moonc_opt.nostd, + moonutil::moon_dir::core_core(moonc_opt.link_opt.target_backend) + .to_str() + .unwrap(), + ) + .args(&item.core_deps) + .arg("-main") + .arg(&item.package_full_name) + .arg("-o") + .arg(&artifact_output_path) + .args_with_prefix_separator( + item.package_sources + .iter() + .map(|(pkg, src)| format!("{}:{}", pkg, src)), + "-pkg-sources", + ) + .args_with_cond( + !moonc_opt.nostd, + [ + "-pkg-sources", + &format!( + "{}:{}", + MOONBITLANG_CORE, + &moonutil::moon_dir::core().display() + ), + ], + ) + .args(["-target", moonc_opt.link_opt.target_backend.to_flag()]) + .arg_with_cond(moonc_opt.link_opt.debug_flag, "-g") + .arg_with_cond(moonc_opt.link_opt.source_map, "-source-map") + .lazy_args_with_cond(exports.is_some(), || { + let es = exports.unwrap(); + if es.is_empty() { + vec!["".to_string()] + } else { + vec![format!( + "-exported_functions={}", + exports.unwrap().join(",") + )] + } + }) + .lazy_args_with_cond(export_memory_name.is_some(), || { + vec![ + "-export-memory-name".to_string(), + export_memory_name.unwrap().to_string(), + ] + }) + .lazy_args_with_cond(import_memory.is_some(), || { + let im = import_memory.unwrap(); + vec![ + "-import-memory-module".to_string(), + im.module.clone(), + "-import-memory-name".to_string(), + im.name.clone(), + ] + }) + .lazy_args_with_cond(heap_start_address.is_some(), || { + vec![ + "-heap-start-address".to_string(), + heap_start_address.unwrap().to_string(), + ] + }) + .lazy_args_with_cond(link_flags.is_some(), || link_flags.unwrap()) + .lazy_args_with_cond( + moonc_opt.link_opt.target_backend == moonutil::common::TargetBackend::Js + && item.link.is_some() + && item.link.as_ref().unwrap().js.is_some(), + || { + let js = item.link.as_ref().unwrap().js.as_ref().unwrap(); + if js.format.is_some() { + vec![ + "-js-format".to_string(), + js.format.unwrap().to_flag().to_string(), + ] + } else { + vec![ + "-js-format".to_string(), + JsFormat::default().to_flag().to_string(), + ] + } + }, + ) + .args(moonc_opt.extra_link_opt.iter()) + .build(); + log::debug!("Command: {}", command); + build.cmdline = Some(command); + (build, artifact_id) +} + +pub fn gen_n2_build_state( + input: &N2BuildInput, + target_dir: &Path, + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, +) -> anyhow::Result { + let _ = moonbuild_opt; + let mut graph = n2graph::Graph::default(); + let mut default = vec![]; + + for item in input.build_items.iter() { + let build = gen_build_command(&mut graph, item, moonc_opt); + graph.add_build(build)?; + } + for item in input.link_items.iter() { + let (build, fid) = gen_link_command(&mut graph, item, moonc_opt); + default.push(fid); + graph.add_build(build)?; + } + + let mut hashes = n2graph::Hashes::default(); + let db = n2::db::open(&target_dir.join("build.moon_db"), &mut graph, &mut hashes)?; + + Ok(State { + graph, + db, + hashes, + default, + pools: SmallMap::default(), + }) +} + +#[rustfmt::skip] +impl LinkDepItem { + pub fn wasm_exports(&self) -> Option<&Vec> { self.link.as_ref()?.wasm.as_ref()?.exports.as_ref() } + pub fn wasm_export_memory_name(&self) -> Option<&String> { self.link.as_ref()?.wasm.as_ref()?.export_memory_name.as_ref() } + pub fn wasm_import_memory(&self) -> Option<&moonutil::package::ImportMemory> { self.link.as_ref()?.wasm.as_ref()?.import_memory.as_ref() } + pub fn wasm_heap_start_address(&self) -> Option<&u32> { self.link.as_ref()?.wasm.as_ref()?.heap_start_address.as_ref() } + pub fn wasm_link_flags(&self) -> Option<&Vec> { self.link.as_ref()?.wasm.as_ref()?.flags.as_ref() } + + pub fn wasm_gc_exports(&self) -> Option<&Vec> { self.link.as_ref()?.wasm_gc.as_ref()?.exports.as_ref() } + pub fn wasm_gc_export_memory_name(&self) -> Option<&String> { self.link.as_ref()?.wasm_gc.as_ref()?.export_memory_name.as_ref() } + pub fn wasm_gc_import_memory(&self) -> Option<&moonutil::package::ImportMemory> { self.link.as_ref()?.wasm_gc.as_ref()?.import_memory.as_ref() } + pub fn wasm_gc_link_flags(&self) -> Option<&Vec> { self.link.as_ref()?.wasm_gc.as_ref()?.flags.as_ref() } + + pub fn js_exports(&self) -> Option<&Vec> { self.link.as_ref()?.js.as_ref()?.exports.as_ref() } + + pub fn exports(&self, b: TargetBackend) -> Option<&Vec> { + match b { + Wasm => self.wasm_exports(), + WasmGC => self.wasm_gc_exports(), + Js => self.js_exports(), + } + } + + pub fn export_memory_name(&self, b: TargetBackend) -> Option<&String> { + match b { + Wasm => self.wasm_export_memory_name(), + WasmGC => self.wasm_gc_export_memory_name(), + Js => None, + } + } + + pub fn heap_start_address(&self, b: TargetBackend) -> Option<&u32> { + match b { + Wasm => self.wasm_heap_start_address(), + WasmGC => None, + Js => None, + } + } + + pub fn import_memory(&self, b: TargetBackend) -> Option<&moonutil::package::ImportMemory> { + match b { + Wasm => self.wasm_import_memory(), + WasmGC => self.wasm_gc_import_memory(), + Js => None, + } + } + + pub fn link_flags(&self, b: TargetBackend) -> Option> { + match b { + Wasm => self.wasm_link_flags().cloned(), + WasmGC => self.wasm_gc_link_flags().cloned(), + Js => None, + } + } +} diff --git a/crates/moonbuild/src/gen/gen_bundle.rs b/crates/moonbuild/src/gen/gen_bundle.rs new file mode 100644 index 00000000..cb8e4621 --- /dev/null +++ b/crates/moonbuild/src/gen/gen_bundle.rs @@ -0,0 +1,300 @@ +use anyhow::bail; +use indexmap::IndexMap; +use moonutil::module::ModuleDB; +use moonutil::package::Package; +use n2::graph::{self as n2graph, Build, BuildIns, BuildOuts, FileLoc}; +use n2::load::State; +use n2::smallmap::SmallMap; +use std::path::{Path, PathBuf}; +use std::rc::Rc; + +use moonutil::common::{MoonbuildOpt, MooncOpt, MOON_PKG_JSON}; + +use super::cmd_builder::CommandBuilder; +use crate::gen::MiAlias; + +#[derive(Debug)] +pub struct BundleDepItem { + pub mi_out: String, + pub core_out: String, + pub mbt_deps: Vec, + pub mi_deps: Vec, + pub package_full_name: String, + pub package_source_dir: String, + pub is_main: bool, +} + +#[derive(Debug)] +pub struct N2BundleAll { + pub order: Vec, + pub name: String, +} + +#[derive(Debug)] +pub struct N2BundleInput { + pub bundle_items: Vec, + pub bundle_order: N2BundleAll, +} + +pub fn gen_bundle( + m: &ModuleDB, + moonc_opt: &MooncOpt, + _moonbuild_opt: &MoonbuildOpt, +) -> anyhow::Result { + let mut dep_items = vec![]; + for (_, pkg) in m.packages.iter() { + let item = pkg_to_bundle_item(&m.source_dir, &m.packages, pkg, moonc_opt)?; + dep_items.push(item); + } + + let nodes = super::util::toposort(m)?; + let mut order = vec![]; + for node in nodes.iter() { + let p = &m.packages[node]; + order.push( + p.artifact + .with_extension("core") + .to_str() + .unwrap() + .to_string(), + ); + } + + Ok(N2BundleInput { + bundle_items: dep_items, + bundle_order: N2BundleAll { + order, + name: m.name.split('/').last().unwrap_or("bundle").to_string(), + }, + }) +} + +pub fn pkg_to_bundle_item( + source_dir: &Path, + packages: &IndexMap, + pkg: &Package, + moonc_opt: &MooncOpt, +) -> anyhow::Result { + let core_out = pkg.artifact.with_extension("core"); + let mi_out = pkg.artifact.with_extension("mi"); + + let backend_filtered = + moonutil::common::backend_filter(&pkg.files, moonc_opt.link_opt.target_backend); + let mbt_deps = backend_filtered + .iter() + .filter(|f| { + !f.file_name() + .unwrap() + .to_str() + .unwrap() + .ends_with("_test.mbt") + }) + .map(|f| f.display().to_string()) + .collect::>(); + + let mut mi_deps = vec![]; + + for dep in pkg.imports.iter() { + let full_import_name = dep.path.make_full_path(); + if !packages.contains_key(&full_import_name) { + bail!( + "{}: the imported package `{}` could not be located.", + source_dir + .join(pkg.rel.fs_full_name()) + .join(MOON_PKG_JSON) + .display(), + full_import_name, + ); + } + let cur_pkg = &packages[&full_import_name]; + let d = cur_pkg.artifact.with_extension("mi"); + let alias = dep.alias.clone().unwrap_or(cur_pkg.last_name().into()); + mi_deps.push(MiAlias { + name: d.display().to_string(), + alias, + }); + } + + let package_full_name = pkg.full_name(); + let package_source_dir: String = if pkg.rel.components.is_empty() { + source_dir.display().to_string() + } else { + source_dir + .join(pkg.rel.fs_full_name()) + .to_str() + .unwrap() + .into() + }; + Ok(BundleDepItem { + mi_out: mi_out.display().to_string(), + core_out: core_out.display().to_string(), + mbt_deps, + mi_deps, + package_full_name, + package_source_dir, + is_main: pkg.is_main, + }) +} + +pub fn gen_build_command( + graph: &mut n2graph::Graph, + item: &BundleDepItem, + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, +) -> Build { + let _ = moonbuild_opt; + let core_output_id = graph.files.id_from_canonical(item.core_out.clone()); + let mi_output_id = graph.files.id_from_canonical(item.mi_out.clone()); + + let loc = FileLoc { + filename: Rc::new(PathBuf::from("build")), + line: 0, + }; + + let mut inputs = item.mbt_deps.clone(); + inputs.extend(item.mi_deps.iter().map(|a| a.name.clone())); + let input_ids = inputs + .iter() + .map(|f| graph.files.id_from_canonical(f.clone())) + .collect::>(); + + let mi_files_with_alias: Vec = item + .mi_deps + .iter() + .map(|a| format!("{}:{}", a.name, a.alias)) + .collect(); + + let len = input_ids.len(); + + let ins = BuildIns { + ids: input_ids, + explicit: len, + implicit: 0, + order_only: 0, + }; + + let outs = BuildOuts { + ids: vec![core_output_id, mi_output_id], + explicit: 1, + }; + + let mut build = Build::new(loc, ins, outs); + + let cur_pkg_warn_list = match moonc_opt.build_opt.warn_lists.get(&item.package_full_name) { + Some(Some(warn_list)) => warn_list, + _ => "", + }; + let cur_pkg_alert_list = match moonc_opt.build_opt.alert_lists.get(&item.package_full_name) { + Some(Some(alert_list)) => alert_list, + _ => "", + }; + + let command = CommandBuilder::new("moonc") + .arg("build-package") + .args_with_cond(moonc_opt.render, vec!["-error-format", "json"]) + .args(&item.mbt_deps) + .args_with_cond(!cur_pkg_warn_list.is_empty(), ["-w", cur_pkg_warn_list]) + .args_with_cond( + !cur_pkg_alert_list.is_empty(), + ["-alert", cur_pkg_alert_list], + ) + .arg("-o") + .arg(&item.core_out) + .arg("-pkg") + .arg(&item.package_full_name) + .arg_with_cond(item.is_main, "-is-main") + .args_with_prefix_separator(mi_files_with_alias, "-i") + .arg("-pkg-sources") + .arg(&format!( + "{}:{}", + &item.package_full_name, &item.package_source_dir + )) + .args(["-target", moonc_opt.build_opt.target_backend.to_flag()]) + .arg_with_cond(moonc_opt.build_opt.debug_flag, "-g") + .arg_with_cond(moonc_opt.link_opt.source_map, "-source-map") + .args(moonc_opt.extra_build_opt.iter()) + .build(); + log::debug!("Command: {}", command); + build.cmdline = Some(command); + build +} + +fn gen_bundle_all( + graph: &mut n2graph::Graph, + bundle_all: &N2BundleAll, + target_dir: &Path, + _moonc_opt: &MooncOpt, +) -> Build { + let loc = FileLoc { + filename: Rc::new(PathBuf::from("bundle")), + line: 0, + }; + + let out = target_dir.join(&bundle_all.name).with_extension("core"); + let core_output_id = graph.files.id_from_canonical(out.display().to_string()); + + let input_ids = bundle_all + .order + .iter() + .map(|f| graph.files.id_from_canonical(f.clone())) + .collect::>(); + + let len = input_ids.len(); + + let ins = BuildIns { + ids: input_ids, + explicit: len, + implicit: 0, + order_only: 0, + }; + + let outs = BuildOuts { + ids: vec![core_output_id], + explicit: 1, + }; + + let mut build = Build::new(loc, ins, outs); + + let command = CommandBuilder::new("moonc") + .arg("bundle-core") + .args(bundle_all.order.iter()) + .arg("-o") + .arg(out.to_str().unwrap()) + .build(); + + log::debug!("Command: {}", command); + build.cmdline = Some(command); + build +} + +pub fn gen_n2_bundle_state( + input: &N2BundleInput, + target_dir: &Path, + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, +) -> anyhow::Result { + let mut graph = n2graph::Graph::default(); + + for item in input.bundle_items.iter() { + let build = gen_build_command(&mut graph, item, moonc_opt, moonbuild_opt); + graph.add_build(build)?; + } + + { + let build = gen_bundle_all(&mut graph, &input.bundle_order, target_dir, moonc_opt); + graph.add_build(build)?; + } + + let default = graph.get_start_nodes(); + + let mut hashes = n2graph::Hashes::default(); + let db = n2::db::open(&target_dir.join("build.moon_db"), &mut graph, &mut hashes)?; + + Ok(State { + graph, + db, + hashes, + default, + pools: SmallMap::default(), + }) +} diff --git a/crates/moonbuild/src/gen/gen_check.rs b/crates/moonbuild/src/gen/gen_check.rs new file mode 100644 index 00000000..7c62a957 --- /dev/null +++ b/crates/moonbuild/src/gen/gen_check.rs @@ -0,0 +1,344 @@ +use super::cmd_builder::CommandBuilder; +use crate::gen::MiAlias; +use anyhow::bail; +use indexmap::map::IndexMap; +use moonutil::module::ModuleDB; +use moonutil::package::Package; +use std::path::{Path, PathBuf}; +use std::rc::Rc; + +use moonutil::common::{MoonbuildOpt, MooncOpt, MOON_PKG_JSON}; +use n2::graph::{self as n2graph, Build, BuildIns, BuildOuts, FileLoc}; +use n2::load::State; +use n2::smallmap::SmallMap; + +#[derive(Debug)] +pub struct CheckDepItem { + pub mi_out: String, + pub mbt_deps: Vec, + pub mi_deps: Vec, + pub package_full_name: String, + pub package_source_dir: String, + pub is_main: bool, +} + +#[derive(Debug)] +pub struct N2CheckInput { + pub dep_items: Vec, +} + +fn pkg_to_check_item( + source_dir: &Path, + packages: &IndexMap, + pkg: &Package, + moonc_opt: &MooncOpt, +) -> anyhow::Result { + let out = pkg.artifact.with_extension("mi"); + + let backend_filtered = + moonutil::common::backend_filter(&pkg.files, moonc_opt.link_opt.target_backend); + let mbt_deps: Vec = backend_filtered + .iter() + .map(|f| f.display().to_string()) + .collect::>(); + + let mut mi_deps = vec![]; + + for dep in pkg.imports.iter() { + let full_import_name = dep.path.make_full_path(); + if !packages.contains_key(&full_import_name) { + bail!( + "{}: the imported package `{}` could not be located.", + source_dir + .join(pkg.rel.fs_full_name()) + .join(MOON_PKG_JSON) + .display(), + full_import_name, + ); + } + let cur_pkg = &packages[&full_import_name]; + let d = cur_pkg.artifact.with_extension("mi"); + let alias = dep.alias.clone().unwrap_or(cur_pkg.last_name().into()); + mi_deps.push(MiAlias { + name: d.display().to_string(), + alias, + }); + } + + let package_full_name = pkg.full_name(); + let package_source_dir: String = pkg.root_path.to_string_lossy().into_owned(); + + Ok(CheckDepItem { + mi_out: out.display().to_string(), + mbt_deps, + mi_deps, + package_full_name, + package_source_dir, + is_main: pkg.is_main, + }) +} + +fn pkg_with_wbtest_to_check_item( + source_dir: &Path, + packages: &IndexMap, + pkg: &Package, + moonc_opt: &MooncOpt, +) -> anyhow::Result { + let out = pkg + .artifact + .with_file_name(format!("{}.underscore_test.mi", pkg.last_name())); + + let backend_filtered = moonutil::common::backend_filter( + &pkg.files + .iter() + .chain(pkg.wbtest_files.iter()) + .cloned() + .collect::>(), + moonc_opt.link_opt.target_backend, + ); + let mbt_deps: Vec = backend_filtered + .iter() + .map(|f| f.display().to_string()) + .collect::>(); + + let mut mi_deps = vec![]; + + for dep in pkg.imports.iter().chain(pkg.wbtest_imports.iter()) { + let full_import_name = dep.path.make_full_path(); + if !packages.contains_key(&full_import_name) { + bail!( + "{}: the imported package `{}` could not be located.", + source_dir + .join(pkg.rel.fs_full_name()) + .join(MOON_PKG_JSON) + .display(), + full_import_name, + ); + } + let cur_pkg = &packages[&full_import_name]; + let d = cur_pkg.artifact.with_extension("mi"); + let alias = dep.alias.clone().unwrap_or(cur_pkg.last_name().into()); + mi_deps.push(MiAlias { + name: d.display().to_string(), + alias, + }); + } + + let package_full_name = pkg.full_name(); + let package_source_dir: String = pkg.root_path.to_string_lossy().into_owned(); + + Ok(CheckDepItem { + mi_out: out.display().to_string(), + mbt_deps, + mi_deps, + package_full_name, + package_source_dir, + is_main: pkg.is_main, + }) +} + +fn pkg_with_test_to_check_item( + source_dir: &Path, + packages: &IndexMap, + pkg: &Package, + moonc_opt: &MooncOpt, +) -> anyhow::Result { + let out = pkg + .artifact + .with_file_name(format!("{}.blackbox_test.mi", pkg.last_name())); + + let backend_filtered = + moonutil::common::backend_filter(&pkg.test_files, moonc_opt.link_opt.target_backend); + let mbt_deps: Vec = backend_filtered + .iter() + .map(|f| f.display().to_string()) + .collect::>(); + + // add cur pkg as .mi dependency + let mut mi_deps = vec![MiAlias { + name: pkg + .artifact + .with_file_name(format!("{}.mi", pkg.last_name())) + .display() + .to_string(), + alias: pkg.last_name().into(), + }]; + + for dep in pkg.imports.iter().chain(pkg.test_imports.iter()) { + let full_import_name = dep.path.make_full_path(); + if !packages.contains_key(&full_import_name) { + bail!( + "{}: the imported package `{}` could not be located.", + source_dir + .join(pkg.rel.fs_full_name()) + .join(MOON_PKG_JSON) + .display(), + full_import_name, + ); + } + let cur_pkg = &packages[&full_import_name]; + let d = cur_pkg.artifact.with_extension("mi"); + let alias = dep.alias.clone().unwrap_or(cur_pkg.last_name().into()); + mi_deps.push(MiAlias { + name: d.display().to_string(), + alias, + }); + } + + // this is used for `-pkg` flag in `moonc check`, shouldn't be `pkg.full_name()` since we aren't check that package, otherwise we might encounter an error like "4015] Error: Type StructName has no method method_name"(however, StructName does has method method_name). + // actually, `-pkg` flag is not necessary for blackbox test, but we still keep it for consistency + let package_full_name = pkg.full_name() + "_blackbox_test"; + let package_source_dir: String = pkg.root_path.to_string_lossy().into_owned(); + + Ok(CheckDepItem { + mi_out: out.display().to_string(), + mbt_deps, + mi_deps, + package_full_name, + package_source_dir, + is_main: pkg.is_main, + }) +} + +pub fn gen_check( + m: &ModuleDB, + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, +) -> anyhow::Result { + let _ = moonc_opt; + let _ = moonbuild_opt; + let mut dep_items = vec![]; + for (_, pkg) in m.packages.iter() { + let item = pkg_to_check_item(&pkg.root_path, &m.packages, pkg, moonc_opt)?; + dep_items.push(item); + if !pkg.wbtest_files.is_empty() { + let item = pkg_with_wbtest_to_check_item(&pkg.root_path, &m.packages, pkg, moonc_opt)?; + dep_items.push(item); + } + if !pkg.test_files.is_empty() { + let item = pkg_with_test_to_check_item(&pkg.root_path, &m.packages, pkg, moonc_opt)?; + dep_items.push(item); + } + } + Ok(N2CheckInput { dep_items }) +} + +pub fn gen_check_command( + graph: &mut n2graph::Graph, + item: &CheckDepItem, + moonc_opt: &MooncOpt, +) -> Build { + let mi_output_id = graph.files.id_from_canonical(item.mi_out.clone()); + let loc = FileLoc { + filename: Rc::new(PathBuf::from("check")), + line: 0, + }; + + let mut inputs = item.mbt_deps.clone(); + inputs.extend(item.mi_deps.iter().map(|a| a.name.clone())); + + let input_ids = inputs + .into_iter() + .map(|f| graph.files.id_from_canonical(f)) + .collect::>(); + + let len = input_ids.len(); + + let ins = BuildIns { + ids: input_ids, + explicit: len, + implicit: 0, + order_only: 0, + }; + + let mi_files_with_alias: Vec = item + .mi_deps + .iter() + .map(|a| format!("{}:{}", a.name, a.alias)) + .collect(); + + let outs = BuildOuts { + ids: vec![mi_output_id], + explicit: 1, + }; + + let mut build = Build::new(loc, ins, outs); + + let cur_pkg_warn_list = match moonc_opt.build_opt.warn_lists.get(&item.package_full_name) { + Some(Some(warn_list)) => warn_list, + _ => "", + }; + let cur_pkg_alert_list = match moonc_opt.build_opt.alert_lists.get(&item.package_full_name) { + Some(Some(alert_list)) => alert_list, + _ => "", + }; + + let command = CommandBuilder::new("moonc") + .arg("check") + .args_with_cond(moonc_opt.render, vec!["-error-format", "json"]) + .args_with_cond( + moonc_opt.build_opt.deny_warn, + // the default strategy for warn and alert is +a and +all-raise-throw-unsafe+deprecated + // we replace + with @ to tell moonc treat warning as error + ["-w", "@a", "-alert", "@all-raise-throw-unsafe+deprecated"], + ) + .args(&item.mbt_deps) + .args_with_cond(!cur_pkg_warn_list.is_empty(), ["-w", cur_pkg_warn_list]) + .args_with_cond( + !cur_pkg_alert_list.is_empty(), + ["-alert", cur_pkg_alert_list], + ) + .arg("-o") + .arg(&item.mi_out) + .arg("-pkg") + .arg(&item.package_full_name) + .arg_with_cond(item.is_main, "-is-main") + .args_with_cond( + !moonc_opt.nostd, + [ + "-std-path", + moonutil::moon_dir::core_bundle(moonc_opt.link_opt.target_backend) + .to_str() + .unwrap(), + ], + ) + .args_with_prefix_separator(mi_files_with_alias, "-i") + .arg("-pkg-sources") + .arg(&format!( + "{}:{}", + &item.package_full_name, &item.package_source_dir + )) + .args(["-target", moonc_opt.build_opt.target_backend.to_flag()]) + .build(); + log::debug!("Command: {}", command); + build.cmdline = Some(command); + build +} + +pub fn gen_n2_check_state( + input: &N2CheckInput, + target_dir: &Path, + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, +) -> anyhow::Result { + let _ = moonbuild_opt; + let mut graph = n2graph::Graph::default(); + + for item in input.dep_items.iter() { + let build = gen_check_command(&mut graph, item, moonc_opt); + graph.add_build(build)?; + } + + let mut hashes = n2graph::Hashes::default(); + let db = n2::db::open(&target_dir.join("check.moon_db"), &mut graph, &mut hashes)?; + + let default = graph.get_start_nodes(); + + Ok(State { + graph, + db, + hashes, + default, + pools: SmallMap::default(), + }) +} diff --git a/crates/moonbuild/src/gen/gen_runtest.rs b/crates/moonbuild/src/gen/gen_runtest.rs new file mode 100644 index 00000000..bed0199b --- /dev/null +++ b/crates/moonbuild/src/gen/gen_runtest.rs @@ -0,0 +1,854 @@ +use anyhow::{bail, Ok}; +use colored::Colorize; +use moonutil::common::{GeneratedTestDriver, MOONBITLANG_CORE}; +use moonutil::module::ModuleDB; +use moonutil::package::Package; + +use super::cmd_builder::CommandBuilder; +use std::collections::HashSet; +use std::path::{Path, PathBuf}; +use std::rc::Rc; + +use moonutil::common::{MoonbuildOpt, MooncOpt, MOON_PKG_JSON}; +use n2::graph::{self as n2graph, Build, BuildIns, BuildOuts, FileLoc}; +use n2::load::State; +use n2::smallmap::SmallMap; + +use crate::gen::MiAlias; + +#[derive(Debug)] +pub struct RuntestDepItem { + pub core_out: String, + pub mi_out: String, + pub mbt_deps: Vec, + pub mi_deps: Vec, // do not need add parent's mi files + pub package_full_name: String, + pub package_source_dir: String, + pub is_main: bool, + pub is_third_party: bool, +} + +#[derive(Debug)] +pub struct RuntestLinkDepItem { + pub out: String, + pub core_deps: Vec, // need add parent's core files recursively + pub package_full_name: String, + pub package_sources: Vec<(String, String)>, // (pkgname, source_dir) + pub is_main: bool, + pub link: Option, +} + +#[derive(Debug)] +pub struct N2RuntestInput<'a> { + pub build_items: Vec, + pub link_items: Vec, // entry points + pub driver_files: Vec<&'a Path>, + pub files_contain_test_block: Vec<&'a Path>, +} + +pub fn gen_package_core( + m: &ModuleDB, + pkg: &Package, + moonc_opt: &MooncOpt, +) -> anyhow::Result { + let core_out = pkg.artifact.with_extension("core"); + let mi_out = pkg.artifact.with_extension("mi"); + + let backend_filtered: Vec = + moonutil::common::backend_filter(&pkg.files, moonc_opt.link_opt.target_backend); + let mbt_deps = backend_filtered + .iter() + .map(|f| f.display().to_string()) + .collect(); + + let mut mi_deps = vec![]; + for dep in pkg.imports.iter() { + let full_import_name = dep.path.make_full_path(); + if !m.packages.contains_key(&full_import_name) { + bail!( + "{}: the imported package `{}` could not be located.", + m.source_dir + .join(pkg.rel.fs_full_name()) + .join(MOON_PKG_JSON) + .display(), + full_import_name, + ); + } + let cur_pkg = &m.packages[&full_import_name]; + let d = cur_pkg.artifact.with_extension("mi"); + let alias = dep.alias.clone().unwrap_or(cur_pkg.last_name().into()); + mi_deps.push(MiAlias { + name: d.display().to_string(), + alias, + }); + } + + let package_full_name = pkg.full_name(); + let package_source_dir = pkg.root_path.to_string_lossy().into_owned(); + + Ok(RuntestDepItem { + core_out: core_out.display().to_string(), + mi_out: mi_out.display().to_string(), + mbt_deps, + mi_deps, + package_full_name, + package_source_dir, + is_main: false, + is_third_party: pkg.is_third_party, + }) +} + +pub fn gen_package_internal_test( + m: &ModuleDB, + pkg: &Package, + moonc_opt: &MooncOpt, +) -> anyhow::Result { + let pkgname = pkg.artifact.file_stem().unwrap().to_str().unwrap(); + let core_out = pkg + .artifact + .with_file_name(format!("{}.internal_test.core", pkgname)); + let mi_out = pkg + .artifact + .with_file_name(format!("{}.internal_test.mi", pkgname)); + + let backend_filtered = + moonutil::common::backend_filter(&pkg.files, moonc_opt.link_opt.target_backend); + let mut mbt_deps: Vec = backend_filtered + .iter() + .map(|f| f.display().to_string()) + .collect(); + + for item in pkg.generated_test_drivers.iter() { + if let GeneratedTestDriver::InternalTest(path) = item { + mbt_deps.push(path.display().to_string()); + } + } + + let mut mi_deps = vec![]; + for dep in pkg.imports.iter() { + let full_import_name = dep.path.make_full_path(); + if !m.packages.contains_key(&full_import_name) { + bail!( + "{}: the imported package `{}` could not be located.", + m.source_dir + .join(pkg.rel.fs_full_name()) + .join(MOON_PKG_JSON) + .display(), + full_import_name, + ); + } + let cur_pkg = &m.packages[&full_import_name]; + let d = cur_pkg.artifact.with_extension("mi"); + let alias = dep.alias.clone().unwrap_or(cur_pkg.last_name().into()); + mi_deps.push(MiAlias { + name: d.display().to_string(), + alias, + }); + } + + let package_full_name = pkg.full_name(); + let package_source_dir = pkg.root_path.to_string_lossy().into_owned(); + + Ok(RuntestDepItem { + core_out: core_out.display().to_string(), + mi_out: mi_out.display().to_string(), + mbt_deps, + mi_deps, + package_full_name, + package_source_dir, + is_main: true, + is_third_party: pkg.is_third_party, + }) +} + +pub fn gen_package_underscore_test( + m: &ModuleDB, + pkg: &Package, + moonc_opt: &MooncOpt, +) -> anyhow::Result { + let pkgname = pkg.artifact.file_stem().unwrap().to_str().unwrap(); + let core_out = pkg + .artifact + .with_file_name(format!("{}.underscore_test.core", pkgname)); + let mi_out = pkg + .artifact + .with_file_name(format!("{}.underscore_test.mi", pkgname)); + + let backend_filtered = + moonutil::common::backend_filter(&pkg.files, moonc_opt.link_opt.target_backend); + let mut mbt_deps: Vec = backend_filtered + .iter() + .chain(pkg.wbtest_files.iter()) + .map(|f| f.display().to_string()) + .collect(); + + for item in pkg.generated_test_drivers.iter() { + if let GeneratedTestDriver::UnderscoreTest(path) = item { + mbt_deps.push(path.display().to_string()); + } + } + + let mut mi_deps = vec![]; + for dep in pkg.imports.iter().chain(pkg.wbtest_imports.iter()) { + let full_import_name = dep.path.make_full_path(); + if !m.packages.contains_key(&full_import_name) { + bail!( + "{}: the imported package `{}` could not be located.", + m.source_dir + .join(pkg.rel.fs_full_name()) + .join(MOON_PKG_JSON) + .display(), + full_import_name, + ); + } + let cur_pkg = &m.packages[&full_import_name]; + let d = cur_pkg.artifact.with_extension("mi"); + let alias = dep.alias.clone().unwrap_or(cur_pkg.last_name().into()); + mi_deps.push(MiAlias { + name: d.display().to_string(), + alias, + }); + } + + let package_full_name = pkg.full_name(); + let package_source_dir = pkg.root_path.to_string_lossy().into_owned(); + + Ok(RuntestDepItem { + core_out: core_out.display().to_string(), + mi_out: mi_out.display().to_string(), + mbt_deps, + mi_deps, + package_full_name, + package_source_dir, + is_main: true, + is_third_party: pkg.is_third_party, + }) +} + +pub fn gen_package_blackbox_test( + m: &ModuleDB, + pkg: &Package, + moonc_opt: &MooncOpt, +) -> anyhow::Result { + let pkgname = pkg.artifact.file_stem().unwrap().to_str().unwrap(); + let core_out = pkg + .artifact + .with_file_name(format!("{}.blackbox_test.core", pkgname)); + let mi_out = pkg + .artifact + .with_file_name(format!("{}.blackbox_test.mi", pkgname)); + + let backend_filtered = + moonutil::common::backend_filter(&pkg.test_files, moonc_opt.link_opt.target_backend); + let mut mbt_deps: Vec = backend_filtered + .iter() + .map(|f| f.display().to_string()) + .collect(); + + for item in pkg.generated_test_drivers.iter() { + if let GeneratedTestDriver::BlackboxTest(path) = item { + mbt_deps.push(path.display().to_string()); + } + } + + // add the cur pkg .mi at build-package stage + let mut mi_deps = vec![MiAlias { + name: pkg + .artifact + .with_file_name(format!("{}.mi", pkgname)) + .display() + .to_string(), + alias: pkg.last_name().into(), + }]; + + for dep in pkg.imports.iter().chain(pkg.test_imports.iter()) { + let full_import_name = dep.path.make_full_path(); + if !m.packages.contains_key(&full_import_name) { + bail!( + "{}: the imported package `{}` could not be located.", + m.source_dir + .join(pkg.rel.fs_full_name()) + .join(MOON_PKG_JSON) + .display(), + full_import_name, + ); + } + let cur_pkg = &m.packages[&full_import_name]; + let d = cur_pkg.artifact.with_extension("mi"); + let alias = dep.alias.clone().unwrap_or(cur_pkg.last_name().into()); + mi_deps.push(MiAlias { + name: d.display().to_string(), + alias, + }); + } + + // this is used for `-pkg` flag in `moonc build-package`, shouldn't be `pkg.full_name()` since we aren't build that package, otherwise we might encounter an error like "4015] Error: Type StructName has no method method_name"(however, StructName does has method method_name). + // actually, `-pkg` flag is not necessary for blackbox test, but we still keep it for consistency + let package_full_name = pkg.full_name() + "_blackbox_test"; + let package_source_dir: String = pkg.root_path.to_string_lossy().into_owned(); + + Ok(RuntestDepItem { + core_out: core_out.display().to_string(), + mi_out: mi_out.display().to_string(), + mbt_deps, + mi_deps, + package_full_name, + package_source_dir, + is_main: true, + is_third_party: pkg.is_third_party, + }) +} + +fn get_pkg_topo_order<'a>( + m: &'a ModuleDB, + leaf: &Package, + with_wbtest_import: bool, + with_test_import: bool, +) -> Vec<&'a Package> { + let mut visited: HashSet = HashSet::new(); + let mut pkg_topo_order: Vec<&Package> = vec![]; + fn dfs<'a>( + m: &'a ModuleDB, + pkg_topo_order: &mut Vec<&'a Package>, + visited: &mut HashSet, + cur_pkg_full_name: &String, + with_wbtest_import: bool, + with_test_import: bool, + ) { + if visited.contains(cur_pkg_full_name) { + return; + } + visited.insert(cur_pkg_full_name.clone()); + let cur_pkg = &m.packages[cur_pkg_full_name]; + let imports = cur_pkg + .imports + .iter() + .chain(if with_wbtest_import { + cur_pkg.wbtest_imports.iter() + } else { + [].iter() + }) + .chain(if with_test_import { + cur_pkg.test_imports.iter() + } else { + [].iter() + }); + + for dep in imports { + dfs( + m, + pkg_topo_order, + visited, + &dep.path.make_full_path(), + false, + false, + ); + } + + pkg_topo_order.push(cur_pkg); + } + dfs( + m, + &mut pkg_topo_order, + &mut visited, + &leaf.full_name(), + with_wbtest_import, + with_test_import, + ); + pkg_topo_order +} + +fn get_package_sources(m: &ModuleDB, pkg_topo_order: &[&Package]) -> Vec<(String, String)> { + let mut package_sources = vec![]; + for cur_pkg in pkg_topo_order { + let package_source_dir: String = if cur_pkg.rel.components.is_empty() { + m.source_dir.display().to_string() + } else { + m.source_dir + .join(cur_pkg.rel.fs_full_name()) + .display() + .to_string() + }; + package_sources.push((cur_pkg.full_name(), package_source_dir)); + } + package_sources +} + +pub fn gen_link_internal_test( + m: &ModuleDB, + pkg: &Package, + _moonc_opt: &MooncOpt, +) -> anyhow::Result { + let out = pkg + .artifact + .with_file_name(format!("{}.internal_test.wat", pkg.last_name())); + + let pkg_topo_order: Vec<&Package> = get_pkg_topo_order(m, pkg, false, false); + + let mut core_deps = vec![]; + for cur_pkg in pkg_topo_order.iter() { + let d = if cur_pkg.full_name() == pkg.full_name() { + cur_pkg + .artifact + .with_file_name(format!("{}.internal_test.core", cur_pkg.last_name())) + } else { + cur_pkg.artifact.with_extension("core") + }; + core_deps.push(d.display().to_string()); + } + let package_sources = get_package_sources(m, &pkg_topo_order); + + let package_full_name = pkg.full_name(); + + Ok(RuntestLinkDepItem { + out: out.display().to_string(), + core_deps, + package_full_name, + package_sources, + is_main: true, + link: pkg.link.clone(), + }) +} + +pub fn gen_link_underscore_test( + m: &ModuleDB, + pkg: &Package, + _moonc_opt: &MooncOpt, +) -> anyhow::Result { + let out = pkg + .artifact + .with_file_name(format!("{}.underscore_test.wat", pkg.last_name())); + + let pkg_topo_order: Vec<&Package> = get_pkg_topo_order(m, pkg, true, false); + + let mut core_deps = vec![]; + for cur_pkg in pkg_topo_order.iter() { + let d = if cur_pkg.full_name() == pkg.full_name() { + cur_pkg + .artifact + .with_file_name(format!("{}.underscore_test.core", cur_pkg.last_name())) + } else { + cur_pkg.artifact.with_extension("core") + }; + core_deps.push(d.display().to_string()); + } + + let package_sources = get_package_sources(m, &pkg_topo_order); + + let package_full_name = pkg.full_name(); + + Ok(RuntestLinkDepItem { + out: out.display().to_string(), + core_deps, + package_full_name, + package_sources, + is_main: true, + link: pkg.link.clone(), + }) +} + +pub fn gen_link_blackbox_test( + m: &ModuleDB, + pkg: &Package, + _moonc_opt: &MooncOpt, +) -> anyhow::Result { + let pkgname = pkg.artifact.file_stem().unwrap().to_str().unwrap(); + let out = pkg + .artifact + .with_file_name(format!("{}.blackbox_test.wat", pkg.last_name())); + + let pkg_topo_order: Vec<&Package> = get_pkg_topo_order(m, pkg, false, true); + + let mut core_deps = vec![]; + for cur_pkg in pkg_topo_order.iter() { + let d = if cur_pkg.full_name() == pkg.full_name() { + // add the cur pkg .core in link-core stage + // make sure that the current package `.core` is placed before `blackbox_test.core` + core_deps.push( + pkg.artifact + .with_file_name(format!("{}.core", pkgname)) + .display() + .to_string(), + ); + + cur_pkg + .artifact + .with_file_name(format!("{}.blackbox_test.core", cur_pkg.last_name())) + } else { + cur_pkg.artifact.with_extension("core") + }; + core_deps.push(d.display().to_string()); + } + + let package_sources = get_package_sources(m, &pkg_topo_order); + + let package_full_name = pkg.full_name(); + + Ok(RuntestLinkDepItem { + out: out.display().to_string(), + core_deps, + package_full_name, + package_sources, + is_main: true, + link: pkg.link.clone(), + }) +} + +pub fn contain_mbt_test_file(pkg: &Package, moonc_opt: &MooncOpt) -> bool { + let backend_filtered = + moonutil::common::backend_filter(&pkg.files, moonc_opt.link_opt.target_backend); + backend_filtered.iter().any(|f| { + let filename = f.file_name().unwrap().to_str().unwrap().to_string(); + filename.ends_with("_test.mbt") + }) +} + +pub fn gen_runtest<'a>( + m: &'a ModuleDB, + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, +) -> anyhow::Result> { + let mut build_items = vec![]; + let mut link_items = vec![]; + let mut driver_files = vec![]; + let mut files_contain_test_block = vec![]; + + let filter_pkg = moonbuild_opt + .test_opt + .as_ref() + .and_then(|f| f.filter_package.as_ref()); + + for (pkgname, pkg) in m.packages.iter() { + if pkg.is_main { + continue; + } + + build_items.push(gen_package_core(m, pkg, moonc_opt)?); + + if pkg.is_third_party { + continue; + } + + files_contain_test_block.extend(pkg.files_contain_test_block.iter().map(|it| it.as_path())); + + if let Some(filter_pkg) = filter_pkg { + if !filter_pkg.contains(Path::new(pkgname)) { + continue; + } + } + + for item in pkg.generated_test_drivers.iter() { + if let GeneratedTestDriver::InternalTest(it) = item { + build_items.push(gen_package_internal_test(m, pkg, moonc_opt)?); + link_items.push(gen_link_internal_test(m, pkg, moonc_opt)?); + driver_files.push(it.as_path()); + } + } + + if !pkg.wbtest_files.is_empty() { + for item in pkg.generated_test_drivers.iter() { + if let GeneratedTestDriver::UnderscoreTest(it) = item { + build_items.push(gen_package_underscore_test(m, pkg, moonc_opt)?); + link_items.push(gen_link_underscore_test(m, pkg, moonc_opt)?); + driver_files.push(it.as_path()); + } + } + } + + if !pkg.test_files.is_empty() { + for item in pkg.generated_test_drivers.iter() { + if let GeneratedTestDriver::BlackboxTest(it) = item { + build_items.push(gen_package_blackbox_test(m, pkg, moonc_opt)?); + link_items.push(gen_link_blackbox_test(m, pkg, moonc_opt)?); + driver_files.push(it.as_path()); + } + } + } + } + + Ok(N2RuntestInput { + build_items, + link_items, + driver_files, + files_contain_test_block, + }) +} + +pub fn gen_runtest_build_command( + graph: &mut n2graph::Graph, + item: &RuntestDepItem, + moonc_opt: &MooncOpt, +) -> Build { + let core_output_id = graph.files.id_from_canonical(item.core_out.clone()); + let mi_output_id = graph.files.id_from_canonical(item.mi_out.clone()); + + let loc = FileLoc { + filename: Rc::new(PathBuf::from("build")), + line: 0, + }; + + let mut inputs = item.mbt_deps.clone(); + inputs.extend(item.mi_deps.iter().map(|a| a.name.clone())); + let input_ids = inputs + .into_iter() + .map(|f| graph.files.id_from_canonical(f)) + .collect::>(); + + let mi_files_with_alias: Vec = item + .mi_deps + .iter() + .map(|a| format!("{}:{}", a.name, a.alias)) + .collect(); + + let len = input_ids.len(); + + let ins = BuildIns { + ids: input_ids, + explicit: len, + implicit: 0, + order_only: 0, + }; + + let outs = BuildOuts { + ids: vec![core_output_id, mi_output_id], + explicit: 1, + }; + + // WORKAROUND: do not test coverage on coverage library itself, because of cyclic dependency + let enable_coverage = moonc_opt.build_opt.enable_coverage + && !super::is_skip_coverage_lib(&item.package_full_name) + && !item.is_third_party; + // WORKAROUND: lang core/builtin and core/coverage should be able to cover themselves + let self_coverage = enable_coverage && super::is_self_coverage_lib(&item.package_full_name); + + let mut build = Build::new(loc, ins, outs); + + let cur_pkg_warn_list = match moonc_opt.build_opt.warn_lists.get(&item.package_full_name) { + Some(Some(warn_list)) => warn_list, + _ => "", + }; + let cur_pkg_alert_list = match moonc_opt.build_opt.alert_lists.get(&item.package_full_name) { + Some(Some(alert_list)) => alert_list, + _ => "", + }; + + let command = CommandBuilder::new("moonc") + .arg("build-package") + .args_with_cond(moonc_opt.render, vec!["-error-format", "json"]) + .args(&item.mbt_deps) + .args_with_cond(!cur_pkg_warn_list.is_empty(), ["-w", cur_pkg_warn_list]) + .args_with_cond( + !cur_pkg_alert_list.is_empty(), + ["-alert", cur_pkg_alert_list], + ) + .arg("-o") + .arg(&item.core_out) + .arg("-pkg") + .arg(&item.package_full_name) + .arg_with_cond(item.is_main, "-is-main") + .args_with_cond( + !moonc_opt.nostd, + [ + "-std-path", + moonutil::moon_dir::core_bundle(moonc_opt.link_opt.target_backend) + .to_str() + .unwrap(), + ], + ) + .args_with_prefix_separator(mi_files_with_alias, "-i") + .arg("-pkg-sources") + .arg(&format!( + "{}:{}", + &item.package_full_name, &item.package_source_dir + )) + .args(["-target", moonc_opt.build_opt.target_backend.to_flag()]) + .arg_with_cond(moonc_opt.build_opt.debug_flag, "-g") + .arg_with_cond(enable_coverage, "-enable-coverage") + .arg_with_cond(self_coverage, "-coverage-package-override=@self") + .args(moonc_opt.extra_build_opt.iter()) + .build(); + log::debug!("Command: {}", command); + build.cmdline = Some(command); + build +} + +pub fn gen_runtest_link_command( + graph: &mut n2graph::Graph, + item: &RuntestLinkDepItem, + moonc_opt: &MooncOpt, +) -> (Build, n2graph::FileId) { + let artifact_output_path = PathBuf::from(&item.out) + .with_extension(moonc_opt.link_opt.output_format.to_str()) + .display() + .to_string(); + + let artifact_id = graph.files.id_from_canonical(artifact_output_path.clone()); + + let loc = FileLoc { + filename: Rc::new(PathBuf::from("build")), + line: 0, + }; + + let input_ids = item + .core_deps + .iter() + .map(|f| graph.files.id_from_canonical(f.clone())) + .collect::>(); + let len = input_ids.len(); + + let ins = BuildIns { + ids: input_ids, + explicit: len, + implicit: 0, + order_only: 0, + }; + + let outs = BuildOuts { + ids: vec![artifact_id], + explicit: 1, + }; + + let mut build = Build::new(loc, ins, outs); + + let command = CommandBuilder::new("moonc") + .arg("link-core") + .arg_with_cond( + !moonc_opt.nostd, + moonutil::moon_dir::core_core(moonc_opt.link_opt.target_backend) + .to_str() + .unwrap(), + ) + .args(&item.core_deps) + .arg("-main") + .arg(&item.package_full_name) + .arg("-o") + .arg(&artifact_output_path) + .arg("-test-mode") // always passing -test-mode to allow recover from panic + .args_with_prefix_separator( + item.package_sources + .iter() + .map(|(pkg, src)| format!("{}:{}", pkg, src)), + "-pkg-sources", + ) + .args_with_cond( + !moonc_opt.nostd, + [ + "-pkg-sources", + &format!( + "{}:{}", + MOONBITLANG_CORE, + &moonutil::moon_dir::core().display() + ), + ], + ) + .args(["-target", moonc_opt.link_opt.target_backend.to_flag()]) + .arg_with_cond(moonc_opt.link_opt.debug_flag, "-g") + .args(moonc_opt.extra_link_opt.iter()) + .build(); + log::debug!("Command: {}", command); + build.cmdline = Some(command); + (build, artifact_id) +} + +pub fn gen_n2_runtest_state( + input: &N2RuntestInput, + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, +) -> anyhow::Result { + let _ = moonbuild_opt; + let mut graph = n2graph::Graph::default(); + let mut default = vec![]; + + log::debug!("input: {:#?}", input); + + let gen_generate_test_driver_command = + gen_generate_test_driver_command(&mut graph, input, moonc_opt, moonbuild_opt); + graph.add_build(gen_generate_test_driver_command)?; + + for item in input.build_items.iter() { + let build = gen_runtest_build_command(&mut graph, item, moonc_opt); + graph.add_build(build)?; + } + for item in input.link_items.iter() { + let (build, fid) = gen_runtest_link_command(&mut graph, item, moonc_opt); + default.push(fid); + graph.add_build(build)?; + } + + if default.is_empty() { + eprintln!("{}: no test entry found", "Warning".yellow().bold()); + std::process::exit(0); + } + + let mut hashes = n2graph::Hashes::default(); + let db = n2::db::open( + &moonbuild_opt.target_dir.join("build.moon_db"), + &mut graph, + &mut hashes, + )?; + + Ok(State { + graph, + db, + hashes, + default, + pools: SmallMap::default(), + }) +} + +fn gen_generate_test_driver_command( + graph: &mut n2graph::Graph, + n2_run_test_input: &N2RuntestInput, + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, +) -> Build { + let (driver_files, files_contain_test_block) = ( + &n2_run_test_input.driver_files, + &n2_run_test_input.files_contain_test_block, + ); + + let ins = BuildIns { + ids: files_contain_test_block + .iter() + .map(|f| graph.files.id_from_canonical(f.display().to_string())) + .collect(), + explicit: files_contain_test_block.len(), + implicit: 0, + order_only: 0, + }; + let outs = BuildOuts { + explicit: driver_files.len(), + ids: driver_files + .iter() + .map(|f| graph.files.id_from_canonical(f.display().to_string())) + .collect(), + }; + + let loc = FileLoc { + filename: Rc::new(PathBuf::from("build")), + line: 0, + }; + + let mut build = Build::new(loc, ins, outs); + + let test_filter_command = moonbuild_opt + .test_opt + .as_ref() + .map_or(vec![], |t| t.to_command()); + let command = CommandBuilder::new( + &std::env::current_exe() + .map_or_else(|_| "moon".into(), |x| x.to_string_lossy().into_owned()), + ) + .arg("generate-test-driver") + .arg("--source-dir") + .arg(&moonbuild_opt.source_dir.display().to_string()) + .arg("--target-dir") + .arg(&moonbuild_opt.target_dir.display().to_string()) + .args_with_cond(!test_filter_command.is_empty(), &test_filter_command) + .arg_with_cond(moonbuild_opt.sort_input, "--sort-input") + .args(["--target", moonc_opt.build_opt.target_backend.to_flag()]) + .build(); + + build.cmdline = Some(command); + build +} diff --git a/crates/moonbuild/src/gen/mod.rs b/crates/moonbuild/src/gen/mod.rs new file mode 100644 index 00000000..f20b532d --- /dev/null +++ b/crates/moonbuild/src/gen/mod.rs @@ -0,0 +1,46 @@ +pub mod cmd_builder; +pub mod gen_build; +pub mod gen_bundle; +pub mod gen_check; +pub mod gen_runtest; +pub mod util; + +// WORKAROUND for do not test coverage on coverage library itself +const MOON_CORE_COVERAGE_LIB: &str = "moonbitlang/core/coverage"; +const MOON_CORE_BUILTIN_LIB: &str = "moonbitlang/core/builtin"; + +#[test] +fn test_start_with() { + use moonutil::common::MOONBITLANG_CORE; + assert!(MOON_CORE_COVERAGE_LIB.starts_with(MOONBITLANG_CORE)); + assert!(MOON_CORE_BUILTIN_LIB.starts_with(MOONBITLANG_CORE)); +} + +static SKIP_COVERAGE_LIBS: &[&str] = &[]; +static SELF_COVERAGE_LIBS: &[&str] = &[MOON_CORE_BUILTIN_LIB, MOON_CORE_COVERAGE_LIB]; + +fn is_skip_coverage_lib(name: &str) -> bool { + SKIP_COVERAGE_LIBS.contains(&name) +} + +fn is_self_coverage_lib(name: &str) -> bool { + SELF_COVERAGE_LIBS.contains(&name) +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct MiAlias { + pub name: String, + pub alias: String, +} + +impl PartialOrd for MiAlias { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.name.cmp(&other.name)) + } +} + +impl Ord for MiAlias { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.name.cmp(&other.name) + } +} diff --git a/crates/moonbuild/src/gen/util.rs b/crates/moonbuild/src/gen/util.rs new file mode 100644 index 00000000..3863fd69 --- /dev/null +++ b/crates/moonbuild/src/gen/util.rs @@ -0,0 +1,92 @@ +use anyhow::bail; +use moonutil::graph::get_example_cycle; +use moonutil::module::ModuleDB; +use moonutil::package::Package; +#[allow(unused)] +use std::collections::HashSet; + +use petgraph::dot::{Config, Dot}; + +pub fn toposort(m: &ModuleDB) -> anyhow::Result> { + let topo = match petgraph::algo::toposort(&m.graph, None) { + Ok(nodes) => { + let nodes_rev = nodes.iter().rev().map(|x| x.index()).collect::>(); + + super::util::nodes_to_names(m, &nodes_rev) + } + Err(cycle) => { + let cycle = get_example_cycle(&m.graph, cycle.node_id()); + let cycle = cycle + .into_iter() + .map(|n| m.packages[n.index()].full_name()) + .collect::>(); + bail!("cyclic dependency detected: {:?}", cycle); + } + }; + Ok(topo) +} + +pub fn topo_from_node(m: &ModuleDB, pkg: &Package) -> anyhow::Result> { + let pkg_full_name = pkg.full_name(); + let mut stk: Vec = Vec::new(); + let mut visited: HashSet = HashSet::new(); + + fn dfs( + m: &ModuleDB, + pkg_full_name: &String, + stk: &mut Vec, + visited: &mut HashSet, + ) -> anyhow::Result<()> { + visited.insert(pkg_full_name.clone()); + + for neighbor in m.packages[pkg_full_name].imports.iter() { + let neighbor_full_name = neighbor.path.make_full_path(); + if !visited.contains(&neighbor_full_name) { + dfs(m, &neighbor_full_name, stk, visited)?; + } + } + + stk.push(pkg_full_name.clone()); + Ok(()) + } + + dfs(m, &pkg_full_name, &mut stk, &mut visited)?; + Ok(stk) +} + +pub fn nodes_to_names(m: &ModuleDB, nodes: &[usize]) -> Vec { + nodes + .iter() + .map(|index| m.packages[*index].full_name()) + .collect::>() +} + +pub fn nodes_to_cores(m: &ModuleDB, nodes: &[String]) -> Vec { + nodes + .iter() + .map(|index| m.packages[index].artifact.with_extension("core")) + .map(|p| p.display().to_string()) + .collect::>() +} + +pub fn nodes_to_pkg_sources(m: &ModuleDB, nodes: &[String]) -> Vec<(String, String)> { + nodes + .iter() + .map(|index| { + let pkg = &m.packages[index]; + let package_source_dir: String = if pkg.rel.components.is_empty() { + m.source_dir.display().to_string() + } else { + m.source_dir + .join(pkg.rel.fs_full_name()) + .display() + .to_string() + }; + (pkg.full_name(), package_source_dir) + }) + .collect::>() +} + +pub fn graph_to_dot(m: &ModuleDB) { + println!("{:?}", Dot::with_config(&m.graph, &[Config::EdgeNoLabel])); +} diff --git a/crates/moonbuild/src/lib.rs b/crates/moonbuild/src/lib.rs new file mode 100644 index 00000000..ebd219d1 --- /dev/null +++ b/crates/moonbuild/src/lib.rs @@ -0,0 +1,59 @@ +use std::io::Write; + +pub mod bench; +pub mod build; +pub mod bundle; +pub mod check; +pub mod doc_http; +pub mod dry_run; +pub mod entry; +pub mod expect; +pub mod fmt; +pub mod gen; +pub mod new; +pub mod runtest; +pub mod section_capture; +pub mod upgrade; + +use sysinfo::{ProcessExt, System, SystemExt}; + +pub const MOON_PID_NAME: &str = ".moon.pid"; + +pub fn bail_moon_check_is_running(p: &std::path::Path) -> anyhow::Result { + anyhow::bail!( + "`moon check` is already running. If you are certain it is not running, you may want to manually delete `{}` and try again.", + p.to_str().unwrap_or(MOON_PID_NAME) + ) +} + +pub fn write_current_pid( + target_dir: &std::path::Path, + pid_path: &std::path::Path, +) -> anyhow::Result<()> { + std::fs::create_dir_all(target_dir)?; + let pid = std::process::id(); + let mut pid_file = std::fs::File::create(pid_path)?; + pid_file.write_all(pid.to_string().as_bytes())?; + Ok(()) +} + +pub fn watcher_is_running(pid_path: &std::path::Path) -> anyhow::Result { + if !pid_path.exists() { + return Ok(false); + } + + let pid = std::fs::read_to_string(pid_path)?; + let pid = pid.parse::()?; + let pid = sysinfo::Pid::from(pid); + let mut sys = System::new(); + sys.refresh_processes(); + if let Some(p) = sys.process(pid) { + if p.name() == "moon" { + Ok(true) + } else { + Ok(false) + } + } else { + Ok(false) + } +} diff --git a/crates/moonbuild/src/new.rs b/crates/moonbuild/src/new.rs new file mode 100644 index 00000000..2a46e4d2 --- /dev/null +++ b/crates/moonbuild/src/new.rs @@ -0,0 +1,219 @@ +use std::io::Write; +use std::path::Path; + +use anyhow::Context; +use colored::Colorize; + +use moonutil::common::MOON_PKG_JSON; +use moonutil::module::MoonModJSON; +use moonutil::package::MoonPkgJSON; +use moonutil::package::PkgJSONImportItem; + +use moonutil::common::MOON_MOD_JSON; + +pub fn create_or_warning(path: &Path) -> anyhow::Result<()> { + if path.exists() { + eprintln!( + "{} {}", + "Warning:".bold().yellow(), + format_args!("{} already exists", path.display()) + ); + } else { + std::fs::create_dir_all(path).context(format!("failed to create {}", path.display()))?; + } + Ok(()) +} + +pub fn moon_new_exec( + target_dir: &Path, + user: String, + name: String, + license: Option<&str>, +) -> anyhow::Result { + let cake_full_name = format!("{}/{}", user, name); + common(target_dir, &cake_full_name, license)?; + + let main_dir = target_dir.join("main"); + create_or_warning(&main_dir)?; + // main/${MOON_PKG} + { + let main_moon_pkg = main_dir.join(MOON_PKG_JSON); + let j = MoonPkgJSON { + name: None, + is_main: Some(true), + import: Some(moonutil::package::PkgJSONImport::List(vec![ + PkgJSONImportItem::String(format!("{}/lib", cake_full_name)), + ])), + wbtest_import: None, + test_import: None, + link: None, + warn_list: None, + alert_list: None, + }; + moonutil::common::write_package_json_to_file(&j, &main_moon_pkg)?; + } + // main/main.mbt + { + let main_moon = main_dir.join("main.mbt"); + let content = r#"fn main { + println(@lib.hello()) +} +"#; + let mut file = std::fs::File::create(main_moon).unwrap(); + file.write_all(content.as_bytes()).unwrap(); + } + + // LICENSE + { + if let Some("Apache-2.0") = license { + let license_file = target_dir.join("LICENSE"); + let content = include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/../moonbuild/template/apache-2.0.txt" + )); + let mut file = std::fs::File::create(license_file).unwrap(); + file.write_all(content.as_bytes()).unwrap(); + } + } + + println!("{} {}", "Created".bold().green(), target_dir.display()); + + Ok(0) +} + +pub fn moon_new_lib( + target_dir: &Path, + user: String, + name: String, + license: Option<&str>, +) -> anyhow::Result { + let cake_full_name = format!("{}/{}", user, name); + common(target_dir, &cake_full_name, license)?; + + // top.mbt + { + let top_mbt = target_dir.join("top.mbt"); + let content = r#"pub fn greeting() -> Unit { + println(@lib.hello()) +} +"#; + let mut file = std::fs::File::create(top_mbt).unwrap(); + file.write_all(content.as_bytes()).unwrap(); + } + + // moon.pkg.json + { + let moon_pkg_json = target_dir.join("moon.pkg.json"); + let content = format!( + r#"{{ + "import": [ + "{}/lib" + ] +}} +"#, + cake_full_name + ); + let mut file = std::fs::File::create(moon_pkg_json).unwrap(); + file.write_all(content.as_bytes()).unwrap(); + } + + println!("{} {}", "Created".bold().green(), target_dir.display()); + + Ok(0) +} + +fn common(target_dir: &Path, cake_full_name: &str, license: Option<&str>) -> anyhow::Result { + std::fs::create_dir_all(target_dir).context("failed to create target directory")?; + let git_init = std::process::Command::new("git") + .arg("init") + .current_dir(target_dir) + .status(); + match git_init { + Ok(status) if status.success() => {} + _ => { + eprintln!( + "{}: git init failed, make sure you have git in PATH", + "Warning".yellow().bold() + ); + } + } + + { + let m: MoonModJSON = MoonModJSON { + name: cake_full_name.into(), + version: Some("0.1.0".parse().unwrap()), + deps: None, + readme: Some("README.md".into()), + repository: Some("".into()), + license: license + .map(|s| s.to_string()) + .or_else(|| Some(String::from(""))), + keywords: Some(vec![]), + description: Some("".into()), + + compile_flags: None, + link_flags: None, + checksum: None, + ext: Default::default(), + }; + moonutil::common::write_module_json_to_file(&m, target_dir) + .context(format!("failed to write `{}`", MOON_MOD_JSON))?; + } + // .gitignore + { + let gitignore = target_dir.join(".gitignore"); + let content = "target/\n.mooncakes/\n"; + let mut file = std::fs::File::create(gitignore).unwrap(); + file.write_all(content.as_bytes()).unwrap(); + } + let lib_dir = target_dir.join("lib"); + create_or_warning(&lib_dir)?; + // lib/hello.mbt + { + let hello_mbt = lib_dir.join("hello.mbt"); + let content = r#"pub fn hello() -> String { + "Hello, world!" +} +"#; + let mut file = std::fs::File::create(hello_mbt).unwrap(); + file.write_all(content.as_bytes()).unwrap(); + } + // lib/hello_wbtest.mbt + { + let hello_mbt = lib_dir.join("hello_wbtest.mbt"); + let content = r#"test "hello" { + if hello() != "Hello, world!" { + raise "hello() != \"Hello, world!\"" + } +} +"#; + + let mut file = std::fs::File::create(hello_mbt).unwrap(); + file.write_all(content.as_bytes()).unwrap(); + } + // lib/moon.pkg.json + { + let lib_moon_pkg = lib_dir.join(MOON_PKG_JSON); + let j = MoonPkgJSON { + name: None, + is_main: None, + import: None, + wbtest_import: None, + test_import: None, + link: None, + warn_list: None, + alert_list: None, + }; + moonutil::common::write_package_json_to_file(&j, &lib_moon_pkg)?; + } + + // READMD.md + { + let md_file = target_dir.join("README.md"); + let content = format!("# {}", cake_full_name); + let mut file = std::fs::File::create(md_file).unwrap(); + file.write_all(content.as_bytes()).unwrap(); + } + + Ok(0) +} diff --git a/crates/moonbuild/src/runtest.rs b/crates/moonbuild/src/runtest.rs new file mode 100644 index 00000000..b35360ab --- /dev/null +++ b/crates/moonbuild/src/runtest.rs @@ -0,0 +1,87 @@ +use crate::section_capture::{handle_stdout, SectionCapture}; + +use super::gen; +use anyhow::{bail, Context}; +use moonutil::common::{ + MoonbuildOpt, MooncOpt, MOON_COVERAGE_DELIMITER_BEGIN, MOON_COVERAGE_DELIMITER_END, + MOON_TEST_DELIMITER_BEGIN, MOON_TEST_DELIMITER_END, +}; +use moonutil::module::ModuleDB; +use n2::load::State; +use serde::{Deserialize, Serialize}; +use std::process::Command; +use std::{path::Path, process::Stdio}; + +pub fn load_moon_proj( + module: &ModuleDB, + moonc_opt: &MooncOpt, + moonbuild_opt: &MoonbuildOpt, +) -> anyhow::Result { + // let module = module.clone(); + let n2_input = gen::gen_runtest::gen_runtest(module, moonc_opt, moonbuild_opt)?; + log::debug!("n2_input: {:#?}", n2_input); + gen::gen_runtest::gen_n2_runtest_state(&n2_input, moonc_opt, moonbuild_opt) +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct TestStatistics { + pub passed: u32, + pub package: String, + pub filenames: Vec, + pub messages: Vec, + pub test_names: Vec, +} + +pub fn run_wat(path: &Path, target_dir: &Path) -> anyhow::Result { + run("moonrun", path, target_dir) +} + +pub fn run_js(path: &Path, target_dir: &Path) -> anyhow::Result { + run("node", path, target_dir) +} + +fn run(command: &str, path: &Path, target_dir: &Path) -> anyhow::Result { + let mut execution = Command::new(command) + .arg(path) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::inherit()) + .spawn() + .with_context(|| format!("failed to execute '{} {}'", command, path.display()))?; + let stdout = execution.stdout.take().unwrap(); + + let mut test_capture = + SectionCapture::new(MOON_TEST_DELIMITER_BEGIN, MOON_TEST_DELIMITER_END, false); + let mut coverage_capture = SectionCapture::new( + MOON_COVERAGE_DELIMITER_BEGIN, + MOON_COVERAGE_DELIMITER_END, + true, + ); + + handle_stdout( + &mut std::io::BufReader::new(stdout), + &mut [&mut test_capture, &mut coverage_capture], + |line| print!("{}", line), + )?; + let output = execution.wait()?; + + if output.success() { + if let Some(coverage_output) = coverage_capture.finish() { + // Output to moonbit_coverage_