Page MenuHomePhabricator

D12436.diff
No OneTemporary

D12436.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
@@ -31,7 +31,7 @@
// We have a passing test
$meta = array();
preg_match(
- '/^--- PASS: (?P<test_name>.+) \((?P<time>.+) seconds\).*/',
+ '/^--- PASS: (?P<test_name>.+) \((?P<time>.+)\s*s(?:econds)?\).*/',
$line,
$meta);
@@ -51,7 +51,7 @@
$reason = trim($test_results[$i + 1]);
$meta = array();
preg_match(
- '/^--- FAIL: (?P<test_name>.+) \((?P<time>.+) seconds\).*/',
+ '/^--- FAIL: (?P<test_name>.+) \((?P<time>.+)\s*s(?:econds)?\).*/',
$line,
$meta);
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
@@ -103,4 +103,102 @@
}
}
+ public function testSingleTestCaseSuccessfulGo14() {
+ $stubbed_results = Filesystem::readFile(
+ dirname(__FILE__).'/testresults/go.single-test-case-successful-go1.4');
+
+ $parsed_results = id(new ArcanistGoTestResultParser())
+ ->parseTestResults('subpackage_test.go', $stubbed_results);
+
+ $this->assertEqual(2, count($parsed_results));
+ $this->assertEqual(
+ 'Go::Test::package::subpackage::TestFoo',
+ $parsed_results[0]->getName());
+ foreach ($parsed_results as $result) {
+ $this->assertEqual(
+ ArcanistUnitTestResult::RESULT_PASS,
+ $result->getResult());
+ }
+ }
+
+ public function testSingleTestCaseFailureGo14() {
+ $stubbed_results = Filesystem::readFile(
+ dirname(__FILE__).'/testresults/go.single-test-case-failure-go1.4');
+
+ $parsed_results = id(new ArcanistGoTestResultParser())
+ ->parseTestResults('subpackage_test.go', $stubbed_results);
+
+ $this->assertEqual(2, count($parsed_results));
+ $this->assertEqual(
+ ArcanistUnitTestResult::RESULT_FAIL,
+ $parsed_results[0]->getResult());
+ $this->assertEqual(
+ ArcanistUnitTestResult::RESULT_PASS,
+ $parsed_results[1]->getResult());
+ }
+
+ public function testNonVerboseOutputGo14() {
+ $stubbed_results = Filesystem::readFile(
+ dirname(__FILE__).'/testresults/go.nonverbose-go1.4');
+
+ $parsed_results = id(new ArcanistGoTestResultParser())
+ ->parseTestResults('package', $stubbed_results);
+
+ $this->assertEqual(2, count($parsed_results));
+ $this->assertEqual(
+ 'Go::TestCase::package::subpackage1',
+ $parsed_results[0]->getName());
+ $this->assertEqual(
+ 'Go::TestCase::package::subpackage2',
+ $parsed_results[1]->getName());
+ foreach ($parsed_results as $result) {
+ $this->assertEqual(
+ ArcanistUnitTestResult::RESULT_PASS,
+ $result->getResult());
+ }
+ }
+
+ public function testMultipleTestCasesSuccessfulGo14() {
+ $stubbed_results = Filesystem::readFile(
+ dirname(__FILE__).'/testresults/go.multiple-test-cases-successful-go1.4');
+
+ $parsed_results = id(new ArcanistGoTestResultParser())
+ ->parseTestResults('package', $stubbed_results);
+
+ $this->assertEqual(3, count($parsed_results));
+ $this->assertEqual(
+ 'Go::Test::package::subpackage1::TestFoo1',
+ $parsed_results[0]->getName());
+ $this->assertEqual(
+ 'Go::Test::package::subpackage2::TestFoo2',
+ $parsed_results[2]->getName());
+ foreach ($parsed_results as $result) {
+ $this->assertEqual(
+ ArcanistUnitTestResult::RESULT_PASS,
+ $result->getResult());
+ }
+ }
+
+
+ public function testMultipleTestCasesFailureGo14() {
+ $stubbed_results = Filesystem::readFile(
+ dirname(__FILE__).'/testresults/go.multiple-test-cases-failure-go1.4');
+
+ $parsed_results = id(new ArcanistGoTestResultParser())
+ ->parseTestResults('package', $stubbed_results);
+
+ $this->assertEqual(3, count($parsed_results));
+ $this->assertEqual(
+ 'Go::Test::package::subpackage1::TestFoo1',
+ $parsed_results[0]->getName());
+ $this->assertEqual(
+ 'Go::Test::package::subpackage2::TestFoo2',
+ $parsed_results[2]->getName());
+ $this->assertEqual(
+ ArcanistUnitTestResult::RESULT_PASS,
+ $parsed_results[0]->getResult());
+ $this->assertEqual(
+ ArcanistUnitTestResult::RESULT_FAIL,
+ $parsed_results[2]->getResult());
+ }
}
diff --git a/src/unit/parser/__tests__/testresults/go.multiple-test-cases-failure-go1.4 b/src/unit/parser/__tests__/testresults/go.multiple-test-cases-failure-go1.4
new file mode 100644
--- /dev/null
+++ b/src/unit/parser/__tests__/testresults/go.multiple-test-cases-failure-go1.4
@@ -0,0 +1,12 @@
+=== RUN TestFoo1
+--- PASS: TestFoo1 (0.03s)
+=== RUN TestBar1
+--- PASS: TestBar1 (0.01s)
+PASS
+ok package/subpackage1 0.042s
+=== RUN TestFoo2
+--- FAIL: TestFoo2 (0.02s)
+ subpackage2_test.go:53: got: 2, want: 1
+FAIL
+exit status 1
+FAIL package/subpackage2 0.020s
diff --git a/src/unit/parser/__tests__/testresults/go.multiple-test-cases-successful-go1.4 b/src/unit/parser/__tests__/testresults/go.multiple-test-cases-successful-go1.4
new file mode 100644
--- /dev/null
+++ b/src/unit/parser/__tests__/testresults/go.multiple-test-cases-successful-go1.4
@@ -0,0 +1,10 @@
+=== RUN TestFoo1
+--- PASS: TestFoo1 (0.03s)
+=== RUN TestBar1
+--- PASS: TestBar1 (0.01s)
+PASS
+ok package/subpackage1 0.042s
+=== RUN TestFoo2
+--- PASS: TestFoo2 (0.02s)
+PASS
+ok package/subpackage2 0.021s
diff --git a/src/unit/parser/__tests__/testresults/go.nonverbose-go1.4 b/src/unit/parser/__tests__/testresults/go.nonverbose-go1.4
new file mode 100644
--- /dev/null
+++ b/src/unit/parser/__tests__/testresults/go.nonverbose-go1.4
@@ -0,0 +1,2 @@
+ok package/subpackage1 0.042s
+ok package/subpackage2 0.021s
diff --git a/src/unit/parser/__tests__/testresults/go.single-test-case-failure-go1.4 b/src/unit/parser/__tests__/testresults/go.single-test-case-failure-go1.4
new file mode 100644
--- /dev/null
+++ b/src/unit/parser/__tests__/testresults/go.single-test-case-failure-go1.4
@@ -0,0 +1,8 @@
+=== RUN TestFoo
+--- FAIL: TestFoo (0.03s)
+ subpackage_test.go:53: got: 2, want: 1
+=== RUN TestBar
+--- PASS: TestBar (0.01s)
+FAIL
+exit status 1
+FAIL package/subpackage 0.042s
diff --git a/src/unit/parser/__tests__/testresults/go.single-test-case-successful-go1.4 b/src/unit/parser/__tests__/testresults/go.single-test-case-successful-go1.4
new file mode 100644
--- /dev/null
+++ b/src/unit/parser/__tests__/testresults/go.single-test-case-successful-go1.4
@@ -0,0 +1,6 @@
+=== RUN TestFoo
+--- PASS: TestFoo (0.03s)
+=== RUN TestBar
+--- PASS: TestBar (0.01s)
+PASS
+ok package/subpackage 0.042s

File Metadata

Mime Type
text/plain
Expires
May 13 2024, 10:33 PM (4 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6276706
Default Alt Text
D12436.diff (6 KB)

Event Timeline