Skip to content

libtest harness: avoid 'extern crate test' with custom runner - #162971

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
RalfJung:libtest-extern-crate
Sep 19, 2026
Merged

rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
RalfJung:libtest-extern-crate

Conversation

@RalfJung

Copy link
Copy Markdown
Member

This might fix the regression reported in #162796 (comment).

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 18, 2026
@rustbot

rustbot commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

r? @jieyouxu

rustbot has assigned @jieyouxu.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 77 candidates
  • Random selection from 21 candidates

@jieyouxu jieyouxu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This sounds plausible. Is there a way we can have a test for this?

View changes since this review

@RalfJung

RalfJung commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

I assume there is. I don't know this custom runner stuff well enough to write one. :)

@Muscraft

Copy link
Copy Markdown
Member

I built a stage 1 with this change and ran it against Cargo's build-std testsuite and it passed1.

If anyone else wants to try the command in the Cargo repo would be:

CARGO_RUN_BUILD_STD_TESTS=1 cargo +stage1 test -p cargo --test build-std

Footnotes

  1. Other than missing the rustdoc component

@RalfJung

Copy link
Copy Markdown
Member Author

I added a test based on the cargo test that broke. But that test does not work once there actually is a #[test] so I also adjusted it a bit. This new test doesn't replicate the failure cargo had (I don't know how to achieve the setup required for that), but it at least lets us see the actual expanded output of the test harness for custom runners.

@RalfJung
RalfJung force-pushed the libtest-extern-crate branch from c339d51 to d4c5b6c Compare September 18, 2026 15:42
Comment thread tests/pretty/custom-test-runner.pp Outdated
test::assert_test_result(mytest())),
};
fn mytest() {}
extern crate test;

@RalfJung RalfJung Sep 18, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This diff (in the 2nd commit) shows the effect of the change.

View changes since the review

@jieyouxu jieyouxu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, that test diff helps a lot. You can r=me when PR CI is green.

View changes since this review

Comment thread tests/pretty/custom-test-runner.rs Outdated
@jieyouxu

Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors

rust-bors Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 95296e6 has been approved by jieyouxu

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Sep 19, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 19, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - #163001 (Temporarily disable `test-x86_64-fuchsia`)
 - #162880 (Mini optimization in `rustc_hir_typeck::upvar::restrict_precision_for_drop_types`)
 - #161424 (implement `VaArgSafe` for `f128`)
 - #161777 (Add Natvis visualiser and debuginfo tests for `f128`)
 - #162506 (Avoid suggesting imports of traits declared inside fn bodies)
 - #162591 (Move parse error recovery for expression operators "out of line" & refactor in the area)
 - #162669 ([rustdoc] Correctly handle intra-doc links on inlined same item with different names)
 - #162733 (Add useful APIs to `Unique(Arc|Rc)`)
 - #162913 (Refactor LivenessResults into LivenessComputation, without typeck)
 - #162924 (Remove applying inline attributes at the callsite)
 - #162940 (Use spawned `SBDebugger` instance)
 - #162950 (More AST lowering cleanups)
 - #162964 (Update `browser-ui-test` version to `0.25.2`)
 - #162979 (mark `f128` as reliable on `powerpc64` with `+vsx`)
 - #161743 (Add performance notes for the floating-point round method)
 - #162797 (yeet AliasConstKind::opt_def_id)
 - #162836 (Ping T-libs-ping instead of T-libs-fcp for backports)
 - #162873 (Adjust `bug!`/`span_bug!` emission)
 - #162956 (Add missing `#[repr(C)]` in UI, codegen and assembly tests)
 - #162971 (libtest harness: avoid 'extern crate test' with custom runner)
 - #162981 (rustc-dev-guide subtree update)
 - #162985 (Error on invalid placements for unstable attributes)
@rust-bors
rust-bors Bot merged commit 252b4ce into rust-lang:main Sep 19, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 19, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 19, 2026
Rollup merge of #162971 - RalfJung:libtest-extern-crate, r=jieyouxu

libtest harness: avoid 'extern crate test' with custom runner

This might fix the regression reported in #162796 (comment).
@RalfJung
RalfJung deleted the libtest-extern-crate branch September 19, 2026 14:25
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Sep 20, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - rust-lang/rust#163001 (Temporarily disable `test-x86_64-fuchsia`)
 - rust-lang/rust#162880 (Mini optimization in `rustc_hir_typeck::upvar::restrict_precision_for_drop_types`)
 - rust-lang/rust#161424 (implement `VaArgSafe` for `f128`)
 - rust-lang/rust#161777 (Add Natvis visualiser and debuginfo tests for `f128`)
 - rust-lang/rust#162506 (Avoid suggesting imports of traits declared inside fn bodies)
 - rust-lang/rust#162591 (Move parse error recovery for expression operators "out of line" & refactor in the area)
 - rust-lang/rust#162669 ([rustdoc] Correctly handle intra-doc links on inlined same item with different names)
 - rust-lang/rust#162733 (Add useful APIs to `Unique(Arc|Rc)`)
 - rust-lang/rust#162913 (Refactor LivenessResults into LivenessComputation, without typeck)
 - rust-lang/rust#162924 (Remove applying inline attributes at the callsite)
 - rust-lang/rust#162940 (Use spawned `SBDebugger` instance)
 - rust-lang/rust#162950 (More AST lowering cleanups)
 - rust-lang/rust#162964 (Update `browser-ui-test` version to `0.25.2`)
 - rust-lang/rust#162979 (mark `f128` as reliable on `powerpc64` with `+vsx`)
 - rust-lang/rust#161743 (Add performance notes for the floating-point round method)
 - rust-lang/rust#162797 (yeet AliasConstKind::opt_def_id)
 - rust-lang/rust#162836 (Ping T-libs-ping instead of T-libs-fcp for backports)
 - rust-lang/rust#162873 (Adjust `bug!`/`span_bug!` emission)
 - rust-lang/rust#162956 (Add missing `#[repr(C)]` in UI, codegen and assembly tests)
 - rust-lang/rust#162971 (libtest harness: avoid 'extern crate test' with custom runner)
 - rust-lang/rust#162981 (rustc-dev-guide subtree update)
 - rust-lang/rust#162985 (Error on invalid placements for unstable attributes)
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants