xref: /llvm-project/llvm/utils/lit/tests/Inputs/test_retry_attempts/test.py (revision b71edfaa4ec3c998aadb35255ce2f60bba2940b0)
1# RUN: "%python" "%s" "%counter"
2
3import sys
4import os
5
6counter_file = sys.argv[1]
7
8# The first time the test is run, initialize the counter to 1.
9if not os.path.exists(counter_file):
10    with open(counter_file, "w") as counter:
11        counter.write("1")
12
13# Succeed if this is the fourth time we're being run.
14with open(counter_file, "r") as counter:
15    num = int(counter.read())
16    if num == 4:
17        sys.exit(0)
18
19# Otherwise, increment the counter and fail
20with open(counter_file, "w") as counter:
21    counter.write(str(num + 1))
22    sys.exit(1)
23