Skip to content

Commit 9f227ff

Browse files
committed
Auto merge of #139578 - ferrocene:pa-compiletest-edition, r=jieyouxu
Fix breakage when running compiletest with `--test-args=--edition=2015` Compiletest has an `--edition` flag to change the default edition tests are run with. Unfortunately no test suite successfully executes when that flag is passed. If the edition is set to something greater than 2015 the breakage is expected, since the test suite currently supports only edition 2015 (Ferrous Systems will open an MCP about fixing that soonish). Surprisingly, the test suite is also broken if `--edition=2015` is passed to compiletest. This PR focuses on fixing the latter. This PR fixes the two categories of failures happening when `--edition=2015` is passed: * Some edition-specific tests set their edition through `//@ compile-flags` instead of `//@ edition`. Compiletest doesn't parse the compile flags, so it would see no `//@ edition` and add another `--edition` flag, leading to a rustc error. * Compiletest would add the edition after `//@ compile-flags`, while some tests depend on flags passed to `//@ compile-flags` being the last flags in the rustc invocation. Note that for the first category, I opted to manually go and replace all `//@ compile-flags` setting an edition with an explicit `//@ edition`. We could've changed compiletest to instead check whether an edition was set in `//@ compile-flags`, but I thought it was better to enforce a consistent way to set the edition in tests. I also added the edition to the stamp, so that changing `--edition` results in tests being re-executed. r? `@jieyouxu`
2 parents e5fa266 + d7631d2 commit 9f227ff

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Diff for: src/tests/directives.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,14 @@ ignoring debuggers.
234234

235235
### Affecting how tests are built
236236

237-
| Directive | Explanation | Supported test suites | Possible values |
238-
|---------------------|----------------------------------------------------------------------------------------------|---------------------------|------------------------------------------------------------------------------|
239-
| `compile-flags` | Flags passed to `rustc` when building the test or aux file | All except for `run-make` | Any valid `rustc` flags, e.g. `-Awarnings -Dfoo`. Cannot be `-Cincremental`. |
240-
| `edition` | Alias for `compile-flags: --edition=xxx` | All except for `run-make` | Any valid `--edition` value |
241-
| `rustc-env` | Env var to set when running `rustc` | All except for `run-make` | `<KEY>=<VALUE>` |
242-
| `unset-rustc-env` | Env var to unset when running `rustc` | All except for `run-make` | Any env var name |
243-
| `incremental` | Proper incremental support for tests outside of incremental test suite | `ui`, `crashes` | N/A |
244-
| `no-prefer-dynamic` | Don't use `-C prefer-dynamic`, don't build as a dylib via a `--crate-type=dylib` preset flag | `ui`, `crashes` | N/A |
237+
| Directive | Explanation | Supported test suites | Possible values |
238+
|---------------------|----------------------------------------------------------------------------------------------|---------------------------|--------------------------------------------------------------------------------------------|
239+
| `compile-flags` | Flags passed to `rustc` when building the test or aux file | All except for `run-make` | Any valid `rustc` flags, e.g. `-Awarnings -Dfoo`. Cannot be `-Cincremental` or `--edition` |
240+
| `edition` | The edition used to build the test | All except for `run-make` | Any valid `--edition` value |
241+
| `rustc-env` | Env var to set when running `rustc` | All except for `run-make` | `<KEY>=<VALUE>` |
242+
| `unset-rustc-env` | Env var to unset when running `rustc` | All except for `run-make` | Any env var name |
243+
| `incremental` | Proper incremental support for tests outside of incremental test suite | `ui`, `crashes` | N/A |
244+
| `no-prefer-dynamic` | Don't use `-C prefer-dynamic`, don't build as a dylib via a `--crate-type=dylib` preset flag | `ui`, `crashes` | N/A |
245245

246246
<div class="warning">
247247
Tests (outside of `run-make`) that want to use incremental tests not in the

0 commit comments

Comments
 (0)