summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/slang-test/slang-test-main.cpp36
1 files changed, 33 insertions, 3 deletions
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp
index 36e79659f..0095a5867 100644
--- a/tools/slang-test/slang-test-main.cpp
+++ b/tools/slang-test/slang-test-main.cpp
@@ -557,13 +557,43 @@ static SlangResult _gatherTestsForFile(
String fileContents;
- SlangResult readResult = Slang::File::readAllText(filePath, fileContents);
+ TestReporter* testReporter = nullptr;
+ if (context)
+ testReporter = context->getTestReporter();
+
+ // Try reading the file with retries on failure to handle intermittent I/O errors
+ // (commonly seen on macOS in CI environments)
+ SlangResult readResult = SLANG_FAIL;
+ for (int retryCount = 0; retryCount < 3 && SLANG_FAILED(readResult); ++retryCount)
+ {
+ if (retryCount)
+ {
+ if (testReporter)
+ {
+ testReporter->messageFormat(
+ TestMessageType::Info,
+ "Retrying to read test file '%s' (attempt %d)",
+ filePath.getBuffer(),
+ retryCount + 1);
+ }
+ else
+ {
+ fprintf(
+ stderr,
+ "Retrying to read test file '%s' (attempt %d)\n",
+ filePath.getBuffer(),
+ retryCount + 1);
+ }
+ std::this_thread::sleep_for(std::chrono::milliseconds(retryCount * 100));
+ }
+ readResult = Slang::File::readAllText(filePath, fileContents);
+ }
if (SLANG_FAILED(readResult))
{
// Log file reading failure with details (thread-safe)
- if (context && context->getTestReporter())
+ if (testReporter)
{
- context->getTestReporter()->messageFormat(
+ testReporter->messageFormat(
TestMessageType::RunError,
"Failed to read test file '%s' (error: 0x%08X)",
filePath.getBuffer(),