Skip to content

Commit 8bc46a6

Browse files
committed
[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.
1 parent e8a9286 commit 8bc46a6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

test/lit.cfg

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,10 @@ kIsAndroid = 'ANDROID_DATA' in os.environ
186186

187187
# Choose between lit's internal shell pipeline runner and a real shell. If
188188
# LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override.
189-
use_lit_shell = os.environ.get('LIT_USE_INTERNAL_SHELL', kIsWindows)
189+
use_lit_shell = os.environ.get('LIT_USE_INTERNAL_SHELL', kIsWindows or lit_config.update_tests)
190190
if not use_lit_shell:
191+
if lit_config.update_tests:
192+
lit_config.fatal('--update-tests cannot be combined with LIT_USE_INTERNAL_SHELL=0')
191193
config.available_features.add('shell')
192194

193195
config.test_format = swift_test.SwiftTest(coverage_mode=config.coverage_mode,

utils/run-test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ def main():
160160
parser.add_argument("--unified", action="store_true",
161161
help="The build directory is an unified LLVM build, "
162162
"not a standalone Swift build")
163+
parser.add_argument("--update-tests", action="store_true",
164+
help="Invoke lit with --update-tests to auto-repair failing tests "
165+
"(when possible)")
163166

164167
args = parser.parse_args()
165168

@@ -280,6 +283,9 @@ def main():
280283
if args.filter:
281284
test_args += ['--filter', args.filter]
282285

286+
if args.update_tests:
287+
test_args.append('--update-tests')
288+
283289
test_cmd = [sys.executable, args.lit] + test_args + paths
284290

285291
# Do execute test

0 commit comments

Comments
 (0)