Skip to content

Commit 29e9502

Browse files
committed
Fix flaky Driver tests
Several Driver tests create a hard link to the compiler in a temporary directory, then invoke it thorugh that hard link to see how it locates items in the resource directory. This pattern can tickle a system-load-dependent macOS bug involving invocations of freshly-created hard links, causing rare test failures in CI or on contributors’ machines. This change avoids the OS bug by always copying instead of hard linking. We already fall back to copying on Windows, so all tests should pass with a copy anyway. Removing this workaround will be tracked by rdar://problem/53507844.
1 parent b368b0d commit 29e9502

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

test/lit.cfg

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,9 +1422,17 @@ if hasattr(config, 'target_cc_options'):
14221422
else:
14231423
config.substitutions.append(('%target-cc-options', ''))
14241424

1425-
config.substitutions.append(
1426-
(r'%hardlink-or-copy\(from: *(.*), *to: *(.*)\)',
1427-
SubstituteCaptures(r'ln \1 \2 || cp \1 \2')))
1425+
# WORKAROUND(rdar://53507844): On some macOS versions, we see flaky failures in
1426+
# tests which create a hard link to an executable and immediately invoke it.
1427+
# Work around this by always copying on Darwin.
1428+
if platform.system() == 'Darwin':
1429+
config.substitutions.append(
1430+
(r'%hardlink-or-copy\(from: *(.*), *to: *(.*)\)',
1431+
SubstituteCaptures(r'cp \1 \2')))
1432+
else:
1433+
config.substitutions.append(
1434+
(r'%hardlink-or-copy\(from: *(.*), *to: *(.*)\)',
1435+
SubstituteCaptures(r'ln \1 \2 || cp \1 \2')))
14281436

14291437
config.substitutions.append(('%utils', config.swift_utils))
14301438
config.substitutions.append(('%line-directive', '%r %s' % (sys.executable, config.line_directive)))

0 commit comments

Comments
 (0)