tesseract v5.3.3.20231005
googletest-output-test.GTestOutputTest Class Reference
Inheritance diagram for googletest-output-test.GTestOutputTest:

Public Member Functions

def RemoveUnsupportedTests (self, test_output)
 
def testOutput (self)
 

Detailed Description

Definition at line 261 of file googletest-output-test.py.

Member Function Documentation

◆ RemoveUnsupportedTests()

def googletest-output-test.GTestOutputTest.RemoveUnsupportedTests (   self,
  test_output 
)

Definition at line 262 of file googletest-output-test.py.

262 def RemoveUnsupportedTests(self, test_output):
263 if not SUPPORTS_DEATH_TESTS:
264 test_output = RemoveMatchingTests(test_output, 'DeathTest')
265 if not SUPPORTS_TYPED_TESTS:
266 test_output = RemoveMatchingTests(test_output, 'TypedTest')
267 test_output = RemoveMatchingTests(test_output, 'TypedDeathTest')
268 test_output = RemoveMatchingTests(test_output, 'TypeParamDeathTest')
269 if not SUPPORTS_THREADS:
270 test_output = RemoveMatchingTests(test_output,
271 'ExpectFailureWithThreadsTest')
272 test_output = RemoveMatchingTests(test_output,
273 'ScopedFakeTestPartResultReporterTest')
274 test_output = RemoveMatchingTests(test_output,
275 'WorksConcurrently')
276 if not SUPPORTS_STACK_TRACES:
277 test_output = RemoveStackTraces(test_output)
278
279 return test_output
280
def RemoveMatchingTests(test_output, pattern)

◆ testOutput()

def googletest-output-test.GTestOutputTest.testOutput (   self)

Definition at line 281 of file googletest-output-test.py.

281 def testOutput(self):
282 output = GetOutputOfAllCommands()
283
284 golden_file = open(GOLDEN_PATH, 'rb')
285 # A mis-configured source control system can cause \r appear in EOL
286 # sequences when we read the golden file irrespective of an operating
287 # system used. Therefore, we need to strip those \r's from newlines
288 # unconditionally.
289 golden = ToUnixLineEnding(golden_file.read().decode())
290 golden_file.close()
291
292 # We want the test to pass regardless of certain features being
293 # supported or not.
294
295 # We still have to remove type name specifics in all cases.
296 normalized_actual = RemoveTypeInfoDetails(output)
297 normalized_golden = RemoveTypeInfoDetails(golden)
298
299 if CAN_GENERATE_GOLDEN_FILE:
300 self.assertEqual(normalized_golden, normalized_actual,
301 '\n'.join(difflib.unified_diff(
302 normalized_golden.split('\n'),
303 normalized_actual.split('\n'),
304 'golden', 'actual')))
305 else:
306 normalized_actual = NormalizeToCurrentPlatform(
307 RemoveTestCounts(normalized_actual))
308 normalized_golden = NormalizeToCurrentPlatform(
309 RemoveTestCounts(self.RemoveUnsupportedTests(normalized_golden)))
310
311 # This code is very handy when debugging golden file differences:
312 if os.getenv('DEBUG_GTEST_OUTPUT_TEST'):
313 open(os.path.join(
315 '_googletest-output-test_normalized_actual.txt'), 'wb').write(
316 normalized_actual)
317 open(os.path.join(
319 '_googletest-output-test_normalized_golden.txt'), 'wb').write(
320 normalized_golden)
321
322 self.assertEqual(normalized_golden, normalized_actual)
323
324
def RemoveTypeInfoDetails(test_output)
def NormalizeToCurrentPlatform(test_output)

The documentation for this class was generated from the following file: