diff --git a/crates/moon/tests/cmd_test.rs b/crates/moon/tests/cmd_test.rs index 7b1f7c84..b282e600 100644 --- a/crates/moon/tests/cmd_test.rs +++ b/crates/moon/tests/cmd_test.rs @@ -123,6 +123,7 @@ fn cmd_test() { ${WORK_DIR}/moon_info_001.in/moon.test, ok, ${WORK_DIR}/moon_info_002.in/moon.test, ok, ${WORK_DIR}/specify_source_dir_001.in/moon.test, ok, + ${WORK_DIR}/test_dot_source.in/moon.test, ok, ${WORK_DIR}/test_exclude_001.in/moon.test, ok, ${WORK_DIR}/test_exclude_002.in/moon.test, ok, ${WORK_DIR}/test_include_001.in/moon.test, ok, diff --git a/crates/moon/tests/test_cases/test_dot_source.in/.gitignore b/crates/moon/tests/test_cases/test_dot_source.in/.gitignore new file mode 100644 index 00000000..b1283a74 --- /dev/null +++ b/crates/moon/tests/test_cases/test_dot_source.in/.gitignore @@ -0,0 +1,2 @@ +target/ +.mooncakes/ diff --git a/crates/moon/tests/test_cases/test_dot_source.in/README.md b/crates/moon/tests/test_cases/test_dot_source.in/README.md new file mode 100644 index 00000000..ae00983f --- /dev/null +++ b/crates/moon/tests/test_cases/test_dot_source.in/README.md @@ -0,0 +1 @@ +# username/hello \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_dot_source.in/lib/hello.mbt b/crates/moon/tests/test_cases/test_dot_source.in/lib/hello.mbt new file mode 100644 index 00000000..9012592a --- /dev/null +++ b/crates/moon/tests/test_cases/test_dot_source.in/lib/hello.mbt @@ -0,0 +1,3 @@ +pub fn hello() -> String { + "Hello, world!" +} diff --git a/crates/moon/tests/test_cases/test_dot_source.in/lib/hello_test.mbt b/crates/moon/tests/test_cases/test_dot_source.in/lib/hello_test.mbt new file mode 100644 index 00000000..e0e3a7d1 --- /dev/null +++ b/crates/moon/tests/test_cases/test_dot_source.in/lib/hello_test.mbt @@ -0,0 +1,5 @@ +test "hello" { + if @lib.hello() != "Hello, world!" { + fail!("@lib.hello() != \"Hello, world!\"") + } +} diff --git a/crates/moon/tests/test_cases/test_dot_source.in/lib/moon.pkg.json b/crates/moon/tests/test_cases/test_dot_source.in/lib/moon.pkg.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/crates/moon/tests/test_cases/test_dot_source.in/lib/moon.pkg.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_dot_source.in/main/main.mbt b/crates/moon/tests/test_cases/test_dot_source.in/main/main.mbt new file mode 100644 index 00000000..d25cb935 --- /dev/null +++ b/crates/moon/tests/test_cases/test_dot_source.in/main/main.mbt @@ -0,0 +1,3 @@ +fn main { + println(@lib.hello()) +} diff --git a/crates/moon/tests/test_cases/test_dot_source.in/main/moon.pkg.json b/crates/moon/tests/test_cases/test_dot_source.in/main/moon.pkg.json new file mode 100644 index 00000000..48783525 --- /dev/null +++ b/crates/moon/tests/test_cases/test_dot_source.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_dot_source.in/moon.mod.json b/crates/moon/tests/test_cases/test_dot_source.in/moon.mod.json new file mode 100644 index 00000000..5a3a8239 --- /dev/null +++ b/crates/moon/tests/test_cases/test_dot_source.in/moon.mod.json @@ -0,0 +1,10 @@ +{ + "name": "username/hello", + "version": "0.1.0", + "readme": "README.md", + "repository": "", + "license": "", + "keywords": [], + "description": "", + "source": "." +} \ No newline at end of file diff --git a/crates/moon/tests/test_cases/test_dot_source.in/moon.test b/crates/moon/tests/test_cases/test_dot_source.in/moon.test new file mode 100644 index 00000000..67509ca0 --- /dev/null +++ b/crates/moon/tests/test_cases/test_dot_source.in/moon.test @@ -0,0 +1,5 @@ + $ moon check --dry-run --sort-input + moonc check ./lib/hello.mbt -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 ./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 -i ./target/wasm-gc/release/check/lib/lib.mi:lib -pkg-sources username/hello/main:./main -target wasm-gc + moonc check ./lib/hello_test.mbt -o ./target/wasm-gc/release/check/lib/lib.blackbox_test.mi -pkg username/hello/lib_blackbox_test -std-path $MOON_HOME/lib/core/target/wasm-gc/release/bundle -i ./target/wasm-gc/release/check/lib/lib.mi:lib -pkg-sources username/hello/lib_blackbox_test:./lib -target wasm-gc + diff --git a/crates/moonutil/src/scan.rs b/crates/moonutil/src/scan.rs index 57151119..a4dfc735 100644 --- a/crates/moonutil/src/scan.rs +++ b/crates/moonutil/src/scan.rs @@ -144,7 +144,7 @@ fn scan_module_packages( let mod_desc = read_module_desc_file_in_dir(module_source_dir)?; let module_source_dir = match &mod_desc.source { None => module_source_dir.to_path_buf(), - Some(p) => module_source_dir.join(p), + Some(p) => dunce::canonicalize(module_source_dir.join(p))?, }; let mut packages: IndexMap = IndexMap::new();