Switch tests to use the rendered form of diagnostics (#8070)

Historically, we disabled the rendered form in tests outside of
`toolchain/diagnostics`. The idea was to keep tests shorter and avoid
very long chains of autoupdate before stabilizing due to all the line
numbers and other artifacts in the rendered form.

This PR adds `--diagnostic-line-numbers=[all|first]` and defaults to
`first` in tests. This keeps the rendered form so that we can easily
code review that form and the visual cues it does or doesn't provide.
But it removes all but the first location's line numbers to provide
significantly more stability in tests.

By default, tests get the full unicode line-drawing form of diagnostics
so we can ensure all of the artifacts there make sense with the specific
case being diagnosed, but we do retain some focused ASCII-rendering
tests to ensure that fallback remains usable.

There are some issues here that will be fixed in subsequent PRs.
Notably, we try to keep the frame together in the check lines, and so
force some parts to use the first location. This largely works, but
fails in some edge cases, causing the entire frame to be located
incorrectly. There is a TODO about this that we need to fix, and it only
occurs 6 times across the test suite, so it didn't seem worth
front-loading a fix for here.

Assisted-by: Claude Code
This commit is contained in:
Chandler Carruth authored and GitHub committed 2026-11-05 07:19:59 +00:00
1 parent 0b7059a360
commit d0badecd2a
888 files changed
+39731 -12799

No files matched your search

@@ -13,7 +13,12 @@
library "[[@TEST_NAME]]";
interface I {
// CHECK:STDERR: fail_tuple_pattern.carbon:[[@LINE+2]]:6: error: expected identifier in associated constant declaration [ExpectedAssociatedConstantIdentifier]
// CHECK:STDERR: ╭─┤ fail_tuple_pattern.carbon:[[@LINE+7]]:6
// CHECK:STDERR: -> │ let (T: type, U: type);
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: expected identifier in associated constant declaration
// CHECK:STDERR: · ┃ [ExpectedAssociatedConstantIdentifier]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
let (T: type, U: type);
}
@@ -23,7 +28,12 @@ interface I {
library "[[@TEST_NAME]]";
interface I {
// CHECK:STDERR: fail_tuple_pattern_with_default.carbon:[[@LINE+2]]:14: error: expected identifier in associated constant declaration [ExpectedAssociatedConstantIdentifier]
// CHECK:STDERR: ╭─┤ fail_tuple_pattern_with_default.carbon:[[@LINE+7]]:14
// CHECK:STDERR: -> │ default let (T: type, U: type) = ({}, {});
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: expected identifier in associated constant declaration
// CHECK:STDERR: · ┃ [ExpectedAssociatedConstantIdentifier]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
default let (T: type, U: type) = ({}, {});
}
@@ -33,7 +43,12 @@ interface I {
library "[[@TEST_NAME]]";
interface I {
// CHECK:STDERR: fail_var_pattern.carbon:[[@LINE+2]]:6: error: expected identifier in associated constant declaration [ExpectedAssociatedConstantIdentifier]
// CHECK:STDERR: ╭─┤ fail_var_pattern.carbon:[[@LINE+7]]:6
// CHECK:STDERR: -> │ let var T: type;
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: expected identifier in associated constant declaration
// CHECK:STDERR: · ┃ [ExpectedAssociatedConstantIdentifier]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
let var T: type;
}
@@ -43,7 +58,12 @@ interface I {
library "[[@TEST_NAME]]";
interface I {
// CHECK:STDERR: fail_var_pattern_with_default.carbon:[[@LINE+2]]:14: error: expected identifier in associated constant declaration [ExpectedAssociatedConstantIdentifier]
// CHECK:STDERR: ╭─┤ fail_var_pattern_with_default.carbon:[[@LINE+7]]:14
// CHECK:STDERR: -> │ default let var T: type = {};
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: expected identifier in associated constant declaration
// CHECK:STDERR: · ┃ [ExpectedAssociatedConstantIdentifier]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
default let var T: type = {};
}
@@ -53,7 +73,12 @@ interface I {
library "[[@TEST_NAME]]";
interface I {
// CHECK:STDERR: fail_not_constant.carbon:[[@LINE+2]]:7-13: error: phase keyword is not allowed on an associated constant [PhaseKeywordInAssociatedConstant]
// CHECK:STDERR: ╭─┤ fail_not_constant.carbon:[[@LINE+7]]:7
// CHECK:STDERR: -> │ let runtime a: {.b: ()};
// CHECK:STDERR: · ━━━┳━━━
// CHECK:STDERR: · ┗━━┫ error: phase keyword is not allowed on an associated constant
// CHECK:STDERR: · ┃ [PhaseKeywordInAssociatedConstant]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
let runtime a: {.b: ()};
}
@@ -63,7 +88,12 @@ interface I {
library "[[@TEST_NAME]]";
interface I {
// CHECK:STDERR: fail_template.carbon:[[@LINE+2]]:7-14: error: phase keyword is not allowed on an associated constant [PhaseKeywordInAssociatedConstant]
// CHECK:STDERR: ╭─┤ fail_template.carbon:[[@LINE+7]]:7
// CHECK:STDERR: -> │ let template T: type;
// CHECK:STDERR: · ━━━━┳━━━
// CHECK:STDERR: · ┗━━┫ error: phase keyword is not allowed on an associated constant
// CHECK:STDERR: · ┃ [PhaseKeywordInAssociatedConstant]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
let template T: type;
}
@@ -73,7 +103,12 @@ interface I {
library "[[@TEST_NAME]]";
interface I {
// CHECK:STDERR: fail_generic.carbon:[[@LINE+2]]:7-13: error: phase keyword is not allowed on an associated constant [PhaseKeywordInAssociatedConstant]
// CHECK:STDERR: ╭─┤ fail_generic.carbon:[[@LINE+7]]:7
// CHECK:STDERR: -> │ let generic a: type;
// CHECK:STDERR: · ━━━┳━━━
// CHECK:STDERR: · ┗━━┫ error: phase keyword is not allowed on an associated constant
// CHECK:STDERR: · ┃ [PhaseKeywordInAssociatedConstant]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
let generic a: type;
}
@@ -83,7 +118,13 @@ interface I {
library "[[@TEST_NAME]]";
interface I {
// CHECK:STDERR: fail_underscore.carbon:[[@LINE+2]]:7: error: expected identifier in associated constant declaration; prefix reserved word with `r#` to form a valid identifier [ExpectedAssociatedConstantIdentifier]
// CHECK:STDERR: ╭─┤ fail_underscore.carbon:[[@LINE+8]]:7
// CHECK:STDERR: -> │ let _: {};
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: expected identifier in associated constant declaration; prefix
// CHECK:STDERR: · ┃ reserved word with `r#` to form a valid identifier
// CHECK:STDERR: · ┃ [ExpectedAssociatedConstantIdentifier]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
let _: {};
}
@@ -93,7 +134,12 @@ interface I {
library "[[@TEST_NAME]]";
interface I {
// CHECK:STDERR: fail_missing_colon.carbon:[[@LINE+2]]:8: error: expected `:` in associated constant declaration [ExpectedAssociatedConstantColon]
// CHECK:STDERR: ╭─┤ fail_missing_colon.carbon:[[@LINE+7]]:8
// CHECK:STDERR: -> │ let a;
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: expected `:` in associated constant declaration
// CHECK:STDERR: · ┃ [ExpectedAssociatedConstantColon]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
let a;
}
@@ -8,7 +8,12 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/generics/interface/fail_missing_name.carbon
// CHECK:STDERR: fail_missing_name.carbon:[[@LINE+2]]:10: error: `interface` introducer should be followed by a name [ExpectedDeclName]
// CHECK:STDERR: ╭─┤ fail_missing_name.carbon:[[@LINE+7]]:10
// CHECK:STDERR: -> │ interface {
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: `interface` introducer should be followed by a name
// CHECK:STDERR: · ┃ [ExpectedDeclName]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
interface {
}
@@ -8,11 +8,23 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/generics/interface/fail_missing_open_curly.carbon
// CHECK:STDERR: fail_missing_open_curly.carbon:[[@LINE+2]]:14: error: `interface` declarations must either end with a `;` or have a `{ ... }` block for a definition [ExpectedDeclSemiOrDefinition]
// CHECK:STDERR: ╭─┤ fail_missing_open_curly.carbon:[[@LINE+8]]:14
// CHECK:STDERR: -> │ interface Bar Baz {}
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: `interface` declarations must either end with a `;` or
// CHECK:STDERR: · ┃ have a `{ ... }` block for a definition
// CHECK:STDERR: · ┃ [ExpectedDeclSemiOrDefinition]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
interface Bar Baz {}
// CHECK:STDERR: fail_missing_open_curly.carbon:[[@LINE+2]]:14: error: `interface` declarations must either end with a `;` or have a `{ ... }` block for a definition [ExpectedDeclSemiOrDefinition]
// CHECK:STDERR: ╭─┤ fail_missing_open_curly.carbon:[[@LINE+8]]:14
// CHECK:STDERR: -> │ interface Foo
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: `interface` declarations must either end with a `;` or
// CHECK:STDERR: · ┃ have a `{ ... }` block for a definition
// CHECK:STDERR: · ┃ [ExpectedDeclSemiOrDefinition]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
interface Foo
@@ -9,7 +9,11 @@
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/generics/interface/fail_self_param_syntax.carbon
interface Foo {
// CHECK:STDERR: fail_self_param_syntax.carbon:[[@LINE+2]]:12: error: expected `,` or `]` [UnexpectedTokenAfterListElement]
// CHECK:STDERR: ╭─┤ fail_self_param_syntax.carbon:[[@LINE+6]]:12
// CHECK:STDERR: -> │ fn Sub[me Self](b: Self) -> Self;
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: expected `,` or `]` [UnexpectedTokenAfterListElement]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
fn Sub[me Self](b: Self) -> Self;
+17 -3
View File
@@ -61,7 +61,12 @@ interface Z {
interface Y {}
interface Z {
// CHECK:STDERR: fail_missing_impls.carbon:[[@LINE+2]]:12: error: expected `impls` in `require` declaration [RequireExpectedImpls]
// CHECK:STDERR: ╭─┤ fail_missing_impls.carbon:[[@LINE+7]]:12
// CHECK:STDERR: -> │ require Y;
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: expected `impls` in `require` declaration
// CHECK:STDERR: · ┃ [RequireExpectedImpls]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
require Y;
}
@@ -71,7 +76,11 @@ interface Z {
interface Y {}
interface Z {
// CHECK:STDERR: fail_wrong_keyword.carbon:[[@LINE+2]]:10: error: expected expression [ExpectedExpr]
// CHECK:STDERR: ╭─┤ fail_wrong_keyword.carbon:[[@LINE+6]]:10
// CHECK:STDERR: -> │ require as Y;
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: expected expression [ExpectedExpr]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
require as Y;
}
@@ -81,7 +90,12 @@ interface Z {
interface Y {}
interface Z {
// CHECK:STDERR: fail_as_in_self.carbon:[[@LINE+2]]:15: error: expected `impls` in `require` declaration [RequireExpectedImpls]
// CHECK:STDERR: ╭─┤ fail_as_in_self.carbon:[[@LINE+7]]:15
// CHECK:STDERR: -> │ require Self as Y impls Y;
// CHECK:STDERR: · ┳
// CHECK:STDERR: · ┗━━┫ error: expected `impls` in `require` declaration
// CHECK:STDERR: · ┃ [RequireExpectedImpls]
// CHECK:STDERR: ╰────
// CHECK:STDERR:
require Self as Y impls Y;
}