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 clean to snapbox #14096

Merged
merged 2 commits into from
Jun 26, 2024
Merged

Conversation

dieterplex
Copy link
Contributor

@dieterplex dieterplex commented Jun 18, 2024

Part of #14039, migrating tests/testsuite/clean.rs to snapbox.

@rustbot
Copy link
Collaborator

rustbot commented Jun 18, 2024

r? @epage

rustbot has assigned @epage.
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 Jun 18, 2024
tests/testsuite/clean.rs Outdated Show resolved Hide resolved
tests/testsuite/clean.rs Outdated Show resolved Hide resolved
tests/testsuite/clean.rs Outdated Show resolved Hide resolved
let obj = obj.unwrap().display().to_string();
expected.push_str(&format!(
"[REMOVING] {}\n",
obj.replace(p.root().to_str().unwrap(), "[ROOT]/foo")
Copy link
Contributor Author

@dieterplex dieterplex Jun 19, 2024

Choose a reason for hiding this comment

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

Replacing root is not enough and there is only 1 of 2 hashes in filename being redacted. How about leave it as is ([..]) for now?

- [REMOVING] [ROOT]/foo/target/debug/deps/bar-966252632dc060f2.bar.cce207b4909ed527-cgu.0.rcgu.o
+ [REMOVING] [ROOT]/foo/target/debug/deps/bar-[HASH].bar.cce207b4909ed527-cgu.0.rcgu.o

Copy link
Member

Choose a reason for hiding this comment

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

Yeah fine we that. I don't think Cargo cares about codegen unit artifacts. What about making it conditional, something like this?

#[cfg(not(target_os = "macos"))]
let expected = str![[r#"
[REMOVING] [ROOT]/foo/target/debug/.fingerprint/bar-[HASH]
[REMOVING] [ROOT]/foo/target/debug/deps/libbar-[HASH].rlib
[REMOVING] [ROOT]/foo/target/debug/deps/bar-[HASH].d
[REMOVING] [ROOT]/foo/target/debug/deps/libbar-[HASH].rmeta
[REMOVED] [FILE_NUM] files, [FILE_SIZE]B total

"#]];
#[cfg(target_os = "macos")]
let expected = str![[r#"
[REMOVING] [ROOT]/foo/target/debug/.fingerprint/bar-[HASH]
[REMOVING] [ROOT]/foo/target/debug/deps/libbar-[HASH].rlib
[REMOVING] [ROOT]/foo/target/debug/deps/bar-[HASH].d
[REMOVING] [ROOT]/foo/target/debug/deps/libbar-[HASH].rmeta
[REMOVING] [ROOT]/foo/target/debug/deps/bar-[HASH][..].o
[REMOVED] [FILE_NUM] files, [FILE_SIZE]B total

"#]];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looks promising, but is there only one .o file?

Copy link
Member

Choose a reason for hiding this comment

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

Nice catch. Could also just count the nubmer of bar-.*.o and push the same number of [REMOVING] [ROOT]/foo/target/debug/deps/bar-[HASH][..].o line.

tests/testsuite/alt_registry.rs Outdated Show resolved Hide resolved
let obj = obj.unwrap().display().to_string();
expected.push_str(&format!(
"[REMOVING] {}\n",
obj.replace(p.root().to_str().unwrap(), "[ROOT]/foo")
Copy link
Member

Choose a reason for hiding this comment

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

Yeah fine we that. I don't think Cargo cares about codegen unit artifacts. What about making it conditional, something like this?

#[cfg(not(target_os = "macos"))]
let expected = str![[r#"
[REMOVING] [ROOT]/foo/target/debug/.fingerprint/bar-[HASH]
[REMOVING] [ROOT]/foo/target/debug/deps/libbar-[HASH].rlib
[REMOVING] [ROOT]/foo/target/debug/deps/bar-[HASH].d
[REMOVING] [ROOT]/foo/target/debug/deps/libbar-[HASH].rmeta
[REMOVED] [FILE_NUM] files, [FILE_SIZE]B total

"#]];
#[cfg(target_os = "macos")]
let expected = str![[r#"
[REMOVING] [ROOT]/foo/target/debug/.fingerprint/bar-[HASH]
[REMOVING] [ROOT]/foo/target/debug/deps/libbar-[HASH].rlib
[REMOVING] [ROOT]/foo/target/debug/deps/bar-[HASH].d
[REMOVING] [ROOT]/foo/target/debug/deps/libbar-[HASH].rmeta
[REMOVING] [ROOT]/foo/target/debug/deps/bar-[HASH][..].o
[REMOVED] [FILE_NUM] files, [FILE_SIZE]B total

"#]];

@dieterplex dieterplex force-pushed the migrate-clean-snapbox branch 2 times, most recently from dac398b to 57af1a1 Compare June 20, 2024 01:12
.run();
// Verify it didn't delete anything.
let after = p.build_dir().ls_r();
assert_eq!(before, after);
let expected = itertools::join(before.iter().map(|p| p.to_str().unwrap()), "\n");
Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/rust-lang/cargo/actions/runs/9590054694/job/26444813493?pr=14096#step:11:4073

Paths on Windows didn't get normalized. It also happened here #14091 (comment).

Seems that expected string won't be normalized? https://docs.rs/snapbox/0.6.2/src/snapbox/assert/mod.rs.html#111-141

@epage, off the top of your head, what could be the cause?

--- Expected
++++ actual:   stdout
   1    1 | [ROOT]/foo/target
   2      - [ROOT]/foo/target\.rustc_info.json
   3      - [ROOT]/foo/target\CACHEDIR.TAG
   4      - [ROOT]/foo/target\debug
   5      - [ROOT]/foo/target\debug\.cargo-lock
   6      - [ROOT]/foo/target\debug\.fingerprint
   7      - [ROOT]/foo/target\debug\.fingerprint\bar-72b289f5cc241a07
   8      - [ROOT]/foo/target\debug\.fingerprint\bar-72b289f5cc241a07\dep-lib-bar
   9      - [ROOT]/foo/target\debug\.fingerprint\bar-72b289f5cc241a07\invoked.timestamp
  10      - [ROOT]/foo/target\debug\.fingerprint\bar-72b289f5cc241a07\lib-bar
  11      - [ROOT]/foo/target\debug\.fingerprint\bar-72b289f5cc241a07\lib-bar.json
  12      - [ROOT]/foo/target\debug\.fingerprint\foo-ad5acdf1e6368b18
  13      - [ROOT]/foo/target\debug\.fingerprint\foo-ad5acdf1e6368b18\dep-lib-foo
  14      - [ROOT]/foo/target\debug\.fingerprint\foo-ad5acdf1e6368b18\invoked.timestamp
  15      - [ROOT]/foo/target\debug\.fingerprint\foo-ad5acdf1e6368b18\lib-foo
  16      - [ROOT]/foo/target\debug\.fingerprint\foo-ad5acdf1e6368b18\lib-foo.json
  17      - [ROOT]/foo/target\debug\build
  18      - [ROOT]/foo/target\debug\deps
  19      - [ROOT]/foo/target\debug\deps\bar-72b289f5cc241a07.d
  20      - [ROOT]/foo/target\debug\deps\foo-ad5acdf1e6368b18.d
  21      - [ROOT]/foo/target\debug\deps\libbar-72b289f5cc241a07.rmeta
  22      - [ROOT]/foo/target\debug\deps\libfoo-ad5acdf1e6368b18.rmeta
  23      - [ROOT]/foo/target\debug\examples
  24      - [ROOT]/foo/target\debug\incremental
        2 + [ROOT]/foo/target/.rustc_info.json
        3 + [ROOT]/foo/target/CACHEDIR.TAG
        4 + [ROOT]/foo/target/debug/.cargo-lock
        5 + [ROOT]/foo/target/debug/.fingerprint/bar-[HASH]/dep-lib-bar
        6 + [ROOT]/foo/target/debug/.fingerprint/bar-[HASH]/invoked.timestamp
        7 + [ROOT]/foo/target/debug/.fingerprint/bar-[HASH]/lib-bar
        8 + [ROOT]/foo/target/debug/.fingerprint/bar-[HASH]/lib-bar.json
        9 + [ROOT]/foo/target/debug/.fingerprint/bar-[HASH]
       10 + [ROOT]/foo/target/debug/.fingerprint/foo-[HASH]/dep-lib-foo
       11 + [ROOT]/foo/target/debug/.fingerprint/foo-[HASH]/invoked.timestamp
       12 + [ROOT]/foo/target/debug/.fingerprint/foo-[HASH]/lib-foo
       13 + [ROOT]/foo/target/debug/.fingerprint/foo-[HASH]/lib-foo.json
       14 + [ROOT]/foo/target/debug/.fingerprint/foo-[HASH]
       15 + [ROOT]/foo/target/debug/.fingerprint
       16 + [ROOT]/foo/target/debug/build
       17 + [ROOT]/foo/target/debug/deps/bar-[HASH].d
       18 + [ROOT]/foo/target/debug/deps/foo-[HASH].d
       19 + [ROOT]/foo/target/debug/deps/libbar-[HASH].rmeta
       20 + [ROOT]/foo/target/debug/deps/libfoo-[HASH].rmeta
       21 + [ROOT]/foo/target/debug/deps
       22 + [ROOT]/foo/target/debug/examples
       23 + [ROOT]/foo/target/debug/incremental
       24 + [ROOT]/foo/target/debug

Copy link
Contributor Author

@dieterplex dieterplex Jun 20, 2024

Choose a reason for hiding this comment

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

It seems cargo_test_support::paths::Path::ls_r() gives non-normalized paths, but actual output. Both are not normalized by calling out normalize_windows() in compare mod.

Copy link
Member

Choose a reason for hiding this comment

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

@dieterplex could you revert change in this specific test case, and put a #[allow(deprecated)], so that we can unblock the entire PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

Choose a reason for hiding this comment

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

@dieterplex could you extract this into a separate PR?
Other places like #14109 (comment) could also benefit from this before we fix the Windows path normalization issue. Thank you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, PR #14121.

Copy link
Contributor

@epage epage Jun 21, 2024

Choose a reason for hiding this comment

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

Unresolved this since this uses #14121 and I'm concerned it might need to be reverted, depending on the answer to the question I posed.

Copy link
Member

Choose a reason for hiding this comment

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

See #14096 (comment). The PR description is updated as well #14121.

bors added a commit that referenced this pull request Jun 21, 2024
test: Auto-redact file number

This is from <#14096 (comment)>.

Although the number of files in `cargo package` is important,
we have `validate_crate_contents` and `validate_upload_with_contents`
that verify the exact contents.
Redacting `Packaged` status should be fine.
@weihanglo
Copy link
Member

Thanks a lot!

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 26, 2024

📌 Commit 1794ce4 has been approved by weihanglo

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 Jun 26, 2024
@bors
Copy link
Collaborator

bors commented Jun 26, 2024

⌛ Testing commit 1794ce4 with merge c81c32b...

@bors
Copy link
Collaborator

bors commented Jun 26, 2024

☀️ Test successful - checks-actions
Approved by: weihanglo
Pushing c81c32b to master...

@bors bors merged commit c81c32b into rust-lang:master Jun 26, 2024
22 checks passed
@dieterplex dieterplex deleted the migrate-clean-snapbox branch June 26, 2024 21:26
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 3, 2024
Update cargo

23 commits in 4ed7bee47f7dd4416b36fada1909e9a62c546246..a515d463427b3912ec0365d106791f88c1c14e1b
2024-06-25 16:28:22 +0000 to 2024-07-02 20:53:36 +0000
- test: migrate rust_version and rustc* to snapbox (rust-lang/cargo#14177)
- test: mirgate fix* and future_incompat_report to snapbox (rust-lang/cargo#14173)
- test:migrate `edition/error` to snapbox (rust-lang/cargo#14175)
- chore(deps): update compatible (rust-lang/cargo#14174)
- refactor(source): Clean up after PathSource/RecursivePathSource split (rust-lang/cargo#14169)
- test: Migrate some files to snapbox (rust-lang/cargo#14132)
- test:  fix several assertions (rust-lang/cargo#14167)
- test: replace glob with explicit unordered calls (rust-lang/cargo#14166)
- Make it clear that `CARGO_CFG_TARGET_FAMILY` is multi-valued (rust-lang/cargo#14165)
- Document `CARGO_CFG_TARGET_ABI` (rust-lang/cargo#14164)
- test: Migrate git to snapbox (rust-lang/cargo#14159)
- test: migrate some files to snapbox (rust-lang/cargo#14158)
- test: migrate registry and registry_auth to snapbox (rust-lang/cargo#14149)
- gix: remove `revision` feature from cargo (rust-lang/cargo#14160)
- test: migrate package* and publish* to snapbox (rust-lang/cargo#14130)
- More `update --breaking` tests (rust-lang/cargo#14049)
- test: migrate clean to snapbox (rust-lang/cargo#14096)
- Allow `unexpected_builtin_cfgs` lint in `user_specific_cfgs` test (rust-lang/cargo#14153)
- test: migrate search, source_replacement and standard_lib to snapbox (rust-lang/cargo#14151)
- Docs: Update config summary to include missing keys. (rust-lang/cargo#14145)
- test: migrate `dep_info/diagnostics/direct_minimal_versions` to snapbox (rust-lang/cargo#14143)
- Docs: Remove duplicate `strip` section. (rust-lang/cargo#14146)
- Docs: Fix curly quotes in config docs. (rust-lang/cargo#14144)
@rustbot rustbot added this to the 1.81.0 milestone Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testing-cargo-itself Area: cargo's tests 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.

None yet

5 participants