Skip to content

testing: tests after a data race are marked as failed (1.9rc2) #21338

@karalabe

Description

@karalabe

Maybe I missed this behavior until now, still it seems a bug. Opposed to Go 1.8.3 (#21338 (comment)), running a racey test suite with Go 1.9rc2 results in all tests after the racey one being marked as failed:

package main

import (
	"testing"
)

func TestPreRace(t *testing.T) {
	// Nothing to do, must succeed
}

func TestRace(t *testing.T) {
	// Blow it up
	var n int

	wait := make(chan struct{})
	go func() {
		defer close(wait)
		n++
	}()

	n++
	<-wait
}

func TestPostRace(t *testing.T) {
	// Nothing to do, must succeed
}
$ go test -v --race

=== RUN   TestPreRace
--- PASS: TestPreRace (0.00s)
=== RUN   TestRace
==================
WARNING: DATA RACE
[...]
==================
--- FAIL: TestRace (1.00s)
	testing.go:700: race detected during execution of test
=== RUN   TestPostRace
--- FAIL: TestPostRace (0.00s)

Note, TestPostRace is marked as failed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions