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

Migrate rustdoc tests syntax to //@ (for coherency) #126788

Merged
merged 5 commits into from
Jun 24, 2024

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Jun 21, 2024

Part of #125813.

cc @jieyouxu
r? @fmease

try-job: aarch64-apple

@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) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jun 21, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jun 21, 2024

Some changes occurred in src/tools/compiletest

cc @jieyouxu

@GuillaumeGomez GuillaumeGomez changed the title Migrate rustdoc tests syntax Migrate rustdoc tests syntax to //@ (for coherency) Jun 21, 2024
@rust-log-analyzer

This comment has been minimized.

Comment on lines 249 to 250
# Equivalent to `src/tools/compiletest/src/header.rs` constant of the same name.
KNOWN_DIRECTIVE_NAMES = [
Copy link
Member

@fmease fmease Jun 21, 2024

Choose a reason for hiding this comment

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

Instead of having to maintain a duplicate of this list, could you instead include! it or #[path] mod it (which might necessitate splitting stuff out of header.rs, I'm on mobile can't check)?

Could you add a FIXME to both compiletest and htmldocck that this setup (the double-parsing essentially) is temporary(tm) until we figure out the child test runner story (registering hooks etc.)? Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea and sure.

@GuillaumeGomez
Copy link
Member Author

Removed the duplication and added FIXME comments.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member Author

Fixed CI. :D

return line.startswith('"') and (line.endswith('",') or line.endswith('"'))

# Equivalent to `src/tools/compiletest/src/header.rs` constant of the same name.
with open(
Copy link
Member

@fmease fmease Jun 22, 2024

Choose a reason for hiding this comment

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

Oh, I briefly forgot that htmldocck isn't in Rust yet (#125780) hence my nonsensical include! suggestion earlier.

Thanks for applying my suggestion. I guess the added runtime cost is unavoidable rn :| (reopening this for each test). I guess that means I have to prioritize #125780 again.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep not great but better than duplicated code. :)

let is_known = |s: &str| {
KNOWN_DIRECTIVE_NAMES.contains(&s)
|| (is_rustdoc
&& original_line.starts_with("//@")
Copy link
Member

Choose a reason for hiding this comment

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

Is this check actually necessary? Isn't s guaranteed to come from a string that starts with //@?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's needed because of comments like // has something tralalala where has is detected as a command (I got the case in a few rustdoc tests).

@@ -186,6 +186,10 @@ fn should_ignore(line: &str) -> bool {
// - `//@[rev] normalize-stderr-test`
|| static_regex!("\\s*//@(\\[.*\\]) (compile-flags|normalize-stderr-test|error-pattern).*")
.is_match(line)
// Matching for rustdoc tests commands.
|| static_regex!(
"\\s*//@ \\!?(count|files|has|has-dir|hasraw|matches|matchesraw|snapshot)\\s.*"
Copy link
Member

@fmease fmease Jun 22, 2024

Choose a reason for hiding this comment

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

ANNOTATIONS_TO_IGNORE already contains some directives specific to htmldocck (and jsondocck I suppose). You should be able to remove them from that constant.

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed! Removed. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

So it was in fact needed for the line length as the CI failure indicates. XD

Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

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

@oli-obk, is this compatible with your vision for ui_test? Namely, extending the set of UI-test directives with non-UI-test (here: HtmlDocCk) ones? Written out like that it seems like the answer is simply "no". Also: https://github.com/oli-obk/ui_test?tab=readme-ov-file#significant-differences-to-compiletest-rs.

Note that the current approach as implemented here is only temporary and "we" plan on taking a more principled approach soon(tm). See #125813 (comment)

@GuillaumeGomez
Copy link
Member Author

Updated, let's see what oli thinks about it.

@rust-log-analyzer

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented Jun 22, 2024

Yea this is fine, ui_test is getting plugin support to add new directives in test suites without needing ui_test to implement it

@fmease
Copy link
Member

fmease commented Jun 22, 2024

r=me then once CI failure fixed

@GuillaumeGomez
Copy link
Member Author

Very conflict prone so upping the priority a bit.

@bors r=fmease,oli-bok p=1

@bors
Copy link
Contributor

bors commented Jun 22, 2024

📌 Commit d43c598 has been approved by fmease,oli-bok

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 22, 2024
@fmease
Copy link
Member

fmease commented Jun 22, 2024

typo @bors r=fmease,oli-obk

@bors
Copy link
Contributor

bors commented Jun 22, 2024

💡 This pull request was already approved, no need to approve it again.

@bors
Copy link
Contributor

bors commented Jun 22, 2024

📌 Commit d43c598 has been approved by fmease,oli-obk

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jun 23, 2024

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout migrate-rustdoc-tests-syntax (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self migrate-rustdoc-tests-syntax --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Auto-merging src/tools/compiletest/src/header.rs
CONFLICT (content): Merge conflict in src/tools/compiletest/src/header.rs
Automatic merge failed; fix conflicts and then commit the result.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 23, 2024
@bors
Copy link
Contributor

bors commented Jun 24, 2024

☔ The latest upstream changes (presumably #126878) made this pull request unmergeable. Please resolve the merge conflicts.

@GuillaumeGomez
Copy link
Member Author

@bors r=fmease,oli-obk p=10

@bors
Copy link
Contributor

bors commented Jun 24, 2024

📌 Commit 6909fea has been approved by fmease,oli-obk

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 24, 2024
@bors
Copy link
Contributor

bors commented Jun 24, 2024

⌛ Testing commit 6909fea with merge 06c072f...

@bors
Copy link
Contributor

bors commented Jun 24, 2024

☀️ Test successful - checks-actions
Approved by: fmease,oli-obk
Pushing 06c072f to master...

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (06c072f): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

Max RSS (memory usage)

Results (secondary 2.4%)

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
Regressions ❌
(secondary)
2.4% [2.1%, 2.8%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results (secondary 2.0%)

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
Regressions ❌
(secondary)
2.0% [2.0%, 2.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 692.382s -> 691.871s (-0.07%)
Artifact size: 326.78 MiB -> 326.79 MiB (0.00%)

bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 19, 2024
…, r=GuillaumeGomez

Update jsondocck directives to follow ui_test-style

Context: Comment chain in rust-lang#125813.
Follow-up to rust-lang#126788.
Use the same temporary approach of "double parsing" until we figure out how we want to support compiletest/ui_test directive "add-ons" for child test runners like HtmlDocCk and JsonDocCk.

I didn't touch much of jsondocck because I want to refactor it some other time (for robustness, maintainability and better diagnostics; basically by following a similar design of my WIP HtmlDocCk-next, cc rust-lang#125780).

r? `@GuillaumeGomez`
jaisnan pushed a commit to jaisnan/rust-dev that referenced this pull request Jul 29, 2024
Update Rust toolchain from nightly-2024-06-24 to nightly-2024-06-25
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@bcf94de
up to
rust-lang@6b0f4b5.
The log for this commit range is:
rust-lang@6b0f4b5ec3 Auto merge of
rust-lang#126914 - compiler-errors:rollup-zx0hchm, r=compiler-errors
rust-lang@16bd6e25e1 Rollup merge of
rust-lang#126911 - oli-obk:do_not_count_errors, r=compiler-errors
rust-lang@59c258f51f Rollup merge of
rust-lang#126909 - onur-ozkan:add-kobzol, r=matthiaskrgr
rust-lang@85eb835a14 Rollup merge of
rust-lang#126904 - GrigorenkoPV:nonzero-fixme, r=joboet
rust-lang@a7721a0373 Rollup merge of
rust-lang#126899 - GrigorenkoPV:suggest-const-block, r=davidtwco
rust-lang@9ce2a070b3 Rollup merge of
rust-lang#126682 - Zalathar:coverage-attr, r=lcnr
rust-lang@49bdf460a2 Rollup merge of
rust-lang#126673 - oli-obk:dont_rely_on_err_reporting, r=compiler-errors
rust-lang@46e43984d1 Rollup merge of
rust-lang#126413 - matthiaskrgr:crshmsg, r=oli-obk
rust-lang@ed460d2eaa Rollup merge of
rust-lang#125575 - dingxiangfei2009:derive-smart-ptr, r=davidtwco
rust-lang@c77dc28f87 Rollup merge of
rust-lang#125082 - kpreid:const-uninit, r=dtolnay
rust-lang@faa28be2f1 Rollup merge of
rust-lang#124712 - Enselic:deprecate-inline-threshold, r=pnkfelix
rust-lang@00e5f5886a Rollup merge of
rust-lang#124460 - long-long-float:show-notice-about-enum-with-debug, r=pnkfelix
rust-lang@d8d5732456 Auto merge of
rust-lang#126784 - scottmcm:smaller-terminator, r=compiler-errors
rust-lang@13fca73f49 Replace
`MaybeUninit::uninit_array()` with array repeat expression.
rust-lang@5a3e2a4e92 Auto merge of
rust-lang#126523 - joboet:the_great_big_tls_refactor, r=Mark-Simulacrum
rust-lang@45261ff2ec add @Kobzol to
bootstrap team for triagebot
rust-lang@84474a25a4 Small fixme in core
now that NonZero is generic
rust-lang@50a02ed789 std: fix wasm builds
rust-lang@8fc6b3de19 Separate the mir
body lifetime from the other lifetimes
rust-lang@1c4d0ced58 Separate the
lifetimes of the `BorrowckInferCtxt` from the other borrowed items
rust-lang@d371d17496 Auto merge of
rust-lang#126900 - matthiaskrgr:rollup-24ah97b, r=matthiaskrgr
rust-lang@8ffb5f936a compiletest: make
the crash test error message abit more informative
rust-lang@a80ee9159b Rollup merge of
rust-lang#126882 - estebank:multiline-order, r=WaffleLapkin
rust-lang@8bfde609e2 Rollup merge of
rust-lang#126414 - ChrisDenton:target-known, r=Nilstrieb
rust-lang@94b9ea417d Rollup merge of
rust-lang#126213 - zachs18:atomicbool-u8-i8-from-ptr-alignment, r=Nilstrieb
rust-lang@9d24ecc37b Rollup merge of
rust-lang#125241 - Veykril:tool-rust-analyzer, r=davidtwco
rust-lang@ba5ec1fc5c Suggest inline const
blocks for array initialization
rust-lang@06c072f158 Auto merge of
rust-lang#126788 - GuillaumeGomez:migrate-rustdoc-tests-syntax, r=fmease,oli-obk
rust-lang@1852141219 coverage: Bless
coverage attribute tests
rust-lang@b7c057c9b2 coverage: Always
error on `#[coverage(..)]` in unexpected places
rust-lang@a000fa8b54 coverage: Tighten
validation of `#[coverage(off)]` and `#[coverage(on)]`
rust-lang@b5dfeba0e1 coverage: Forbid
multiple `#[coverage(..)]` attributes
rust-lang@6909feab8e Allow numbers in
rustdoc tests commands
rust-lang@4e258bb4c3 Fix tidy issue for
rustdoc tests commands
rust-lang@51fedf65ff Remove commands
duplication between `compiletest` and `tests/rustdoc`
rust-lang@1b67035579 Update
`tests/rustdoc` to new test syntax
rust-lang@d3ec92e16e Move `tests/rustdoc`
testsuite to `//@` syntax
rust-lang@2c243d9570 Auto merge of
rust-lang#126891 - matthiaskrgr:rollup-p6dl1gk, r=matthiaskrgr
rust-lang@b94d2754b5 Rollup merge of
rust-lang#126888 - compiler-errors:oops-debug-printing, r=dtolnay
rust-lang@9892b3e9fe Rollup merge of
rust-lang#126854 - devnexen:std_unix_os_fallback_upd, r=Mark-Simulacrum
rust-lang@3108dfaced Rollup merge of
rust-lang#126849 - workingjubilee:correctly-classify-arm-low-dregs, r=Amanieu
rust-lang@dcace866f0 Rollup merge of
rust-lang#126845 - rust-lang:cargo_update, r=Mark-Simulacrum
rust-lang@21850f5bd8 Rollup merge of
rust-lang#126807 - devnexen:copy_file_macos_simpl, r=Mark-Simulacrum
rust-lang@b24e3df0df Rollup merge of
rust-lang#126754 - compiler-errors:use-rustfmt, r=calebcartwright
rust-lang@ad0531ae0d Rollup merge of
rust-lang#126455 - surechen:fix_126222, r=estebank
rust-lang@7babf99ea9 Rollup merge of
rust-lang#126298 - heiher:loongarch64-musl-ci, r=Mark-Simulacrum
rust-lang@9a591ea1ce Rollup merge of
rust-lang#126177 - carbotaniuman:unsafe_attr_errors, r=jieyouxu
rust-lang@25446c25fc Remove stray println
from rustfmt
rust-lang@d49994b060 Auto merge of
rust-lang#126023 - amandasystems:you-dropped-this-again, r=nikomatsakis
rust-lang@a23917cfd0 Add hard error and
migration lint for unsafe attrs
rust-lang@284437d434 Special case when a
code line only has multiline span starts
rust-lang@f1be59fa72 SmartPointer
derive-macro
rust-lang@a426d6fdf0 Implement use<>
formatting in rustfmt
rust-lang@16fef40896 Promote
loongarch64-unknown-linux-musl to Tier 2 with host tools
rust-lang@03d73fa6ba ci: Add support for
dist-loongarch64-musl
rust-lang@fc50acae90 fix build
rust-lang@bd9ce3e074
std::unix::os::home_dir: fallback's optimisation.
rust-lang@0d8f734172 compiler: Fix arm32
asm issues by hierarchically sorting reg classes
rust-lang@e8b5ba1111 For [E0308]:
mismatched types, when expr is in an arm's body, not add semicolon ';'
at the end of it.
rust-lang@990535723d cargo update
rust-lang@b28efb11af Save 2 pointers in
`TerminatorKind` (96 → 80 bytes)
rust-lang@65530ba100 std::unix::fs: copy
simplification for apple.
rust-lang@339015920d Add `rust_analyzer`
as a predefined tool
rust-lang@3f2f8438b4 Ensure we don't
accidentally succeed when we want to report an error
rust-lang@32f9b8bf76 std: rename module
for clarity
rust-lang@35f050b8da std: update TLS
module documentation
rust-lang@b2f29edc81 std: use the `c_int`
from `core::ffi` instead of `libc`
rust-lang@d70f071392 std: simplify
`#[cfg]`s for TLS
rust-lang@d630f5da7a Show notice about
"never used" for enum
rust-lang@f3facf1175 std: refactor the
TLS implementation
rust-lang@f5f067bf9d Deprecate no-op
codegen option `-Cinline-threshold=...`
rust-lang@651ff643ae Fix typo in
`-Cno-stack-check` deprecation warning
rust-lang@3af624272a rustc_codegen_ssa:
Remove unused ModuleConfig::inline_threshold
rust-lang@34e6ea1446 Tier 2 std support
must always be known
rust-lang@2d4cb7aa5a Update docs for
AtomicU8/I8.
rust-lang@7885c7b7b2 Update safety docs
for AtomicBool::from_ptr.
rust-lang@7b5b7a7010 Remove confusing
`use_polonius` flag and do less cloning

Co-authored-by: tautschnig <1144736+tautschnig@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants