v2 / vlib / v / tests / retry_test.v
25 lines · 21 sloc · 739 bytes · 2ad5d0cd153c658ae5629b043c9116b6e69726d0
Raw
1import os
2
3// vtest retry: 2
4// vtest hide_retries
5
6// This tests whether the V test runner, can handle retries.
7//
8// The comment above, should make it try re-running the same test,
9// a maximum of 2 times. It will fail for all, but the last retry.
10// This is useful for reducing false positives on the CI, due to
11// flakiness of specific tests like `vlib/v/live/live_test.v` for example.
12
13// Note: this test is supposed to be run with `v test retry_test.v`.
14// Running just `v retry_test.v` WILL fail.
15
16fn test_test_runner_retrying_failing_tests() {
17 n := os.getenv('VTEST_RETRY').int()
18 maxn := os.getenv('VTEST_RETRY_MAX').int()
19 eprintln('> n: ${n} | maxn: ${maxn}')
20 if n > 0 && n == maxn {
21 assert true
22 return
23 }
24 assert false
25}
26