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