xref: /llvm-project/llvm/utils/lit/tests/allow-retries.py (revision f223022a4c521296a6d058862d66443ab9e355bf)
1# Check the behavior of the ALLOW_RETRIES keyword.
2
3# This test uses a file that's stable across retries of the test to fail and
4# only succeed the fourth time it is retried.
5#
6# RUN: rm -f %t.counter
7# RUN: %{lit} %{inputs}/allow-retries/succeeds-within-limit.py -Dcounter=%t.counter -Dpython=%{python} | FileCheck --check-prefix=CHECK-TEST1 %s
8# CHECK-TEST1: Passed With Retry: 1
9
10# Test that a per-file ALLOW_RETRIES overwrites the config-wide test_retry_attempts property, if any.
11#
12# RUN: rm -f %t.counter
13# RUN: %{lit} %{inputs}/allow-retries/succeeds-within-limit.py -Dtest_retry_attempts=2 -Dcounter=%t.counter -Dpython=%{python} | FileCheck --check-prefix=CHECK-TEST2 %s
14# CHECK-TEST2: Passed With Retry: 1
15
16# This test does not succeed within the allowed retry limit
17#
18# Check that the execution trace isn't corrupt due to reprocessing the script
19# multiple times (e.g., '%dbg(...)' processing used to accumulate across
20# retries).
21#
22# RUN: not %{lit} %{inputs}/allow-retries/does-not-succeed-within-limit.py -v |\
23# RUN:   FileCheck --check-prefix=CHECK-TEST3 -match-full-lines %s
24#
25#       CHECK-TEST3: FAIL: allow-retries :: does-not-succeed-within-limit.py (1 of 1)
26#  CHECK-TEST3-NEXT: {{\**}} TEST 'allow-retries :: does-not-succeed-within-limit.py' FAILED {{\**}}
27#  CHECK-TEST3-NEXT: Exit Code: 1
28# CHECK-TEST3-EMPTY:
29#  CHECK-TEST3-NEXT: Command Output (stdout):
30#  CHECK-TEST3-NEXT: --
31#  CHECK-TEST3-NEXT: # {{RUN}}: at line 3
32#  CHECK-TEST3-NEXT: false
33#  CHECK-TEST3-NEXT: # executed command: false
34#  CHECK-TEST3-NEXT: # note: command had no output on stdout or stderr
35#  CHECK-TEST3-NEXT: # error: command failed with exit status: 1
36# CHECK-TEST3-EMPTY:
37#  CHECK-TEST3-NEXT: --
38#       CHECK-TEST3: Failed Tests (1):
39#       CHECK-TEST3: allow-retries :: does-not-succeed-within-limit.py
40
41# This test should be UNRESOLVED since it has more than one ALLOW_RETRIES
42# lines, and that is not allowed.
43#
44# RUN: not %{lit} %{inputs}/allow-retries/more-than-one-allow-retries-lines.py | FileCheck --check-prefix=CHECK-TEST4 %s
45# CHECK-TEST4: Unresolved Tests (1):
46# CHECK-TEST4: allow-retries :: more-than-one-allow-retries-lines.py
47
48# This test does not provide a valid integer to the ALLOW_RETRIES keyword.
49# It should be unresolved.
50#
51# RUN: not %{lit} %{inputs}/allow-retries/not-a-valid-integer.py | FileCheck --check-prefix=CHECK-TEST5 %s
52# CHECK-TEST5: Unresolved Tests (1):
53# CHECK-TEST5: allow-retries :: not-a-valid-integer.py
54
55# This test checks that the config-wide test_retry_attempts property is used
56# when no ALLOW_RETRIES keyword is present.
57#
58# RUN: rm -f %t.counter
59# RUN: %{lit} %{inputs}/test_retry_attempts/test.py -Dcounter=%t.counter -Dpython=%{python} | FileCheck --check-prefix=CHECK-TEST6 %s
60# CHECK-TEST6: Passed With Retry: 1
61
62# This test checks that --per-test-coverage doesn't accumulate inserted
63# LLVM_PROFILE_FILE= commands across retries.
64#
65# RUN: rm -f %t.counter
66# RUN: %{lit} -a %{inputs}/test_retry_attempts/test.py --per-test-coverage\
67# RUN:     -Dcounter=%t.counter -Dpython=%{python} | \
68# RUN:   FileCheck --check-prefix=CHECK-TEST7 %s
69#     CHECK-TEST7: Command Output (stdout):
70#     CHECK-TEST7: # executed command: export LLVM_PROFILE_FILE=
71# CHECK-TEST7-NOT: # executed command: export LLVM_PROFILE_FILE=
72#     CHECK-TEST7: Passed With Retry: 1
73