tesseract v5.3.3.20231005
googletest-filter-unittest Namespace Reference

Classes

class  GTestFilterUnitTest
 

Functions

def SetEnvVar (env_var, value)
 
def RunAndReturnOutput (args=None)
 
def RunAndExtractTestList (args=None)
 
def InvokeWithModifiedEnv (extra_env, function, *args, **kwargs)
 
def RunWithSharding (total_shards, shard_index, command)
 

Variables

bool CAN_PASS_EMPTY_ENV = False
 
 child
 
bool CAN_UNSET_ENV = False
 
tuple CAN_TEST_EMPTY_FILTER = (CAN_PASS_EMPTY_ENV and CAN_UNSET_ENV)
 
string FILTER_ENV_VAR = 'GTEST_FILTER'
 
string TOTAL_SHARDS_ENV_VAR = 'GTEST_TOTAL_SHARDS'
 
string SHARD_INDEX_ENV_VAR = 'GTEST_SHARD_INDEX'
 
string SHARD_STATUS_FILE_ENV_VAR = 'GTEST_SHARD_STATUS_FILE'
 
string FILTER_FLAG = 'gtest_filter'
 
string ALSO_RUN_DISABLED_TESTS_FLAG = 'gtest_also_run_disabled_tests'
 
 COMMAND = gtest_test_utils.GetTestExecutablePath('googletest-filter-unittest_')
 
 PARAM_TEST_REGEX = re.compile(r'/ParamTest')
 
 TEST_CASE_REGEX = re.compile(r'^\[\-+\] \d+ tests? from (\w+(/\w+)?)')
 
 TEST_REGEX = re.compile(r'^\[\s*RUN\s*\].*\.(\w+(/\w+)?)')
 
string LIST_TESTS_FLAG = '--gtest_list_tests'
 
string SUPPORTS_DEATH_TESTS
 
list PARAM_TESTS
 
list DISABLED_TESTS
 
list DEATH_TESTS
 
list ACTIVE_TESTS
 
 param_tests_present = None
 
 environ = os.environ.copy()
 

Function Documentation

◆ InvokeWithModifiedEnv()

def googletest-filter-unittest.InvokeWithModifiedEnv (   extra_env,
  function,
args,
**  kwargs 
)
Runs the given function and arguments in a modified environment.

Definition at line 209 of file googletest-filter-unittest.py.

209def InvokeWithModifiedEnv(extra_env, function, *args, **kwargs):
210 """Runs the given function and arguments in a modified environment."""
211 try:
212 original_env = environ.copy()
213 environ.update(extra_env)
214 return function(*args, **kwargs)
215 finally:
216 environ.clear()
217 environ.update(original_env)
218
219
def InvokeWithModifiedEnv(extra_env, function, *args, **kwargs)

◆ RunAndExtractTestList()

def googletest-filter-unittest.RunAndExtractTestList (   args = None)
Runs the test program and returns its exit code and a list of tests run.

Definition at line 190 of file googletest-filter-unittest.py.

190def RunAndExtractTestList(args = None):
191 """Runs the test program and returns its exit code and a list of tests run."""
192
193 p = gtest_test_utils.Subprocess([COMMAND] + (args or []), env=environ)
194 tests_run = []
195 test_case = ''
196 test = ''
197 for line in p.output.split('\n'):
198 match = TEST_CASE_REGEX.match(line)
199 if match is not None:
200 test_case = match.group(1)
201 else:
202 match = TEST_REGEX.match(line)
203 if match is not None:
204 test = match.group(1)
205 tests_run.append(test_case + '.' + test)
206 return (tests_run, p.exit_code)
207
208

◆ RunAndReturnOutput()

def googletest-filter-unittest.RunAndReturnOutput (   args = None)
Runs the test program and returns its output.

Definition at line 183 of file googletest-filter-unittest.py.

183def RunAndReturnOutput(args = None):
184 """Runs the test program and returns its output."""
185
186 return gtest_test_utils.Subprocess([COMMAND] + (args or []),
187 env=environ).output
188
189

◆ RunWithSharding()

def googletest-filter-unittest.RunWithSharding (   total_shards,
  shard_index,
  command 
)
Runs a test program shard and returns exit code and a list of tests run.

Definition at line 220 of file googletest-filter-unittest.py.

220def RunWithSharding(total_shards, shard_index, command):
221 """Runs a test program shard and returns exit code and a list of tests run."""
222
223 extra_env = {SHARD_INDEX_ENV_VAR: str(shard_index),
224 TOTAL_SHARDS_ENV_VAR: str(total_shards)}
225 return InvokeWithModifiedEnv(extra_env, RunAndExtractTestList, command)
226
227# The unit test.
228
229
def RunWithSharding(total_shards, shard_index, command)

◆ SetEnvVar()

def googletest-filter-unittest.SetEnvVar (   env_var,
  value 
)
Sets the env variable to 'value'; unsets it when 'value' is None.

Definition at line 174 of file googletest-filter-unittest.py.

174def SetEnvVar(env_var, value):
175 """Sets the env variable to 'value'; unsets it when 'value' is None."""
176
177 if value is not None:
178 environ[env_var] = value
179 elif env_var in environ:
180 del environ[env_var]
181
182

Variable Documentation

◆ ACTIVE_TESTS

list googletest-filter-unittest.ACTIVE_TESTS
Initial value:
1= [
2 'FooTest.Abc',
3 'FooTest.Xyz',
4
5 'BarTest.TestOne',
6 'BarTest.TestTwo',
7 'BarTest.TestThree',
8
9 'BazTest.TestOne',
10 'BazTest.TestA',
11 'BazTest.TestB',
12 ] + DEATH_TESTS + PARAM_TESTS

Definition at line 154 of file googletest-filter-unittest.py.

◆ ALSO_RUN_DISABLED_TESTS_FLAG

string googletest-filter-unittest.ALSO_RUN_DISABLED_TESTS_FLAG = 'gtest_also_run_disabled_tests'

Definition at line 102 of file googletest-filter-unittest.py.

◆ CAN_PASS_EMPTY_ENV

googletest-filter-unittest.CAN_PASS_EMPTY_ENV = False

Definition at line 59 of file googletest-filter-unittest.py.

◆ CAN_TEST_EMPTY_FILTER

tuple googletest-filter-unittest.CAN_TEST_EMPTY_FILTER = (CAN_PASS_EMPTY_ENV and CAN_UNSET_ENV)

Definition at line 87 of file googletest-filter-unittest.py.

◆ CAN_UNSET_ENV

googletest-filter-unittest.CAN_UNSET_ENV = False

Definition at line 73 of file googletest-filter-unittest.py.

◆ child

googletest-filter-unittest.child
Initial value:
2 [sys.executable, '-c', 'import os; print(\'EMPTY_VAR\' in os.environ)'])

Definition at line 62 of file googletest-filter-unittest.py.

◆ COMMAND

googletest-filter-unittest.COMMAND = gtest_test_utils.GetTestExecutablePath('googletest-filter-unittest_')

Definition at line 105 of file googletest-filter-unittest.py.

◆ DEATH_TESTS

list googletest-filter-unittest.DEATH_TESTS
Initial value:
1= [
2 'HasDeathTest.Test1',
3 'HasDeathTest.Test2',
4 ]

Definition at line 146 of file googletest-filter-unittest.py.

◆ DISABLED_TESTS

list googletest-filter-unittest.DISABLED_TESTS
Initial value:
1= [
2 'BarTest.DISABLED_TestFour',
3 'BarTest.DISABLED_TestFive',
4 'BazTest.DISABLED_TestC',
5 'DISABLED_FoobarTest.Test1',
6 'DISABLED_FoobarTest.DISABLED_Test2',
7 'DISABLED_FoobarbazTest.TestA',
8 ]

Definition at line 136 of file googletest-filter-unittest.py.

◆ environ

googletest-filter-unittest.environ = os.environ.copy()

Definition at line 171 of file googletest-filter-unittest.py.

◆ FILTER_ENV_VAR

string googletest-filter-unittest.FILTER_ENV_VAR = 'GTEST_FILTER'

Definition at line 91 of file googletest-filter-unittest.py.

◆ FILTER_FLAG

string googletest-filter-unittest.FILTER_FLAG = 'gtest_filter'

Definition at line 99 of file googletest-filter-unittest.py.

◆ LIST_TESTS_FLAG

string googletest-filter-unittest.LIST_TESTS_FLAG = '--gtest_list_tests'

Definition at line 118 of file googletest-filter-unittest.py.

◆ PARAM_TEST_REGEX

googletest-filter-unittest.PARAM_TEST_REGEX = re.compile(r'/ParamTest')

Definition at line 108 of file googletest-filter-unittest.py.

◆ PARAM_TESTS

list googletest-filter-unittest.PARAM_TESTS
Initial value:
1= [
2 'SeqP/ParamTest.TestX/0',
3 'SeqP/ParamTest.TestX/1',
4 'SeqP/ParamTest.TestY/0',
5 'SeqP/ParamTest.TestY/1',
6 'SeqQ/ParamTest.TestX/0',
7 'SeqQ/ParamTest.TestX/1',
8 'SeqQ/ParamTest.TestY/0',
9 'SeqQ/ParamTest.TestY/1',
10 ]

Definition at line 125 of file googletest-filter-unittest.py.

◆ param_tests_present

googletest-filter-unittest.param_tests_present = None

Definition at line 167 of file googletest-filter-unittest.py.

◆ SHARD_INDEX_ENV_VAR

string googletest-filter-unittest.SHARD_INDEX_ENV_VAR = 'GTEST_SHARD_INDEX'

Definition at line 95 of file googletest-filter-unittest.py.

◆ SHARD_STATUS_FILE_ENV_VAR

string googletest-filter-unittest.SHARD_STATUS_FILE_ENV_VAR = 'GTEST_SHARD_STATUS_FILE'

Definition at line 96 of file googletest-filter-unittest.py.

◆ SUPPORTS_DEATH_TESTS

string googletest-filter-unittest.SUPPORTS_DEATH_TESTS
Initial value:
1= 'HasDeathTest' in gtest_test_utils.Subprocess(
2 [COMMAND, LIST_TESTS_FLAG]).output

Definition at line 121 of file googletest-filter-unittest.py.

◆ TEST_CASE_REGEX

googletest-filter-unittest.TEST_CASE_REGEX = re.compile(r'^\[\-+\] \d+ tests? from (\w+(/\w+)?)')

Definition at line 111 of file googletest-filter-unittest.py.

◆ TEST_REGEX

googletest-filter-unittest.TEST_REGEX = re.compile(r'^\[\s*RUN\s*\].*\.(\w+(/\w+)?)')

Definition at line 114 of file googletest-filter-unittest.py.

◆ TOTAL_SHARDS_ENV_VAR

string googletest-filter-unittest.TOTAL_SHARDS_ENV_VAR = 'GTEST_TOTAL_SHARDS'

Definition at line 94 of file googletest-filter-unittest.py.