Skip to content

Introduce and use specialized //@ ignore-auxiliary for test support files instead of using //@ ignore-test #139967

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

Merged
merged 5 commits into from
Apr 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/doc/rustc-dev-guide/src/tests/best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ See [compiletest directives] for a listing of directives.
- For `ignore-*`/`needs-*`/`only-*` directives, unless extremely obvious,
provide a brief remark on why the directive is needed. E.g. `"//@ ignore-wasi
(wasi codegens the main symbol differently)"`.
- When using `//@ ignore-auxiliary`, specify the corresponding main test files,
e.g. ``//@ ignore-auxiliary (used by `./foo.rs`)``.

## FileCheck best practices

Expand Down
3 changes: 3 additions & 0 deletions src/doc/rustc-dev-guide/src/tests/directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ means the test won't be compiled or run.
* `ignore-X` where `X` is a target detail or other criteria on which to ignore the test (see below)
* `only-X` is like `ignore-X`, but will *only* run the test on that target or
stage
* `ignore-auxiliary` is intended for files that *participate* in one or more other
main test files but that `compiletest` should not try to build the file itself.
Please backlink to which main test is actually using the auxiliary file.
* `ignore-test` always ignores the test. This can be used to temporarily disable
a test if it is currently not working, but you want to keep it in tree to
re-enable it later.
Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/src/directive-list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"ignore-arm-unknown-linux-gnueabihf",
"ignore-arm-unknown-linux-musleabi",
"ignore-arm-unknown-linux-musleabihf",
"ignore-auxiliary",
"ignore-avr",
"ignore-beta",
"ignore-cdb",
Expand Down
4 changes: 4 additions & 0 deletions src/tools/compiletest/src/header/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ fn parse_cfg_name_directive<'a>(
name: "test",
message: "always"
}
condition! {
name: "auxiliary",
message: "used by another main test file"
}
condition! {
name: &config.target,
allowed_names: &target_cfgs.all_targets,
Expand Down
6 changes: 6 additions & 0 deletions src/tools/compiletest/src/header/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,3 +940,9 @@ fn test_supported_crate_types() {
"//@ needs-crate-type: bin, cdylib, dylib, lib, proc-macro, rlib, staticlib"
));
}

#[test]
fn test_ignore_auxiliary() {
let config = cfg().build();
assert!(check_ignore(&config, "//@ ignore-auxiliary"));
}
2 changes: 1 addition & 1 deletion tests/codegen/remap_path_prefix/aux_mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ ignore-test: this is not a test
//@ ignore-auxiliary (used by `./main.rs`)

#[inline]
pub fn some_aux_mod_function() -> i32 {
Expand Down
4 changes: 3 additions & 1 deletion tests/debuginfo/drop-locations.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//@ ignore-android
//@ ignore-test: #128971

// FIXME: stepping with "next" in a debugger skips past end-of-scope drops
//@ ignore-test (broken, see #128971)
Comment on lines -2 to +4
Copy link
Member Author

Choose a reason for hiding this comment

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

Remark: drive-by comment


#![allow(unused)]

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/borrowck/move-error-snippets-ext.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ ignore-test (auxiliary, used by other tests)
//@ ignore-auxiliary (used by `./move-error-snippets.rs`)

macro_rules! aaa {
($c:ident) => {{
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/codemap_tests/two_files_data.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ ignore-test (auxiliary, used by other tests)
//@ ignore-auxiliary (used by `./two_files.rs`)

trait Foo { }

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/conditional-compilation/module_with_cfg.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
//@ ignore-test (auxiliary, used by other tests)
//@ ignore-auxiliary (used by `./inner-cfg-non-inline-mod.rs`)

#![cfg_attr(all(), cfg(FALSE))]
2 changes: 1 addition & 1 deletion tests/ui/cross/cross-file-errors/underscore.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ ignore-test (auxiliary, used by other tests)
//@ ignore-auxiliary (used by `./main.rs`)
#![crate_type = "lib"]

macro_rules! underscore {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
//@ ignore-test not a test, auxiliary
//@ ignore-auxiliary (used by `../../macro-expanded-mod.rs`)
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
//@ ignore-test not a test, auxiliary
//@ ignore-auxiliary (used by `../../macro-expanded-mod.rs`)

mod_decl!(bar);
6 changes: 0 additions & 6 deletions tests/ui/directory_ownership/mod_file_not_owning_aux1.rs
Copy link
Member Author

@jieyouxu jieyouxu Apr 17, 2025

Choose a reason for hiding this comment

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

Remark: I believe there used to be a test that used these, but somehow that test either got changed, moved or removed, and now these aux files are no longer used. I couldn't find the cause of this through git blame.

Copy link
Member

@wesleywiser wesleywiser Apr 17, 2025

Choose a reason for hiding this comment

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

These seem to be the commits:

I found these by doing git log -- **/aux_file_name.rs to find the commit which introduced the file and associated test and then I repeated the same thing again with the actual test name to find the commit where it was removed.

This file was deleted.

1 change: 0 additions & 1 deletion tests/ui/directory_ownership/mod_file_not_owning_aux2.rs

This file was deleted.

3 changes: 0 additions & 3 deletions tests/ui/directory_ownership/mod_file_not_owning_aux3.rs

This file was deleted.

2 changes: 1 addition & 1 deletion tests/ui/lint/expansion-time-include.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ ignore-test auxiliary file for expansion-time.rs
//@ ignore-auxiliary (used by `./expansion-time.rs`)

1
2
2 changes: 1 addition & 1 deletion tests/ui/lint/known-tool-in-submodule/submodule.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ ignore-test: not a test
//@ ignore-auxiliary (used by `./root.rs`)

#[allow(tool::lint)]
pub fn foo() {}
2 changes: 1 addition & 1 deletion tests/ui/lint/lint_pre_expansion_extern_module_aux.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
//@ ignore-test: not a test
//@ ignore-auxiliary (used by `./lint-pre-expansion-extern-module.rs`)

pub fn try() {}
4 changes: 1 addition & 3 deletions tests/ui/lint/unknown-lints/other.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//@ ignore-test (auxiliary)

// Companion to allow-in-other-module.rs
//@ ignore-auxiliary (used by `./allow-in-other-module.rs`)

// This should not warn.
#![allow(not_a_real_lint)]
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/macros/auxiliary/macro-include-items-expr.rs
Copy link
Member Author

Choose a reason for hiding this comment

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

Remark: This directory already has compiletest-ignore-dir, so this aux file and tests/ui/macros/auxiliary/macro-include-items-item.rs has // ignore-test (note the lack of @) which are redundant and never ported during the // -> //@ migration.

Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
// ignore-test: this is not a test

1
2 changes: 0 additions & 2 deletions tests/ui/macros/auxiliary/macro-include-items-item.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
// ignore-test: this is not a test

fn foo() { bar() }
2 changes: 1 addition & 1 deletion tests/ui/macros/include-single-expr-helper-1.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ ignore-test auxiliary file for include-single-expr.rs
//@ ignore-auxiliary (used by `./include-single-expr.rs`)

0

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/macros/include-single-expr-helper.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ ignore-test auxiliary file for include-single-expr.rs
//@ ignore-auxiliary (used by `./include-single-expr.rs`)

0
10
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/macros/issue-69838-dir/bar.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
//@ ignore-test -- this is an auxiliary file as part of another test.
//@ ignore-auxiliary (used by `../issue-69838-mods-relative-to-included-path.rs`)

pub fn i_am_in_bar() {}
2 changes: 1 addition & 1 deletion tests/ui/macros/issue-69838-dir/included.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
//@ ignore-test -- this is an auxiliary file as part of another test.
//@ ignore-auxiliary (used by `../issue-69838-mods-relative-to-included-path.rs`)

pub mod bar;
2 changes: 1 addition & 1 deletion tests/ui/macros/macro-expanded-include/foo/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ ignore-test (auxiliary, used by other tests)
//@ ignore-auxiliary (used by `../test.rs`)

macro_rules! m {
() => { include!("file.txt"); }
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/missing_non_modrs_mod/foo.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//
//@ ignore-test this is just a helper for the real test in this dir
Copy link
Member Author

@jieyouxu jieyouxu Apr 17, 2025

Choose a reason for hiding this comment

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

Remark: removing this extra // caused a .stderr line number shift in tests/ui/missing_non_modrs_mod/missing_non_modrs_mod.stderr.

//@ ignore-auxiliary (used by `./missing_non_modrs_mod.rs`)

mod missing;
2 changes: 1 addition & 1 deletion tests/ui/missing_non_modrs_mod/foo_inline.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ ignore-test this is just a helper for the real test in this dir
//@ ignore-auxiliary (used by `./missing_non_modrs_mod_inline.rs`)

mod inline {
mod missing;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0583]: file not found for module `missing`
--> $DIR/foo.rs:4:1
--> $DIR/foo.rs:3:1
|
LL | mod missing;
| ^^^^^^^^^^^^
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/modules/mod_file_aux.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//@ run-pass
//@ ignore-test Not a test. Used by other tests
Copy link
Member Author

Choose a reason for hiding this comment

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

Remark: useless/misleading //@ run-pass in a few aux files that are //@ ignore-test (//@ ignore-auxiliary)

//@ ignore-auxiliary (used by `./mod_file_with_path_attr.rs` and `mod_file.rs`)

pub fn foo() -> isize { 10 }
2 changes: 1 addition & 1 deletion tests/ui/modules_and_files_visibility/mod_file_aux.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
//@ ignore-test Not a test. Used by other tests
//@ ignore-auxiliary (used by `./mod_file_correct_spans.rs`)

pub fn foo() -> isize { 10 }
Original file line number Diff line number Diff line change
@@ -1 +1 @@
//@ ignore-test not a test. aux file
//@ ignore-auxiliary (used by `./mod_file_disambig.rs`)
Original file line number Diff line number Diff line change
@@ -1 +1 @@
//@ ignore-test not a test. aux file
//@ ignore-auxiliary (used by `../mod_file_disambig.rs`)
4 changes: 1 addition & 3 deletions tests/ui/non_modrs_mods/foors_mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//@ run-pass
//
//@ ignore-test: not a test, used by non_modrs_mods.rs
//@ ignore-auxiliary (used by `./non_modrs_mods.rs`)

pub mod inner_modrs_mod;
pub mod inner_foors_mod;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/non_modrs_mods_and_inline_mods/x.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ ignore-test: not a test
//@ ignore-auxiliary (used by `./non_modrs_mods_and_inline_mods.rs`)

pub mod y {
pub mod z;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/non_modrs_mods_and_inline_mods/x/y/z/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
//@ ignore-test: not a test
//@ ignore-auxiliary (used by `../../../non_modrs_mods_and_inline_mods.rs`)
2 changes: 1 addition & 1 deletion tests/ui/numbers-arithmetic/saturating-float-casts-impl.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ ignore-test (auxiliary, used by other tests)
//@ ignore-auxiliary (used by `./saturating-float-casts.rs` and `./saturating-float-casts-wasm.rs`)

// Tests saturating float->int casts. See u128-as-f32.rs for the opposite direction.
//
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/parser/circular_modules_hello.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ ignore-test: this is an auxiliary file for circular-modules-main.rs
//@ ignore-auxiliary (used by `./circular-modules-main.rs`)

#[path = "circular_modules_main.rs"]
mod circular_modules_main;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ ignore-test: this is an auxiliary file for circular-module-with-doc-comment-issue-97589.rs
//@ ignore-auxiliary (used by `./circular-module-with-doc-comment-issue-97589.rs`)

//! this comment caused the circular dependency checker to break

Expand Down
3 changes: 1 addition & 2 deletions tests/ui/parser/issues/issue-48508-aux.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ run-pass
//@ ignore-test Not a test. Used by issue-48508.rs
//@ ignore-auxiliary (used by `./issue-48508.rs`)

pub fn other() -> f64 {
let µ = 1.0;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/proc-macro/module.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
//@ ignore-test (auxiliary, used by other tests)
//@ ignore-auxiliary (used by `./attributes-on-modules-fail.rs`)
2 changes: 1 addition & 1 deletion tests/ui/proc-macro/module_with_attrs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ ignore-test (auxiliary, used by other tests)
//@ ignore-auxiliary (used by `../inner-attr-non-inline-mod.rs`)

#![rustfmt::skip]
#![print_attr]
2 changes: 1 addition & 1 deletion tests/ui/proc-macro/outer/inner.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
//@ ignore-test (auxiliary, used by other tests)
//@ ignore-auxiliary (used by `../attributes-on-modules-fail.rs`)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ ignore-test (auxiliary, used by other tests)
//@ ignore-auxiliary (used by `../../../pretty-print-hack-show.rs`)

#[derive(Print)]
enum ProceduralMasqueradeDummyType {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ ignore-test (auxiliary, used by other tests)
//@ ignore-auxiliary (used by `../../../pretty-print-hack-show.rs`)

#[derive(Print)]
enum ProceduralMasqueradeDummyType {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ ignore-test (auxiliary, used by other tests)
//@ ignore-auxiliary (used by `../../../pretty-print-hack/hide.rs`)

#[derive(Print)]
enum ProceduralMasqueradeDummyType {
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/runtime/backtrace-debuginfo-aux.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ run-pass
//@ ignore-test: not a test, used by backtrace-debuginfo.rs to test file!()
//@ ignore-auxiliary (used by `./backtrace-debuginfo.rs` to test `file!()`)

#[inline(never)]
pub fn callback<F>(f: F) where F: FnOnce((&'static str, u32)) {
Expand Down
Loading