Skip to content

Commit

Permalink
Merge pull request #392 from moonbitlang/test-package-list
Browse files Browse the repository at this point in the history
test package list
  • Loading branch information
lijunchen authored Oct 16, 2024
2 parents a06362b + e355578 commit 075e55b
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ jobs:
chmod +x ~/.moon/bin/tcc
git clone --depth 1 https://github.com/moonbitlang/core.git ~/.moon/lib/core
echo "$HOME/.moon/bin" >> $GITHUB_PATH
echo "$GITHUB_WORKSPACE/target/debug" >> $GITHUB_PATH
- name: install MoonBit(Windows)
if: ${{ matrix.os == 'windows-latest' }}
Expand All @@ -153,6 +154,7 @@ jobs:
Invoke-WebRequest -Uri https://cli.moonbitlang.com/moon-ci/Windows-x86_64/mooncake.exe -OutFile "$env:USERPROFILE/.moon/bin/mooncake.exe"
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
"$env:GITHUB_WORKSPACE\target\debug" | Out-File -FilePath $env:GITHUB_PATH -Append
- name: Build
run: cargo build
Expand Down Expand Up @@ -223,6 +225,7 @@ jobs:
chmod +x ~/.moon/bin/tcc
git clone --depth 1 https://github.com/moonbitlang/core.git ~/.moon/lib/core
echo "$HOME/.moon/bin" >> $GITHUB_PATH
echo "$GITHUB_WORKSPACE/target/debug" >> $GITHUB_PATH
- name: install cargo-tarpaulin ${{ env.CARGO_TARPAULIN_VERSION }}
run: |
Expand Down
24 changes: 24 additions & 0 deletions crates/moon/tests/test_cases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7217,3 +7217,27 @@ fn test_use_cc_for_native_release() {
);
}
}

#[test]
fn test_moon_package_list() {
let dir = TestDir::new("test_publish.in");
check(
get_stderr(&dir, ["package", "--list"]),
expect![[r#"
Running moon check ...
Finished. moon: ran 3 tasks, now up to date
Check passed
README.md
moon.mod.json
src
src/lib
src/lib/hello.mbt
src/lib/hello_test.mbt
src/lib/moon.pkg.json
src/main
src/main/main.mbt
src/main/moon.pkg.json
Package to $ROOT/target/publish/username-hello-0.1.0.zip
"#]],
);
}
2 changes: 2 additions & 0 deletions crates/moon/tests/test_cases/test_publish.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_publish.in/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# username/hello
10 changes: 10 additions & 0 deletions crates/moon/tests/test_cases/test_publish.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": "MIT",
"keywords": [],
"description": "",
"source": "src"
}
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 @@
{}
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"
]
}

0 comments on commit 075e55b

Please sign in to comment.