14fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar#!/usr/bin/env python 24fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar 34fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbarimport sys 44fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar 54fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbarif len(sys.argv) != 2: 64fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar raise ValueError("unexpected number of args") 74fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar 84fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbarif sys.argv[1] == "--gtest_list_tests": 94fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar print("""\ 104fa59392684435c2196baf43c35c07fe8b348caeDaniel DunbarFirstTest. 114fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar subTestA 124fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar subTestB 134fa59392684435c2196baf43c35c07fe8b348caeDaniel DunbarParameterizedTest/0. 144fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar subTest 154fa59392684435c2196baf43c35c07fe8b348caeDaniel DunbarParameterizedTest/1. 164fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar subTest""") 174fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar sys.exit(0) 184fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbarelif not sys.argv[1].startswith("--gtest_filter="): 194fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar raise ValueError("unexpected argument: %r" % (sys.argv[1])) 204fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar 214fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbartest_name = sys.argv[1].split('=',1)[1] 224fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbarif test_name == 'FirstTest.subTestA': 234fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar print('I am subTest A, I PASS') 244fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar sys.exit(0) 254fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbarelif test_name == 'FirstTest.subTestB': 264fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar print('I am subTest B, I FAIL') 274fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar print('And I have two lines of output') 284fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar sys.exit(1) 294fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbarelif test_name in ('ParameterizedTest/0.subTest', 304fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar 'ParameterizedTest/1.subTest'): 314fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar print('I am a parameterized test, I also PASS') 324fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar sys.exit(0) 334fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbarelse: 344fa59392684435c2196baf43c35c07fe8b348caeDaniel Dunbar raise SystemExit("error: invalid test name: %r" % (test_name,)) 35