Make lots of tests run in parallel
Putting t.Parallel() in each test makes them run in parallel. Additional t.Parallel() could be added to each subtest, although that requires making a local copy of the loop variable for table driven tests. Test: m checkbuild Change-Id: I5d9869ead441093f4d7c5757f2447385333a95a4
This commit is contained in:
@@ -29,6 +29,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCreateFileWithRotation(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir, err := ioutil.TempDir("", "test-rotation")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to get TempDir: %v", err)
|
||||
@@ -96,6 +97,7 @@ func TestCreateFileWithRotation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPanic(t *testing.T) {
|
||||
t.Parallel()
|
||||
if os.Getenv("ACTUALLY_PANIC") == "1" {
|
||||
panicValue := "foo"
|
||||
log := New(&bytes.Buffer{})
|
||||
@@ -128,6 +130,7 @@ func TestPanic(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFatal(t *testing.T) {
|
||||
t.Parallel()
|
||||
if os.Getenv("ACTUALLY_FATAL") == "1" {
|
||||
log := New(&bytes.Buffer{})
|
||||
defer func() {
|
||||
@@ -150,6 +153,7 @@ func TestFatal(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNonFatal(t *testing.T) {
|
||||
t.Parallel()
|
||||
if os.Getenv("ACTUAL_TEST") == "1" {
|
||||
log := New(&bytes.Buffer{})
|
||||
defer log.Cleanup()
|
||||
@@ -166,6 +170,7 @@ func TestNonFatal(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRecoverFatal(t *testing.T) {
|
||||
t.Parallel()
|
||||
log := New(&bytes.Buffer{})
|
||||
defer func() {
|
||||
if p := recover(); p != nil {
|
||||
@@ -182,6 +187,7 @@ func TestRecoverFatal(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRecoverNonFatal(t *testing.T) {
|
||||
t.Parallel()
|
||||
log := New(&bytes.Buffer{})
|
||||
defer func() {
|
||||
if p := recover(); p == nil {
|
||||
@@ -198,6 +204,7 @@ func TestRecoverNonFatal(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRuntimePanic(t *testing.T) {
|
||||
t.Parallel()
|
||||
defer func() {
|
||||
if p := recover(); p == nil {
|
||||
t.Errorf("Panic not thrown")
|
||||
|
Reference in New Issue
Block a user