1 #!/usr/bin/env python 2 3 import sys 4 5 if len(sys.argv) != 2: 6 raise ValueError("unexpected number of args") 7 8 if sys.argv[1] == "--gtest_list_tests": 9 print("""\ 10 FirstTest. 11 subTestA 12 subTestB 13 ParameterizedTest/0. 14 subTest 15 ParameterizedTest/1. 16 subTest""") 17 sys.exit(0) 18 elif not sys.argv[1].startswith("--gtest_filter="): 19 raise ValueError("unexpected argument: %r" % (sys.argv[1])) 20 21 test_name = sys.argv[1].split('=',1)[1] 22 if test_name == 'FirstTest.subTestA': 23 print('I am subTest A, I PASS') 24 print('[ PASSED ] 1 test.') 25 sys.exit(0) 26 elif test_name == 'FirstTest.subTestB': 27 print('I am subTest B, I FAIL') 28 print('And I have two lines of output') 29 sys.exit(1) 30 elif test_name in ('ParameterizedTest/0.subTest', 31 'ParameterizedTest/1.subTest'): 32 print('I am a parameterized test, I also PASS') 33 print('[ PASSED ] 1 test.') 34 sys.exit(0) 35 else: 36 raise SystemExit("error: invalid test name: %r" % (test_name,)) 37