Skip to content

Commit

Permalink
fix test assertions after rust upgrade that changed the stdout output…
Browse files Browse the repository at this point in the history
… message (#287)
  • Loading branch information
calvinrp authored May 6, 2024
1 parent b9515c6 commit 782584e
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 28 deletions.
46 changes: 31 additions & 15 deletions tests/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ fn it_builds_debug() -> Result<()> {
project
.cargo_component("build")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();

validate_component(&project.debug_wasm("foo"))?;
Expand All @@ -34,7 +36,7 @@ fn it_builds_a_bin_project_with_snake_case() -> Result<()> {
project
.cargo_component("build --release")
.assert()
.stderr(contains("Finished release [optimized] target(s)"))
.stderr(contains("Finished `release` profile [optimized] target(s)"))
.success();

validate_component(&project.release_wasm("hello_world"))?;
Expand All @@ -49,7 +51,7 @@ fn it_builds_a_bin_project() -> Result<()> {
project
.cargo_component("build --release")
.assert()
.stderr(contains("Finished release [optimized] target(s)"))
.stderr(contains("Finished `release` profile [optimized] target(s)"))
.success();

validate_component(&project.release_wasm("foo"))?;
Expand Down Expand Up @@ -101,7 +103,9 @@ edition = "2021"
project
.cargo_component("build")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();

validate_component(&project.debug_wasm("foo"))?;
Expand All @@ -117,7 +121,7 @@ fn it_supports_wit_keywords() -> Result<()> {
project
.cargo_component("build --release")
.assert()
.stderr(contains("Finished release [optimized] target(s)"))
.stderr(contains("Finished `release` profile [optimized] target(s)"))
.success();

validate_component(&project.release_wasm("interface"))?;
Expand All @@ -132,7 +136,7 @@ fn it_adds_a_producers_field() -> Result<()> {
project
.cargo_component("build --release")
.assert()
.stderr(contains("Finished release [optimized] target(s)"))
.stderr(contains("Finished `release` profile [optimized] target(s)"))
.success();

let path = project.release_wasm("foo");
Expand Down Expand Up @@ -162,7 +166,9 @@ fn it_builds_wasm32_unknown_unknown() -> Result<()> {
project
.cargo_component("build --target wasm32-unknown-unknown")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();

validate_component(
Expand All @@ -187,7 +193,9 @@ fn it_regenerates_target_if_wit_changed() -> Result<()> {
project
.cargo_component("build")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();

validate_component(&project.debug_wasm("foo"))?;
Expand Down Expand Up @@ -293,7 +301,9 @@ bindings::export!(Component with_types_in bindings);
project
.cargo_component("build")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();

validate_component(&project.debug_wasm("foo"))?;
Expand Down Expand Up @@ -580,7 +590,7 @@ bindings::export!(Component with_types_in bindings);
comp1
.cargo_component("build --release")
.assert()
.stderr(contains("Finished release [optimized] target(s)"))
.stderr(contains("Finished `release` profile [optimized] target(s)"))
.success();

let dep = comp1.release_wasm("comp1");
Expand Down Expand Up @@ -627,7 +637,7 @@ bindings::export!(Component with_types_in bindings);
comp2
.cargo_component("build --release")
.assert()
.stderr(contains("Finished release [optimized] target(s)"))
.stderr(contains("Finished `release` profile [optimized] target(s)"))
.success();

let path: std::path::PathBuf = comp2.release_wasm("comp2");
Expand Down Expand Up @@ -660,7 +670,9 @@ fn it_builds_with_adapter() -> Result<()> {
project
.cargo_component("build")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();

validate_component(&project.debug_wasm("foo"))?;
Expand Down Expand Up @@ -751,7 +763,9 @@ bindings::export!(Component with_types_in bindings);
project
.cargo_component("build")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();

validate_component(&project.debug_wasm("foo"))?;
Expand Down Expand Up @@ -852,7 +866,9 @@ fn it_builds_with_proxy_adapter() -> Result<()> {
project
.cargo_component("build")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();

validate_component(&project.debug_wasm("foo"))?;
Expand All @@ -875,7 +891,7 @@ fn it_does_not_generate_bindings_for_cargo_projects() -> Result<()> {
cmd.current_dir(dir.path());
cmd.args(args);
cmd.arg(name);
cmd.assert().stderr(contains("Created")).success();
cmd.assert().stderr(contains("Creating")).success();

let mut cmd = cargo_component("build");
cmd.current_dir(dir.path().join(name));
Expand Down
4 changes: 3 additions & 1 deletion tests/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ edition = "2021"
project
.cargo_component("check")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();

Ok(())
Expand Down
4 changes: 3 additions & 1 deletion tests/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ fn it_documents() -> Result<()> {
project
.cargo_component("doc")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();

let doc = project.build_dir().join("doc");
Expand Down
4 changes: 3 additions & 1 deletion tests/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ world foo {
project
.cargo_component("build")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();
validate_component(&project.debug_wasm("component"))?;

Expand Down
40 changes: 30 additions & 10 deletions tests/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ world foo {
project
.cargo_component("build")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();
validate_component(&project.debug_wasm("component"))?;

Expand Down Expand Up @@ -81,7 +83,9 @@ world foo {
project
.cargo_component("build")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();
validate_component(&project.debug_wasm("component"))?;

Expand All @@ -106,7 +110,9 @@ world foo {
project
.cargo_component("build")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();
validate_component(&project.debug_wasm("component"))?;

Expand Down Expand Up @@ -137,7 +143,9 @@ world foo {
project
.cargo_component("build")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();
validate_component(&project.debug_wasm("component"))?;

Expand Down Expand Up @@ -180,7 +188,9 @@ bindings::export!(Component with_types_in bindings);
project
.cargo_component("build")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();
validate_component(&project.debug_wasm("component"))?;

Expand Down Expand Up @@ -211,7 +221,9 @@ world foo {
project
.cargo_component("build")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();
validate_component(&project.debug_wasm("component"))?;

Expand Down Expand Up @@ -240,7 +252,9 @@ world foo {
project
.cargo_component("build")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();

validate_component(&project.debug_wasm("component"))?;
Expand All @@ -262,7 +276,9 @@ async fn update_with_changed_dependencies() -> Result<()> {
project
.cargo_component("build")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();

validate_component(&project.debug_wasm("foo"))?;
Expand All @@ -276,7 +292,9 @@ async fn update_with_changed_dependencies() -> Result<()> {
project
.cargo_component("build")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();

project.update_manifest(|mut doc| {
Expand All @@ -300,7 +318,9 @@ async fn update_with_changed_dependencies() -> Result<()> {
project
.cargo_component("build")
.assert()
.stderr(contains("Finished dev [unoptimized + debuginfo] target(s)"))
.stderr(contains(
"Finished `dev` profile [unoptimized + debuginfo] target(s)",
))
.success();

Ok(())
Expand Down

0 comments on commit 782584e

Please sign in to comment.