MCPcopy
hub / github.com/tailscale/tailscale / Mark

Function Mark

cmd/testwrapper/flakytest/flakytest.go:48–77  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

46//
47// https://github.com/tailscale/myRepo-H3re/issues/12345
48func 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.
80func Marked(t testing.TB) bool {

Callers 13

TestLoopbackLocalAPIFunction · 0.92
TestLoopbackSOCKS5Function · 0.92
TestContainerBootFunction · 0.92
TestDownloadFunction · 0.92
TestNodeAddressIPFieldsFunction · 0.92
TestClientSideJailingFunction · 0.92
TestNATPingFunction · 0.92
TestPeerRelayPingFunction · 0.92
TestFlakeRunFunction · 0.85
TestMarked_RootFunction · 0.85

Calls 8

SetFunction · 0.92
boolEnvFunction · 0.85
FatalfMethod · 0.65
LogfMethod · 0.65
SkipfMethod · 0.65
LockMethod · 0.65
UnlockMethod · 0.65
NameMethod · 0.65

Tested by 13

TestLoopbackLocalAPIFunction · 0.74
TestLoopbackSOCKS5Function · 0.74
TestContainerBootFunction · 0.74
TestDownloadFunction · 0.74
TestNodeAddressIPFieldsFunction · 0.74
TestClientSideJailingFunction · 0.74
TestNATPingFunction · 0.74
TestPeerRelayPingFunction · 0.74
TestFlakeRunFunction · 0.68
TestMarked_RootFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…