-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #694 from Pauan/quiet
Adding in `--quiet` and `--log-level` flags
- Loading branch information
Showing
9 changed files
with
240 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
use assert_cmd::prelude::*; | ||
use predicates::boolean::PredicateBooleanExt; | ||
use predicates::prelude::predicate::str::contains; | ||
use predicates::reflection::PredicateReflection; | ||
use predicates::Predicate; | ||
use utils; | ||
|
||
fn matches_info() -> impl Predicate<str> + PredicateReflection { | ||
contains("[INFO]: Checking for the Wasm target...") | ||
.and(contains("[INFO]: Compiling to Wasm...")) | ||
.and(contains("[INFO]: License key is set in Cargo.toml but no LICENSE file(s) were found; Please add the LICENSE file(s) to your project directory")) | ||
.and(contains("[INFO]: Installing wasm-bindgen...")) | ||
.and(contains("[INFO]: Optimizing wasm binaries with `wasm-opt`...")) | ||
.and(contains("[INFO]: :-) Done in ")) | ||
.and(contains("[INFO]: :-) Your wasm pkg is ready to publish at ")) | ||
} | ||
|
||
fn matches_warn() -> impl Predicate<str> + PredicateReflection { | ||
contains(":-) [WARN]: origin crate has no README") | ||
} | ||
|
||
fn matches_cargo() -> impl Predicate<str> + PredicateReflection { | ||
contains("Finished release [optimized] target(s) in ") | ||
} | ||
|
||
#[test] | ||
fn quiet() { | ||
utils::fixture::Fixture::new() | ||
.cargo_toml("js-hello-world") | ||
.hello_world_src_lib() | ||
.wasm_pack() | ||
.arg("--quiet") | ||
.arg("build") | ||
.assert() | ||
.success() | ||
.stdout("") | ||
.stderr(""); | ||
} | ||
|
||
#[test] | ||
fn log_level_info() { | ||
utils::fixture::Fixture::new() | ||
.cargo_toml("js-hello-world") | ||
.hello_world_src_lib() | ||
.wasm_pack() | ||
.arg("--log-level") | ||
.arg("info") | ||
.arg("build") | ||
.assert() | ||
.success() | ||
.stdout("") | ||
.stderr(matches_cargo().and(matches_warn()).and(matches_info())); | ||
} | ||
|
||
#[test] | ||
fn log_level_warn() { | ||
utils::fixture::Fixture::new() | ||
.cargo_toml("js-hello-world") | ||
.hello_world_src_lib() | ||
.wasm_pack() | ||
.arg("--log-level") | ||
.arg("warn") | ||
.arg("build") | ||
.assert() | ||
.success() | ||
.stdout("") | ||
.stderr( | ||
matches_cargo() | ||
.and(matches_warn()) | ||
.and(matches_info().not()), | ||
); | ||
} | ||
|
||
#[test] | ||
fn log_level_error() { | ||
utils::fixture::Fixture::new() | ||
.cargo_toml("js-hello-world") | ||
.hello_world_src_lib() | ||
.wasm_pack() | ||
.arg("--log-level") | ||
.arg("error") | ||
.arg("build") | ||
.assert() | ||
.success() | ||
.stdout("") | ||
.stderr( | ||
matches_cargo() | ||
.and(matches_warn().not()) | ||
.and(matches_info().not()), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters