Make the 'library' lines in tests use a substitution. (#4278)

This opens the door for replacing all `library ...` lines in toolchain
test files with `library "[[@TEST_NAME]]";`. That's technically more
typing in a lot of cases, but OTOH means we can just do some copy-paste
boilerplate and stop carefully writing library names.

Also cleans up the test setup, because it's getting messy. I'm trying to
make it easier to see the divisions of tests and the output associated
with them. StringSwitch looked like a way to do this, with a few edits
to make it work nicely.
This commit is contained in:
Jon Ross-Perkins
2024-09-10 20:24:11 +00:00
committed by GitHub
parent 5806d8385d
commit 2e299f5fc4
7 changed files with 341 additions and 128 deletions
+35
View File
@@ -0,0 +1,35 @@
// 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
// AUTOUPDATE
// TIP: To test this file alone, run:
// TIP: bazel test //testing/file_test:file_test_base_test --test_arg=--file_tests=testing/file_test/testdata/replace_split_content.carbon
// TIP: To dump output, run:
// TIP: bazel run //testing/file_test:file_test_base_test -- --dump_output --file_tests=testing/file_test/testdata/replace_split_content.carbon
// CHECK:STDOUT: 6 args: `default_args`, `a.carbon`, `b.impl.carbon`, `todo_c.carbon`, `todo_fail_d.carbon`, `triplicate.carbon`
// --- a.carbon
library "[[@TEST_NAME]]";
// CHECK:STDOUT: a.carbon:[[@LINE-1]]: library "a";
// --- b.impl.carbon
library "[[@TEST_NAME]]";
// CHECK:STDOUT: b.impl.carbon:[[@LINE-1]]: library "b";
// --- todo_c.carbon
library "[[@TEST_NAME]]";
// CHECK:STDOUT: todo_c.carbon:[[@LINE-1]]: library "c";
// --- todo_fail_d.carbon
library "[[@TEST_NAME]]";
// CHECK:STDOUT: todo_fail_d.carbon:[[@LINE-1]]: library "d";
// --- triplicate.carbon
[[@TEST_NAME]][[@TEST_NAME]][[@TEST_NAME]]
// CHECK:STDOUT: triplicate.carbon:[[@LINE-1]]: triplicatetriplicatetriplicate