Commits

Jiri Simsa committed 0f71efb

Marking tests with data races as failed.

Comments (0)

Files changed (2)

 	return len(suite.Tests)
 }
 
+func hasDatarace(lines []string) bool {
+	has_datarace := regexp.MustCompile("^WARNING: DATA RACE$").MatchString
+	for _, line := range lines {
+		if has_datarace(line) {
+			return true
+		}
+	}
+	return false
+}
+
 func gt_Parse(rd io.Reader) ([]*Suite, error) {
 	find_start := regexp.MustCompile(gt_startRE).FindStringSubmatch
 	find_end := regexp.MustCompile(gt_endRE).FindStringSubmatch
 			if tokens[2] != curTest.Name {
 				return nil, fmt.Errorf("%d: name mismatch", lnum)
 			}
-			curTest.Failed = (tokens[1] == "FAIL")
+			curTest.Failed = (tokens[1] == "FAIL") || hasDatarace(out)
 			curTest.Skipped = (tokens[1] == "SKIP")
 			curTest.Time = tokens[3]
 			curTest.Message = strings.Join(out, "\n")
 	}
 }
 
+func Test_parseDatarace(t *testing.T) {
+	filename := "data/gotest-datarace.out"
+	suites, err := loadGotest(filename, t)
+	if err != nil {
+		t.Fatalf("error loading %s - %s", filename, err)
+	}
+
+	suite := suites[0]
+	tests := suite.Tests
+	numTests := 1
+	if len(tests) != numTests {
+		t.Fatalf("got %d tests instead of %d", len(tests), numTests)
+	}
+
+	expectedMessage := "WARNING: DATA RACE"
+	for i, test := range suite.Tests {
+		if test.Message != expectedMessage {
+			t.Errorf(
+				"test %v message does not match expected result:\n\tGot: \"%v\"\n\tExpected: \"%v\"\n",
+				i,
+				test.Message,
+				expectedMessage)
+		}
+	}
+	numFailed := 1
+	if suite.NumFailed() != numFailed {
+		t.Fatalf("wrong number of failed %d, should be %d", suite.NumFailed(), numFailed)
+	}
+}
+
 func Test_parseLogOutput(t *testing.T) {
 	filename := "data/gotest-log.out"
 	suites, err := loadGotest(filename, t)