This repository has been archived by the owner on Nov 8, 2021. It is now read-only.
forked from rustwasm/wasm-pack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog_level.rs
91 lines (84 loc) · 2.49 KB
/
log_level.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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()),
);
}