@@ -37,7 +37,7 @@ The error levels that you can have are:
3737Header commands specify something about the entire test file as a
3838whole, instead of just a few lines inside the test.
3939
40- * ` ignore-X ` where ` X ` is an architecture, OS or stage will ignore the test accordingly
40+ * ` ignore-X ` where ` X ` is a target detail or stage will ignore the test accordingly (see below)
4141* ` ignore-pretty ` will not compile the pretty-printed test (this is done to test the pretty-printer, but might not always work)
4242* ` ignore-test ` always ignores the test
4343* ` ignore-lldb ` and ` ignore-gdb ` will skip the debuginfo tests
@@ -50,6 +50,14 @@ whole, instead of just a few lines inside the test.
5050 feature is attempted without the proper ` #![feature(X)] ` tag.
5151 Each unstable lang feature is required to have a gate test.
5252
53+ Some examples of ` X ` in ` ignore-X ` :
54+
55+ * Architecture: ` aarch64 ` , ` arm ` , ` asmjs ` , ` mips ` , ` wasm32 ` , ` x86_64 ` , ` x86 ` , ...
56+ * OS: ` android ` , ` emscripten ` , ` freebsd ` , ` ios ` , ` linux ` , ` macos ` , ` windows ` , ...
57+ * Environment (fourth word of the target triple): ` gnu ` , ` msvc ` , ` musl ` .
58+ * Pointer width: ` 32bit ` , ` 64bit ` .
59+ * Stage: ` stage0 ` , ` stage1 ` , ` stage2 ` .
60+
5361## Revisions
5462
5563Certain classes of tests support "revisions" (as of the time of this
@@ -86,3 +94,66 @@ For example, the `ignore-test` header (and all "ignore" headers)
8694currently only apply to the test as a whole, not to particular
8795revisions. The only headers that are intended to really work when
8896customized to a revision are error patterns and compiler flags.
97+
98+ ## Guide to the UI Tests
99+
100+ The UI tests are intended to capture the compiler's complete output,
101+ so that we can test all aspects of the presentation. They work by
102+ compiling a file (e.g., ` ui/hello_world/main.rs ` ), capturing the output,
103+ and then applying some normalization (see below). This normalized
104+ result is then compared against reference files named
105+ ` ui/hello_world/main.stderr ` and ` ui/hello_world/main.stdout ` . If either of
106+ those files doesn't exist, the output must be empty. If the test run
107+ fails, we will print out the current output, but it is also saved in
108+ ` build/<target-triple>/test/ui/hello_world/main.stdout ` (this path is
109+ printed as part of the test failure mesage), so you can run ` diff ` and
110+ so forth.
111+
112+ ### Editing and updating the reference files
113+
114+ If you have changed the compiler's output intentionally, or you are
115+ making a new test, you can use the script ` ui/update-references.sh ` to
116+ update the references. When you run the test framework, it will report
117+ various errors: in those errors is a command you can use to run the
118+ ` ui/update-references.sh ` script, which will then copy over the files
119+ from the build directory and use them as the new reference. You can
120+ also just run ` ui/update-all-references.sh ` . In both cases, you can run
121+ the script with ` --help ` to get a help message.
122+
123+ ### Normalization
124+
125+ The normalization applied is aimed at eliminating output difference
126+ between platforms, mainly about filenames:
127+
128+ - the test directory is replaced with ` $DIR `
129+ - all backslashes (` \ ` ) are converted to forward slashes (` / ` ) (for Windows)
130+ - all CR LF newlines are converted to LF
131+
132+ Sometimes these built-in normalizations are not enough. In such cases, you
133+ may provide custom normalization rules using the header commands, e.g.
134+
135+ ```
136+ // normalize-stderr-32bit: "fn() (32 bits)" -> "fn() ($PTR bits)"
137+ // normalize-stderr-64bit: "fn() (64 bits)" -> "fn() ($PTR bits)"
138+ ```
139+
140+ This tells the test, on 32-bit platforms, whenever the compiler writes
141+ ` fn() (32 bits) ` to stderr, it should be normalized to read ` fn() ($PTR bits) `
142+ instead. Similar for 64-bit.
143+
144+ The corresponding reference file will use the normalized output to test both
145+ 32-bit and 64-bit platforms:
146+
147+ ```
148+ ...
149+ |
150+ = note: source type: fn() ($PTR bits)
151+ = note: target type: u16 (16 bits)
152+ ...
153+ ```
154+
155+ Please see ` ui/transmute/main.rs ` and ` .stderr ` for a concrete usage example.
156+
157+ Besides ` normalize-stderr-32bit ` and ` -64bit ` , one may use any target
158+ information or stage supported by ` ignore-X ` here as well (e.g.
159+ ` normalize-stderr-windows ` ).
0 commit comments