• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2
3import sys
4
5if len(sys.argv) != 2:
6    raise ValueError("unexpected number of args")
7
8if sys.argv[1] == "--gtest_list_tests":
9    print("""\
10FirstTest.
11  subTestA
12  subTestB
13ParameterizedTest/0.
14  subTest
15ParameterizedTest/1.
16  subTest""")
17    sys.exit(0)
18elif not sys.argv[1].startswith("--gtest_filter="):
19    raise ValueError("unexpected argument: %r" % (sys.argv[1]))
20
21test_name = sys.argv[1].split('=',1)[1]
22if test_name == 'FirstTest.subTestA':
23    print('I am subTest A, I PASS')
24    print('[  PASSED  ] 1 test.')
25    sys.exit(0)
26elif 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)
30elif 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)
35else:
36    raise SystemExit("error: invalid test name: %r" % (test_name,))
37