Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: migrate serveral files to snapbox #14180

Merged
merged 4 commits into from
Jul 6, 2024
Merged

Conversation

eth3lbert
Copy link
Contributor

What does this PR try to resolve?

Part of #14039.

Migrate following to snapbox:

  • tests/testsuite/read_manifest.rs
  • tests/testsuite/rustdoc_extern_html.rs
  • tests/testsuite/tool_paths.rs
  • tests/testsuite/warn_on_failure.rs

@rustbot
Copy link
Collaborator

rustbot commented Jul 2, 2024

r? @ehuss

rustbot has assigned @ehuss.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 2, 2024
@eth3lbert eth3lbert force-pushed the snapbox-rrtw branch 2 times, most recently from b134964 to f171e94 Compare July 2, 2024 22:51
@@ -34,6 +32,7 @@ fn basic_project() -> Project {
.build()
}

#[allow(deprecated)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with_stderr_does_not_contain is being used in this function.

@@ -419,6 +450,7 @@ fn alt_sparse_registry() {
assert!(gold.contains(r#"href="https://docs.rs/grimm/1.0.0/grimm/struct.Gold.html""#));
}

#[allow(deprecated)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with_stderr_does_not_contain is being used in this function.

.run();
}

#[cargo_test]
fn warning_on_lib_failure() {
make_lib("err()");
make_lib("hi()");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, the error message varied between local and CI environments. I've changed this to avoid the issue of "similar name exists".
https://github.com/rust-lang/cargo/actions/runs/9768426106/job/26965899179#step:7:4040

   7      -    --> [ROOT]/home/.cargo/registry/src/-[HASH]/bar-0.0.1/src/lib.rs:1:10
   8      -     |
   9      - 1   | fn f() { err() }
  10      -     |          ^^^ [HELP] a tuple variant with a similar name exists: `Err`
  11      -     |
  12      -    ::: [..]/lib/rustlib/src/rust/library/core/src/result.rs:536:5
  13      -     |
  14      - 536 |     Err(#[stable(feature = "rust1", since = "1.0.0")] E),
  15      -     |     --- similarly named tuple variant `Err` defined here
        7 +  --> [ROOT]/home/.cargo/registry/src/-[HASH]/bar-0.0.1/src/lib.rs:1:10
        8 +   |
        9 + 1 | fn f() { err() }
       10 +   |          ^^^ [HELP] a tuple variant with a similar name exists: `Err`
       11 +  --> /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/result.rs:511:5
       12 +   |
       13 +   = [NOTE] similarly named tuple variant `Err` defined here

Please let me know if this change is inappropriate.

Comment on lines 84 to 102
.with_status(101)
.with_stdout_does_not_contain("hidden stdout")
.with_stderr_does_not_contain("hidden stderr")
.with_stderr_does_not_contain(&format!("[WARNING] {}", WARNING1))
.with_stderr_does_not_contain(&format!("[WARNING] {}", WARNING2))
.with_stderr_contains("[UPDATING] `[..]` index")
.with_stderr_contains("[DOWNLOADED] bar v0.0.1 ([..])")
.with_stderr_contains("[COMPILING] bar v0.0.1")
.with_stderr_contains("[COMPILING] foo v0.0.1 ([..])")
.with_stdout_data("")
.with_stderr_data(str![[r#"
[UPDATING] `dummy-registry` index
[LOCKING] 2 packages to latest compatible versions
[DOWNLOADING] crates ...
[DOWNLOADED] bar v0.0.1 (registry `dummy-registry`)
[COMPILING] bar v0.0.1
[COMPILING] foo v0.0.1 ([ROOT]/foo)
error[E0425]: cannot find function `hi` in this scope
--> src/main.rs:1:13
|
1 | fn main() { hi() }
| ^^ not found in this scope

For more information about this error, try `rustc --explain E0425`.
[ERROR] could not compile `foo` (bin "foo") due to 1 previous error

"#]])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the does_not_contain assertion by directly comparing against the full output.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in this case it works because if something changes and, the diff for the snapshot update will be suspicious, having "hidden" stuff showing up.

Comment on lines 112 to 134
.with_status(101)
.with_stdout_does_not_contain("hidden stdout")
.with_stderr_does_not_contain("hidden stderr")
.with_stderr_does_not_contain("[COMPILING] foo v0.0.1 ([..])")
.with_stderr_contains("[UPDATING] `[..]` index")
.with_stderr_contains("[DOWNLOADED] bar v0.0.1 ([..])")
.with_stderr_contains("[COMPILING] bar v0.0.1")
.with_stderr_contains(&format!("[WARNING] bar@0.0.1: {}", WARNING1))
.with_stderr_contains(&format!("[WARNING] bar@0.0.1: {}", WARNING2))
.with_stdout_data("")
.with_stderr_data(str![[r#"
[UPDATING] `dummy-registry` index
[LOCKING] 2 packages to latest compatible versions
[DOWNLOADING] crates ...
[DOWNLOADED] bar v0.0.1 (registry `dummy-registry`)
[COMPILING] bar v0.0.1
error[E0425]: cannot find function `hi` in this scope
--> [ROOT]/home/.cargo/registry/src/-[HASH]/bar-0.0.1/src/lib.rs:1:10
|
1 | fn f() { hi() }
| ^^ not found in this scope

For more information about this error, try `rustc --explain E0425`.
The following warnings were emitted during compilation:

[WARNING] bar@0.0.1: Hello! I'm a warning. :)
[WARNING] bar@0.0.1: And one more!

[ERROR] could not compile `bar` (lib) due to 1 previous error

"#]])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the does_not_contain assertion by directly comparing against the full output.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modify to a snapshot-aware assertion that enables auto-updating.

)
.with_stderr_data(str![[r#"
...
[RUNNING] `rustdoc [..]--crate-name foo [..]--extern-html-root-url [..]bar=https://docs.rs/bar/1.0.0/[..]`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glob redaction is required since its not surrounded by quotes on windows.

https://github.com/rust-lang/cargo/actions/runs/9768726905/job/26966828626#step:11:4295

   1      - ...
   2      - [RUNNING] `rustdoc [..]--crate-name foo [..]--extern-html-root-url 'bar=https://docs.rs/bar/1.0.0/' [..]`
[omit...]
        8 + [RUNNING] `rustdoc --edition=2018 --crate-type lib --crate-name foo src/lib.rs -o [ROOT]/foo/target/doc --check-cfg cfg(docsrs) --check-cfg "cfg(feature, values())" --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat -C metadata=a7e7c9482575de28 -L dependency=[ROOT]/foo/target/debug/deps --extern bar=[ROOT]/foo/target/debug/deps/libbar-[HASH].rmeta --extern-html-root-url bar=https://docs.rs/bar/1.0.0/ -Zunstable-options --crate-version 0.1.0`

@epage
Copy link
Contributor

epage commented Jul 6, 2024

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 6, 2024

📌 Commit b11e741 has been approved by epage

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 6, 2024
@bors
Copy link
Collaborator

bors commented Jul 6, 2024

⌛ Testing commit b11e741 with merge 6d68563...

@bors
Copy link
Collaborator

bors commented Jul 6, 2024

☀️ Test successful - checks-actions
Approved by: epage
Pushing 6d68563 to master...

@bors bors merged commit 6d68563 into rust-lang:master Jul 6, 2024
22 checks passed
@eth3lbert eth3lbert deleted the snapbox-rrtw branch July 6, 2024 03:42
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 7, 2024
Update cargo

20 commits in a515d463427b3912ec0365d106791f88c1c14e1b..154fdac39ae9629954e19e9986fd2cf2cdd8d964
2024-07-02 20:53:36 +0000 to 2024-07-07 01:28:23 +0000
- test: relax redactions for rust-lang/rust (rust-lang/cargo#14203)
- use "bootstrap" instead of "rustbuild" (rust-lang/cargo#14207)
- test: migrate serveral files to snapbox (rust-lang/cargo#14180)
- Add rustdocflags to Unit's Debug impl (rust-lang/cargo#14201)
- Allow enabling `config-include` feature in config (rust-lang/cargo#14196)
- fix(test): Restore `does_not_contain` for check (rust-lang/cargo#14198)
- test: migrate patch, pkgid, proc_macro and progress to snapbox (rust-lang/cargo#14181)
- test: Migrate jobserver to snapbox (rust-lang/cargo#14191)
- chore(deps): update msrv (3 versions) to v1.77 (rust-lang/cargo#14186)
- test: migrate build_plan and build_script to snapbox (rust-lang/cargo#14193)
- test: migrate cfg and check to snapbox (rust-lang/cargo#14185)
- test: migrate install* and inheritable_workspace_fields to snapbox (rust-lang/cargo#14170)
- Pass rustflags to artifacts built with implicit targets when using target-applies-to-host (rust-lang/cargo#13900)
- test: Migrate network tests to snapbox (rust-lang/cargo#14187)
- test: migrate some files to snapbox (rust-lang/cargo#14113)
- test: Auto-redact `... after last build at ...`; Migrate `freshness` to Snapbox (rust-lang/cargo#14161)
- chore: fix some typos (rust-lang/cargo#14182)
- fix: improve message for inactive weak optional feature with edition2024 through unused dep collection (rust-lang/cargo#14026)
- test:migrate `doc/directory/docscrape` to snapbox (rust-lang/cargo#14171)
- test: Migrate git_auth to snapbox (rust-lang/cargo#14172)
@rustbot rustbot added this to the 1.81.0 milestone Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants