Page MenuHomePhabricator

D12546.id30128.diff
No OneTemporary

D12546.id30128.diff

diff --git a/src/unit/parser/ArcanistGoTestResultParser.php b/src/unit/parser/ArcanistGoTestResultParser.php
--- a/src/unit/parser/ArcanistGoTestResultParser.php
+++ b/src/unit/parser/ArcanistGoTestResultParser.php
@@ -25,7 +25,42 @@
// Temp store for test case results (in case we run multiple test cases)
$test_case_results = array();
- foreach ($test_results as $i => $line) {
+ for ($i = 0; $i < count($test_results); $i++) {
+ $line = $test_results[$i];
+
+ if (strncmp($line, '=== RUN', 6) === 0) {
+ if (strncmp($test_results[$i + 1], '==================', 19) === 0
+ && strncmp($test_results[$i + 2], 'WARNING: DATA RACE', 19) === 0) {
+ // We have a race condition
+ $i += 2; // Advance to the first goroutine
+ $reason = '';
+
+ // loop to collect all data
+ while (strncmp($test_results[$i], '==================', 19) !== 0) {
+ $reason .= $test_results[$i++]."\n";
+ }
+
+ // We are at ====... advance one line.
+ $line = $test_results[++$i];
+
+ // Collect the test name
+ $meta = array();
+ preg_match(
+ '/^--- PASS: (?P<test_name>.+) \((?P<time>.+)\s*s(?:econds)?\).*/',
+ $line,
+ $meta);
+
+ $result = new ArcanistUnitTestResult();
+ $result->setName($meta['test_name']);
+ $result->setResult(ArcanistUnitTestResult::RESULT_FAIL);
+ $result->setDuration($meta['time']);
+ $result->setUserData($reason);
+
+ $test_case_results[] = $result;
+
+ continue;
+ }
+ }
if (strncmp($line, '--- PASS', 8) === 0) {
// We have a passing test
diff --git a/src/unit/parser/__tests__/ArcanistGoTestResultParserTestCase.php b/src/unit/parser/__tests__/ArcanistGoTestResultParserTestCase.php
--- a/src/unit/parser/__tests__/ArcanistGoTestResultParserTestCase.php
+++ b/src/unit/parser/__tests__/ArcanistGoTestResultParserTestCase.php
@@ -39,6 +39,25 @@
$parsed_results[1]->getResult());
}
+ public function testRaceWarningTestCaseFailure() {
+ $stubbed_results = Filesystem::readFile(
+ dirname(__FILE__).'/testresults/go.race-warning-test-case-failure-go1.4');
+
+ $parsed_results = id(new ArcanistGoTestResultParser())
+ ->parseTestResults('racepackage_test.go', $stubbed_results);
+
+ $this->assertEqual(2, count($parsed_results));
+ $this->assertEqual(
+ ArcanistUnitTestResult::RESULT_PASS,
+ $parsed_results[0]->getResult());
+ $this->assertEqual(
+ ArcanistUnitTestResult::RESULT_FAIL,
+ $parsed_results[1]->getResult());
+ $this->assertEqual(
+ 'WARNING: DATA RACE',
+ idx(explode("\n", $parsed_results[1]->getUserData()), 0));
+ }
+
public function testMultipleTestCasesSuccessful() {
$stubbed_results = Filesystem::readFile(
dirname(__FILE__).'/testresults/go.multiple-test-cases-successful');
diff --git a/src/unit/parser/__tests__/testresults/go.race-warning-test-case-failure-go1.4 b/src/unit/parser/__tests__/testresults/go.race-warning-test-case-failure-go1.4
new file mode 100644
--- /dev/null
+++ b/src/unit/parser/__tests__/testresults/go.race-warning-test-case-failure-go1.4
@@ -0,0 +1,28 @@
+=== RUN TestFoo
+--- PASS: TestFoo (0.03s)
+=== RUN TestBar
+==================
+WARNING: DATA RACE
+Write by goroutine 8:
+ racepackage.func~002()
+ /tmp/racepackage_test.go:21 +0x5d
+
+Previous write by goroutine 7:
+ racepackage.func~001()
+ /tmp/racepackage_test.go:17 +0x5d
+
+Goroutine 8 (running) created at:
+ racepackage.TestBar()
+ /tmp/racepackage_test.go:22 +0x1e8
+ testing.tRunner()
+ /usr/local/Cellar/go/1.4.2/libexec/src/testing/testing.go:447 +0x133
+
+Goroutine 7 (finished) created at:
+ racepackage.TestBar()
+ /tmp/racepackage_test.go:18 +0x13e
+ testing.tRunner()
+ /usr/local/Cellar/go/1.4.2/libexec/src/testing/testing.go:447 +0x133
+==================
+--- PASS: TestBar (0.01s)
+PASS
+ok package/racepackage 0.042s

File Metadata

Mime Type
text/plain
Expires
Thu, Apr 3, 11:53 AM (3 w, 20 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7716373
Default Alt Text
D12546.id30128.diff (3 KB)

Event Timeline