Skip to content

Commit f36290d

Browse files
authored
Rollup merge of rust-lang#148065 - Zalathar:test-paths, r=jieyouxu
compiletest: Add concrete examples for some config/test path fields Seeing a specific example path can be much more enlightening than trying to figure out what the prose is gesturing towards. Also, in some cases the existing comments were incorrect or misleading, as demonstrated by the example paths. The example paths were determined by dumping them directly out of the config with `dbg!`, and then lightly anonymizing them for example purposes. --- No functional changes. r? jieyouxu
2 parents 27fca17 + 2a84161 commit f36290d

File tree

1 file changed

+61
-11
lines changed

1 file changed

+61
-11
lines changed

src/tools/compiletest/src/common.rs

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,19 @@ pub struct Config {
248248

249249
/// Path to libraries needed to run the *staged* `rustc`-under-test on the **host** platform.
250250
///
251+
/// For example:
252+
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage1/bin/lib`
253+
///
251254
/// FIXME: maybe rename this to reflect (1) which target platform (host, not target), and (2)
252255
/// which `rustc` (the `rustc`-under-test, not the stage 0 `rustc` unless forced).
253256
pub compile_lib_path: Utf8PathBuf,
254257

255258
/// Path to libraries needed to run the compiled executable for the **target** platform. This
256259
/// corresponds to the **target** sysroot libraries, including the **target** standard library.
257260
///
261+
/// For example:
262+
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/i686-unknown-linux-gnu/lib`
263+
///
258264
/// FIXME: maybe rename this to reflect (1) which target platform (target, not host), and (2)
259265
/// what "run libraries" are against.
260266
///
@@ -266,6 +272,9 @@ pub struct Config {
266272
/// Path to the *staged* `rustc`-under-test. Unless forced, this `rustc` is *staged*, and must
267273
/// not be confused with [`Self::stage0_rustc_path`].
268274
///
275+
/// For example:
276+
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage1/bin/rustc`
277+
///
269278
/// FIXME: maybe rename this to reflect that this is the `rustc`-under-test.
270279
pub rustc_path: Utf8PathBuf,
271280

@@ -274,11 +283,17 @@ pub struct Config {
274283
/// *not* used to compile the test recipes), and so must be staged as there may be differences
275284
/// between e.g. beta `cargo` vs in-tree `cargo`.
276285
///
286+
/// For example:
287+
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage1-tools-bin/cargo`
288+
///
277289
/// FIXME: maybe rename this to reflect that this is a *staged* host cargo.
278290
pub cargo_path: Option<Utf8PathBuf>,
279291

280292
/// Path to the stage 0 `rustc` used to build `run-make` recipes. This must not be confused with
281293
/// [`Self::rustc_path`].
294+
///
295+
/// For example:
296+
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage0/bin/rustc`
282297
pub stage0_rustc_path: Option<Utf8PathBuf>,
283298

284299
/// Path to the stage 1 or higher `rustc` used to obtain target information via
@@ -312,6 +327,9 @@ pub struct Config {
312327
pub llvm_filecheck: Option<Utf8PathBuf>,
313328

314329
/// Path to a host LLVM bintools directory.
330+
///
331+
/// For example:
332+
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/llvm/bin`
315333
pub llvm_bin_dir: Option<Utf8PathBuf>,
316334

317335
/// The path to the **target** `clang` executable to run `clang`-based tests with. If `None`,
@@ -321,28 +339,39 @@ pub struct Config {
321339
/// Path to the directory containing the sources. This corresponds to the root folder of a
322340
/// `rust-lang/rust` checkout.
323341
///
342+
/// For example:
343+
/// - `/home/ferris/rust`
344+
///
324345
/// FIXME: this name is confusing, because this is actually `$checkout_root`, **not** the
325346
/// `$checkout_root/src/` folder.
326347
pub src_root: Utf8PathBuf,
327348

328-
/// Path to the directory containing the test suites sources. This corresponds to the
329-
/// `$src_root/tests/` folder.
330-
///
331-
/// Must be an immediate subdirectory of [`Self::src_root`].
349+
/// Absolute path to the test suite directory.
332350
///
333-
/// FIXME: this name is also confusing, maybe just call it `tests_root`.
351+
/// For example:
352+
/// - `/home/ferris/rust/tests/ui`
353+
/// - `/home/ferris/rust/tests/coverage`
334354
pub src_test_suite_root: Utf8PathBuf,
335355

336-
/// Path to the build directory (e.g. `build/`).
356+
/// Path to the top-level build directory used by bootstrap.
357+
///
358+
/// For example:
359+
/// - `/home/ferris/rust/build`
337360
pub build_root: Utf8PathBuf,
338361

339-
/// Path to the test suite specific build directory (e.g. `build/host/test/ui/`).
362+
/// Path to the build directory used by the current test suite.
340363
///
341-
/// Must be a subdirectory of [`Self::build_root`].
364+
/// For example:
365+
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/test/ui`
366+
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/test/coverage`
342367
pub build_test_suite_root: Utf8PathBuf,
343368

344369
/// Path to the directory containing the sysroot of the `rustc`-under-test.
345370
///
371+
/// For example:
372+
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage1`
373+
/// - `/home/ferris/rust/build/x86_64-unknown-linux-gnu/stage2`
374+
///
346375
/// When stage 0 is forced, this will correspond to the sysroot *of* that specified stage 0
347376
/// `rustc`.
348377
///
@@ -1075,10 +1104,31 @@ fn query_rustc_output(config: &Config, args: &[&str], envs: HashMap<String, Stri
10751104
String::from_utf8(output.stdout).unwrap()
10761105
}
10771106

1107+
/// Path information for a single test file.
10781108
#[derive(Debug, Clone)]
1079-
pub struct TestPaths {
1080-
pub file: Utf8PathBuf, // e.g., compile-test/foo/bar/baz.rs
1081-
pub relative_dir: Utf8PathBuf, // e.g., foo/bar
1109+
pub(crate) struct TestPaths {
1110+
/// Full path to the test file.
1111+
///
1112+
/// For example:
1113+
/// - `/home/ferris/rust/tests/ui/warnings/hello-world.rs`
1114+
///
1115+
/// ---
1116+
///
1117+
/// For `run-make` tests, this path is the _directory_ that contains
1118+
/// `rmake.rs`.
1119+
///
1120+
/// For example:
1121+
/// - `/home/ferris/rust/tests/run-make/emit`
1122+
pub(crate) file: Utf8PathBuf,
1123+
1124+
/// Subset of the full path that excludes the suite directory and the
1125+
/// test filename. For tests in the root of their test suite directory,
1126+
/// this is blank.
1127+
///
1128+
/// For example:
1129+
/// - `file`: `/home/ferris/rust/tests/ui/warnings/hello-world.rs`
1130+
/// - `relative_dir`: `warnings`
1131+
pub(crate) relative_dir: Utf8PathBuf,
10821132
}
10831133

10841134
/// Used by `ui` tests to generate things like `foo.stderr` from `foo.rs`.

0 commit comments

Comments
 (0)