compiletest/common.rs
1use std::borrow::Cow;
2use std::collections::{BTreeSet, HashMap, HashSet};
3use std::iter;
4use std::process::Command;
5use std::sync::OnceLock;
6
7use build_helper::git::GitConfig;
8use camino::{Utf8Path, Utf8PathBuf};
9use semver::Version;
10
11use crate::edition::Edition;
12use crate::executor::ColorConfig;
13use crate::fatal;
14use crate::util::{Utf8PathBufExt, add_dylib_path, string_enum};
15
16string_enum! {
17 #[derive(Clone, Copy, PartialEq, Debug)]
18 pub enum TestMode {
19 Pretty => "pretty",
20 DebugInfo => "debuginfo",
21 Codegen => "codegen",
22 Rustdoc => "rustdoc",
23 RustdocJson => "rustdoc-json",
24 CodegenUnits => "codegen-units",
25 Incremental => "incremental",
26 RunMake => "run-make",
27 Ui => "ui",
28 RustdocJs => "rustdoc-js",
29 MirOpt => "mir-opt",
30 Assembly => "assembly",
31 CoverageMap => "coverage-map",
32 CoverageRun => "coverage-run",
33 Crashes => "crashes",
34 }
35}
36
37impl TestMode {
38 pub fn aux_dir_disambiguator(self) -> &'static str {
39 // Pretty-printing tests could run concurrently, and if they do,
40 // they need to keep their output segregated.
41 match self {
42 TestMode::Pretty => ".pretty",
43 _ => "",
44 }
45 }
46
47 pub fn output_dir_disambiguator(self) -> &'static str {
48 // Coverage tests use the same test files for multiple test modes,
49 // so each mode should have a separate output directory.
50 match self {
51 TestMode::CoverageMap | TestMode::CoverageRun => self.to_str(),
52 _ => "",
53 }
54 }
55}
56
57// Note that coverage tests use the same test files for multiple test modes.
58string_enum! {
59 #[derive(Clone, Copy, PartialEq, Debug)]
60 pub enum TestSuite {
61 AssemblyLlvm => "assembly-llvm",
62 CodegenLlvm => "codegen-llvm",
63 CodegenUnits => "codegen-units",
64 Coverage => "coverage",
65 CoverageRunRustdoc => "coverage-run-rustdoc",
66 Crashes => "crashes",
67 Debuginfo => "debuginfo",
68 Incremental => "incremental",
69 MirOpt => "mir-opt",
70 Pretty => "pretty",
71 RunMake => "run-make",
72 RunMakeCargo => "run-make-cargo",
73 Rustdoc => "rustdoc",
74 RustdocGui => "rustdoc-gui",
75 RustdocJs => "rustdoc-js",
76 RustdocJsStd=> "rustdoc-js-std",
77 RustdocJson => "rustdoc-json",
78 RustdocUi => "rustdoc-ui",
79 Ui => "ui",
80 UiFullDeps => "ui-fulldeps",
81 }
82}
83
84string_enum! {
85 #[derive(Clone, Copy, PartialEq, Debug, Hash)]
86 pub enum PassMode {
87 Check => "check",
88 Build => "build",
89 Run => "run",
90 }
91}
92
93string_enum! {
94 #[derive(Clone, Copy, PartialEq, Debug, Hash)]
95 pub enum RunResult {
96 Pass => "run-pass",
97 Fail => "run-fail",
98 Crash => "run-crash",
99 }
100}
101
102#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
103pub enum RunFailMode {
104 /// Running the program must make it exit with a regular failure exit code
105 /// in the range `1..=127`. If the program is terminated by e.g. a signal
106 /// the test will fail.
107 Fail,
108 /// Running the program must result in a crash, e.g. by `SIGABRT` or
109 /// `SIGSEGV` on Unix or on Windows by having an appropriate NTSTATUS high
110 /// bit in the exit code.
111 Crash,
112 /// Running the program must either fail or crash. Useful for e.g. sanitizer
113 /// tests since some sanitizer implementations exit the process with code 1
114 /// to in the face of memory errors while others abort (crash) the process
115 /// in the face of memory errors.
116 FailOrCrash,
117}
118
119#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
120pub enum FailMode {
121 Check,
122 Build,
123 Run(RunFailMode),
124}
125
126string_enum! {
127 #[derive(Clone, Debug, PartialEq)]
128 pub enum CompareMode {
129 Polonius => "polonius",
130 NextSolver => "next-solver",
131 NextSolverCoherence => "next-solver-coherence",
132 SplitDwarf => "split-dwarf",
133 SplitDwarfSingle => "split-dwarf-single",
134 }
135}
136
137string_enum! {
138 #[derive(Clone, Copy, Debug, PartialEq)]
139 pub enum Debugger {
140 Cdb => "cdb",
141 Gdb => "gdb",
142 Lldb => "lldb",
143 }
144}
145
146#[derive(Clone, Copy, Debug, PartialEq, Default, serde::Deserialize)]
147#[serde(rename_all = "kebab-case")]
148pub enum PanicStrategy {
149 #[default]
150 Unwind,
151 Abort,
152}
153
154impl PanicStrategy {
155 pub(crate) fn for_miropt_test_tools(&self) -> miropt_test_tools::PanicStrategy {
156 match self {
157 PanicStrategy::Unwind => miropt_test_tools::PanicStrategy::Unwind,
158 PanicStrategy::Abort => miropt_test_tools::PanicStrategy::Abort,
159 }
160 }
161}
162
163#[derive(Clone, Debug, PartialEq, serde::Deserialize)]
164#[serde(rename_all = "kebab-case")]
165pub enum Sanitizer {
166 Address,
167 Cfi,
168 Dataflow,
169 Kcfi,
170 KernelAddress,
171 Leak,
172 Memory,
173 Memtag,
174 Safestack,
175 ShadowCallStack,
176 Thread,
177 Hwaddress,
178 Realtime,
179}
180
181#[derive(Clone, Copy, Debug, PartialEq)]
182pub enum CodegenBackend {
183 Cranelift,
184 Gcc,
185 Llvm,
186}
187
188impl<'a> TryFrom<&'a str> for CodegenBackend {
189 type Error = &'static str;
190
191 fn try_from(value: &'a str) -> Result<Self, Self::Error> {
192 match value.to_lowercase().as_str() {
193 "cranelift" => Ok(Self::Cranelift),
194 "gcc" => Ok(Self::Gcc),
195 "llvm" => Ok(Self::Llvm),
196 _ => Err("unknown backend"),
197 }
198 }
199}
200
201impl CodegenBackend {
202 pub fn as_str(self) -> &'static str {
203 match self {
204 Self::Cranelift => "cranelift",
205 Self::Gcc => "gcc",
206 Self::Llvm => "llvm",
207 }
208 }
209
210 pub fn is_llvm(self) -> bool {
211 matches!(self, Self::Llvm)
212 }
213}
214
215/// Configuration for `compiletest` *per invocation*.
216///
217/// In terms of `bootstrap`, this means that `./x test tests/ui tests/run-make` actually correspond
218/// to *two* separate invocations of `compiletest`.
219///
220/// FIXME: this `Config` struct should be broken up into smaller logically contained sub-config
221/// structs, it's too much of a "soup" of everything at the moment.
222///
223/// # Configuration sources
224///
225/// Configuration values for `compiletest` comes from several sources:
226///
227/// - CLI args passed from `bootstrap` while running the `compiletest` binary.
228/// - Env vars.
229/// - Discovery (e.g. trying to identify a suitable debugger based on filesystem discovery).
230/// - Cached output of running the `rustc` under test (e.g. output of `rustc` print requests).
231///
232/// FIXME: make sure we *clearly* account for sources of *all* config options.
233///
234/// FIXME: audit these options to make sure we are not hashing less than necessary for build stamp
235/// (for changed test detection).
236#[derive(Debug, Clone)]
237pub struct Config {
238 /// Some [`TestMode`]s support [snapshot testing], where a *reference snapshot* of outputs (of
239 /// `stdout`, `stderr`, or other form of artifacts) can be compared to the *actual output*.
240 ///
241 /// This option can be set to `true` to update the *reference snapshots* in-place, otherwise
242 /// `compiletest` will only try to compare.
243 ///
244 /// [snapshot testing]: https://jestjs.io/docs/snapshot-testing
245 pub bless: bool,
246
247 /// Attempt to stop as soon as possible after any test fails. We may still run a few more tests
248 /// before stopping when multiple test threads are used.
249 pub fail_fast: bool,
250
251 /// Path to libraries needed to run the *staged* `rustc`-under-test on the **host** platform.
252 ///
253 /// For example:
254 /// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage1/bin/lib`
255 pub host_compile_lib_path: Utf8PathBuf,
256
257 /// Path to libraries needed to run the compiled executable for the **target** platform. This
258 /// corresponds to the **target** sysroot libraries, including the **target** standard library.
259 ///
260 /// For example:
261 /// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/i686-unknown-linux-gnu/lib`
262 ///
263 /// FIXME: this is very under-documented in conjunction with the `remote-test-client` scheme and
264 /// `RUNNER` scheme to actually run the target executable under the target platform environment,
265 /// cf. [`Self::remote_test_client`] and [`Self::runner`].
266 pub target_run_lib_path: Utf8PathBuf,
267
268 /// Path to the `rustc`-under-test.
269 ///
270 /// For `ui-fulldeps` test suite specifically:
271 ///
272 /// - This is the **stage 0** compiler when testing `ui-fulldeps` under `--stage=1`.
273 /// - This is the **stage 2** compiler when testing `ui-fulldeps` under `--stage=2`.
274 ///
275 /// See [`Self::query_rustc_path`] for the `--stage=1` `ui-fulldeps` scenario where a separate
276 /// in-tree `rustc` is used for querying target information.
277 ///
278 /// For example:
279 /// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage1/bin/rustc`
280 ///
281 /// # Note on forced stage0
282 ///
283 /// It is possible for this `rustc` to be a stage 0 `rustc` if explicitly configured with the
284 /// bootstrap option `build.compiletest-allow-stage0=true` and specifying `--stage=0`.
285 pub rustc_path: Utf8PathBuf,
286
287 /// Path to a *staged* **host** platform cargo executable (unless stage 0 is forced). This
288 /// staged `cargo` is only used within `run-make` test recipes during recipe run time (and is
289 /// *not* used to compile the test recipes), and so must be staged as there may be differences
290 /// between e.g. beta `cargo` vs in-tree `cargo`.
291 ///
292 /// For example:
293 /// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage1-tools-bin/cargo`
294 ///
295 /// FIXME: maybe rename this to reflect that this is a *staged* host cargo.
296 pub cargo_path: Option<Utf8PathBuf>,
297
298 /// Path to the stage 0 `rustc` used to build `run-make` recipes. This must not be confused with
299 /// [`Self::rustc_path`].
300 ///
301 /// For example:
302 /// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage0/bin/rustc`
303 pub stage0_rustc_path: Option<Utf8PathBuf>,
304
305 /// Path to the stage 1 or higher `rustc` used to obtain target information via
306 /// `--print=all-target-specs-json` and similar queries.
307 ///
308 /// Normally this is unset, because [`Self::rustc_path`] can be used instead.
309 /// But when running "stage 1" ui-fulldeps tests, `rustc_path` is a stage 0
310 /// compiler, whereas target specs must be obtained from a stage 1+ compiler
311 /// (in case the JSON format has changed since the last bootstrap bump).
312 pub query_rustc_path: Option<Utf8PathBuf>,
313
314 /// Path to the `rustdoc`-under-test. Like [`Self::rustc_path`], this `rustdoc` is *staged*.
315 pub rustdoc_path: Option<Utf8PathBuf>,
316
317 /// Path to the `src/tools/coverage-dump/` bootstrap tool executable.
318 pub coverage_dump_path: Option<Utf8PathBuf>,
319
320 /// Path to the Python 3 executable to use for htmldocck and some run-make tests.
321 pub python: String,
322
323 /// Path to the `src/tools/jsondocck/` bootstrap tool executable.
324 pub jsondocck_path: Option<Utf8PathBuf>,
325
326 /// Path to the `src/tools/jsondoclint/` bootstrap tool executable.
327 pub jsondoclint_path: Option<Utf8PathBuf>,
328
329 /// Path to a host LLVM `FileCheck` executable.
330 pub llvm_filecheck: Option<Utf8PathBuf>,
331
332 /// Path to a host LLVM bintools directory.
333 ///
334 /// For example:
335 /// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/llvm/bin`
336 pub llvm_bin_dir: Option<Utf8PathBuf>,
337
338 /// The path to the **target** `clang` executable to run `clang`-based tests with. If `None`,
339 /// then these tests will be ignored.
340 pub run_clang_based_tests_with: Option<Utf8PathBuf>,
341
342 /// Path to the directory containing the sources. This corresponds to the root folder of a
343 /// `rust-lang/rust` checkout.
344 ///
345 /// For example:
346 /// - `/home/ferris/rust`
347 ///
348 /// FIXME: this name is confusing, because this is actually `$checkout_root`, **not** the
349 /// `$checkout_root/src/` folder.
350 pub src_root: Utf8PathBuf,
351
352 /// Absolute path to the test suite directory.
353 ///
354 /// For example:
355 /// - `/home/ferris/rust/tests/ui`
356 /// - `/home/ferris/rust/tests/coverage`
357 pub src_test_suite_root: Utf8PathBuf,
358
359 /// Path to the top-level build directory used by bootstrap.
360 ///
361 /// For example:
362 /// - `/home/ferris/rust/build`
363 pub build_root: Utf8PathBuf,
364
365 /// Path to the build directory used by the current test suite.
366 ///
367 /// For example:
368 /// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/test/ui`
369 /// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/test/coverage`
370 pub build_test_suite_root: Utf8PathBuf,
371
372 /// Path to the directory containing the sysroot of the `rustc`-under-test.
373 ///
374 /// For example:
375 /// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage1`
376 /// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage2`
377 ///
378 /// When stage 0 is forced, this will correspond to the sysroot *of* that specified stage 0
379 /// `rustc`.
380 ///
381 /// FIXME: this name is confusing, because it doesn't specify *which* compiler this sysroot
382 /// corresponds to. It's actually the `rustc`-under-test, and not the bootstrap `rustc`, unless
383 /// stage 0 is forced and no custom stage 0 `rustc` was otherwise specified (so that it
384 /// *happens* to run against the bootstrap `rustc`, but this non-custom bootstrap `rustc` case
385 /// is not really supported).
386 pub sysroot_base: Utf8PathBuf,
387
388 /// The number of the stage under test.
389 pub stage: u32,
390
391 /// The id of the stage under test (stage1-xxx, etc).
392 ///
393 /// FIXME: reconsider this string; this is hashed for test build stamp.
394 pub stage_id: String,
395
396 /// The [`TestMode`]. E.g. [`TestMode::Ui`]. Each test mode can correspond to one or more test
397 /// suites.
398 ///
399 /// FIXME: stop using stringly-typed test suites!
400 pub mode: TestMode,
401
402 /// The test suite.
403 ///
404 /// Example: `tests/ui/` is [`TestSuite::Ui`] test *suite*, which happens to also be of the
405 /// [`TestMode::Ui`] test *mode*.
406 ///
407 /// Note that the same test suite (e.g. `tests/coverage/`) may correspond to multiple test
408 /// modes, e.g. `tests/coverage/` can be run under both [`TestMode::CoverageRun`] and
409 /// [`TestMode::CoverageMap`].
410 pub suite: TestSuite,
411
412 /// When specified, **only** the specified [`Debugger`] will be used to run against the
413 /// `tests/debuginfo` test suite. When unspecified, `compiletest` will attempt to find all three
414 /// of {`lldb`, `cdb`, `gdb`} implicitly, and then try to run the `debuginfo` test suite against
415 /// all three debuggers.
416 ///
417 /// FIXME: this implicit behavior is really nasty, in that it makes it hard for the user to
418 /// control *which* debugger(s) are available and used to run the debuginfo test suite. We
419 /// should have `bootstrap` allow the user to *explicitly* configure the debuggers, and *not*
420 /// try to implicitly discover some random debugger from the user environment. This makes the
421 /// debuginfo test suite particularly hard to work with.
422 pub debugger: Option<Debugger>,
423
424 /// Run ignored tests *unconditionally*, overriding their ignore reason.
425 ///
426 /// FIXME: this is wired up through the test execution logic, but **not** accessible from
427 /// `bootstrap` directly; `compiletest` exposes this as `--ignored`. I.e. you'd have to use `./x
428 /// test $test_suite -- --ignored=true`.
429 pub run_ignored: bool,
430
431 /// Whether *staged* `rustc`-under-test was built with debug assertions.
432 ///
433 /// FIXME: make it clearer that this refers to the staged `rustc`-under-test, not stage 0
434 /// `rustc`.
435 pub with_rustc_debug_assertions: bool,
436
437 /// Whether *staged* `std` was built with debug assertions.
438 ///
439 /// FIXME: make it clearer that this refers to the staged `std`, not stage 0 `std`.
440 pub with_std_debug_assertions: bool,
441
442 /// Only run tests that match these filters (using `libtest` "test name contains" filter logic).
443 ///
444 /// FIXME(#139660): the current hand-rolled test executor intentionally mimics the `libtest`
445 /// "test name contains" filter matching logic to preserve previous `libtest` executor behavior,
446 /// but this is often not intuitive. We should consider changing that behavior with an MCP to do
447 /// test path *prefix* matching which better corresponds to how `compiletest` `tests/` are
448 /// organized, and how users would intuitively expect the filtering logic to work like.
449 pub filters: Vec<String>,
450
451 /// Skip tests matching these substrings. The matching logic exactly corresponds to
452 /// [`Self::filters`] but inverted.
453 ///
454 /// FIXME(#139660): ditto on test matching behavior.
455 pub skip: Vec<String>,
456
457 /// Exactly match the filter, rather than a substring.
458 ///
459 /// FIXME(#139660): ditto on test matching behavior.
460 pub filter_exact: bool,
461
462 /// Force the pass mode of a check/build/run test to instead use this mode instead.
463 ///
464 /// FIXME: make it even more obvious (especially in PR CI where `--pass=check` is used) when a
465 /// pass mode is forced when the test fails, because it can be very non-obvious when e.g. an
466 /// error is emitted only when `//@ build-pass` but not `//@ check-pass`.
467 pub force_pass_mode: Option<PassMode>,
468
469 /// Explicitly enable or disable running of the target test binary.
470 ///
471 /// FIXME: this scheme is a bit confusing, and at times questionable. Re-evaluate this run
472 /// scheme.
473 ///
474 /// FIXME: Currently `--run` is a tri-state, it can be `--run={auto,always,never}`, and when
475 /// `--run=auto` is specified, it's run if the platform doesn't end with `-fuchsia`. See
476 /// [`Config::run_enabled`].
477 pub run: Option<bool>,
478
479 /// A command line to prefix target program execution with, for running under valgrind for
480 /// example, i.e. `$runner target.exe [args..]`. Similar to `CARGO_*_RUNNER` configuration.
481 ///
482 /// Note: this is not to be confused with [`Self::remote_test_client`], which is a different
483 /// scheme.
484 ///
485 /// FIXME: the runner scheme is very under-documented.
486 pub runner: Option<String>,
487
488 /// Compiler flags to pass to the *staged* `rustc`-under-test when building for the **host**
489 /// platform.
490 pub host_rustcflags: Vec<String>,
491
492 /// Compiler flags to pass to the *staged* `rustc`-under-test when building for the **target**
493 /// platform.
494 pub target_rustcflags: Vec<String>,
495
496 /// Whether the *staged* `rustc`-under-test and the associated *staged* `std` has been built
497 /// with randomized struct layouts.
498 pub rust_randomized_layout: bool,
499
500 /// Whether tests should be optimized by default (`-O`). Individual test suites and test files
501 /// may override this setting.
502 ///
503 /// FIXME: this flag / config option is somewhat misleading. For instance, in ui tests, it's
504 /// *only* applied to the [`PassMode::Run`] test crate and not its auxiliaries.
505 pub optimize_tests: bool,
506
507 /// Target platform tuple.
508 pub target: String,
509
510 /// Host platform tuple.
511 pub host: String,
512
513 /// Path to / name of the Microsoft Console Debugger (CDB) executable.
514 ///
515 /// FIXME: this is an *opt-in* "override" option. When this isn't provided, we try to conjure a
516 /// cdb by looking at the user's program files on Windows... See `debuggers::find_cdb`.
517 pub cdb: Option<Utf8PathBuf>,
518
519 /// Version of CDB.
520 ///
521 /// FIXME: `cdb_version` is *derived* from cdb, but it's *not* technically a config!
522 ///
523 /// FIXME: audit cdb version gating.
524 pub cdb_version: Option<[u16; 4]>,
525
526 /// Path to / name of the GDB executable.
527 ///
528 /// FIXME: the fallback path when `gdb` isn't provided tries to find *a* `gdb` or `gdb.exe` from
529 /// `PATH`, which is... arguably questionable.
530 ///
531 /// FIXME: we are propagating a python from `PYTHONPATH`, not from an explicit config for gdb
532 /// debugger script.
533 pub gdb: Option<Utf8PathBuf>,
534
535 /// Version of GDB, encoded as ((major * 1000) + minor) * 1000 + patch
536 ///
537 /// FIXME: this gdb version gating scheme is possibly questionable -- gdb does not use semver,
538 /// only its major version is likely materially meaningful, cf.
539 /// <https://sourceware.org/gdb/wiki/Internals%20Versions>. Even the major version I'm not sure
540 /// is super meaningful. Maybe min gdb `major.minor` version gating is sufficient for the
541 /// purposes of debuginfo tests?
542 ///
543 /// FIXME: `gdb_version` is *derived* from gdb, but it's *not* technically a config!
544 pub gdb_version: Option<u32>,
545
546 /// Path to or name of the LLDB executable to use for debuginfo tests.
547 pub lldb: Option<Utf8PathBuf>,
548
549 /// Version of LLDB.
550 ///
551 /// FIXME: `lldb_version` is *derived* from lldb, but it's *not* technically a config!
552 pub lldb_version: Option<u32>,
553
554 /// Version of LLVM.
555 ///
556 /// FIXME: Audit the fallback derivation of
557 /// [`crate::directives::extract_llvm_version_from_binary`], that seems very questionable?
558 pub llvm_version: Option<Version>,
559
560 /// Is LLVM a system LLVM.
561 pub system_llvm: bool,
562
563 /// Path to the android tools.
564 ///
565 /// Note: this is only used for android gdb debugger script in the debuginfo test suite.
566 ///
567 /// FIXME: take a look at this; this is piggy-backing off of gdb code paths but only for
568 /// `arm-linux-androideabi` target.
569 pub android_cross_path: Utf8PathBuf,
570
571 /// Extra parameter to run adb on `arm-linux-androideabi`.
572 ///
573 /// FIXME: is this *only* `arm-linux-androideabi`, or is it also for other Tier 2/3 android
574 /// targets?
575 ///
576 /// FIXME: take a look at this; this is piggy-backing off of gdb code paths but only for
577 /// `arm-linux-androideabi` target.
578 pub adb_path: Utf8PathBuf,
579
580 /// Extra parameter to run test suite on `arm-linux-androideabi`.
581 ///
582 /// FIXME: is this *only* `arm-linux-androideabi`, or is it also for other Tier 2/3 android
583 /// targets?
584 ///
585 /// FIXME: take a look at this; this is piggy-backing off of gdb code paths but only for
586 /// `arm-linux-androideabi` target.
587 pub adb_test_dir: Utf8PathBuf,
588
589 /// Status whether android device available or not. When unavailable, this will cause tests to
590 /// panic when the test binary is attempted to be run.
591 ///
592 /// FIXME: take a look at this; this also influences adb in gdb code paths in a strange way.
593 pub adb_device_status: bool,
594
595 /// Verbose dump a lot of info.
596 ///
597 /// FIXME: this is *way* too coarse; the user can't select *which* info to verbosely dump.
598 pub verbose: bool,
599
600 /// Whether to use colors in test output.
601 ///
602 /// Note: the exact control mechanism is delegated to [`colored`].
603 pub color: ColorConfig,
604
605 /// Where to find the remote test client process, if we're using it.
606 ///
607 /// Note: this is *only* used for target platform executables created by `run-make` test
608 /// recipes.
609 ///
610 /// Note: this is not to be confused with [`Self::runner`], which is a different scheme.
611 ///
612 /// FIXME: the `remote_test_client` scheme is very under-documented.
613 pub remote_test_client: Option<Utf8PathBuf>,
614
615 /// [`CompareMode`] describing what file the actual ui output will be compared to.
616 ///
617 /// FIXME: currently, [`CompareMode`] is a mishmash of lot of things (different borrow-checker
618 /// model, different trait solver, different debugger, etc.).
619 pub compare_mode: Option<CompareMode>,
620
621 /// If true, this will generate a coverage file with UI test files that run `MachineApplicable`
622 /// diagnostics but are missing `run-rustfix` annotations. The generated coverage file is
623 /// created in `$test_suite_build_root/rustfix_missing_coverage.txt`
624 pub rustfix_coverage: bool,
625
626 /// Whether to run `tidy` (html-tidy) when a rustdoc test fails.
627 pub has_html_tidy: bool,
628
629 /// Whether to run `enzyme` autodiff tests.
630 pub has_enzyme: bool,
631
632 /// The current Rust channel info.
633 ///
634 /// FIXME: treat this more carefully; "stable", "beta" and "nightly" are definitely valid, but
635 /// channel might also be "dev" or such, which should be treated as "nightly".
636 pub channel: String,
637
638 /// Whether adding git commit information such as the commit hash has been enabled for building.
639 ///
640 /// FIXME: `compiletest` cannot trust `bootstrap` for this information, because `bootstrap` can
641 /// have bugs and had bugs on that logic. We need to figure out how to obtain this e.g. directly
642 /// from CI or via git locally.
643 pub git_hash: bool,
644
645 /// The default Rust edition.
646 pub edition: Option<Edition>,
647
648 // Configuration for various run-make tests frobbing things like C compilers or querying about
649 // various LLVM component information.
650 //
651 // FIXME: this really should be better packaged together.
652 // FIXME: these need better docs, e.g. for *host*, or for *target*?
653 pub cc: String,
654 pub cxx: String,
655 pub cflags: String,
656 pub cxxflags: String,
657 pub ar: String,
658 pub target_linker: Option<String>,
659 pub host_linker: Option<String>,
660 pub llvm_components: String,
661
662 /// Path to a NodeJS executable. Used for JS doctests, emscripten and WASM tests.
663 pub nodejs: Option<Utf8PathBuf>,
664
665 /// Whether to rerun tests even if the inputs are unchanged.
666 pub force_rerun: bool,
667
668 /// Only rerun the tests that result has been modified according to `git status`.
669 ///
670 /// FIXME: this is undocumented.
671 ///
672 /// FIXME: how does this interact with [`Self::force_rerun`]?
673 pub only_modified: bool,
674
675 // FIXME: these are really not "config"s, but rather are information derived from
676 // `rustc`-under-test. This poses an interesting conundrum: if we're testing the
677 // `rustc`-under-test, can we trust its print request outputs and target cfgs? In theory, this
678 // itself can break or be unreliable -- ideally, we'd be sharing these kind of information not
679 // through `rustc`-under-test's execution output. In practice, however, print requests are very
680 // unlikely to completely break (we also have snapshot ui tests for them). Furthermore, even if
681 // we share them via some kind of static config, that static config can still be wrong! Who
682 // tests the tester? Therefore, we make a pragmatic compromise here, and use information derived
683 // from print requests produced by the `rustc`-under-test.
684 //
685 // FIXME: move them out from `Config`, because they are *not* configs.
686 pub target_cfgs: OnceLock<TargetCfgs>,
687 pub builtin_cfg_names: OnceLock<HashSet<String>>,
688 pub supported_crate_types: OnceLock<HashSet<String>>,
689
690 /// Should we capture console output that would be printed by test runners via their `stdout`
691 /// and `stderr` trait objects, or via the custom panic hook.
692 ///
693 /// The default is `true`. This can be disabled via the compiletest cli flag `--no-capture`
694 /// (which mirrors the libtest `--no-capture` flag).
695 pub capture: bool,
696
697 /// Needed both to construct [`build_helper::git::GitConfig`].
698 pub nightly_branch: String,
699 pub git_merge_commit_email: String,
700
701 /// True if the profiler runtime is enabled for this target. Used by the
702 /// `needs-profiler-runtime` directive in test files.
703 pub profiler_runtime: bool,
704
705 /// Command for visual diff display, e.g. `diff-tool --color=always`.
706 pub diff_command: Option<String>,
707
708 /// Path to minicore aux library (`tests/auxiliary/minicore.rs`), used for `no_core` tests that
709 /// need `core` stubs in cross-compilation scenarios that do not otherwise want/need to
710 /// `-Zbuild-std`. Used in e.g. ABI tests.
711 pub minicore_path: Utf8PathBuf,
712
713 /// Current codegen backend used.
714 pub default_codegen_backend: CodegenBackend,
715 /// Name/path of the backend to use instead of `default_codegen_backend`.
716 pub override_codegen_backend: Option<String>,
717 /// Whether to ignore `//@ ignore-backends`.
718 pub bypass_ignore_backends: bool,
719}
720
721impl Config {
722 /// FIXME: this run scheme is... confusing.
723 pub fn run_enabled(&self) -> bool {
724 self.run.unwrap_or_else(|| {
725 // Auto-detect whether to run based on the platform.
726 !self.target.ends_with("-fuchsia")
727 })
728 }
729
730 pub fn target_cfgs(&self) -> &TargetCfgs {
731 self.target_cfgs.get_or_init(|| TargetCfgs::new(self))
732 }
733
734 pub fn target_cfg(&self) -> &TargetCfg {
735 &self.target_cfgs().current
736 }
737
738 pub fn matches_arch(&self, arch: &str) -> bool {
739 self.target_cfg().arch == arch
740 || {
741 // Matching all the thumb variants as one can be convenient.
742 // (thumbv6m, thumbv7em, thumbv7m, etc.)
743 arch == "thumb" && self.target.starts_with("thumb")
744 }
745 || (arch == "i586" && self.target.starts_with("i586-"))
746 }
747
748 pub fn matches_os(&self, os: &str) -> bool {
749 self.target_cfg().os == os
750 }
751
752 pub fn matches_env(&self, env: &str) -> bool {
753 self.target_cfg().env == env
754 }
755
756 pub fn matches_abi(&self, abi: &str) -> bool {
757 self.target_cfg().abi == abi
758 }
759
760 #[cfg_attr(not(test), expect(dead_code, reason = "only used by tests for `ignore-{family}`"))]
761 pub(crate) fn matches_family(&self, family: &str) -> bool {
762 self.target_cfg().families.iter().any(|f| f == family)
763 }
764
765 pub fn is_big_endian(&self) -> bool {
766 self.target_cfg().endian == Endian::Big
767 }
768
769 pub fn get_pointer_width(&self) -> u32 {
770 *&self.target_cfg().pointer_width
771 }
772
773 pub fn can_unwind(&self) -> bool {
774 self.target_cfg().panic == PanicStrategy::Unwind
775 }
776
777 /// Get the list of builtin, 'well known' cfg names
778 pub fn builtin_cfg_names(&self) -> &HashSet<String> {
779 self.builtin_cfg_names.get_or_init(|| builtin_cfg_names(self))
780 }
781
782 /// Get the list of crate types that the target platform supports.
783 pub fn supported_crate_types(&self) -> &HashSet<String> {
784 self.supported_crate_types.get_or_init(|| supported_crate_types(self))
785 }
786
787 pub fn has_threads(&self) -> bool {
788 // Wasm targets don't have threads unless `-threads` is in the target
789 // name, such as `wasm32-wasip1-threads`.
790 if self.target.starts_with("wasm") {
791 return self.target.contains("threads");
792 }
793 true
794 }
795
796 pub fn has_asm_support(&self) -> bool {
797 // This should match the stable list in `LoweringContext::lower_inline_asm`.
798 static ASM_SUPPORTED_ARCHS: &[&str] = &[
799 "x86",
800 "x86_64",
801 "arm",
802 "aarch64",
803 "arm64ec",
804 "riscv32",
805 "riscv64",
806 "loongarch32",
807 "loongarch64",
808 "s390x",
809 // These targets require an additional asm_experimental_arch feature.
810 // "nvptx64", "hexagon", "mips", "mips64", "spirv", "wasm32",
811 ];
812 ASM_SUPPORTED_ARCHS.contains(&self.target_cfg().arch.as_str())
813 }
814
815 pub fn git_config(&self) -> GitConfig<'_> {
816 GitConfig {
817 nightly_branch: &self.nightly_branch,
818 git_merge_commit_email: &self.git_merge_commit_email,
819 }
820 }
821
822 pub fn has_subprocess_support(&self) -> bool {
823 // FIXME(#135928): compiletest is always a **host** tool. Building and running an
824 // capability detection executable against the **target** is not trivial. The short term
825 // solution here is to hard-code some targets to allow/deny, unfortunately.
826
827 let unsupported_target = self.target_cfg().env == "sgx"
828 || matches!(self.target_cfg().arch.as_str(), "wasm32" | "wasm64")
829 || self.target_cfg().os == "emscripten";
830 !unsupported_target
831 }
832}
833
834/// Known widths of `target_has_atomic`.
835pub const KNOWN_TARGET_HAS_ATOMIC_WIDTHS: &[&str] = &["8", "16", "32", "64", "128", "ptr"];
836
837#[derive(Debug, Clone)]
838pub struct TargetCfgs {
839 pub current: TargetCfg,
840 pub all_targets: HashSet<String>,
841 pub all_archs: HashSet<String>,
842 pub all_oses: HashSet<String>,
843 pub all_oses_and_envs: HashSet<String>,
844 pub all_envs: HashSet<String>,
845 pub all_abis: HashSet<String>,
846 pub all_families: HashSet<String>,
847 pub all_pointer_widths: HashSet<String>,
848 pub all_rustc_abis: HashSet<String>,
849}
850
851impl TargetCfgs {
852 fn new(config: &Config) -> TargetCfgs {
853 let mut targets: HashMap<String, TargetCfg> = serde_json::from_str(&query_rustc_output(
854 config,
855 &["--print=all-target-specs-json", "-Zunstable-options"],
856 Default::default(),
857 ))
858 .unwrap();
859
860 let mut all_targets = HashSet::new();
861 let mut all_archs = HashSet::new();
862 let mut all_oses = HashSet::new();
863 let mut all_oses_and_envs = HashSet::new();
864 let mut all_envs = HashSet::new();
865 let mut all_abis = HashSet::new();
866 let mut all_families = HashSet::new();
867 let mut all_pointer_widths = HashSet::new();
868 // NOTE: for distinction between `abi` and `rustc_abi`, see comment on
869 // `TargetCfg::rustc_abi`.
870 let mut all_rustc_abis = HashSet::new();
871
872 // If current target is not included in the `--print=all-target-specs-json` output,
873 // we check whether it is a custom target from the user or a synthetic target from bootstrap.
874 if !targets.contains_key(&config.target) {
875 let mut envs: HashMap<String, String> = HashMap::new();
876
877 if let Ok(t) = std::env::var("RUST_TARGET_PATH") {
878 envs.insert("RUST_TARGET_PATH".into(), t);
879 }
880
881 // This returns false only when the target is neither a synthetic target
882 // nor a custom target from the user, indicating it is most likely invalid.
883 if config.target.ends_with(".json") || !envs.is_empty() {
884 targets.insert(
885 config.target.clone(),
886 serde_json::from_str(&query_rustc_output(
887 config,
888 &[
889 "--print=target-spec-json",
890 "-Zunstable-options",
891 "--target",
892 &config.target,
893 ],
894 envs,
895 ))
896 .unwrap(),
897 );
898 }
899 }
900
901 for (target, cfg) in targets.iter() {
902 all_archs.insert(cfg.arch.clone());
903 all_oses.insert(cfg.os.clone());
904 all_oses_and_envs.insert(cfg.os_and_env());
905 all_envs.insert(cfg.env.clone());
906 all_abis.insert(cfg.abi.clone());
907 for family in &cfg.families {
908 all_families.insert(family.clone());
909 }
910 all_pointer_widths.insert(format!("{}bit", cfg.pointer_width));
911 if let Some(rustc_abi) = &cfg.rustc_abi {
912 all_rustc_abis.insert(rustc_abi.clone());
913 }
914 all_targets.insert(target.clone());
915 }
916
917 Self {
918 current: Self::get_current_target_config(config, &targets),
919 all_targets,
920 all_archs,
921 all_oses,
922 all_oses_and_envs,
923 all_envs,
924 all_abis,
925 all_families,
926 all_pointer_widths,
927 all_rustc_abis,
928 }
929 }
930
931 fn get_current_target_config(
932 config: &Config,
933 targets: &HashMap<String, TargetCfg>,
934 ) -> TargetCfg {
935 let mut cfg = targets[&config.target].clone();
936
937 // To get the target information for the current target, we take the target spec obtained
938 // from `--print=all-target-specs-json`, and then we enrich it with the information
939 // gathered from `--print=cfg --target=$target`.
940 //
941 // This is done because some parts of the target spec can be overridden with `-C` flags,
942 // which are respected for `--print=cfg` but not for `--print=all-target-specs-json`. The
943 // code below extracts them from `--print=cfg`: make sure to only override fields that can
944 // actually be changed with `-C` flags.
945 for config in query_rustc_output(
946 config,
947 &["--print=cfg", "--target", &config.target],
948 Default::default(),
949 )
950 .trim()
951 .lines()
952 {
953 let (name, value) = config
954 .split_once("=\"")
955 .map(|(name, value)| {
956 (
957 name,
958 Some(
959 value
960 .strip_suffix('\"')
961 .expect("key-value pair should be properly quoted"),
962 ),
963 )
964 })
965 .unwrap_or_else(|| (config, None));
966
967 match (name, value) {
968 // Can be overridden with `-C panic=$strategy`.
969 ("panic", Some("abort")) => cfg.panic = PanicStrategy::Abort,
970 ("panic", Some("unwind")) => cfg.panic = PanicStrategy::Unwind,
971 ("panic", other) => panic!("unexpected value for panic cfg: {other:?}"),
972
973 ("target_has_atomic", Some(width))
974 if KNOWN_TARGET_HAS_ATOMIC_WIDTHS.contains(&width) =>
975 {
976 cfg.target_has_atomic.insert(width.to_string());
977 }
978 ("target_has_atomic", Some(other)) => {
979 panic!("unexpected value for `target_has_atomic` cfg: {other:?}")
980 }
981 // Nightly-only std-internal impl detail.
982 ("target_has_atomic", None) => {}
983 _ => {}
984 }
985 }
986
987 cfg
988 }
989}
990
991#[derive(Clone, Debug, serde::Deserialize)]
992#[serde(rename_all = "kebab-case")]
993pub struct TargetCfg {
994 pub(crate) arch: String,
995 #[serde(default = "default_os")]
996 pub(crate) os: String,
997 #[serde(default)]
998 pub(crate) env: String,
999 #[serde(default)]
1000 pub(crate) abi: String,
1001 #[serde(rename = "target-family", default)]
1002 pub(crate) families: Vec<String>,
1003 #[serde(rename = "target-pointer-width")]
1004 pub(crate) pointer_width: u32,
1005 #[serde(rename = "target-endian", default)]
1006 endian: Endian,
1007 #[serde(rename = "panic-strategy", default)]
1008 pub(crate) panic: PanicStrategy,
1009 #[serde(default)]
1010 pub(crate) dynamic_linking: bool,
1011 #[serde(rename = "supported-sanitizers", default)]
1012 pub(crate) sanitizers: Vec<Sanitizer>,
1013 #[serde(rename = "supports-xray", default)]
1014 pub(crate) xray: bool,
1015 #[serde(default = "default_reloc_model")]
1016 pub(crate) relocation_model: String,
1017 // NOTE: `rustc_abi` should not be confused with `abi`. `rustc_abi` was introduced in #137037 to
1018 // make SSE2 *required* by the ABI (kind of a hack to make a target feature *required* via the
1019 // target spec).
1020 pub(crate) rustc_abi: Option<String>,
1021
1022 /// ELF is the "default" binary format, so the compiler typically doesn't
1023 /// emit a `"binary-format"` field for ELF targets.
1024 ///
1025 /// See `impl ToJson for Target` in `compiler/rustc_target/src/spec/json.rs`.
1026 #[serde(default = "default_binary_format_elf")]
1027 pub(crate) binary_format: Cow<'static, str>,
1028
1029 // Not present in target cfg json output, additional derived information.
1030 #[serde(skip)]
1031 /// Supported target atomic widths: e.g. `8` to `128` or `ptr`. This is derived from the builtin
1032 /// `target_has_atomic` `cfg`s e.g. `target_has_atomic="8"`.
1033 pub(crate) target_has_atomic: BTreeSet<String>,
1034}
1035
1036impl TargetCfg {
1037 pub(crate) fn os_and_env(&self) -> String {
1038 format!("{}-{}", self.os, self.env)
1039 }
1040}
1041
1042fn default_os() -> String {
1043 "none".into()
1044}
1045
1046fn default_reloc_model() -> String {
1047 "pic".into()
1048}
1049
1050fn default_binary_format_elf() -> Cow<'static, str> {
1051 Cow::Borrowed("elf")
1052}
1053
1054#[derive(Eq, PartialEq, Clone, Debug, Default, serde::Deserialize)]
1055#[serde(rename_all = "kebab-case")]
1056pub enum Endian {
1057 #[default]
1058 Little,
1059 Big,
1060}
1061
1062fn builtin_cfg_names(config: &Config) -> HashSet<String> {
1063 query_rustc_output(
1064 config,
1065 &["--print=check-cfg", "-Zunstable-options", "--check-cfg=cfg()"],
1066 Default::default(),
1067 )
1068 .lines()
1069 .map(|l| if let Some((name, _)) = l.split_once('=') { name.to_string() } else { l.to_string() })
1070 .chain(std::iter::once(String::from("test")))
1071 .collect()
1072}
1073
1074pub const KNOWN_CRATE_TYPES: &[&str] =
1075 &["bin", "cdylib", "dylib", "lib", "proc-macro", "rlib", "staticlib"];
1076
1077fn supported_crate_types(config: &Config) -> HashSet<String> {
1078 let crate_types: HashSet<_> = query_rustc_output(
1079 config,
1080 &["--target", &config.target, "--print=supported-crate-types", "-Zunstable-options"],
1081 Default::default(),
1082 )
1083 .lines()
1084 .map(|l| l.to_string())
1085 .collect();
1086
1087 for crate_type in crate_types.iter() {
1088 assert!(
1089 KNOWN_CRATE_TYPES.contains(&crate_type.as_str()),
1090 "unexpected crate type `{}`: known crate types are {:?}",
1091 crate_type,
1092 KNOWN_CRATE_TYPES
1093 );
1094 }
1095
1096 crate_types
1097}
1098
1099pub(crate) fn query_rustc_output(
1100 config: &Config,
1101 args: &[&str],
1102 envs: HashMap<String, String>,
1103) -> String {
1104 let query_rustc_path = config.query_rustc_path.as_deref().unwrap_or(&config.rustc_path);
1105
1106 let mut command = Command::new(query_rustc_path);
1107 add_dylib_path(&mut command, iter::once(&config.host_compile_lib_path));
1108 command.args(&config.target_rustcflags).args(args);
1109 command.env("RUSTC_BOOTSTRAP", "1");
1110 command.envs(envs);
1111
1112 let output = match command.output() {
1113 Ok(output) => output,
1114 Err(e) => {
1115 fatal!("failed to run {command:?}: {e}");
1116 }
1117 };
1118 if !output.status.success() {
1119 fatal!(
1120 "failed to run {command:?}\n--- stdout\n{}\n--- stderr\n{}",
1121 String::from_utf8(output.stdout).unwrap(),
1122 String::from_utf8(output.stderr).unwrap(),
1123 );
1124 }
1125 String::from_utf8(output.stdout).unwrap()
1126}
1127
1128/// Path information for a single test file.
1129#[derive(Debug, Clone)]
1130pub(crate) struct TestPaths {
1131 /// Full path to the test file.
1132 ///
1133 /// For example:
1134 /// - `/home/ferris/rust/tests/ui/warnings/hello-world.rs`
1135 ///
1136 /// ---
1137 ///
1138 /// For `run-make` tests, this path is the _directory_ that contains
1139 /// `rmake.rs`.
1140 ///
1141 /// For example:
1142 /// - `/home/ferris/rust/tests/run-make/emit`
1143 pub(crate) file: Utf8PathBuf,
1144
1145 /// Subset of the full path that excludes the suite directory and the
1146 /// test filename. For tests in the root of their test suite directory,
1147 /// this is blank.
1148 ///
1149 /// For example:
1150 /// - `file`: `/home/ferris/rust/tests/ui/warnings/hello-world.rs`
1151 /// - `relative_dir`: `warnings`
1152 pub(crate) relative_dir: Utf8PathBuf,
1153}
1154
1155/// Used by `ui` tests to generate things like `foo.stderr` from `foo.rs`.
1156pub fn expected_output_path(
1157 testpaths: &TestPaths,
1158 revision: Option<&str>,
1159 compare_mode: &Option<CompareMode>,
1160 kind: &str,
1161) -> Utf8PathBuf {
1162 assert!(UI_EXTENSIONS.contains(&kind));
1163 let mut parts = Vec::new();
1164
1165 if let Some(x) = revision {
1166 parts.push(x);
1167 }
1168 if let Some(ref x) = *compare_mode {
1169 parts.push(x.to_str());
1170 }
1171 parts.push(kind);
1172
1173 let extension = parts.join(".");
1174 testpaths.file.with_extension(extension)
1175}
1176
1177pub const UI_EXTENSIONS: &[&str] = &[
1178 UI_STDERR,
1179 UI_SVG,
1180 UI_WINDOWS_SVG,
1181 UI_STDOUT,
1182 UI_FIXED,
1183 UI_RUN_STDERR,
1184 UI_RUN_STDOUT,
1185 UI_STDERR_64,
1186 UI_STDERR_32,
1187 UI_STDERR_16,
1188 UI_COVERAGE,
1189 UI_COVERAGE_MAP,
1190];
1191pub const UI_STDERR: &str = "stderr";
1192pub const UI_SVG: &str = "svg";
1193pub const UI_WINDOWS_SVG: &str = "windows.svg";
1194pub const UI_STDOUT: &str = "stdout";
1195pub const UI_FIXED: &str = "fixed";
1196pub const UI_RUN_STDERR: &str = "run.stderr";
1197pub const UI_RUN_STDOUT: &str = "run.stdout";
1198pub const UI_STDERR_64: &str = "64bit.stderr";
1199pub const UI_STDERR_32: &str = "32bit.stderr";
1200pub const UI_STDERR_16: &str = "16bit.stderr";
1201pub const UI_COVERAGE: &str = "coverage";
1202pub const UI_COVERAGE_MAP: &str = "cov-map";
1203
1204/// Absolute path to the directory where all output for all tests in the given `relative_dir` group
1205/// should reside. Example:
1206///
1207/// ```text
1208/// /path/to/build/host-tuple/test/ui/relative/
1209/// ```
1210///
1211/// This is created early when tests are collected to avoid race conditions.
1212pub fn output_relative_path(config: &Config, relative_dir: &Utf8Path) -> Utf8PathBuf {
1213 config.build_test_suite_root.join(relative_dir)
1214}
1215
1216/// Generates a unique name for the test, such as `testname.revision.mode`.
1217pub fn output_testname_unique(
1218 config: &Config,
1219 testpaths: &TestPaths,
1220 revision: Option<&str>,
1221) -> Utf8PathBuf {
1222 let mode = config.compare_mode.as_ref().map_or("", |m| m.to_str());
1223 let debugger = config.debugger.as_ref().map_or("", |m| m.to_str());
1224 Utf8PathBuf::from(&testpaths.file.file_stem().unwrap())
1225 .with_extra_extension(config.mode.output_dir_disambiguator())
1226 .with_extra_extension(revision.unwrap_or(""))
1227 .with_extra_extension(mode)
1228 .with_extra_extension(debugger)
1229}
1230
1231/// Absolute path to the directory where all output for the given
1232/// test/revision should reside. Example:
1233/// /path/to/build/host-tuple/test/ui/relative/testname.revision.mode/
1234pub fn output_base_dir(
1235 config: &Config,
1236 testpaths: &TestPaths,
1237 revision: Option<&str>,
1238) -> Utf8PathBuf {
1239 output_relative_path(config, &testpaths.relative_dir)
1240 .join(output_testname_unique(config, testpaths, revision))
1241}
1242
1243/// Absolute path to the base filename used as output for the given
1244/// test/revision. Example:
1245/// /path/to/build/host-tuple/test/ui/relative/testname.revision.mode/testname
1246pub fn output_base_name(
1247 config: &Config,
1248 testpaths: &TestPaths,
1249 revision: Option<&str>,
1250) -> Utf8PathBuf {
1251 output_base_dir(config, testpaths, revision).join(testpaths.file.file_stem().unwrap())
1252}
1253
1254/// Absolute path to the directory to use for incremental compilation. Example:
1255/// /path/to/build/host-tuple/test/ui/relative/testname.mode/testname.inc
1256pub fn incremental_dir(
1257 config: &Config,
1258 testpaths: &TestPaths,
1259 revision: Option<&str>,
1260) -> Utf8PathBuf {
1261 output_base_name(config, testpaths, revision).with_extension("inc")
1262}