mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-22 08:51:41 +00:00
cmd/testwrapper: add pkg runtime to output (#13894)
Some checks are pending
checklocks / checklocks (push) Waiting to run
CodeQL / Analyze (go) (push) Waiting to run
Dockerfile build / deploy (push) Waiting to run
CI / race-root-integration (1/4) (push) Waiting to run
CI / race-root-integration (2/4) (push) Waiting to run
CI / race-root-integration (3/4) (push) Waiting to run
CI / race-root-integration (4/4) (push) Waiting to run
CI / test (-coverprofile=/tmp/coverage.out, amd64) (push) Waiting to run
CI / test (-race, amd64, 1/3) (push) Waiting to run
CI / test (-race, amd64, 2/3) (push) Waiting to run
CI / test (-race, amd64, 3/3) (push) Waiting to run
CI / test (386) (push) Waiting to run
CI / windows (push) Waiting to run
CI / privileged (push) Waiting to run
CI / vm (push) Waiting to run
CI / race-build (push) Waiting to run
CI / go_generate (push) Waiting to run
CI / cross (386, linux) (push) Waiting to run
CI / cross (amd64, darwin) (push) Waiting to run
CI / cross (amd64, freebsd) (push) Waiting to run
CI / cross (amd64, openbsd) (push) Waiting to run
CI / cross (amd64, windows) (push) Waiting to run
CI / cross (arm, 5, linux) (push) Waiting to run
CI / cross (arm, 7, linux) (push) Waiting to run
CI / cross (arm64, darwin) (push) Waiting to run
CI / cross (arm64, linux) (push) Waiting to run
CI / cross (arm64, windows) (push) Waiting to run
CI / cross (loong64, linux) (push) Waiting to run
CI / ios (push) Waiting to run
CI / crossmin (amd64, plan9) (push) Waiting to run
CI / go_mod_tidy (push) Waiting to run
CI / crossmin (ppc64, aix) (push) Waiting to run
CI / android (push) Waiting to run
CI / wasm (push) Waiting to run
CI / tailscale_go (push) Waiting to run
CI / fuzz (push) Waiting to run
CI / depaware (push) Waiting to run
CI / licenses (push) Waiting to run
CI / staticcheck (386, windows) (push) Waiting to run
CI / staticcheck (amd64, darwin) (push) Waiting to run
CI / staticcheck (amd64, linux) (push) Waiting to run
CI / staticcheck (amd64, windows) (push) Waiting to run
CI / notify_slack (push) Blocked by required conditions
CI / check_mergeability (push) Blocked by required conditions
Some checks are pending
checklocks / checklocks (push) Waiting to run
CodeQL / Analyze (go) (push) Waiting to run
Dockerfile build / deploy (push) Waiting to run
CI / race-root-integration (1/4) (push) Waiting to run
CI / race-root-integration (2/4) (push) Waiting to run
CI / race-root-integration (3/4) (push) Waiting to run
CI / race-root-integration (4/4) (push) Waiting to run
CI / test (-coverprofile=/tmp/coverage.out, amd64) (push) Waiting to run
CI / test (-race, amd64, 1/3) (push) Waiting to run
CI / test (-race, amd64, 2/3) (push) Waiting to run
CI / test (-race, amd64, 3/3) (push) Waiting to run
CI / test (386) (push) Waiting to run
CI / windows (push) Waiting to run
CI / privileged (push) Waiting to run
CI / vm (push) Waiting to run
CI / race-build (push) Waiting to run
CI / go_generate (push) Waiting to run
CI / cross (386, linux) (push) Waiting to run
CI / cross (amd64, darwin) (push) Waiting to run
CI / cross (amd64, freebsd) (push) Waiting to run
CI / cross (amd64, openbsd) (push) Waiting to run
CI / cross (amd64, windows) (push) Waiting to run
CI / cross (arm, 5, linux) (push) Waiting to run
CI / cross (arm, 7, linux) (push) Waiting to run
CI / cross (arm64, darwin) (push) Waiting to run
CI / cross (arm64, linux) (push) Waiting to run
CI / cross (arm64, windows) (push) Waiting to run
CI / cross (loong64, linux) (push) Waiting to run
CI / ios (push) Waiting to run
CI / crossmin (amd64, plan9) (push) Waiting to run
CI / go_mod_tidy (push) Waiting to run
CI / crossmin (ppc64, aix) (push) Waiting to run
CI / android (push) Waiting to run
CI / wasm (push) Waiting to run
CI / tailscale_go (push) Waiting to run
CI / fuzz (push) Waiting to run
CI / depaware (push) Waiting to run
CI / licenses (push) Waiting to run
CI / staticcheck (386, windows) (push) Waiting to run
CI / staticcheck (amd64, darwin) (push) Waiting to run
CI / staticcheck (amd64, linux) (push) Waiting to run
CI / staticcheck (amd64, windows) (push) Waiting to run
CI / notify_slack (push) Blocked by required conditions
CI / check_mergeability (push) Blocked by required conditions
Fixes #13893 Signed-off-by: Paul Scott <paul@tailscale.com>
This commit is contained in:
parent
b2665d9b89
commit
212270463b
@ -42,6 +42,7 @@ type testAttempt struct {
|
|||||||
testName string // "TestFoo"
|
testName string // "TestFoo"
|
||||||
outcome string // "pass", "fail", "skip"
|
outcome string // "pass", "fail", "skip"
|
||||||
logs bytes.Buffer
|
logs bytes.Buffer
|
||||||
|
start, end time.Time
|
||||||
isMarkedFlaky bool // set if the test is marked as flaky
|
isMarkedFlaky bool // set if the test is marked as flaky
|
||||||
issueURL string // set if the test is marked as flaky
|
issueURL string // set if the test is marked as flaky
|
||||||
|
|
||||||
@ -132,11 +133,17 @@ func runTests(ctx context.Context, attempt int, pt *packageTests, goTestArgs, te
|
|||||||
}
|
}
|
||||||
pkg := goOutput.Package
|
pkg := goOutput.Package
|
||||||
pkgTests := resultMap[pkg]
|
pkgTests := resultMap[pkg]
|
||||||
|
if pkgTests == nil {
|
||||||
|
pkgTests = make(map[string]*testAttempt)
|
||||||
|
resultMap[pkg] = pkgTests
|
||||||
|
}
|
||||||
if goOutput.Test == "" {
|
if goOutput.Test == "" {
|
||||||
switch goOutput.Action {
|
switch goOutput.Action {
|
||||||
|
case "start":
|
||||||
|
pkgTests[""] = &testAttempt{start: goOutput.Time}
|
||||||
case "fail", "pass", "skip":
|
case "fail", "pass", "skip":
|
||||||
for _, test := range pkgTests {
|
for _, test := range pkgTests {
|
||||||
if test.outcome == "" {
|
if test.testName != "" && test.outcome == "" {
|
||||||
test.outcome = "fail"
|
test.outcome = "fail"
|
||||||
ch <- test
|
ch <- test
|
||||||
}
|
}
|
||||||
@ -144,15 +151,13 @@ func runTests(ctx context.Context, attempt int, pt *packageTests, goTestArgs, te
|
|||||||
ch <- &testAttempt{
|
ch <- &testAttempt{
|
||||||
pkg: goOutput.Package,
|
pkg: goOutput.Package,
|
||||||
outcome: goOutput.Action,
|
outcome: goOutput.Action,
|
||||||
|
start: pkgTests[""].start,
|
||||||
|
end: goOutput.Time,
|
||||||
pkgFinished: true,
|
pkgFinished: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if pkgTests == nil {
|
|
||||||
pkgTests = make(map[string]*testAttempt)
|
|
||||||
resultMap[pkg] = pkgTests
|
|
||||||
}
|
|
||||||
testName := goOutput.Test
|
testName := goOutput.Test
|
||||||
if test, _, isSubtest := strings.Cut(goOutput.Test, "/"); isSubtest {
|
if test, _, isSubtest := strings.Cut(goOutput.Test, "/"); isSubtest {
|
||||||
testName = test
|
testName = test
|
||||||
@ -168,8 +173,10 @@ func runTests(ctx context.Context, attempt int, pt *packageTests, goTestArgs, te
|
|||||||
pkgTests[testName] = &testAttempt{
|
pkgTests[testName] = &testAttempt{
|
||||||
pkg: pkg,
|
pkg: pkg,
|
||||||
testName: testName,
|
testName: testName,
|
||||||
|
start: goOutput.Time,
|
||||||
}
|
}
|
||||||
case "skip", "pass", "fail":
|
case "skip", "pass", "fail":
|
||||||
|
pkgTests[testName].end = goOutput.Time
|
||||||
pkgTests[testName].outcome = goOutput.Action
|
pkgTests[testName].outcome = goOutput.Action
|
||||||
ch <- pkgTests[testName]
|
ch <- pkgTests[testName]
|
||||||
case "output":
|
case "output":
|
||||||
@ -213,7 +220,7 @@ func main() {
|
|||||||
firstRun.tests = append(firstRun.tests, &packageTests{Pattern: pkg})
|
firstRun.tests = append(firstRun.tests, &packageTests{Pattern: pkg})
|
||||||
}
|
}
|
||||||
toRun := []*nextRun{firstRun}
|
toRun := []*nextRun{firstRun}
|
||||||
printPkgOutcome := func(pkg, outcome string, attempt int) {
|
printPkgOutcome := func(pkg, outcome string, attempt int, runtime time.Duration) {
|
||||||
if outcome == "skip" {
|
if outcome == "skip" {
|
||||||
fmt.Printf("?\t%s [skipped/no tests] \n", pkg)
|
fmt.Printf("?\t%s [skipped/no tests] \n", pkg)
|
||||||
return
|
return
|
||||||
@ -225,10 +232,10 @@ func main() {
|
|||||||
outcome = "FAIL"
|
outcome = "FAIL"
|
||||||
}
|
}
|
||||||
if attempt > 1 {
|
if attempt > 1 {
|
||||||
fmt.Printf("%s\t%s [attempt=%d]\n", outcome, pkg, attempt)
|
fmt.Printf("%s\t%s\t%.3fs\t[attempt=%d]\n", outcome, pkg, runtime.Seconds(), attempt)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Printf("%s\t%s\n", outcome, pkg)
|
fmt.Printf("%s\t%s\t%.3fs\n", outcome, pkg, runtime.Seconds())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for -coverprofile argument and filter it out
|
// Check for -coverprofile argument and filter it out
|
||||||
@ -307,7 +314,7 @@ func main() {
|
|||||||
// when a package times out.
|
// when a package times out.
|
||||||
failed = true
|
failed = true
|
||||||
}
|
}
|
||||||
printPkgOutcome(tr.pkg, tr.outcome, thisRun.attempt)
|
printPkgOutcome(tr.pkg, tr.outcome, thisRun.attempt, tr.end.Sub(tr.start))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if testingVerbose || tr.outcome == "fail" {
|
if testingVerbose || tr.outcome == "fail" {
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@ -76,7 +77,10 @@ func TestFlakeRun(t *testing.T) {
|
|||||||
t.Fatalf("go run . %s: %s with output:\n%s", testfile, err, out)
|
t.Fatalf("go run . %s: %s with output:\n%s", testfile, err, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
want := []byte("ok\t" + testfile + " [attempt=2]")
|
// Replace the unpredictable timestamp with "0.00s".
|
||||||
|
out = regexp.MustCompile(`\t\d+\.\d\d\ds\t`).ReplaceAll(out, []byte("\t0.00s\t"))
|
||||||
|
|
||||||
|
want := []byte("ok\t" + testfile + "\t0.00s\t[attempt=2]")
|
||||||
if !bytes.Contains(out, want) {
|
if !bytes.Contains(out, want) {
|
||||||
t.Fatalf("wanted output containing %q but got:\n%s", want, out)
|
t.Fatalf("wanted output containing %q but got:\n%s", want, out)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user