Skip to content

Commit 214598d

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 ff8c6e2 commit 214598d

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
@@ -1553,9 +1553,17 @@ if hasattr(config, 'target_cc_options'):
15531553
else:
15541554
config.substitutions.append(('%target-cc-options', ''))
15551555

1556-
config.substitutions.append(
1557-
(r'%hardlink-or-copy\(from: *(.*), *to: *(.*)\)',
1558-
SubstituteCaptures(r'ln \1 \2 || cp \1 \2')))
1556+
# WORKAROUND(rdar://53507844): On some macOS versions, we see flaky failures in
1557+
# tests which create a hard link to an executable and immediately invoke it.
1558+
# Work around this by always copying on Darwin.
1559+
if platform.system() == 'Darwin':
1560+
config.substitutions.append(
1561+
(r'%hardlink-or-copy\(from: *(.*), *to: *(.*)\)',
1562+
SubstituteCaptures(r'cp \1 \2')))
1563+
else:
1564+
config.substitutions.append(
1565+
(r'%hardlink-or-copy\(from: *(.*), *to: *(.*)\)',
1566+
SubstituteCaptures(r'ln \1 \2 || cp \1 \2')))
15591567

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

0 commit comments

Comments
 (0)