[Utils] Add support for lit's --update-tests to run-test

This flag checks for known test patterns in failed tests, and tries to
automatically update the test to pass.
This commit is contained in:
Henrik G. Olsson
2025-09-05 20:43:40 -07:00
parent e8a9286c4a
commit 8bc46a6a62
2 changed files with 9 additions and 1 deletions

View File

@@ -186,8 +186,10 @@ kIsAndroid = 'ANDROID_DATA' in os.environ
# Choose between lit's internal shell pipeline runner and a real shell. If
# LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override.
use_lit_shell = os.environ.get('LIT_USE_INTERNAL_SHELL', kIsWindows)
use_lit_shell = os.environ.get('LIT_USE_INTERNAL_SHELL', kIsWindows or lit_config.update_tests)
if not use_lit_shell:
if lit_config.update_tests:
lit_config.fatal('--update-tests cannot be combined with LIT_USE_INTERNAL_SHELL=0')
config.available_features.add('shell')
config.test_format = swift_test.SwiftTest(coverage_mode=config.coverage_mode,

View File

@@ -160,6 +160,9 @@ def main():
parser.add_argument("--unified", action="store_true",
help="The build directory is an unified LLVM build, "
"not a standalone Swift build")
parser.add_argument("--update-tests", action="store_true",
help="Invoke lit with --update-tests to auto-repair failing tests "
"(when possible)")
args = parser.parse_args()
@@ -280,6 +283,9 @@ def main():
if args.filter:
test_args += ['--filter', args.filter]
if args.update_tests:
test_args.append('--update-tests')
test_cmd = [sys.executable, args.lit] + test_args + paths
# Do execute test