Skip to content

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

Closed

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.

Activity

  1. davecheney commented on Aug 8, 2017

    @davecheney
    Contributor
  2. dominikh commented on Aug 8, 2017

    @dominikh
    Member

    Failing tests due to races is new in 1.9 – that it flags all following tests as failed might be a bug.

  3. karalabe commented on Aug 8, 2017

    @karalabe
    ContributorAuthor

    @dominikh Tests always failed if a data race was detected.

    @davecheney Go 1.8.3 only marks the racey test failed, not the others.

    $ GOROOT=/tmp/go1.8.3 /tmp/go1.8.3/bin/go test -v --race
    
    === RUN   TestPreRace
    --- PASS: TestPreRace (0.00s)
    === RUN   TestRace
    ==================
    WARNING: DATA RACE
    [...]
    ==================
    --- FAIL: TestRace (0.00s)
    	testing.go:610: race detected during execution of test
    === RUN   TestPostRace
    --- PASS: TestPostRace (0.00s)
    
  4. dominikh commented on Aug 8, 2017

    @dominikh
    Member

    @karalabe The commit I was thinking of is 221541e

  5. davecheney commented on Aug 8, 2017

    @davecheney
    Contributor

    This may be a regression /cc @ianlancetaylor @broady

  6. mvdan commented on Aug 8, 2017

    @mvdan
    Member

    I also saw this recently and was puzzled, but I assumed it was somehow on purpose to highlight the data race. If it was on purpose, this should be documented in the release notes. Either way, something to do for 1.9.

  7. added this to the Go1.9 milestone on Aug 8, 2017
  8. ianlancetaylor commented on Aug 8, 2017

    @ianlancetaylor
    Contributor
  9. cespare commented on Aug 8, 2017

    @cespare
    Contributor

    Yeah, unintended consequence of 221541e.

    We could probably just revert for 1.9, since #19851 doesn't seem too serious, and fix it properly later. But I'll check right now to see whether the real fix is trivial.

  10. ianlancetaylor commented on Aug 8, 2017

    @ianlancetaylor
    Contributor

    I'm testing a fix.

  11. gopherbot commented on Aug 8, 2017

    @gopherbot
    Contributor

    Change https://golang.org/cl/54050 mentions this issue: testing: don't fail all tests after racy test failure

  12. ianlancetaylor commented on Aug 15, 2017

    @ianlancetaylor
    Contributor

    Reopening for 1.9 backport.

  13. gopherbot commented on Aug 18, 2017

    @gopherbot
    Contributor

    Change https://golang.org/cl/57151 mentions this issue: [release-branch.go1.9] testing: don't fail all tests after racy test failure

  14. added a commit that references this issue on Aug 18, 2017
    fbf7e1f
  15. aclements commented on Aug 19, 2017

    @aclements
    Member

    Fixed on 1.9 by fbf7e1f

  16. locked and limited conversation to collaborators on Aug 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions