Index: build/android/pylib/gtest/gtest_test_instance_test.py |
diff --git a/build/android/pylib/gtest/gtest_test_instance_test.py b/build/android/pylib/gtest/gtest_test_instance_test.py |
index c52b2354c4183663890327e471e6306c1db2997f..910ac40fe0709b38e4f5b009f2e6907c36adde40 100755 |
--- a/build/android/pylib/gtest/gtest_test_instance_test.py |
+++ b/build/android/pylib/gtest/gtest_test_instance_test.py |
@@ -5,6 +5,7 @@ |
import unittest |
+from pylib.base import base_test_result |
from pylib.gtest import gtest_test_instance |
@@ -80,6 +81,77 @@ class GtestTestInstanceTests(unittest.TestCase): |
] |
self.assertEqual(expected, actual) |
+ def testParseGTestOutput_pass(self): |
+ raw_output = [ |
+ '[ RUN ] FooTest.Bar', |
+ '[ OK ] FooTest.Bar (1 ms)', |
+ ] |
+ actual = gtest_test_instance.ParseGTestOutput(raw_output) |
+ self.assertEquals(1, len(actual)) |
+ self.assertEquals('FooTest.Bar', actual[0].GetName()) |
+ self.assertEquals(1, actual[0].GetDuration()) |
+ self.assertEquals(base_test_result.ResultType.PASS, actual[0].GetType()) |
+ |
+ def testParseGTestOutput_fail(self): |
+ raw_output = [ |
+ '[ RUN ] FooTest.Bar', |
+ '[ FAILED ] FooTest.Bar (1 ms)', |
+ ] |
+ actual = gtest_test_instance.ParseGTestOutput(raw_output) |
+ self.assertEquals(1, len(actual)) |
+ self.assertEquals('FooTest.Bar', actual[0].GetName()) |
+ self.assertEquals(1, actual[0].GetDuration()) |
+ self.assertEquals(base_test_result.ResultType.FAIL, actual[0].GetType()) |
+ |
+ def testParseGTestOutput_crash(self): |
+ raw_output = [ |
+ '[ RUN ] FooTest.Bar', |
+ '[ CRASHED ] FooTest.Bar (1 ms)', |
+ ] |
+ actual = gtest_test_instance.ParseGTestOutput(raw_output) |
+ self.assertEquals(1, len(actual)) |
+ self.assertEquals('FooTest.Bar', actual[0].GetName()) |
+ self.assertEquals(1, actual[0].GetDuration()) |
+ self.assertEquals(base_test_result.ResultType.CRASH, actual[0].GetType()) |
+ |
+ def testParseGTestOutput_errorCrash(self): |
+ raw_output = [ |
+ '[ RUN ] FooTest.Bar', |
+ '[ERROR:blah] Currently running: FooTest.Bar', |
+ ] |
+ actual = gtest_test_instance.ParseGTestOutput(raw_output) |
+ self.assertEquals(1, len(actual)) |
+ self.assertEquals('FooTest.Bar', actual[0].GetName()) |
+ self.assertEquals(0, actual[0].GetDuration()) |
+ self.assertEquals(base_test_result.ResultType.CRASH, actual[0].GetType()) |
+ |
+ def testParseGTestOutput_unknown(self): |
+ raw_output = [ |
+ '[ RUN ] FooTest.Bar', |
+ ] |
+ actual = gtest_test_instance.ParseGTestOutput(raw_output) |
+ self.assertEquals(1, len(actual)) |
+ self.assertEquals('FooTest.Bar', actual[0].GetName()) |
+ self.assertEquals(0, actual[0].GetDuration()) |
+ self.assertEquals(base_test_result.ResultType.UNKNOWN, actual[0].GetType()) |
+ |
+ def testParseGTestOutput_nonterminalUnknown(self): |
+ raw_output = [ |
+ '[ RUN ] FooTest.Bar', |
+ '[ RUN ] FooTest.Baz', |
+ '[ OK ] FooTest.Baz (1 ms)', |
+ ] |
+ actual = gtest_test_instance.ParseGTestOutput(raw_output) |
+ self.assertEquals(2, len(actual)) |
+ |
+ self.assertEquals('FooTest.Bar', actual[0].GetName()) |
+ self.assertEquals(0, actual[0].GetDuration()) |
+ self.assertEquals(base_test_result.ResultType.UNKNOWN, actual[0].GetType()) |
+ |
+ self.assertEquals('FooTest.Baz', actual[1].GetName()) |
+ self.assertEquals(1, actual[1].GetDuration()) |
+ self.assertEquals(base_test_result.ResultType.PASS, actual[1].GetType()) |
+ |
if __name__ == '__main__': |
unittest.main(verbosity=2) |