Debian Codegraph @

llvm/utils/lit/tests/Inputs/max-retries-per-test/allow-retries-test_retry_attempts/test.py

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