Skip to content

Commit b5f9296

Browse files
authored
Unrolled build for #147221
Rollup merge of #147221 - Zalathar:incremental, r=lqd Forbid `//@ compile-flags: -Cincremental=` in tests Tests should not try to manually enable incremental compilation with `-Cincremental`, because that typically results in stray directories being created in the repository root. Also, if the incremental directory is not cleared, there is a risk of interference between successive runs of the same test. Instead, use the `//@ incremental` directive, which instructs compiletest to handle the details of passing `-Cincremental` with a fresh directory.
2 parents 4b9c62b + 59c4dfe commit b5f9296

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/tools/compiletest/src/directives.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,18 @@ impl TestProps {
415415
config.parse_name_value_directive(ln, COMPILE_FLAGS, testfile)
416416
{
417417
let flags = split_flags(&flags);
418-
for flag in &flags {
418+
for (i, flag) in flags.iter().enumerate() {
419419
if flag == "--edition" || flag.starts_with("--edition=") {
420420
panic!("you must use `//@ edition` to configure the edition");
421421
}
422+
if (flag == "-C"
423+
&& flags.get(i + 1).is_some_and(|v| v.starts_with("incremental=")))
424+
|| flag.starts_with("-Cincremental=")
425+
{
426+
panic!(
427+
"you must use `//@ incremental` to enable incremental compilation"
428+
);
429+
}
422430
}
423431
self.compile_flags.extend(flags);
424432
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@ revisions: good bad bad-space
2+
//@ check-pass
3+
4+
//@[bad] compile-flags: -Cincremental=true
5+
//@[bad] should-fail
6+
7+
//@[bad-space] compile-flags: -C incremental=dir
8+
//@[bad-space] should-fail
9+
10+
fn main() {}
11+
12+
// Tests should not try to manually enable incremental compilation with
13+
// `-Cincremental`, because that typically results in stray directories being
14+
// created in the repository root.
15+
//
16+
// Instead, use the `//@ incremental` directive, which instructs compiletest
17+
// to handle the details of passing `-Cincremental` with a fresh directory.

0 commit comments

Comments
 (0)