Allow autoupdate_testdata.py to update C++ file tests (#8124)

Some driver file tests are C++ files, such as
toolchain/driver/testdata/fail_clang_no_args.cpp, but
autoupdate_testdata.py ignored any file argument that wasn't a .carbon
file.

I tested this manually (since there's no automated test coverage for the
script)
by making a modification to that .cpp file's CHECK before and after this
PR's
change:

Before:
```
[hi on] blaikie@blaikie-cloudtop2:~/dev/carbon$ ./toolchain/autoupdate_testdata.py toolchain/driver/testdata/fail_clang_no_args.cpp
Args do not seem to be test files; for example, toolchain/driver/testdata/fail_clang_no_args.cpp
```
After:
```
[hi on] blaikie@blaikie-cloudtop2:~/dev/carbon$ ./toolchain/autoupdate_testdata.py toolchain/driver/testdata/fail_clang_no_args.cpp
...
TEST: toolchain/driver/testdata/fail_clang_no_args.cpp !
Ran 1 tests in 25 ms wall time, 1 ms across threads
```

This improves the situation for those two .cpp files, and paves the way
for more
top-level C++ test coverage for reverse interop functionality.
This commit is contained in:
David Blaikie authored and GitHub committed 2026-11-11 22:57:11 +00:00
1 parent 86e6f42822
commit e2603996e5
1 file changed
+3 -2
+3 -2
View File
@@ -110,9 +110,10 @@ def main() -> None:
if args.files:
repo_root = Path(__file__).parents[1]
file_tests = []
# Filter down to just test files.
# Filter down to just test files. Most are Carbon files, but some
# driver tests are C++ files.
for f in args.files:
if f.endswith(".carbon"):
if f.endswith((".carbon", ".cpp")):
path = str(Path(f).resolve().relative_to(repo_root))
if path.count("/testdata/"):
file_tests.append(path)