mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 21:21:19 +01:00
Move CHECK lines in tests next to the line that caused the output. (#1224)
Use FileCheck's `[[@LINE+n]]` mechanism to refer to the next line. This is made awkward by a couple of things: * We want to keep the `CHECK` lines in the original order. * Errors are sometimes more than one line long. The approach we use is to interleave the original lines and the check lines, putting each check line as early as possible subject to two rules: 1) Check lines never precede the 'AUTOUPDATE' line 2) Except when required by rule (1), a check line that refers to a source line by line number is never placed earlier than a source line that precedes that source line. The actual `[[@LINE+n]]` annotations are created in a second pass after we've interleaved the lines so that we can work out the correct offsets. Co-authored-by: Jon Meow <jperkins@google.com>
This commit is contained in:
committed by
GitHub
co-authored by
Jon Meow
parent
4a8ca9cd0f
commit
e85f45de10
+1
-1
@@ -7,11 +7,11 @@
|
||||
// RUN: %{not} %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
|
||||
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
|
||||
// AUTOUPDATE: %{explorer} %s
|
||||
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/array/fail_negative_size.carbon:15: Array size cannot be negative
|
||||
|
||||
package ExplorerTest api;
|
||||
|
||||
fn Main() -> i32 {
|
||||
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/array/fail_negative_size.carbon:[[@LINE+1]]: Array size cannot be negative
|
||||
var x: [i32; -1] = ();
|
||||
return x[0];
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,11 +7,11 @@
|
||||
// RUN: %{not} %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
|
||||
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
|
||||
// AUTOUPDATE: %{explorer} %s
|
||||
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/array/fail_size_mismatch.carbon:15: type error in name binding: '(i32, i32, i32)' is not implicitly convertible to '[i32; 2]'
|
||||
|
||||
package ExplorerTest api;
|
||||
|
||||
fn Main() -> i32 {
|
||||
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/array/fail_size_mismatch.carbon:[[@LINE+1]]: type error in name binding: '(i32, i32, i32)' is not implicitly convertible to '[i32; 2]'
|
||||
var x: [i32; 2] = (0, 1, 2);
|
||||
return x[0];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user