Skip to content

Commit a05852e

Browse files
jyn514Joshua Nelson
authored and
Joshua Nelson
committed
Document test input normalization
1 parent 0687daa commit a05852e

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

Diff for: src/tests/adding.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ you can even run the resulting program. Just add one of the following
425425
- `// run-pass` – compilation should succeed and we should run the
426426
resulting binary
427427

428-
### Normalization
428+
### Output Normalization
429429

430430
The compiler output is normalized to eliminate output difference between
431431
platforms, mainly about filenames.
@@ -500,3 +500,23 @@ Besides `normalize-stderr-32bit` and `-64bit`, one may use any target
500500
information or stage supported by [`ignore-X`](#ignoring-tests) here as well (e.g.
501501
`normalize-stderr-windows` or simply `normalize-stderr-test` for unconditional
502502
replacement).
503+
504+
## Input Normalization
505+
506+
Sometimes, you want to normalize the inputs to a test. For example, you may
507+
want to pass `// compile-flags: --x=y.rs`, where y.rs is some file in the test
508+
directory. In this case you can use input normalization. The following strings
509+
are replaced in header inputs:
510+
511+
- {{cwd}}: The directory where compiletest is run from. This may not be the
512+
root of the checkout, so you should avoid using it where possible.
513+
- Example: `/path/to/rust`
514+
- {{src-base}}: The directory where the test is defined. This is equivalent to
515+
`$DIR` for output normalization.
516+
- Example: `/path/to/rust/src/test/ui/error-codes`
517+
- {{build-base}}: The base directory where the test's output goes. This is
518+
equivalent to `$TEST_BUILD_DIR` for output normalization.
519+
- Example: `/path/to/rust/build/x86_64-unknown-linux-gnu/test/ui`
520+
521+
See [`src/test/ui/commandline-argfile.rs`](https://github.com/rust-lang/rust/blob/a5029ac0ab372aec515db2e718da6d7787f3d122/src/test/ui/commandline-argfile.rs)
522+
for an example of a test that uses input normalization.

0 commit comments

Comments
 (0)