Skip to content

Commit

Permalink
Add a newline after diagnostic output when testing (#4818)
Browse files Browse the repository at this point in the history
This removes some churn when adding new diagnostic cases to test files
(where previous to this change the newly added newline would cause the
previous diagnostic CHECKs to be updated including changes to the line
number because the CHECK for the blank line meant an extra line between
CHECK and source line).

A few alternatives discussed here:
https://discord.com/channels/655572317891461132/655578254970716160/1329573358475673723

---------

Co-authored-by: Jon Ross-Perkins <[email protected]>
  • Loading branch information
dwblaikie and jonmeow authored Jan 16, 2025
1 parent a8b46cf commit e6c1f06
Show file tree
Hide file tree
Showing 582 changed files with 2,575 additions and 1,988 deletions.
3 changes: 2 additions & 1 deletion toolchain/check/testdata/alias/fail_bool_value.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/alias/fail_bool_value.carbon

// CHECK:STDERR: fail_bool_value.carbon:[[@LINE+3]]:11: error: alias initializer must be a name reference [AliasRequiresNameRef]
// CHECK:STDERR: fail_bool_value.carbon:[[@LINE+4]]:11: error: alias initializer must be a name reference [AliasRequiresNameRef]
// CHECK:STDERR: alias a = false;
// CHECK:STDERR: ^~~~~
// CHECK:STDERR:
alias a = false;
let a_test: bool = a;

Expand Down
3 changes: 2 additions & 1 deletion toolchain/check/testdata/alias/fail_builtins.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
// CHECK:STDERR:
alias a = i32;

// CHECK:STDERR: fail_builtins.carbon:[[@LINE+3]]:11: error: alias initializer must be a name reference [AliasRequiresNameRef]
// CHECK:STDERR: fail_builtins.carbon:[[@LINE+4]]:11: error: alias initializer must be a name reference [AliasRequiresNameRef]
// CHECK:STDERR: alias b = bool;
// CHECK:STDERR: ^~~~
// CHECK:STDERR:
alias b = bool;

// CHECK:STDOUT: --- fail_builtins.carbon
Expand Down
11 changes: 6 additions & 5 deletions toolchain/check/testdata/alias/fail_control_flow.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/alias/fail_control_flow.carbon

// CHECK:STDERR: fail_control_flow.carbon:[[@LINE+15]]:11: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
// CHECK:STDERR: fail_control_flow.carbon:[[@LINE+16]]:11: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
// CHECK:STDERR: alias a = true or false;
// CHECK:STDERR: ^~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_control_flow.carbon:[[@LINE+11]]:11: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
// CHECK:STDERR: fail_control_flow.carbon:[[@LINE+12]]:11: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
// CHECK:STDERR: alias a = true or false;
// CHECK:STDERR: ^~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_control_flow.carbon:[[@LINE+7]]:11: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
// CHECK:STDERR: fail_control_flow.carbon:[[@LINE+8]]:11: error: semantics TODO: `Control flow expressions are currently only supported inside functions.` [SemanticsTodo]
// CHECK:STDERR: alias a = true or false;
// CHECK:STDERR: ^~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_control_flow.carbon:[[@LINE+3]]:11: error: alias initializer must be a name reference [AliasRequiresNameRef]
// CHECK:STDERR: fail_control_flow.carbon:[[@LINE+4]]:11: error: alias initializer must be a name reference [AliasRequiresNameRef]
// CHECK:STDERR: alias a = true or false;
// CHECK:STDERR: ^~~~~~~~~~~~~
// CHECK:STDERR:
alias a = true or false;

// CHECK:STDOUT: --- fail_control_flow.carbon
Expand All @@ -35,7 +36,7 @@ alias a = true or false;
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: %.loc26: bool = block_arg <unexpected instblockref inst_block5> [template = constants.%true]
// CHECK:STDOUT: %.loc27: bool = block_arg <unexpected instblockref inst_block5> [template = constants.%true]
// CHECK:STDOUT: %a: <error> = bind_alias a, <error> [template = <error>]
// CHECK:STDOUT: }
// CHECK:STDOUT:
5 changes: 3 additions & 2 deletions toolchain/check/testdata/alias/no_prelude/export_name.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ library "[[@TEST_NAME]]";

import library "export";

// CHECK:STDERR: fail_orig_name_not_in_export.carbon:[[@LINE+3]]:8: error: name `C` not found [NameNotFound]
// CHECK:STDERR: fail_orig_name_not_in_export.carbon:[[@LINE+4]]:8: error: name `C` not found [NameNotFound]
// CHECK:STDERR: var c: C = {};
// CHECK:STDERR: ^
// CHECK:STDERR:
var c: C = {};

// --- indirect_compat.carbon
Expand Down Expand Up @@ -204,7 +205,7 @@ var d: D* = &c;
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %.loc9: %empty_struct_type = struct_literal ()
// CHECK:STDOUT: %.loc10: %empty_struct_type = struct_literal ()
// CHECK:STDOUT: assign file.%c.var, <error>
// CHECK:STDOUT: return
// CHECK:STDOUT: }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ class D {}
alias c = C;
var d: D = {};

// CHECK:STDERR: fail_aliased_name_in_diag.carbon:[[@LINE+3]]:1: error: `Core.ImplicitAs` implicitly referenced here, but package `Core` not found [CoreNotFound]
// CHECK:STDERR: fail_aliased_name_in_diag.carbon:[[@LINE+4]]:1: error: `Core.ImplicitAs` implicitly referenced here, but package `Core` not found [CoreNotFound]
// CHECK:STDERR: let c_var: c = d;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~
// CHECK:STDERR:
let c_var: c = d;

// CHECK:STDOUT: --- fail_aliased_name_in_diag.carbon
Expand Down Expand Up @@ -62,7 +63,7 @@ let c_var: c = d;
// CHECK:STDOUT: %.loc15_14: init %D = converted %.loc15_13.1, %.loc15_13.2 [template = constants.%D.val]
// CHECK:STDOUT: assign file.%d.var, %.loc15_14
// CHECK:STDOUT: %d.ref: ref %D = name_ref d, file.%d
// CHECK:STDOUT: %.loc20: %C = converted %d.ref, <error> [template = <error>]
// CHECK:STDOUT: %.loc21: %C = converted %d.ref, <error> [template = <error>]
// CHECK:STDOUT: %c_var: %C = bind_name c_var, <error>
// CHECK:STDOUT: return
// CHECK:STDOUT: }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ fn F() -> {} {
// CHECK:STDERR: ^~
// CHECK:STDERR:
alias NS.a = {};
// CHECK:STDERR: fail_local_in_namespace.carbon:[[@LINE+3]]:10: error: member name `a` not found in `NS` [MemberNameNotFoundInScope]
// CHECK:STDERR: fail_local_in_namespace.carbon:[[@LINE+4]]:10: error: member name `a` not found in `NS` [MemberNameNotFoundInScope]
// CHECK:STDERR: return NS.a;
// CHECK:STDERR: ^~~~
// CHECK:STDERR:
return NS.a;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ abstract base default final alias A = Class;
// CHECK:STDERR:
impl alias B = Class;

// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+3]]:1: error: `extern` not allowed on `alias` declaration [ModifierNotAllowedOnDeclaration]
// CHECK:STDERR: fail_modifiers.carbon:[[@LINE+4]]:1: error: `extern` not allowed on `alias` declaration [ModifierNotAllowedOnDeclaration]
// CHECK:STDERR: extern alias C = Class;
// CHECK:STDERR: ^~~~~~
// CHECK:STDERR:
extern alias C = Class;

// CHECK:STDOUT: --- fail_modifiers.carbon
Expand All @@ -68,7 +69,7 @@ extern alias C = Class;
// CHECK:STDOUT: %A: type = bind_alias A, %Class.decl [template = constants.%Class]
// CHECK:STDOUT: %Class.ref.loc44: type = name_ref Class, %Class.decl [template = constants.%Class]
// CHECK:STDOUT: %B: type = bind_alias B, %Class.decl [template = constants.%Class]
// CHECK:STDOUT: %Class.ref.loc49: type = name_ref Class, %Class.decl [template = constants.%Class]
// CHECK:STDOUT: %Class.ref.loc50: type = name_ref Class, %Class.decl [template = constants.%Class]
// CHECK:STDOUT: %C: type = bind_alias C, %Class.decl [template = constants.%Class]
// CHECK:STDOUT: }
// CHECK:STDOUT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ alias a = C;
var a: C = {};

var b: C = {};
// CHECK:STDERR: fail_name_conflict.carbon:[[@LINE+6]]:7: error: duplicate name being declared in the same scope [NameDeclDuplicate]
// CHECK:STDERR: fail_name_conflict.carbon:[[@LINE+7]]:7: error: duplicate name being declared in the same scope [NameDeclDuplicate]
// CHECK:STDERR: alias b = C;
// CHECK:STDERR: ^
// CHECK:STDERR: fail_name_conflict.carbon:[[@LINE-4]]:5: note: name is previously declared here [NameDeclPrevious]
// CHECK:STDERR: var b: C = {};
// CHECK:STDERR: ^
// CHECK:STDERR:
alias b = C;

// CHECK:STDOUT: --- fail_name_conflict.carbon
Expand All @@ -51,8 +52,8 @@ alias b = C;
// CHECK:STDOUT: %a.loc21: ref %C = bind_name a, %a.var
// CHECK:STDOUT: %b.var: ref %C = var b
// CHECK:STDOUT: %b: ref %C = bind_name b, %b.var
// CHECK:STDOUT: %C.ref.loc30: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %.loc30: type = bind_alias <invalid>, %C.decl [template = constants.%C]
// CHECK:STDOUT: %C.ref.loc31: type = name_ref C, %C.decl [template = constants.%C]
// CHECK:STDOUT: %.loc31: type = bind_alias <invalid>, %C.decl [template = constants.%C]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: class @C {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
fn F() {
var a: () = ();
var b: ()* = &a;
// CHECK:STDERR: fail_not_constant.carbon:[[@LINE+3]]:13: error: alias initializer must be a name reference [AliasRequiresNameRef]
// CHECK:STDERR: fail_not_constant.carbon:[[@LINE+4]]:13: error: alias initializer must be a name reference [AliasRequiresNameRef]
// CHECK:STDERR: alias c = *b;
// CHECK:STDERR: ^~
// CHECK:STDERR:
alias c = *b;
}

Expand Down Expand Up @@ -48,8 +49,8 @@ fn F() {
// CHECK:STDOUT: %addr: %ptr = addr_of %a.ref
// CHECK:STDOUT: assign %b.var, %addr
// CHECK:STDOUT: %b.ref: ref %ptr = name_ref b, %b
// CHECK:STDOUT: %.loc17_14: %ptr = bind_value %b.ref
// CHECK:STDOUT: %.loc17_13: ref %empty_tuple.type = deref %.loc17_14
// CHECK:STDOUT: %.loc18_14: %ptr = bind_value %b.ref
// CHECK:STDOUT: %.loc18_13: ref %empty_tuple.type = deref %.loc18_14
// CHECK:STDOUT: %c: <error> = bind_alias c, <error> [template = <error>]
// CHECK:STDOUT: return
// CHECK:STDOUT: }
Expand Down
5 changes: 3 additions & 2 deletions toolchain/check/testdata/alias/no_prelude/fail_params.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/alias/no_prelude/fail_params.carbon

// CHECK:STDERR: fail_params.carbon:[[@LINE+7]]:8: error: `alias` declaration cannot have parameters [UnexpectedDeclNameParams]
// CHECK:STDERR: fail_params.carbon:[[@LINE+8]]:8: error: `alias` declaration cannot have parameters [UnexpectedDeclNameParams]
// CHECK:STDERR: alias A(T:! type) = T*;
// CHECK:STDERR: ^~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: fail_params.carbon:[[@LINE+3]]:21: error: alias initializer must be a name reference [AliasRequiresNameRef]
// CHECK:STDERR: fail_params.carbon:[[@LINE+4]]:21: error: alias initializer must be a name reference [AliasRequiresNameRef]
// CHECK:STDERR: alias A(T:! type) = T*;
// CHECK:STDERR: ^~
// CHECK:STDERR:
alias A(T:! type) = T*;

// CHECK:STDOUT: --- fail_params.carbon
Expand Down
9 changes: 5 additions & 4 deletions toolchain/check/testdata/alias/no_prelude/import.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ var b: () = a_alias;

library "[[@TEST_NAME]]";

// CHECK:STDERR: fail_var3.carbon:[[@LINE+4]]:1: in import [InImport]
// CHECK:STDERR: fail_var3.carbon:[[@LINE+5]]:1: in import [InImport]
// CHECK:STDERR: var2.carbon:8:5: error: semantics TODO: `Non-constant ImportRefLoaded (comes up with var)` [SemanticsTodo]
// CHECK:STDERR: var b: () = a_alias;
// CHECK:STDERR: ^
// CHECK:STDERR:
import library "var2";

var c: () = a_alias_alias;
Expand Down Expand Up @@ -246,9 +247,9 @@ var c: () = a_alias_alias;
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %a_alias_alias.ref: ref %empty_tuple.type = name_ref a_alias_alias, imports.%import_ref.692 [template = <error>]
// CHECK:STDOUT: %.loc10_13: init %empty_tuple.type = tuple_init () to file.%c.var [template = constants.%empty_tuple]
// CHECK:STDOUT: %.loc10_26: init %empty_tuple.type = converted %a_alias_alias.ref, %.loc10_13 [template = constants.%empty_tuple]
// CHECK:STDOUT: assign file.%c.var, %.loc10_26
// CHECK:STDOUT: %.loc11_13: init %empty_tuple.type = tuple_init () to file.%c.var [template = constants.%empty_tuple]
// CHECK:STDOUT: %.loc11_26: init %empty_tuple.type = converted %a_alias_alias.ref, %.loc11_13 [template = constants.%empty_tuple]
// CHECK:STDOUT: assign file.%c.var, %.loc11_26
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ package Other library "[[@TEST_NAME]]";

import Test library "def";

// CHECK:STDERR: fail_other_def.carbon:[[@LINE+3]]:11: error: member name `A` not found in `Test` [MemberNameNotFoundInScope]
// CHECK:STDERR: fail_other_def.carbon:[[@LINE+4]]:11: error: member name `A` not found in `Test` [MemberNameNotFoundInScope]
// CHECK:STDERR: var inst: Test.A = {};
// CHECK:STDERR: ^~~~~~
// CHECK:STDERR:
var inst: Test.A = {};

// CHECK:STDOUT: --- def.carbon
Expand Down Expand Up @@ -166,7 +167,7 @@ var inst: Test.A = {};
// CHECK:STDOUT:
// CHECK:STDOUT: fn @__global_init() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %.loc9: %empty_struct_type = struct_literal ()
// CHECK:STDOUT: %.loc10: %empty_struct_type = struct_literal ()
// CHECK:STDOUT: assign file.%inst.var, <error>
// CHECK:STDOUT: return
// CHECK:STDOUT: }
Expand Down
3 changes: 2 additions & 1 deletion toolchain/check/testdata/array/fail_bound_negative.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@

fn Negate(n: i32) -> i32 = "int.snegate";

// CHECK:STDERR: fail_bound_negative.carbon:[[@LINE+3]]:14: error: array bound of -1 is negative [ArrayBoundNegative]
// CHECK:STDERR: fail_bound_negative.carbon:[[@LINE+4]]:14: error: array bound of -1 is negative [ArrayBoundNegative]
// CHECK:STDERR: var a: [i32; Negate(1)];
// CHECK:STDERR: ^~~~~~~~~
// CHECK:STDERR:
var a: [i32; Negate(1)];

// CHECK:STDOUT: --- fail_bound_negative.carbon
Expand Down
5 changes: 3 additions & 2 deletions toolchain/check/testdata/array/fail_bound_overflow.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
// CHECK:STDERR:
var a: [i32; 39999999999999999993];

// CHECK:STDERR: fail_bound_overflow.carbon:[[@LINE+6]]:9: error: cannot implicitly convert from `Core.IntLiteral` to `type` [ImplicitAsConversionFailure]
// CHECK:STDERR: fail_bound_overflow.carbon:[[@LINE+7]]:9: error: cannot implicitly convert from `Core.IntLiteral` to `type` [ImplicitAsConversionFailure]
// CHECK:STDERR: var b: [1; 39999999999999999993];
// CHECK:STDERR: ^
// CHECK:STDERR: fail_bound_overflow.carbon:[[@LINE+3]]:9: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote]
// CHECK:STDERR: fail_bound_overflow.carbon:[[@LINE+4]]:9: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote]
// CHECK:STDERR: var b: [1; 39999999999999999993];
// CHECK:STDERR: ^
// CHECK:STDERR:
var b: [1; 39999999999999999993];

// CHECK:STDOUT: --- fail_bound_overflow.carbon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@

class Incomplete;

// CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE+6]]:8: error: variable has incomplete type `[Incomplete; 1]` [IncompleteTypeInVarDecl]
// CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE+7]]:8: error: variable has incomplete type `[Incomplete; 1]` [IncompleteTypeInVarDecl]
// CHECK:STDERR: var a: [Incomplete; 1];
// CHECK:STDERR: ^~~~~~~~~~~~~~~
// CHECK:STDERR: fail_incomplete_element.carbon:[[@LINE-5]]:1: note: class was forward declared here [ClassForwardDeclaredHere]
// CHECK:STDERR: class Incomplete;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~
// CHECK:STDERR:
var a: [Incomplete; 1];

var p: Incomplete* = &a[0];
Expand Down
5 changes: 3 additions & 2 deletions toolchain/check/testdata/array/fail_invalid_type.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/fail_invalid_type.carbon

// CHECK:STDERR: fail_invalid_type.carbon:[[@LINE+6]]:9: error: cannot implicitly convert from `Core.IntLiteral` to `type` [ImplicitAsConversionFailure]
// CHECK:STDERR: fail_invalid_type.carbon:[[@LINE+7]]:9: error: cannot implicitly convert from `Core.IntLiteral` to `type` [ImplicitAsConversionFailure]
// CHECK:STDERR: var a: [1; 1];
// CHECK:STDERR: ^
// CHECK:STDERR: fail_invalid_type.carbon:[[@LINE+3]]:9: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote]
// CHECK:STDERR: fail_invalid_type.carbon:[[@LINE+4]]:9: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote]
// CHECK:STDERR: var a: [1; 1];
// CHECK:STDERR: ^
// CHECK:STDERR:
var a: [1; 1];

// CHECK:STDOUT: --- fail_invalid_type.carbon
Expand Down
5 changes: 3 additions & 2 deletions toolchain/check/testdata/array/fail_out_of_bound.carbon
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/fail_out_of_bound.carbon

// CHECK:STDERR: fail_out_of_bound.carbon:[[@LINE+3]]:19: error: cannot initialize array of 1 element from 3 initializers [ArrayInitFromLiteralArgCountMismatch]
// CHECK:STDERR: fail_out_of_bound.carbon:[[@LINE+4]]:19: error: cannot initialize array of 1 element from 3 initializers [ArrayInitFromLiteralArgCountMismatch]
// CHECK:STDERR: var a: [i32; 1] = (1, 2, 3);
// CHECK:STDERR: ^~~~~~~~~
// CHECK:STDERR:
var a: [i32; 1] = (1, 2, 3);

// CHECK:STDOUT: --- fail_out_of_bound.carbon
Expand Down Expand Up @@ -48,7 +49,7 @@ var a: [i32; 1] = (1, 2, 3);
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1]
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2]
// CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3]
// CHECK:STDOUT: %.loc14: %tuple.type = tuple_literal (%int_1, %int_2, %int_3)
// CHECK:STDOUT: %.loc15: %tuple.type = tuple_literal (%int_1, %int_2, %int_3)
// CHECK:STDOUT: assign file.%a.var, <error>
// CHECK:STDOUT: return
// CHECK:STDOUT: }
Expand Down
Loading

0 comments on commit e6c1f06

Please sign in to comment.