Files
sourcekit-lsp/Sources/SKTestSupport/String+writeWithRetry.swift
Alex Hoppen 3528e52bcb Add delay before writing file to disk in tests
Depending on the system, mtime resolution might not be perfectly accurate. Particularly containers appear to have imprecise mtimes.
Wait a short time period before writing the new file to avoid situations like the following:
 - We index a source file and the unit receives a time stamp and wait for indexing to finish
 - We modify the source file but so quickly after the unit has been modified that the updated source file
   receives the same mtime as the unit file
 - We now assume that the we have an up-to-date index for this source file even though we do not.

Waiting 10ms appears to be enough to avoid this situation on the systems we care about.

rdar://147811044
2025-03-25 18:59:01 -07:00

2.4 KiB