Skip to content

Commit

Permalink
internal: tweak review
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Flash committed Sep 9, 2024
1 parent 14c1c64 commit 61c2551
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 26 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Options:
-v, --verbose Increase verbosity
--trace Trace the execution of the program
--dry-run Do not actually run the command
--build-graph generate build graph
-h, --help Print help
```
Expand Down
28 changes: 5 additions & 23 deletions crates/moon/tests/test_cases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3548,20 +3548,11 @@ fn test_deny_warn() {
"#]],
);

let out = snapbox::cmd::Command::new(moon_bin())
.current_dir(&dir)
.args(["check", "--deny-warn", "--sort-input"])
.assert()
.failure()
.get_output()
.stdout
.to_owned();

check(
std::str::from_utf8(&out).unwrap(),
&get_err_stdout_with_args_and_replace_dir(&dir, ["check", "--deny-warn", "--sort-input"]),
expect![[r#"
failed: check: username/hello/lib
"#]],
failed: moonc check -error-format json -w @a -alert @all-raise-throw-unsafe+deprecated $ROOT/lib/hello.mbt -o $ROOT/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:$ROOT/lib -target wasm-gc
"#]],
);

check(
Expand Down Expand Up @@ -3613,19 +3604,10 @@ fn test_deny_warn() {
"#]],
);

let out = snapbox::cmd::Command::new(moon_bin())
.current_dir(&dir)
.args(["build", "--deny-warn", "--sort-input"])
.assert()
.failure()
.get_output()
.stdout
.to_owned();

check(
std::str::from_utf8(&out).unwrap(),
&get_err_stdout_with_args_and_replace_dir(&dir, ["build", "--deny-warn", "--sort-input"]),
expect![[r#"
failed: build-package: username/hello/lib
failed: moonc build-package -error-format json -w @a -alert @all-raise-throw-unsafe+deprecated $ROOT/lib/hello.mbt -o $ROOT/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:$ROOT/lib -target wasm-gc
"#]],
);
}
Expand Down
22 changes: 21 additions & 1 deletion crates/moon/tests/test_cases/moon_build_package.in/moon.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,31 @@
moonc build-package ./src/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:./src/lib -target wasm-gc
moonc build-package ./src/top.mbt -o ./target/wasm-gc/release/build/hello.core -pkg username/hello -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:./src -target wasm-gc

$ moon build --build-graph
$ moon build --build-graph --sort-input

generated build graph: ${WORK_DIR}/target/wasm-gc/release/build/build_graph.dot
Finished. moon: ran 2 tasks, now up to date

$ xls ./target/wasm-gc/release/build/lib/
lib.core lib.mi
$ xls ./target/wasm-gc/release/build/
.moon-lock build.moon_db build.output build_graph.dot hello.core hello.mi lib moon.db
$ xcat ./target/wasm-gc/release/build/build_graph.dot
digraph BuildGraph {
"./target/wasm-gc/release/build/hello.core" [shape=box, style=filled, fillcolor=black, fontcolor=white];
"./target/wasm-gc/release/build/hello.mi" [shape=box, color=black, ];
"./src/top.mbt" [shape=box, color=black, ];
"./target/wasm-gc/release/build/lib/lib.mi" [shape=box, color=black, ];
"./target/wasm-gc/release/build/lib/lib.core" [shape=box, style=filled, fillcolor=black, fontcolor=white];
"./src/lib/hello.mbt" [shape=box, color=black, ];
"build-package: username/hello" [shape=ellipse];
"./src/top.mbt" -> "build-package: username/hello";
"./target/wasm-gc/release/build/lib/lib.mi" -> "build-package: username/hello";
"build-package: username/hello" -> "./target/wasm-gc/release/build/hello.core";
"build-package: username/hello" -> "./target/wasm-gc/release/build/hello.mi";
"build-package: username/hello/lib" [shape=ellipse];
"./src/lib/hello.mbt" -> "build-package: username/hello/lib";
"build-package: username/hello/lib" -> "./target/wasm-gc/release/build/lib/lib.core";
"build-package: username/hello/lib" -> "./target/wasm-gc/release/build/lib/lib.mi";
}

3 changes: 2 additions & 1 deletion crates/moonbuild/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ fn vis_build_graph(state: &State, moonbuild_opt: &MoonbuildOpt) {
}

dot.push_str("}\n");
std::fs::write(path, dot).expect("Unable to write dot file");
std::fs::write(&path, dot).expect("Unable to write dot file");
eprintln!("generated build graph: {}", path.display());
}

pub fn run_check(
Expand Down
2 changes: 1 addition & 1 deletion crates/moonutil/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ pub struct UniversalFlags {
pub dry_run: bool,

/// generate build graph
#[clap(long, global = true)]
#[clap(long, global = true, conflicts_with = "dry_run")]
pub build_graph: bool,
}
1 change: 1 addition & 0 deletions docs/manual-zh/src/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
-v, --verbose Increase verbosity
--trace Trace the execution of the program
--dry-run Do not actually run the command
--build-graph generate build graph
-h, --help Print help
```
Expand Down
1 change: 1 addition & 0 deletions docs/manual/src/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Before you begin with this tutorial, make sure you have installed the following:
-v, --verbose Increase verbosity
--trace Trace the execution of the program
--dry-run Do not actually run the command
--build-graph generate build graph
-h, --help Print help
```
Expand Down

0 comments on commit 61c2551

Please sign in to comment.