def _evaluate_pass_test(self, test, tmpBase, lit_config):
execDir = os.path.dirname(test.getExecPath())
source_path = test.getSourcePath()
+ with open(source_path, 'r') as f:
+ contents = f.read()
+ is_flaky = 'FLAKY_TEST' in contents
exec_path = tmpBase + '.exe'
object_path = tmpBase + '.o'
# Create the output directory if it does not already exist.
# should add a `// FILE-DEP: foo.dat` to each test to track this.
data_files = [os.path.join(local_cwd, f)
for f in os.listdir(local_cwd) if f.endswith('.dat')]
- cmd, out, err, rc = self.executor.run(exec_path, [exec_path],
- local_cwd, data_files, env)
- if rc != 0:
- report = libcxx.util.makeReport(cmd, out, err, rc)
- report = "Compiled With: %s\n%s" % (compile_cmd, report)
- report += "Compiled test failed unexpectedly!"
- return lit.Test.FAIL, report
- return lit.Test.PASS, ''
+ max_retry = 3 if is_flaky else 1
+ for retry_count in range(max_retry):
+ cmd, out, err, rc = self.executor.run(exec_path, [exec_path],
+ local_cwd, data_files,
+ env)
+ if rc == 0:
+ res = lit.Test.PASS if retry_count == 0 else lit.Test.FLAKYPASS
+ return res, ''
+ elif rc != 0 and retry_count + 1 == max_retry:
+ report = libcxx.util.makeReport(cmd, out, err, rc)
+ report = "Compiled With: %s\n%s" % (compile_cmd, report)
+ report += "Compiled test failed unexpectedly!"
+ return lit.Test.FAIL, report
+
+ assert False # Unreachable
finally:
# Note that cleanup of exec_file happens in `_clean()`. If you
# override this, cleanup is your reponsibility.