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

coverage: Unify tests/coverage-map and tests/run-coverage into tests/coverage #117484

Merged
merged 11 commits into from
Nov 8, 2023

Conversation

Zalathar
Copy link
Contributor

@Zalathar Zalathar commented Nov 1, 2023

Ever since the introduction of the coverage-map suite, it's been awkward to have to manage two separate coverage test directories containing dozens of mostly-identical files.

However, those two suites were separate for good reasons. They have very different requirements (since only one of them requires actually running the test program), running only one suite is noticeably faster than running both, and having separate suites allows them to be blessed separately if desired. So while unifying them was an obvious idea, actually doing so was non-trivial.


Nevertheless, this PR finds a way to merge the two suites into one directory while retaining almost all of the developer-experience benefits of having two suites. This required non-trivial implementations of Step, but the end result works very smoothly.


The first 5 commits are a copy of #117340, which has been closed in favour of this PR.

@rustbot
Copy link
Collaborator

rustbot commented Nov 1, 2023

r? @Mark-Simulacrum

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Nov 1, 2023
@Zalathar
Copy link
Contributor Author

Zalathar commented Nov 1, 2023

Some other approaches that I considered but ultimately rejected:

  • The original idea was to just declare two different test suites in bootstrap that point to the same directory. However, bootstrap contains some assumptions that aren't compatible with this, so the easy approach doesn't actually work.
    • One of those assumptions is fixed by one of the patches in this PR, but there were other remaining difficulties with path handling. This PR is in many ways an improved variant of that original approach.
  • An obvious idea is to fully unify the two suites/modes into one compiletest mode that runs both sets of checks. This carries several drawbacks:
    • A key advantage of the coverage-map tests is that they don't require the profiler runtime, which lets them run in more CI configurations (e.g. for PRs) and makes them easier to run locally. There's no way to reconcile that with the fact that run-coverage tests do require the profiler runtime, which is a major reason why the two suites were separate in the first place.
    • During development, it's important to be able to run only one of the modes if desired, both to make relevant test rebuilds/runs faster, and to allow selective blessing of only one mode. So while I did have a mostly-working implementation of this approach, I discarded it because the developer-experience regression would have been unacceptable.
  • A related idea I had was to hook into the compiletest code that splits a test into multiple revisions, and have it also split run-coverage tests into multiple modes.
    • This would have required adding several new features to compiletest to preserve important properties of the existing developer experience.
    • I did have a mostly-working implementation of this, but once I figured out how to do a similar thing at the bootstrap level with aliases, the bootstrap approach seemed like a clearly superior solution.

@Zalathar
Copy link
Contributor Author

Zalathar commented Nov 1, 2023

I've also been thinking about renaming the run-coverage alias/mode to coverage-run, but I think that's too much scope creep for this PR. Better to keep the old name for now, and worry about changing it in a separate PR.

@Zalathar
Copy link
Contributor Author

Zalathar commented Nov 2, 2023

Found and fixed an additional papercut: Because compiletest was using the same output directory for both modes, they would interfere with each others' timestamp files.

I've fixed this by adding a special case to compiletest's output path for coverage test modes (diff).

@Zalathar
Copy link
Contributor Author

Zalathar commented Nov 2, 2023

@rustbot label +A-code-coverage

@rustbot rustbot added the A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) label Nov 2, 2023
@Zalathar
Copy link
Contributor Author

Zalathar commented Nov 2, 2023

Oh, I notice there's already a Mode::disambiguator method that serves a similar purpose; perhaps I should hook into that instead.

EDIT: Done. The existing method wasn't quite what I wanted, but I used it as inspiration for a new method.

@Mark-Simulacrum
Copy link
Member

@bors r+ p=1

@bors
Copy link
Contributor

bors commented Nov 4, 2023

📌 Commit 523997b has been approved by Mark-Simulacrum

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 Nov 4, 2023
@bors
Copy link
Contributor

bors commented Nov 4, 2023

⌛ Testing commit 523997b with merge 08c3545...

bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 4, 2023
coverage: Unify `tests/coverage-map` and `tests/run-coverage` into `tests/coverage`

Ever since the introduction of the `coverage-map` suite, it's been awkward to have to manage two separate coverage test directories containing dozens of mostly-identical files.

However, those two suites were separate for good reasons. They have very different requirements (since only one of them requires actually running the test program), running only one suite is noticeably faster than running both, and having separate suites allows them to be blessed separately if desired. So while unifying them was an obvious idea, actually doing so was non-trivial.

---

Nevertheless, this PR finds a way to merge the two suites into one directory while retaining almost all of the developer-experience benefits of having two suites. This required non-trivial implementations of `Step`, but the end result works very smoothly.

---

The first 5 commits are a copy of rust-lang#117340, which is a necessary prerequisite, though they can be reviewed directly as part of this PR if desired.
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Nov 4, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 4, 2023
@Zalathar
Copy link
Contributor Author

Zalathar commented Nov 4, 2023

Looks like output normalization is missing paths on Windows.

Perhaps because we’re using suite_path in --src-base, which has a forward slash.

There is another test named `if.rs` in `tests/coverage-map/status-quo/`, so
this test stands in the way of flattening that directory into its parent.

Fortunately both tests are more-or-less equivalent, so removing this one is
fine.
These multi-file tests were not copied over in rust-lang#114843 because they weren't
working, but it turns out that they just need the correct crate-type.
When multiple test modes share the same test directory, this will allow them to
avoid interfering with each others' files and timestamps.
…rage`

This restores the ability to run a coverage test by specifying its path, e.g.
`./x.py test tests/coverage/if.rs`. This runs the test in both modes.
@cjgillot
Copy link
Contributor

cjgillot commented Nov 8, 2023

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Nov 8, 2023

📌 Commit 4e6f438 has been approved by cjgillot

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 Nov 8, 2023
@bors
Copy link
Contributor

bors commented Nov 8, 2023

⌛ Testing commit 4e6f438 with merge 91cfcb0...

@bors
Copy link
Contributor

bors commented Nov 8, 2023

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing 91cfcb0 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 8, 2023
@bors bors merged commit 91cfcb0 into rust-lang:master Nov 8, 2023
12 checks passed
@rustbot rustbot added this to the 1.75.0 milestone Nov 8, 2023
@Zalathar Zalathar deleted the tests branch November 8, 2023 05:40
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (91cfcb0): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.5% [0.5%, 0.5%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.5% [0.5%, 0.5%] 1

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.9% [0.4%, 1.7%] 11
Regressions ❌
(secondary)
3.2% [2.1%, 4.4%] 2
Improvements ✅
(primary)
-0.6% [-1.0%, -0.5%] 5
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.4% [-1.0%, 1.7%] 16

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 662.798s -> 664.133s (0.20%)
Artifact size: 308.75 MiB -> 308.79 MiB (0.01%)

fmease added a commit to fmease/rust that referenced this pull request Nov 8, 2023
…ur-ozkan

coverage: Rename the `run-coverage` test mode to `coverage-run`

Follow-up to rust-lang#117484 (comment).

Renaming this test mode to `coverage-run` makes it more consistent with the `coverage-map` mode and the shared `tests/coverage` test directory.

---

`@rustbot` label +A-code-coverage
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 8, 2023
…ur-ozkan

coverage: Rename the `run-coverage` test mode to `coverage-run`

Follow-up to rust-lang#117484 (comment).

Renaming this test mode to `coverage-run` makes it more consistent with the `coverage-map` mode and the shared `tests/coverage` test directory.

---

``@rustbot`` label +A-code-coverage
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 8, 2023
Rollup merge of rust-lang#117700 - Zalathar:rename-run-coverage, r=onur-ozkan

coverage: Rename the `run-coverage` test mode to `coverage-run`

Follow-up to rust-lang#117484 (comment).

Renaming this test mode to `coverage-run` makes it more consistent with the `coverage-map` mode and the shared `tests/coverage` test directory.

---

``@rustbot`` label +A-code-coverage
celinval added a commit to celinval/rust-dev that referenced this pull request Jun 4, 2024
Update Rust toolchain from nightly-2023-11-08 to nightly-2023-11-09
without any other source changes.
This is an automatically generated pull request. If any of the CI checks
fail, manual intervention is required. In such a case, review the
changes at https://github.com/rust-lang/rust from
rust-lang@7adc89b
up to
rust-lang@fdaaaf9.
The log for this commit range is:
rust-lang@fdaaaf9f92 Auto merge of
rust-lang#116930 - RalfJung:raw-ptr-match, r=davidtwco
rust-lang@30588657b7 avoid unnecessary
nested conditionals
rust-lang@90fdc1fc27 Auto merge of
rust-lang#117716 - GuillaumeGomez:rollup-83gnhll, r=GuillaumeGomez
rust-lang@9d3c80248b Rollup merge of
rust-lang#117713 - GuillaumeGomez:document-hidden-json, r=notriddle
rust-lang@d8c52b378d Rollup merge of
rust-lang#117702 - davidtwco:target-tier-refactors, r=petrochenkov
rust-lang@5d00a5d936 Rollup merge of
rust-lang#117679 - aDotInTheVoid:yes-core, r=GuillaumeGomez
rust-lang@c828371179 Rollup merge of
rust-lang#117282 - clubby789:recover-wrong-function-header, r=TaKO8Ki
rust-lang@e05e4f38b5 Rollup merge of
rust-lang#117263 - onur-ozkan:change-id-fix, r=saethlin
rust-lang@341efb1017 Auto merge of
rust-lang#117560 - lqd:issue-117146, r=matthewjasper
rust-lang@33edea60f0 Add test for
reexported hidden item with `--document-hidden-items`
rust-lang@28acba3c61 Auto merge of
rust-lang#115460 - zachs18:borrowedcursor_write_no_panic, r=dtolnay
rust-lang@755629fe59 Auto merge of
rust-lang#117706 - matthiaskrgr:rollup-lscx7dg, r=matthiaskrgr
rust-lang@e0cb1cc296 bootstrap: add more
detail on change-id comments
rust-lang@e878100386 bootstrap: improve
`fn check_version`
rust-lang@ae4d18b2da handle the case when
the change-id isn't found
rust-lang@7e4ffa98b5 Rollup merge of
rust-lang#117700 - Zalathar:rename-run-coverage, r=onur-ozkan
rust-lang@55306535dd Rollup merge of
rust-lang#117698 - nnethercote:space_between-2, r=petrochenkov
rust-lang@b1b5a8ea9d Rollup merge of
rust-lang#117667 - Alexendoo:doc-clippy-config, r=albertlarsan68
rust-lang@adf4981969 Rollup merge of
rust-lang#117663 - klensy:bump-deps, r=davidtwco
rust-lang@8198864377 Rollup merge of
rust-lang#117650 - saethlin:inline-me-please, r=davidtwco
rust-lang@ba7ec56639 Rollup merge of
rust-lang#117531 - fmease:rustdoc-effects-properly-elide-x-crate-host-args,
r=GuillaumeGomez
rust-lang@b74a84c0bc Rollup merge of
rust-lang#114316 - ecnelises:aix_doc, r=workingjubilee
rust-lang@fab1054e17 Auto merge of
rust-lang#117542 - compiler-errors:only-normalize-predicate, r=lcnr
rust-lang@750c2ecd15 Auto merge of
rust-lang#116881 - LuuuXXX:issue-110087, r=onur-ozkan
rust-lang@b9b7982f72 Add AIX
platform-support doc
rust-lang@ef7ebaa788 rustc_target: move
file for uniformity
rust-lang@1af256fe8a targets: move target
specs to spec/targets
rust-lang@76aa83e3e1 target: move base
specs to spec/base
rust-lang@a573880373 coverage: Rename the
`run-coverage` test mode to `coverage-run`
rust-lang@7cc997d373 Auto merge of
rust-lang#117699 - weihanglo:update-cargo, r=weihanglo
rust-lang@0670466e2c Update cargo
rust-lang@438b9a6e82 More tests for token
stream pretty-printing with adjacent punctuation.
rust-lang@783d4b8b26 Clarify
`space_between`.
rust-lang@91cfcb0219 Auto merge of
rust-lang#117484 - Zalathar:tests, r=cjgillot
rust-lang@97c9d8f405 Only use
normalize_param_env when normalizing predicate in check_item_bounds
rust-lang@1b8dee19e8 Fix issue rust-lang#110087
rust-lang@0d5ec963bb Auto merge of
rust-lang#117692 - matthiaskrgr:rollup-umaf5pr, r=matthiaskrgr
rust-lang@f72e974e3f Rollup merge of
rust-lang#117655 - compiler-errors:method-tweaks, r=estebank
rust-lang@7552dd19ad Rollup merge of
rust-lang#117625 - nnethercote:clippy-perf, r=cuviper
rust-lang@3c6307240c Rollup merge of
rust-lang#116399 - WaffleLapkin:erase_small_things, r=cjgillot
rust-lang@b724d9c90e Rollup merge of
rust-lang#113925 - clubby789:const-ctor-repeat, r=estebank
rust-lang@fcdd99edca Add
-Zcross-crate-inline-threshold=yes
rust-lang@e8cf29b584 rustdoc: minor
changes suggested by clippy perf lints.
rust-lang@ff0b4b6091 Auto merge of
rust-lang#117672 - lqd:ci-gcc-lld, r=Kobzol
rust-lang@1b3733e5a4 rustc: minor changes
suggested by clippy perf lints.
rust-lang@eca9a1533f Add an explanation
for `transmute_unchecked`
rust-lang@1d1fe9a205 add note to remember
to update a url when bumping to gcc 10.1.0
rust-lang@434b69a1d6 tests/rustdoc-json:
Rewrite tests no not use `#![no_core]`.
rust-lang@0875f456f1 tests/rustdoc-json:
Remove more needless uses of `#![no_core]`.
rust-lang@f784fa7bd9 tests/rustdoc-json:
Remove some needless uses of `#![no_core]`.
rust-lang@d73eaaac5f ci: bump gcc on dist
x64 linux builder to 9.5
rust-lang@f2fd8ad788 Document
clippy_config in nightly-rustc docs
rust-lang@eed89185bb bump some deps
rust-lang@0add056dee Rework
print_disambiguation_help
rust-lang@88a37acb26 Yeet
MethodCallComponents
rust-lang@4e6f438d2a coverage: Register
`test::Coverage` as the test suite for `tests/coverage`
rust-lang@49127c64d6 coverage: Migrate
`tests/coverage-map` into `tests/coverage`
rust-lang@e9d04c5e24 coverage: Migrate
`tests/run-coverage` into `tests/coverage`
rust-lang@aea7c27eae coverage: Set up a
macro for declaring unified coverage test suites
rust-lang@3509aed632 coverage: Add
`./x.py test coverage`, an alias for `coverage-map` and `run-coverage`
rust-lang@e585a99230 coverage: Give each
coverage test mode a separate output directory
rust-lang@211d4cee8e coverage: Copy all
remaining run-coverage tests into coverage-map
rust-lang@4b76b97bc8 coverage: Copy all
remaining coverage-map tests into run-coverage
rust-lang@f5df56b26b coverage: Flatten
`coverage-map/status-quo/` into its parent directory
rust-lang@8eef39f082 coverage: Remove
`tests/coverage-map/if.rs`
rust-lang@7f8a6de72c coverage: Use
`-Copt-level=2` by default in run-coverage tests
rust-lang@1dcdf83927 rustdoc: properly
elide cross-crate host effect args
rust-lang@2dff90dc23 add test for issue
117146
rust-lang@de7a8305ae traverse region
graph instead of SCCs to compute polonius loan scopes
rust-lang@03b24f2756 remove some dead
code
rust-lang@70a8e157ab make
pointer_structural_match warn-by-default
rust-lang@af6c7e0ca1 also lint against fn
ptr and raw ptr nested inside the const
rust-lang@bec88ad4aa patterns: reject raw
pointers that are not just integers
rust-lang@be0b42fabe Recover from
incorrectly ordered/duplicated function keywords
rust-lang@b3d50255d9 Use consisntent
style of `size_of` in query type erasure
rust-lang@61361bb212 Use
`transmute_unchecked` and make the types explicit in query type erasure
rust-lang@11a64a1834 don't panic in
BorrowedCursor::write
rust-lang@86b112204a Improve diagnostic
for const ctors in array repeat expressions

Co-authored-by: celinval <celinval@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants