Skip to content

Commit

Permalink
Merge pull request #410 from moonbitlang/fix-dot-source
Browse files Browse the repository at this point in the history
fix dot source
  • Loading branch information
lijunchen authored Oct 22, 2024
2 parents 9d3a2d5 + 3c436dd commit 8c345fb
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions crates/moon/tests/cmd_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions crates/moon/tests/test_cases/test_dot_source.in/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
.mooncakes/
1 change: 1 addition & 0 deletions crates/moon/tests/test_cases/test_dot_source.in/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# username/hello
3 changes: 3 additions & 0 deletions crates/moon/tests/test_cases/test_dot_source.in/lib/hello.mbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn hello() -> String {
"Hello, world!"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test "hello" {
if @lib.hello() != "Hello, world!" {
fail!("@lib.hello() != \"Hello, world!\"")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
3 changes: 3 additions & 0 deletions crates/moon/tests/test_cases/test_dot_source.in/main/main.mbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main {
println(@lib.hello())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"is-main": true,
"import": [
"username/hello/lib"
]
}
10 changes: 10 additions & 0 deletions crates/moon/tests/test_cases/test_dot_source.in/moon.mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "username/hello",
"version": "0.1.0",
"readme": "README.md",
"repository": "",
"license": "",
"keywords": [],
"description": "",
"source": "."
}
5 changes: 5 additions & 0 deletions crates/moon/tests/test_cases/test_dot_source.in/moon.test
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion crates/moonutil/src/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Package> = IndexMap::new();
Expand Down

0 comments on commit 8c345fb

Please sign in to comment.