import (
"bufio"
"bytes"
+ "errors"
"fmt"
"internal/testenv"
"io"
gotRace = true
break
}
+ if strings.Contains(s, "--- SKIP:") {
+ return fmt.Sprintf("%-*s SKIPPED", visibleLen, testName)
+ }
}
failing := strings.Contains(testName, "Failing")
expRace := !strings.HasPrefix(testName, "No")
- for len(testName) < visibleLen {
- testName += " "
- }
if expRace == gotRace {
passedTests++
totalTests++
failed = true
failingNeg++
}
- return fmt.Sprintf("%s .", testName)
+ return fmt.Sprintf("%-*s .", visibleLen, testName)
}
pos := ""
if expRace {
failed = true
}
totalTests++
- return fmt.Sprintf("%s %s%s", testName, "FAILED", pos)
+ return fmt.Sprintf("%-*s %s%s", visibleLen, testName, "FAILED", pos)
}
// runTests assures that the package and its dependencies is
if fatals > mapFatals {
// But don't expect runtime to crash (other than
// in the map concurrent access detector).
- return out, fmt.Errorf("runtime fatal error")
+ return out, errors.New("runtime fatal error")
+ }
+ if !bytes.Contains(out, []byte("ALL TESTS COMPLETE")) {
+ return out, errors.New("not all tests ran")
}
return out, nil
}
--- /dev/null
+// Copyright 2025 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package race_test
+
+import (
+ "fmt"
+ "testing"
+)
+
+func TestMain(m *testing.M) {
+ m.Run()
+ fmt.Println("ALL TESTS COMPLETE")
+}
// TestRaceRangeFuncIterator races because x%5 can be equal to 4,
// therefore foo can early exit.
func TestRaceRangeFuncIterator(t *testing.T) {
+ t.Skip("#72925: uncaught panic ends tests")
x := foo(4)
t.Logf("foo(4)=%d", x)
}
// TestNoRaceRangeFuncIterator does not race because x%5 is never 5,
// therefore foo's loop will not exit early, and this it will not race.
func TestNoRaceRangeFuncIterator(t *testing.T) {
+ t.Skip("#72925: unexpected data race")
x := foo(5)
t.Logf("foo(5)=%d", x)
}