Skip to content

Commit 0fc6743

Browse files
authored
Rollup merge of #155474 - Zalathar:bpass, r=jieyouxu
Rename incremental `cfail`/`cpass` revisions to `bfail`/`bpass` Long ago, UI tests were divided into *compile* and *run* tests. Later, the compile tests were further subdivided into *check* and *build* tests, to speed up tests that don't need a full build. The same split was never applied to incremental test revisions, so the only way to perform a check build in incremental tests is (confusingly) to use a `cfail` revision and then specify `//@ check-fail` or `//@ check-pass`. This PR makes room for dedicated check-fail and check-pass revisions by renaming the existing `cfail` and `cpass` revisions to `bfail` and `bpass`, since they currently perform a full build. --- The test updates were done with a regex whole-word find-and-replace for `c(fail|pass)(\d*)`, and I also took the opportunity to manually add a space after `revisions:` on affected lines. r? jieyouxu
2 parents a394d5e + 72abf37 commit 0fc6743

99 files changed

Lines changed: 3152 additions & 3153 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/doc/rustc-dev-guide/src/tests/compiletest.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ then runs the compiler for each revision, reusing the incremental results from p
158158

159159
The revisions should start with:
160160

161-
* `cfail` — the test should fail to compile
162-
* `cpass` — the test should compile successully
161+
* `bfail` — the test should fail to compile
162+
* `bpass` — the test should compile successully
163163
* `rpass` — the test should compile and run successfully
164164

165165
To make the revisions unique, you should add a suffix like `rpass1` and `rpass2`.
@@ -185,7 +185,7 @@ fn foo() {
185185
fn main() { foo(); }
186186
```
187187

188-
`cfail` tests support the `forbid-output` directive to specify that a certain
188+
Incremental tests support the `forbid-output` directive to specify that a certain
189189
substring must not appear anywhere in the compiler output.
190190
This can be useful to ensure certain errors do not appear, but this can be fragile as error messages
191191
change over time, and a test may no longer be checking the right thing but will still pass.

src/doc/rustc-dev-guide/src/tests/directives.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ comparison](ui.md#output-comparison) and [Rustfix tests](ui.md#rustfix-tests) fo
106106
| `exec-env` | Env var to set when executing a test | `ui`, `crashes` | `<KEY>=<VALUE>` |
107107
| `unset-exec-env` | Env var to unset when executing a test | `ui`, `crashes` | Any env var name |
108108
| `stderr-per-bitwidth` | Generate a stderr snapshot for each bitwidth | `ui` | N/A |
109-
| `forbid-output` | A pattern which must not appear in stderr/`cfail` output | `ui`, `incremental` | Regex pattern |
109+
| `forbid-output` | Check that compile/run output does not contain a specific string | `ui`, `incremental` | String |
110110
| `run-flags` | Flags passed to the test executable | `ui` | Arbitrary flags |
111111
| `known-bug` | No error annotation needed due to known bug | `ui`, `crashes`, `incremental` | Issue number `#123456` |
112112
| `compare-output-by-lines` | Compare the output by lines, rather than as a single string | All | N/A |
@@ -315,8 +315,7 @@ See [Pretty-printer](compiletest.md#pretty-printer-tests).
315315

316316
- `no-auto-check-cfg` — disable auto check-cfg (only for `--check-cfg` tests)
317317
- [`revisions`](compiletest.md#revisions) — compile multiple times
318-
-[`forbid-output`](compiletest.md#incremental-tests) — incremental cfail rejects
319-
output pattern
318+
- [`forbid-output`](compiletest.md#incremental-tests) — check that output does not contain a specified string
320319
- [`reference`] — an annotation linking to a rule in the reference
321320
- `disable-gdb-pretty-printers` — disable gdb pretty printers for debuginfo tests
322321

src/tools/compiletest/src/directives.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub(crate) struct TestProps {
135135
pub(crate) pretty_mode: String,
136136
// Only compare pretty output and don't try compiling
137137
pub(crate) pretty_compare_only: bool,
138-
// Patterns which must not appear in the output of a cfail test.
138+
/// Strings that must not appear in compile/run output.
139139
pub(crate) forbid_output: Vec<String>,
140140
// Revisions to test for incremental compilation.
141141
pub(crate) revisions: Vec<String>,
@@ -442,8 +442,8 @@ impl TestProps {
442442
(TestMode::Incremental, _) => {
443443
// FIXME(Zalathar): This only detects forbidden directives that are
444444
// declared _after_ the incompatible `//@ revisions:` directive(s).
445-
if self.revisions.iter().any(|r| !r.starts_with("cfail")) {
446-
panic!("`{s}` directive is only supported in `cfail` incremental tests")
445+
if self.revisions.iter().any(|r| !r.starts_with("bfail")) {
446+
panic!("`{s}` directive is only supported in `bfail` incremental tests")
447447
}
448448
}
449449
(mode, _) => panic!("`{s}` directive is not supported in `{mode}` tests"),

src/tools/compiletest/src/runtest.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,12 @@ impl<'test> TestCx<'test> {
327327
TestMode::Incremental => {
328328
let revision =
329329
self.revision.expect("incremental tests require a list of revisions");
330-
if revision.starts_with("cpass") || revision.starts_with("rpass") {
330+
if revision.starts_with("bpass") || revision.starts_with("rpass") {
331331
true
332-
} else if revision.starts_with("cfail") {
332+
} else if revision.starts_with("bfail") {
333333
pm.is_some()
334334
} else {
335-
panic!("revision name must begin with `cfail`, `cpass`, or `rpass`");
335+
panic!("revision name must begin with `bfail`, `bpass`, or `rpass`");
336336
}
337337
}
338338
mode => panic!("unimplemented for mode {:?}", mode),

src/tools/compiletest/src/runtest/incremental.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ use super::{FailMode, ProcRes, TestCx, WillExecute};
33
impl TestCx<'_> {
44
pub(super) fn run_incremental_test(&self) {
55
// Basic plan for a test incremental/foo/bar.rs:
6-
// - load list of revisions rpass1, cfail2, rpass3
7-
// - each should begin with `cfail`, `cpass`, or `rpass`
8-
// - if `cpass`, expect compilation to succeed, don't execute
6+
// - load list of revisions rpass1, bfail2, rpass3
7+
// - each should begin with `bfail`, `bpass`, or `rpass`
8+
// - if `bfail`, expect compilation to fail
9+
// - if `bpass`, expect compilation to succeed, don't execute
910
// - if `rpass`, expect compilation and execution to succeed
10-
// - if `cfail`, expect compilation to fail
1111
// - create a directory build/foo/bar.incremental
1212
// - compile foo/bar.rs with -C incremental=.../foo/bar.incremental and -C rpass1
1313
// - because name of revision starts with "rpass", expect success
14-
// - compile foo/bar.rs with -C incremental=.../foo/bar.incremental and -C cfail2
15-
// - because name of revision starts with "cfail", expect an error
16-
// - load expected errors as usual, but filter for those with `[cfail2]`
14+
// - compile foo/bar.rs with -C incremental=.../foo/bar.incremental and -C bfail2
15+
// - because name of revision starts with "bfail", expect an error
16+
// - load expected errors as usual, but filter for those with `[bfail2]`
1717
// - compile foo/bar.rs with -C incremental=.../foo/bar.incremental and -C rpass3
1818
// - because name of revision starts with "rpass", expect success
1919
// - execute build/foo/bar.exe and save output
@@ -31,18 +31,18 @@ impl TestCx<'_> {
3131
write!(self.stdout, "revision={:?} props={:#?}", revision, self.props);
3232
}
3333

34-
if revision.starts_with("cpass") {
35-
self.run_cpass_test();
34+
if revision.starts_with("bpass") {
35+
self.run_bpass_test();
3636
} else if revision.starts_with("rpass") {
3737
self.run_rpass_test();
38-
} else if revision.starts_with("cfail") {
39-
self.run_cfail_test();
38+
} else if revision.starts_with("bfail") {
39+
self.run_bfail_test();
4040
} else {
41-
self.fatal("revision name must begin with `cfail`, `cpass`, or `rpass`");
41+
self.fatal("revision name must begin with `bfail`, `bpass`, or `rpass`");
4242
}
4343
}
4444

45-
fn run_cpass_test(&self) {
45+
fn run_bpass_test(&self) {
4646
let emit_metadata = self.should_emit_metadata(self.pass_mode());
4747
let proc_res = self.compile_test(WillExecute::No, emit_metadata);
4848

@@ -74,7 +74,7 @@ impl TestCx<'_> {
7474
}
7575
}
7676

77-
fn run_cfail_test(&self) {
77+
fn run_bfail_test(&self) {
7878
let pm = self.pass_mode();
7979
let proc_res = self.compile_test(WillExecute::No, self.should_emit_metadata(pm));
8080
self.check_if_test_should_compile(Some(FailMode::Build), pm, &proc_res);

tests/incremental/add_private_fn_at_krate_root_cc/struct_point.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// crate. This should not cause anything we use to be invalidated.
33
// Regression test for #36168.
44

5-
//@ revisions:cfail1 cfail2
5+
//@ revisions: bfail1 bfail2
66
//@ compile-flags: -Z query-dep-graph
77
//@ aux-build:point.rs
88
//@ build-pass
@@ -12,19 +12,19 @@
1212
#![allow(dead_code)]
1313
#![crate_type = "rlib"]
1414

15-
#![rustc_partition_reused(module="struct_point-fn_calls_methods_in_same_impl", cfg="cfail2")]
16-
#![rustc_partition_reused(module="struct_point-fn_calls_free_fn", cfg="cfail2")]
17-
#![rustc_partition_reused(module="struct_point-fn_read_field", cfg="cfail2")]
18-
#![rustc_partition_reused(module="struct_point-fn_write_field", cfg="cfail2")]
19-
#![rustc_partition_reused(module="struct_point-fn_make_struct", cfg="cfail2")]
15+
#![rustc_partition_reused(module="struct_point-fn_calls_methods_in_same_impl", cfg="bfail2")]
16+
#![rustc_partition_reused(module="struct_point-fn_calls_free_fn", cfg="bfail2")]
17+
#![rustc_partition_reused(module="struct_point-fn_read_field", cfg="bfail2")]
18+
#![rustc_partition_reused(module="struct_point-fn_write_field", cfg="bfail2")]
19+
#![rustc_partition_reused(module="struct_point-fn_make_struct", cfg="bfail2")]
2020

2121
extern crate point;
2222

2323
/// A fn item that calls (public) methods on `Point` from the same impl
2424
pub mod fn_calls_methods_in_same_impl {
2525
use point::Point;
2626

27-
#[rustc_clean(cfg="cfail2")]
27+
#[rustc_clean(cfg="bfail2")]
2828
pub fn check() {
2929
let x = Point { x: 2.0, y: 2.0 };
3030
x.distance_from_origin();
@@ -35,7 +35,7 @@ pub mod fn_calls_methods_in_same_impl {
3535
pub mod fn_calls_free_fn {
3636
use point::{self, Point};
3737

38-
#[rustc_clean(cfg="cfail2")]
38+
#[rustc_clean(cfg="bfail2")]
3939
pub fn check() {
4040
let x = Point { x: 2.0, y: 2.0 };
4141
point::distance_squared(&x);
@@ -46,7 +46,7 @@ pub mod fn_calls_free_fn {
4646
pub mod fn_make_struct {
4747
use point::Point;
4848

49-
#[rustc_clean(cfg="cfail2")]
49+
#[rustc_clean(cfg="bfail2")]
5050
pub fn make_origin() -> Point {
5151
Point { x: 2.0, y: 2.0 }
5252
}
@@ -56,7 +56,7 @@ pub mod fn_make_struct {
5656
pub mod fn_read_field {
5757
use point::Point;
5858

59-
#[rustc_clean(cfg="cfail2")]
59+
#[rustc_clean(cfg="bfail2")]
6060
pub fn get_x(p: Point) -> f32 {
6161
p.x
6262
}
@@ -66,7 +66,7 @@ pub mod fn_read_field {
6666
pub mod fn_write_field {
6767
use point::Point;
6868

69-
#[rustc_clean(cfg="cfail2")]
69+
#[rustc_clean(cfg="bfail2")]
7070
pub fn inc_x(p: &mut Point) {
7171
p.x += 1.0;
7272
}

tests/incremental/auxiliary/incremental_proc_macro_aux.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ extern crate proc_macro;
33
use proc_macro::TokenStream;
44

55
// Add a function to shift DefIndex of registrar function
6-
#[cfg(cfail2)]
6+
#[cfg(bfail2)]
77
fn foo() {}
88

99
#[proc_macro_derive(IncrementalMacro)]
1010
pub fn derive(input: TokenStream) -> TokenStream {
11-
#[cfg(cfail2)]
11+
#[cfg(bfail2)]
1212
{
1313
foo();
1414
}

tests/incremental/cache-lint-expectation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Regression test for #154878
2-
//@ revisions: cpass1 cpass2
2+
//@ revisions: bpass1 bpass2
33

44
pub fn main() {
55
let x = 42.0;

tests/incremental/change_add_field/struct_point.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Fns with that type used only in their body are also recompiled, but
44
// their callers are not.
55

6-
//@ revisions:cfail1 cfail2
6+
//@ revisions: bfail1 bfail2
77
//@ compile-flags: -Z query-dep-graph
88
//@ build-pass
99
//@ ignore-backends: gcc
@@ -13,24 +13,24 @@
1313
#![crate_type = "rlib"]
1414

1515
// These are expected to require codegen.
16-
#![rustc_partition_codegened(module="struct_point-point", cfg="cfail2")]
17-
#![rustc_partition_codegened(module="struct_point-fn_with_type_in_sig", cfg="cfail2")]
18-
#![rustc_partition_codegened(module="struct_point-call_fn_with_type_in_sig", cfg="cfail2")]
19-
#![rustc_partition_codegened(module="struct_point-fn_with_type_in_body", cfg="cfail2")]
20-
#![rustc_partition_codegened(module="struct_point-fn_make_struct", cfg="cfail2")]
21-
#![rustc_partition_codegened(module="struct_point-fn_read_field", cfg="cfail2")]
22-
#![rustc_partition_codegened(module="struct_point-fn_write_field", cfg="cfail2")]
16+
#![rustc_partition_codegened(module="struct_point-point", cfg="bfail2")]
17+
#![rustc_partition_codegened(module="struct_point-fn_with_type_in_sig", cfg="bfail2")]
18+
#![rustc_partition_codegened(module="struct_point-call_fn_with_type_in_sig", cfg="bfail2")]
19+
#![rustc_partition_codegened(module="struct_point-fn_with_type_in_body", cfg="bfail2")]
20+
#![rustc_partition_codegened(module="struct_point-fn_make_struct", cfg="bfail2")]
21+
#![rustc_partition_codegened(module="struct_point-fn_read_field", cfg="bfail2")]
22+
#![rustc_partition_codegened(module="struct_point-fn_write_field", cfg="bfail2")]
2323

24-
#![rustc_partition_reused(module="struct_point-call_fn_with_type_in_body", cfg="cfail2")]
24+
#![rustc_partition_reused(module="struct_point-call_fn_with_type_in_body", cfg="bfail2")]
2525

2626
pub mod point {
27-
#[cfg(cfail1)]
27+
#[cfg(bfail1)]
2828
pub struct Point {
2929
pub x: f32,
3030
pub y: f32,
3131
}
3232

33-
#[cfg(cfail2)]
33+
#[cfg(bfail2)]
3434
pub struct Point {
3535
pub x: f32,
3636
pub y: f32,
@@ -39,18 +39,18 @@ pub mod point {
3939

4040
impl Point {
4141
pub fn origin() -> Point {
42-
#[cfg(cfail1)]
42+
#[cfg(bfail1)]
4343
return Point { x: 0.0, y: 0.0 };
4444

45-
#[cfg(cfail2)]
45+
#[cfg(bfail2)]
4646
return Point { x: 0.0, y: 0.0, z: 0.0 };
4747
}
4848

4949
pub fn total(&self) -> f32 {
50-
#[cfg(cfail1)]
50+
#[cfg(bfail1)]
5151
return self.x + self.y;
5252

53-
#[cfg(cfail2)]
53+
#[cfg(bfail2)]
5454
return self.x + self.y + self.z;
5555
}
5656

@@ -70,7 +70,7 @@ pub mod point {
7070
pub mod fn_with_type_in_sig {
7171
use point::Point;
7272

73-
#[rustc_clean(except="typeck_root,fn_sig,optimized_mir", cfg="cfail2")]
73+
#[rustc_clean(except="typeck_root,fn_sig,optimized_mir", cfg="bfail2")]
7474
pub fn boop(p: Option<&Point>) -> f32 {
7575
p.map(|p| p.total()).unwrap_or(0.0)
7676
}
@@ -86,7 +86,7 @@ pub mod fn_with_type_in_sig {
8686
pub mod call_fn_with_type_in_sig {
8787
use fn_with_type_in_sig;
8888

89-
#[rustc_clean(except="typeck_root,optimized_mir", cfg="cfail2")]
89+
#[rustc_clean(except="typeck_root,optimized_mir", cfg="bfail2")]
9090
pub fn bip() -> f32 {
9191
fn_with_type_in_sig::boop(None)
9292
}
@@ -102,7 +102,7 @@ pub mod call_fn_with_type_in_sig {
102102
pub mod fn_with_type_in_body {
103103
use point::Point;
104104

105-
#[rustc_clean(except="typeck_root,optimized_mir", cfg="cfail2")]
105+
#[rustc_clean(except="typeck_root,optimized_mir", cfg="bfail2")]
106106
pub fn boop() -> f32 {
107107
Point::origin().total()
108108
}
@@ -115,7 +115,7 @@ pub mod fn_with_type_in_body {
115115
pub mod call_fn_with_type_in_body {
116116
use fn_with_type_in_body;
117117

118-
#[rustc_clean(cfg="cfail2")]
118+
#[rustc_clean(cfg="bfail2")]
119119
pub fn bip() -> f32 {
120120
fn_with_type_in_body::boop()
121121
}
@@ -125,7 +125,7 @@ pub mod call_fn_with_type_in_body {
125125
pub mod fn_make_struct {
126126
use point::Point;
127127

128-
#[rustc_clean(except="typeck_root,fn_sig,optimized_mir", cfg="cfail2")]
128+
#[rustc_clean(except="typeck_root,fn_sig,optimized_mir", cfg="bfail2")]
129129
pub fn make_origin(p: Point) -> Point {
130130
Point { ..p }
131131
}
@@ -135,7 +135,7 @@ pub mod fn_make_struct {
135135
pub mod fn_read_field {
136136
use point::Point;
137137

138-
#[rustc_clean(except="typeck_root,fn_sig,optimized_mir", cfg="cfail2")]
138+
#[rustc_clean(except="typeck_root,fn_sig,optimized_mir", cfg="bfail2")]
139139
pub fn get_x(p: Point) -> f32 {
140140
p.x
141141
}
@@ -145,7 +145,7 @@ pub mod fn_read_field {
145145
pub mod fn_write_field {
146146
use point::Point;
147147

148-
#[rustc_clean(except="typeck_root,fn_sig,optimized_mir", cfg="cfail2")]
148+
#[rustc_clean(except="typeck_root,fn_sig,optimized_mir", cfg="bfail2")]
149149
pub fn inc_x(p: &mut Point) {
150150
p.x += 1.0;
151151
}

tests/incremental/change_crate_dep_kind.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
// detected then -Zincremental-verify-ich will trigger an assertion.
33

44
//@ needs-unwind
5-
//@ revisions:cfail1 cfail2
5+
//@ revisions: bfail1 bfail2
66
//@ compile-flags: -Z query-dep-graph -Cpanic=unwind
77
//@ needs-unwind
88
//@ build-pass (FIXME(62277): could be check-pass?)
99
//@ ignore-backends: gcc
1010

11-
#![cfg_attr(cfail1, feature(panic_unwind))]
11+
#![cfg_attr(bfail1, feature(panic_unwind))]
1212

1313
// Turn the panic_unwind crate from an explicit into an implicit query:
14-
#[cfg(cfail1)]
14+
#[cfg(bfail1)]
1515
extern crate panic_unwind;
1616

1717
fn main() {}

0 commit comments

Comments
 (0)