• 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("""\
10Running main() from gtest_main.cc
11FirstTest.
12  subTestA
13  subTestB
14ParameterizedTest/0.
15  subTest
16ParameterizedTest/1.
17  subTest""")
18    sys.exit(0)
19elif not sys.argv[1].startswith("--gtest_filter="):
20    raise ValueError("unexpected argument: %r" % (sys.argv[1]))
21
22test_name = sys.argv[1].split('=',1)[1]
23print('Running main() from gtest_main.cc')
24if test_name == 'FirstTest.subTestA':
25    print('I am subTest A, I PASS')
26    print('[  PASSED  ] 1 test.')
27    sys.exit(0)
28elif test_name == 'FirstTest.subTestB':
29    print('I am subTest B, I FAIL')
30    print('And I have two lines of output')
31    sys.exit(1)
32elif test_name in ('ParameterizedTest/0.subTest',
33                   'ParameterizedTest/1.subTest'):
34    print('I am a parameterized test, I also PASS')
35    print('[  PASSED  ] 1 test.')
36    sys.exit(0)
37else:
38    raise SystemExit("error: invalid test name: %r" % (test_name,))
39