diff --git a/toolchain/check/testdata/basics/no_prelude/dump_raw_builtins.carbon b/toolchain/check/testdata/basics/raw_sem_ir/builtins.carbon similarity index 93% rename from toolchain/check/testdata/basics/no_prelude/dump_raw_builtins.carbon rename to toolchain/check/testdata/basics/raw_sem_ir/builtins.carbon index 79e311c0daf3..08e03eb3278d 100644 --- a/toolchain/check/testdata/basics/no_prelude/dump_raw_builtins.carbon +++ b/toolchain/check/testdata/basics/raw_sem_ir/builtins.carbon @@ -2,16 +2,16 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // -// ARGS: --include-diagnostic-kind compile --no-prelude-import --phase=check --dump-raw-sem-ir --builtin-sem-ir %s +// EXTRA-ARGS: --no-prelude-import --dump-raw-sem-ir --builtin-sem-ir // // AUTOUPDATE // TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/basics/no_prelude/dump_raw_builtins.carbon +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/basics/raw_sem_ir/builtins.carbon // TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/basics/no_prelude/dump_raw_builtins.carbon +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/basics/raw_sem_ir/builtins.carbon // CHECK:STDOUT: --- -// CHECK:STDOUT: filename: dump_raw_builtins.carbon +// CHECK:STDOUT: filename: builtins.carbon // CHECK:STDOUT: sem_ir: // CHECK:STDOUT: import_irs: // CHECK:STDOUT: ir0: {decl_id: inst, is_export: false} @@ -74,3 +74,4 @@ // CHECK:STDOUT: inst_block4: // CHECK:STDOUT: 0: inst14 // CHECK:STDOUT: ... +// CHECK:STDOUT: diff --git a/toolchain/driver/testdata/compile/multifile_raw_ir.carbon b/toolchain/check/testdata/basics/raw_sem_ir/multifile.carbon similarity index 97% rename from toolchain/driver/testdata/compile/multifile_raw_ir.carbon rename to toolchain/check/testdata/basics/raw_sem_ir/multifile.carbon index 16ecf76a7ff8..d5e6ccbaee07 100644 --- a/toolchain/driver/testdata/compile/multifile_raw_ir.carbon +++ b/toolchain/check/testdata/basics/raw_sem_ir/multifile.carbon @@ -2,15 +2,15 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // -// ARGS: --include-diagnostic-kind compile --no-prelude-import --phase=check --dump-raw-sem-ir %s +// EXTRA-ARGS: --no-prelude-import --dump-raw-sem-ir --no-dump-sem-ir // // Check that raw IR dumping works as expected. // // AUTOUPDATE // TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/driver/testdata/compile/multifile_raw_ir.carbon +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/basics/raw_sem_ir/multifile.carbon // TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/driver/testdata/compile/multifile_raw_ir.carbon +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/basics/raw_sem_ir/multifile.carbon // --- a.carbon package A; diff --git a/toolchain/driver/testdata/compile/multifile_raw_and_textual_ir.carbon b/toolchain/check/testdata/basics/raw_sem_ir/multifile_with_textual_ir.carbon similarity index 97% rename from toolchain/driver/testdata/compile/multifile_raw_and_textual_ir.carbon rename to toolchain/check/testdata/basics/raw_sem_ir/multifile_with_textual_ir.carbon index b32aefdd0780..0646260e5736 100644 --- a/toolchain/driver/testdata/compile/multifile_raw_and_textual_ir.carbon +++ b/toolchain/check/testdata/basics/raw_sem_ir/multifile_with_textual_ir.carbon @@ -2,15 +2,15 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // -// ARGS: --include-diagnostic-kind compile --no-prelude-import --phase=check --dump-sem-ir --dump-raw-sem-ir %s +// EXTRA-ARGS: --no-prelude-import --dump-raw-sem-ir --dump-sem-ir-ranges=if-present // // Check that we can combine textual IR and raw IR dumping in one compile. // // AUTOUPDATE // TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/driver/testdata/compile/multifile_raw_and_textual_ir.carbon +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/basics/raw_sem_ir/multifile_with_textual_ir.carbon // TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/driver/testdata/compile/multifile_raw_and_textual_ir.carbon +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/basics/raw_sem_ir/multifile_with_textual_ir.carbon // --- a.carbon package A; diff --git a/toolchain/driver/testdata/compile/raw_ir.carbon b/toolchain/check/testdata/basics/raw_sem_ir/one_file.carbon similarity index 98% rename from toolchain/driver/testdata/compile/raw_ir.carbon rename to toolchain/check/testdata/basics/raw_sem_ir/one_file.carbon index 63194ff5af27..11076bd4319b 100644 --- a/toolchain/driver/testdata/compile/raw_ir.carbon +++ b/toolchain/check/testdata/basics/raw_sem_ir/one_file.carbon @@ -2,22 +2,22 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // -// ARGS: --include-diagnostic-kind compile --no-prelude-import --phase=check --dump-raw-sem-ir %s +// EXTRA-ARGS: --no-prelude-import --dump-raw-sem-ir --no-dump-sem-ir // // Check that raw IR dumping works as expected. // // AUTOUPDATE // TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/driver/testdata/compile/raw_ir.carbon +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/basics/raw_sem_ir/one_file.carbon // TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/driver/testdata/compile/raw_ir.carbon +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/basics/raw_sem_ir/one_file.carbon fn Foo[T:! type](n: T) -> (T, ()) { return (n, ()); } // CHECK:STDOUT: --- -// CHECK:STDOUT: filename: raw_ir.carbon +// CHECK:STDOUT: filename: one_file.carbon // CHECK:STDOUT: sem_ir: // CHECK:STDOUT: import_irs: // CHECK:STDOUT: ir0: {decl_id: inst, is_export: false} diff --git a/toolchain/driver/testdata/compile/raw_and_textual_ir.carbon b/toolchain/check/testdata/basics/raw_sem_ir/one_file_with_textual_ir.carbon similarity index 97% rename from toolchain/driver/testdata/compile/raw_and_textual_ir.carbon rename to toolchain/check/testdata/basics/raw_sem_ir/one_file_with_textual_ir.carbon index d20811ab9187..408c1877e26d 100644 --- a/toolchain/driver/testdata/compile/raw_and_textual_ir.carbon +++ b/toolchain/check/testdata/basics/raw_sem_ir/one_file_with_textual_ir.carbon @@ -2,22 +2,22 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // -// ARGS: --include-diagnostic-kind compile --no-prelude-import --phase=check --dump-sem-ir --dump-raw-sem-ir %s +// EXTRA-ARGS: --no-prelude-import --dump-raw-sem-ir --dump-sem-ir-ranges=if-present // // Check that we can combine textual IR and raw IR dumping in one compile. // // AUTOUPDATE // TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/driver/testdata/compile/raw_and_textual_ir.carbon +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/basics/raw_sem_ir/one_file_with_textual_ir.carbon // TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/driver/testdata/compile/raw_and_textual_ir.carbon +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/basics/raw_sem_ir/one_file_with_textual_ir.carbon fn Foo(n: ()) -> ((), ()) { return (n, ()); } // CHECK:STDOUT: --- -// CHECK:STDOUT: filename: raw_and_textual_ir.carbon +// CHECK:STDOUT: filename: one_file_with_textual_ir.carbon // CHECK:STDOUT: sem_ir: // CHECK:STDOUT: import_irs: // CHECK:STDOUT: ir0: {decl_id: inst, is_export: false} @@ -186,7 +186,7 @@ fn Foo(n: ()) -> ((), ()) { // CHECK:STDOUT: 1: inst36 // CHECK:STDOUT: ... // CHECK:STDOUT: -// CHECK:STDOUT: --- raw_and_textual_ir.carbon +// CHECK:STDOUT: --- one_file_with_textual_ir.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] diff --git a/toolchain/codegen/testdata/assembly/basic.carbon b/toolchain/codegen/testdata/assembly/basic.carbon index dfcb97b1d94b..2dec686a916e 100644 --- a/toolchain/codegen/testdata/assembly/basic.carbon +++ b/toolchain/codegen/testdata/assembly/basic.carbon @@ -2,7 +2,7 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // -// ARGS: --include-diagnostic-kind compile --no-prelude-import --target=x86_64-unknown-linux-gnu --output=- %s +// EXTRA-ARGS: --no-prelude-import --target=x86_64-unknown-linux-gnu --output=- // // To test this file alone, run: // bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/codegen/testdata/assembly/basic.carbon diff --git a/toolchain/codegen/testdata/fail_target_triple.carbon b/toolchain/codegen/testdata/fail_target_triple.carbon index ff044f846fa3..34579e1d62b9 100644 --- a/toolchain/codegen/testdata/fail_target_triple.carbon +++ b/toolchain/codegen/testdata/fail_target_triple.carbon @@ -2,7 +2,8 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // -// ARGS: --include-diagnostic-kind compile --no-prelude-import --target=x86_687-unknown-linux-gnu --output=- %s +// EXTRA-ARGS: --no-prelude-import --target=x86_687-unknown-linux-gnu --output=- +// // No autoupdate because the message comes from LLVM. // To test this file alone, run: // bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/codegen/testdata/fail_target_triple.carbon diff --git a/toolchain/codegen/testdata/objcode/basic.carbon b/toolchain/codegen/testdata/objcode/basic.carbon index b1a44b03efe3..78f5e85a4dc1 100644 --- a/toolchain/codegen/testdata/objcode/basic.carbon +++ b/toolchain/codegen/testdata/objcode/basic.carbon @@ -2,7 +2,7 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // -// ARGS: --include-diagnostic-kind compile --no-prelude-import --target=x86_64-unknown-linux-gnu --output=%t %s +// EXTRA-ARGS: --no-prelude-import --target=x86_64-unknown-linux-gnu --output=%t // // TODO: Add a way to write some basic tests for object file outputs. // AUTOUPDATE diff --git a/toolchain/diagnostics/BUILD b/toolchain/diagnostics/BUILD index 77f0f5b05483..bb57e5672437 100644 --- a/toolchain/diagnostics/BUILD +++ b/toolchain/diagnostics/BUILD @@ -7,11 +7,6 @@ load("//bazel/manifest:defs.bzl", "manifest") package(default_visibility = ["//visibility:public"]) -filegroup( - name = "testdata", - srcs = glob(["testdata/**/*.carbon"]), -) - cc_library( name = "diagnostic_emitter", srcs = [ diff --git a/toolchain/diagnostics/testdata/fail_multiline_token.carbon b/toolchain/diagnostics/testdata/fail_multiline_token.carbon deleted file mode 100644 index c01a736e1602..000000000000 --- a/toolchain/diagnostics/testdata/fail_multiline_token.carbon +++ /dev/null @@ -1,19 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// ARGS: --include-diagnostic-kind compile --phase=parse %s -// -// AUTOUPDATE -// TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/diagnostics/testdata/fail_multiline_token.carbon -// TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/diagnostics/testdata/fail_multiline_token.carbon - -// CHECK:STDERR: fail_multiline_token.carbon:[[@LINE+4]]:1: error: unrecognized declaration introducer [UnrecognizedDecl] -// CHECK:STDERR: ''' -// CHECK:STDERR: ^~~ -// CHECK:STDERR: -''' -hello -''' diff --git a/toolchain/driver/testdata/compile/textual_ir.carbon b/toolchain/driver/testdata/compile/textual_ir.carbon deleted file mode 100644 index e34fd0634bed..000000000000 --- a/toolchain/driver/testdata/compile/textual_ir.carbon +++ /dev/null @@ -1,74 +0,0 @@ -// Part of the Carbon Language project, under the Apache License v2.0 with LLVM -// Exceptions. See /LICENSE for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// ARGS: --include-diagnostic-kind compile --no-prelude-import --phase=check --dump-sem-ir %s -// -// Check that the command-line flag to dump textual IR works. -// -// AUTOUPDATE -// TIP: To test this file alone, run: -// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/driver/testdata/compile/textual_ir.carbon -// TIP: To dump output, run: -// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/driver/testdata/compile/textual_ir.carbon - -fn Foo(n: ()) -> ((), ()) { - return (n, ()); -} - -// CHECK:STDOUT: --- textual_ir.carbon -// CHECK:STDOUT: -// CHECK:STDOUT: constants { -// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] -// CHECK:STDOUT: %pattern_type.cb1: type = pattern_type %empty_tuple.type [concrete] -// CHECK:STDOUT: %tuple.type: type = tuple_type (%empty_tuple.type, %empty_tuple.type) [concrete] -// CHECK:STDOUT: %pattern_type.5b8: type = pattern_type %tuple.type [concrete] -// CHECK:STDOUT: %Foo.type: type = fn_type @Foo [concrete] -// CHECK:STDOUT: %Foo: %Foo.type = struct_value () [concrete] -// CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete] -// CHECK:STDOUT: %tuple: %tuple.type = tuple_value (%empty_tuple, %empty_tuple) [concrete] -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: file { -// CHECK:STDOUT: package: = namespace [concrete] { -// CHECK:STDOUT: .Foo = %Foo.decl -// CHECK:STDOUT: } -// CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [concrete = constants.%Foo] { -// CHECK:STDOUT: %n.patt: %pattern_type.cb1 = binding_pattern n [concrete] -// CHECK:STDOUT: %n.param_patt: %pattern_type.cb1 = value_param_pattern %n.patt, call_param0 [concrete] -// CHECK:STDOUT: %return.patt: %pattern_type.5b8 = return_slot_pattern [concrete] -// CHECK:STDOUT: %return.param_patt: %pattern_type.5b8 = out_param_pattern %return.patt, call_param1 [concrete] -// CHECK:STDOUT: } { -// CHECK:STDOUT: %.loc15_20: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %.loc15_24: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %.loc15_25.1: %tuple.type = tuple_literal (%.loc15_20, %.loc15_24) -// CHECK:STDOUT: %.loc15_25.2: type = converted %.loc15_20, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] -// CHECK:STDOUT: %.loc15_25.3: type = converted %.loc15_24, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] -// CHECK:STDOUT: %.loc15_25.4: type = converted %.loc15_25.1, constants.%tuple.type [concrete = constants.%tuple.type] -// CHECK:STDOUT: %n.param: %empty_tuple.type = value_param call_param0 -// CHECK:STDOUT: %.loc15_12.1: type = splice_block %.loc15_12.3 [concrete = constants.%empty_tuple.type] { -// CHECK:STDOUT: %.loc15_12.2: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %.loc15_12.3: type = converted %.loc15_12.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type] -// CHECK:STDOUT: } -// CHECK:STDOUT: %n: %empty_tuple.type = bind_name n, %n.param -// CHECK:STDOUT: %return.param: ref %tuple.type = out_param call_param1 -// CHECK:STDOUT: %return: ref %tuple.type = return_slot %return.param -// CHECK:STDOUT: } -// CHECK:STDOUT: } -// CHECK:STDOUT: -// CHECK:STDOUT: fn @Foo(%n.param: %empty_tuple.type) -> %return.param: %tuple.type { -// CHECK:STDOUT: !entry: -// CHECK:STDOUT: %n.ref: %empty_tuple.type = name_ref n, %n -// CHECK:STDOUT: %.loc16_15.1: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %.loc16_16.1: %tuple.type = tuple_literal (%n.ref, %.loc16_15.1) -// CHECK:STDOUT: %tuple.elem0: ref %empty_tuple.type = tuple_access %return, element0 -// CHECK:STDOUT: %.loc16_11: init %empty_tuple.type = tuple_init () to %tuple.elem0 [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc16_16.2: init %empty_tuple.type = converted %n.ref, %.loc16_11 [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %tuple.elem1: ref %empty_tuple.type = tuple_access %return, element1 -// CHECK:STDOUT: %.loc16_15.2: init %empty_tuple.type = tuple_init () to %tuple.elem1 [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc16_16.3: init %empty_tuple.type = converted %.loc16_15.1, %.loc16_15.2 [concrete = constants.%empty_tuple] -// CHECK:STDOUT: %.loc16_16.4: init %tuple.type = tuple_init (%.loc16_16.2, %.loc16_16.3) to %return [concrete = constants.%tuple] -// CHECK:STDOUT: %.loc16_17: init %tuple.type = converted %.loc16_16.1, %.loc16_16.4 [concrete = constants.%tuple] -// CHECK:STDOUT: return %.loc16_17 to %return -// CHECK:STDOUT: } -// CHECK:STDOUT: diff --git a/toolchain/driver/testdata/dump_mem_usage.carbon b/toolchain/driver/testdata/dump_mem_usage.carbon index ef580bc91b04..caf71a21d05c 100644 --- a/toolchain/driver/testdata/dump_mem_usage.carbon +++ b/toolchain/driver/testdata/dump_mem_usage.carbon @@ -2,7 +2,7 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // -// ARGS: --include-diagnostic-kind compile --phase=check --dump-mem-usage %s +// ARGS: compile --phase=check --dump-mem-usage %s // // To test this file alone, run: // bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/driver/testdata/dump_mem_usage.carbon diff --git a/toolchain/driver/testdata/dump_shared_values.carbon b/toolchain/driver/testdata/dump_shared_values.carbon index aa8b8062a533..e13e938ed4b8 100644 --- a/toolchain/driver/testdata/dump_shared_values.carbon +++ b/toolchain/driver/testdata/dump_shared_values.carbon @@ -2,7 +2,7 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // -// ARGS: --include-diagnostic-kind compile --phase=lex --dump-shared-values %s +// ARGS: compile --phase=lex --dump-shared-values %s // // AUTOUPDATE // TIP: To test this file alone, run: diff --git a/toolchain/driver/testdata/dump_timings.carbon b/toolchain/driver/testdata/dump_timings.carbon index d0d4d31afea7..8c4ce718d88e 100644 --- a/toolchain/driver/testdata/dump_timings.carbon +++ b/toolchain/driver/testdata/dump_timings.carbon @@ -2,7 +2,7 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // -// ARGS: --include-diagnostic-kind compile --dump-timings --phase=check %s +// ARGS: compile --phase=check --dump-timings %s // // SET-CHECK-SUBSET // diff --git a/toolchain/driver/testdata/fail_flush_errors.carbon b/toolchain/driver/testdata/fail_flush_errors.carbon index c45a25622e26..83c63427d5de 100644 --- a/toolchain/driver/testdata/fail_flush_errors.carbon +++ b/toolchain/driver/testdata/fail_flush_errors.carbon @@ -2,8 +2,10 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // -// INCLUDE-FILE: toolchain/testing/min_prelude/destroy.carbon -// ARGS: --include-diagnostic-kind compile --custom-core %s +// This test is validating that the delayed error flush doesn't break on string +// lifetimes. +// +// ARGS: --include-diagnostic-kind compile --no-prelude-import %s // // AUTOUPDATE // TIP: To test this file alone, run: diff --git a/toolchain/driver/testdata/fail_missing_stdin_output.carbon b/toolchain/driver/testdata/fail_missing_stdin_output.carbon index b94a73a67f2a..6adb4f0cc2e0 100644 --- a/toolchain/driver/testdata/fail_missing_stdin_output.carbon +++ b/toolchain/driver/testdata/fail_missing_stdin_output.carbon @@ -2,7 +2,7 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // -// ARGS: --include-diagnostic-kind compile --no-prelude-import - +// ARGS: --include-diagnostic-kind compile - // // AUTOUPDATE // TIP: To test this file alone, run: diff --git a/toolchain/driver/testdata/stdin.carbon b/toolchain/driver/testdata/stdin.carbon index 348dd35a68ca..35a7e40a8ece 100644 --- a/toolchain/driver/testdata/stdin.carbon +++ b/toolchain/driver/testdata/stdin.carbon @@ -2,7 +2,11 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // -// ARGS: --include-diagnostic-kind compile - --no-prelude-import --phase=check --dump-sem-ir +// This is checking that the stdin filename is handled consistently across +// dump flags. +// TODO: Align lex/parse with check/lower. +// +// ARGS: compile - --phase=lower --no-prelude-import --target=x86_64-linux-gnu --dump-tokens --dump-parse-tree --dump-sem-ir --dump-raw-sem-ir --dump-llvm-ir // // AUTOUPDATE // TIP: To test this file alone, run: @@ -10,9 +14,65 @@ // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/driver/testdata/stdin.carbon +// CHECK:STDOUT: - filename: +// CHECK:STDOUT: tokens: +// CHECK:STDOUT: - { index: 0, kind: "FileStart", line: 1, column: 1, indent: 1, spelling: "" } +// CHECK:STDOUT: - { index: 1, kind: "FileEnd", line: 1, column: 1, indent: 1, spelling: "", has_leading_space: true } +// CHECK:STDOUT: - filename: +// CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, +// CHECK:STDOUT: {kind: 'FileEnd', text: ''}, +// CHECK:STDOUT: ] +// CHECK:STDOUT: --- +// CHECK:STDOUT: filename: '-' +// CHECK:STDOUT: sem_ir: +// CHECK:STDOUT: import_irs: +// CHECK:STDOUT: ir0: {decl_id: inst, is_export: false} +// CHECK:STDOUT: ir1: {decl_id: inst, is_export: false} +// CHECK:STDOUT: import_ir_insts: {} +// CHECK:STDOUT: name_scopes: +// CHECK:STDOUT: name_scope0: {inst: inst14, parent_scope: name_scope, has_error: false, extended_scopes: [], names: {}} +// CHECK:STDOUT: entity_names: {} +// CHECK:STDOUT: functions: {} +// CHECK:STDOUT: classes: {} +// CHECK:STDOUT: generics: {} +// CHECK:STDOUT: specifics: {} +// CHECK:STDOUT: struct_type_fields: +// CHECK:STDOUT: struct_type_fields0: {} +// CHECK:STDOUT: types: +// CHECK:STDOUT: 'type(TypeType)': +// CHECK:STDOUT: value_repr: {kind: copy, type: type(TypeType)} +// CHECK:STDOUT: 'type(Error)': +// CHECK:STDOUT: value_repr: {kind: copy, type: type(Error)} +// CHECK:STDOUT: 'type(inst(NamespaceType))': +// CHECK:STDOUT: value_repr: {kind: copy, type: type(inst(NamespaceType))} +// CHECK:STDOUT: insts: +// CHECK:STDOUT: inst14: {kind: Namespace, arg0: name_scope0, arg1: inst, type: type(inst(NamespaceType))} +// CHECK:STDOUT: constant_values: +// CHECK:STDOUT: inst14: concrete_constant(inst14) +// CHECK:STDOUT: symbolic_constants: {} +// CHECK:STDOUT: inst_blocks: +// CHECK:STDOUT: inst_block_empty: {} +// CHECK:STDOUT: exports: {} +// CHECK:STDOUT: import_refs: {} +// CHECK:STDOUT: global_init: {} +// CHECK:STDOUT: inst_block4: +// CHECK:STDOUT: 0: inst14 +// CHECK:STDOUT: ... +// CHECK:STDOUT: // CHECK:STDOUT: --- - // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [concrete] {} // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: ; ModuleID = '-' +// CHECK:STDOUT: source_filename = "-" +// CHECK:STDOUT: +// CHECK:STDOUT: !llvm.module.flags = !{!0, !1} +// CHECK:STDOUT: !llvm.dbg.cu = !{!2} +// CHECK:STDOUT: +// CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5} +// CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3} +// CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) +// CHECK:STDOUT: !3 = !DIFile(filename: "-", directory: "") diff --git a/toolchain/lower/testdata/debug/nodebug.carbon b/toolchain/lower/testdata/debug/nodebug.carbon index 7e9cb7f67894..399927374ee2 100644 --- a/toolchain/lower/testdata/debug/nodebug.carbon +++ b/toolchain/lower/testdata/debug/nodebug.carbon @@ -2,7 +2,7 @@ // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // -// ARGS: --include-diagnostic-kind compile --no-debug-info --phase=lower --dump-llvm-ir --output=- --exclude-dump-file-prefix=%{core_package_dir} %s +// EXTRA-ARGS: --no-debug-info // // AUTOUPDATE // TIP: To test this file alone, run: diff --git a/toolchain/parse/testdata/basics/multiline_token.carbon b/toolchain/parse/testdata/basics/multiline_token.carbon new file mode 100644 index 000000000000..1283e7caba06 --- /dev/null +++ b/toolchain/parse/testdata/basics/multiline_token.carbon @@ -0,0 +1,33 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// This is validating that the multi-line token's hint prints correctly. +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/basics/multiline_token.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/basics/multiline_token.carbon + +// --- fail_multiline_token.carbon + +// CHECK:STDERR: fail_multiline_token.carbon:[[@LINE+4]]:1: error: unrecognized declaration introducer [UnrecognizedDecl] +// CHECK:STDERR: ''' +// CHECK:STDERR: ^~~ +// CHECK:STDERR: +''' +hello +''' + +// CHECK:STDOUT: - filename: fail_multiline_token.carbon +// CHECK:STDOUT: parse_tree: [ +// CHECK:STDOUT: {kind: 'FileStart', text: ''}, +// CHECK:STDOUT: {kind: 'InvalidParseStart', text: '''' +// CHECK:STDOUT: hello +// CHECK:STDOUT: '''', has_error: yes}, +// CHECK:STDOUT: {kind: 'InvalidParseSubtree', text: '''' +// CHECK:STDOUT: hello +// CHECK:STDOUT: '''', has_error: yes, subtree_size: 2}, +// CHECK:STDOUT: {kind: 'FileEnd', text: ''}, +// CHECK:STDOUT: ] diff --git a/toolchain/testing/BUILD b/toolchain/testing/BUILD index a6f50efae75e..9071ea98e017 100644 --- a/toolchain/testing/BUILD +++ b/toolchain/testing/BUILD @@ -12,7 +12,6 @@ filegroup( srcs = [ "//toolchain/check:testdata", "//toolchain/codegen:testdata", - "//toolchain/diagnostics:testdata", "//toolchain/driver:testdata", "//toolchain/format:testdata", "//toolchain/language_server:testdata", diff --git a/toolchain/testing/file_test.cpp b/toolchain/testing/file_test.cpp index 7a5fbed1e8a4..a18efc49cd99 100644 --- a/toolchain/testing/file_test.cpp +++ b/toolchain/testing/file_test.cpp @@ -195,6 +195,8 @@ auto ToolchainFileTest::GetDefaultArgs() const args.insert(args.end(), {"--dump-sem-ir", "--dump-sem-ir-ranges=only"}); } else if (component_ == "lower") { args.insert(args.end(), {"--dump-llvm-ir", "--target=x86_64-linux-gnu"}); + } else if (component_ == "codegen") { + // codegen tests specify flags as needed. } else { CARBON_FATAL("Unexpected test component {0}: {1}", component_, test_name()); }