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