@@ -9,7 +9,7 @@ UI tests are a particular [test suite](compiletest.md#test-suites) of compiletes
9
9
The tests in [ ` src/test/ui ` ] are a collection of general-purpose tests which
10
10
primarily focus on validating the console output of the compiler, but can be
11
11
used for many other purposes.
12
- For example, tests can also be configure to [ run the resulting
12
+ For example, tests can also be configured to [ run the resulting
13
13
program] ( #controlling-passfail-expectations ) to verify its behavior.
14
14
15
15
[ `src/test/ui` ] : https://github.com/rust-lang/rust/blob/master/src/test/ui
@@ -96,41 +96,42 @@ generated.
96
96
The compiler output is normalized to eliminate output difference between
97
97
platforms, mainly about filenames.
98
98
99
- The following strings replace their corresponding values:
100
-
101
- - ` $DIR ` : The directory where the test is defined.
102
- - Example: ` /path/to/rust/src/test/ui/error-codes `
103
- - ` $SRC_DIR ` : The root source directory.
104
- - Example: ` /path/to/rust/src `
105
- - ` $TEST_BUILD_DIR ` : The base directory where the test's output goes.
106
- - Example: ` /path/to/rust/build/x86_64-unknown-linux-gnu/test/ui `
107
-
108
- Additionally, the following changes are made:
109
-
110
- - Line and column numbers for paths in ` $SRC_DIR ` are replaced with ` LL:CC ` .
111
- For example, ` /path/to/rust/library/core/src/clone.rs:122:8 ` is replaced with
112
- ` $SRC_DIR/core/src/clone.rs:LL:COL ` .
113
-
114
- Note: The line and column numbers for ` --> ` lines pointing to the test are
115
- * not* normalized, and left as-is. This ensures that the compiler continues
116
- to point to the correct location, and keeps the stderr files readable.
117
- Ideally all line/column information would be retained, but small changes to
118
- the source causes large diffs, and more frequent merge conflicts and test
119
- errors. See also ` -Z ui-testing ` below which applies additional line number
120
- normalization.
121
- - ` \t ` is replaced with an actual tab character.
122
- - Error line annotations like ` //~ ERROR some message ` are removed.
99
+ Compiletest makes the following replacements on the compiler output:
100
+
101
+ - The directory where the test is defined is replaced with ` $DIR ` .
102
+ Example: ` /path/to/rust/src/test/ui/error-codes `
103
+ - The directory to the standard library source is replaced with ` $SRC_DIR ` .
104
+ Example: ` /path/to/rust/library `
105
+ - Line and column numbers for paths in ` $SRC_DIR ` are replaced with ` LL:COL ` .
106
+ This helps ensure that changes to the layout of the standard library do not
107
+ cause widespread changes to the ` .stderr ` files.
108
+ Example: ` $SRC_DIR/alloc/src/sync.rs:53:46 `
109
+ - The base directory where the test's output goes is replaced with ` $TEST_BUILD_DIR ` .
110
+ This only comes up in a few rare circumstances.
111
+ Example: ` /path/to/rust/build/x86_64-unknown-linux-gnu/test/ui `
112
+ - Tabs are replaced with ` \t ` .
123
113
- Backslashes (` \ ` ) are converted to forward slashes (` / ` ) within paths (using
124
114
a heuristic). This helps normalize differences with Windows-style paths.
125
115
- CRLF newlines are converted to LF.
116
+ - Error line annotations like ` //~ ERROR some message ` are removed.
117
+ - Various v0 and legacy symbol hashes are replaced with placeholders like
118
+ ` [HASH] ` or ` <SYMBOL_HASH> ` .
126
119
127
120
Additionally, the compiler is run with the ` -Z ui-testing ` flag which causes
128
121
the compiler itself to apply some changes to the diagnostic output to make it
129
- more suitable for UI testing. For example, it will anonymize line numbers in
130
- the output (line numbers prefixing each source line are replaced with ` LL ` ).
122
+ more suitable for UI testing.
123
+ For example, it will anonymize line numbers in the output (line numbers
124
+ prefixing each source line are replaced with ` LL ` ).
131
125
In extremely rare situations, this mode can be disabled with the header
132
126
command ` // compile-flags: -Z ui-testing=no ` .
133
127
128
+ Note: The line and column numbers for ` --> ` lines pointing to the test are
129
+ * not* normalized, and left as-is. This ensures that the compiler continues
130
+ to point to the correct location, and keeps the stderr files readable.
131
+ Ideally all line/column information would be retained, but small changes to
132
+ the source causes large diffs, and more frequent merge conflicts and test
133
+ errors.
134
+
134
135
Sometimes these built-in normalizations are not enough. In such cases, you
135
136
may provide custom normalization rules using the header commands, e.g.
136
137
@@ -189,8 +190,9 @@ the source.
189
190
Finally, they ensure that no additional unexpected errors are generated.
190
191
191
192
They have several forms, but generally are a comment with the diagnostic
192
- level (such as ` ERROR ` ) and a substring of the expected error output
193
- (you don't have to write out the entire text, just whatever is important).
193
+ level (such as ` ERROR ` ) and a substring of the expected error output.
194
+ You don't have to write out the entire message, just make sure to include the
195
+ important part of the message to make it self-documenting.
194
196
195
197
The error annotation needs to match with the line of the diagnostic.
196
198
There are several ways to match the message with the line (see the examples below):
@@ -205,13 +207,6 @@ There are several ways to match the message with the line (see the examples belo
205
207
This is more convenient than using multiple carets when there are multiple
206
208
messages associated with the same line.
207
209
208
- Error annotations are considered during tidy lints of line length and should
209
- be formatted according to tidy requirements.
210
- You may use an error message prefix sub-string if necessary to meet line
211
- length requirements.
212
- Make sure that the text is long enough for the error message to be
213
- self-documenting.
214
-
215
210
### Error annotation examples
216
211
217
212
Here are examples of error annotations on different lines of UI test
0 commit comments