Mark sets the current test as a flaky test, such that if it fails, it will be retried a few times on failure. issue must be a GitHub issue that tracks the status of the flaky test being marked, of the format: https://github.com/tailscale/myRepo-H3re/issues/12345
(t testing.TB, issue string)
| 46 | // |
| 47 | // https://github.com/tailscale/myRepo-H3re/issues/12345 |
| 48 | func Mark(t testing.TB, issue string) { |
| 49 | if !issueRegexp.MatchString(issue) { |
| 50 | t.Fatalf("bad issue format: %q", issue) |
| 51 | } |
| 52 | if _, ok := os.LookupEnv(FlakeAttemptEnv); ok { |
| 53 | // We're being run under cmd/testwrapper so send our sentinel message |
| 54 | // to stderr. (We avoid doing this when the env is absent to avoid |
| 55 | // spamming people running tests without the wrapper) |
| 56 | fmt.Fprintf(os.Stderr, "%s: %s\n", FlakyTestLogMessage, issue) |
| 57 | } |
| 58 | t.Attr("flaky-test-issue-url", issue) |
| 59 | |
| 60 | // The Attr method above also emits human-readable output, so this t.Logf |
| 61 | // is somewhat redundant, but we keep it for compatibility with |
| 62 | // old test runs, so cmd/testwrapper doesn't need to be modified. |
| 63 | // TODO(bradfitz): switch testwrapper to look for Action "attr" |
| 64 | // instead: |
| 65 | // "Action":"attr","Package":"tailscale.com/cmd/testwrapper/flakytest","Test":"TestMarked_Root","Key":"flaky-test-issue-url","Value":"https://github.com/tailscale/tailscale/issues/0"} |
| 66 | // And then remove this Logf a month or so after that. |
| 67 | t.Logf("flakytest: issue tracking this flaky test: %s", issue) |
| 68 | |
| 69 | if boolEnv("TS_SKIP_FLAKY_TESTS") { |
| 70 | t.Skipf("skipping due to TS_SKIP_FLAKY_TESTS") |
| 71 | } |
| 72 | |
| 73 | // Record the root test name as flakey. |
| 74 | rootFlakesMu.Lock() |
| 75 | defer rootFlakesMu.Unlock() |
| 76 | mak.Set(&rootFlakes, t.Name(), true) |
| 77 | } |
| 78 | |
| 79 | // Marked reports whether the current test or one of its parents was marked flaky. |
| 80 | func Marked(t testing.TB) bool { |
searching dependent graphs…