proxygen
gmock_output_test Namespace Reference

Classes

class  GMockOutputTest
 

Functions

def ToUnixLineEnding (s)
 
def RemoveReportHeaderAndFooter (output)
 
def RemoveLocations (output)
 
def NormalizeErrorMarker (output)
 
def RemoveMemoryAddresses (output)
 
def RemoveTestNamesOfLeakedMocks (output)
 
def GetLeakyTests (output)
 
def GetNormalizedOutputAndLeakyTests (output)
 
def GetShellCommandOutput (cmd)
 
def GetNormalizedCommandOutputAndLeakyTests (cmd)
 

Variables

string __author__ = 'wan@google.com (Zhanyong Wan)'
 
string GENGOLDEN_FLAG = '--gengolden'
 
 PROGRAM_PATH = gmock_test_utils.GetTestExecutablePath('gmock_output_test_')
 
list COMMAND = [PROGRAM_PATH, '--gtest_stack_trace_depth=0', '--gtest_print_time=0']
 
string GOLDEN_NAME = 'gmock_output_test_golden.txt'
 
 GOLDEN_PATH = os.path.join(gmock_test_utils.GetSourceDir(), GOLDEN_NAME)
 
 output
 
 _
 
 golden_file = open(GOLDEN_PATH, 'wb')
 

Function Documentation

def gmock_output_test.GetLeakyTests (   output)
Returns a list of test names that leak mock objects.

Definition at line 110 of file gmock_output_test.py.

Referenced by GetNormalizedOutputAndLeakyTests().

110 def GetLeakyTests(output):
111  """Returns a list of test names that leak mock objects."""
112 
113  # findall() returns a list of all matches of the regex in output.
114  # For example, if '(used in test FooTest.Bar)' is in output, the
115  # list will contain 'FooTest.Bar'.
116  return re.findall(r'\(used in test (.+)\)', output)
117 
118 
def GetLeakyTests(output)
def gmock_output_test.GetNormalizedCommandOutputAndLeakyTests (   cmd)
Runs a command and returns its normalized output and a list of leaky tests.

Args:
  cmd:  the shell command.

Definition at line 144 of file gmock_output_test.py.

References GetNormalizedOutputAndLeakyTests(), and GetShellCommandOutput().

Referenced by gmock_output_test.GMockOutputTest.testOutput().

145  """Runs a command and returns its normalized output and a list of leaky tests.
146 
147  Args:
148  cmd: the shell command.
149  """
150 
151  # Disables exception pop-ups on Windows.
152  os.environ['GTEST_CATCH_EXCEPTIONS'] = '1'
154 
155 
def GetNormalizedOutputAndLeakyTests(output)
def GetNormalizedCommandOutputAndLeakyTests(cmd)
def GetShellCommandOutput(cmd)
def gmock_output_test.GetNormalizedOutputAndLeakyTests (   output)
Normalizes the output of gmock_output_test_.

Args:
  output: The test output.

Returns:
  A tuple (the normalized test output, the list of test names that have
  leaked mocks).

Definition at line 119 of file gmock_output_test.py.

References GetLeakyTests(), NormalizeErrorMarker(), RemoveLocations(), RemoveMemoryAddresses(), RemoveReportHeaderAndFooter(), RemoveTestNamesOfLeakedMocks(), and ToUnixLineEnding().

Referenced by GetNormalizedCommandOutputAndLeakyTests().

120  """Normalizes the output of gmock_output_test_.
121 
122  Args:
123  output: The test output.
124 
125  Returns:
126  A tuple (the normalized test output, the list of test names that have
127  leaked mocks).
128  """
129 
130  output = ToUnixLineEnding(output)
131  output = RemoveReportHeaderAndFooter(output)
132  output = NormalizeErrorMarker(output)
133  output = RemoveLocations(output)
134  output = RemoveMemoryAddresses(output)
135  return (RemoveTestNamesOfLeakedMocks(output), GetLeakyTests(output))
136 
137 
def GetNormalizedOutputAndLeakyTests(output)
def NormalizeErrorMarker(output)
def RemoveLocations(output)
def RemoveMemoryAddresses(output)
def GetLeakyTests(output)
def RemoveTestNamesOfLeakedMocks(output)
def RemoveReportHeaderAndFooter(output)
def gmock_output_test.GetShellCommandOutput (   cmd)
Runs a command in a sub-process, and returns its STDOUT in a string.

Definition at line 138 of file gmock_output_test.py.

References gmock_test_utils.Subprocess.

Referenced by GetNormalizedCommandOutputAndLeakyTests().

139  """Runs a command in a sub-process, and returns its STDOUT in a string."""
140 
141  return gmock_test_utils.Subprocess(cmd, capture_stderr=False).output
142 
143 
def GetShellCommandOutput(cmd)
def gmock_output_test.NormalizeErrorMarker (   output)
Normalizes the error marker, which is different on Windows vs on Linux.

Definition at line 92 of file gmock_output_test.py.

Referenced by GetNormalizedOutputAndLeakyTests().

93  """Normalizes the error marker, which is different on Windows vs on Linux."""
94 
95  return re.sub(r' error: ', ' Failure\n', output)
96 
97 
def NormalizeErrorMarker(output)
def gmock_output_test.RemoveLocations (   output)
Removes all file location info from a Google Test program's output.

Args:
     output:  the output of a Google Test program.

Returns:
     output with all file location info (in the form of
     'DIRECTORY/FILE_NAME:LINE_NUMBER: 'or
     'DIRECTORY\\FILE_NAME(LINE_NUMBER): ') replaced by
     'FILE:#: '.

Definition at line 76 of file gmock_output_test.py.

Referenced by GetNormalizedOutputAndLeakyTests().

76 def RemoveLocations(output):
77  """Removes all file location info from a Google Test program's output.
78 
79  Args:
80  output: the output of a Google Test program.
81 
82  Returns:
83  output with all file location info (in the form of
84  'DIRECTORY/FILE_NAME:LINE_NUMBER: 'or
85  'DIRECTORY\\FILE_NAME(LINE_NUMBER): ') replaced by
86  'FILE:#: '.
87  """
88 
89  return re.sub(r'.*[/\\](.+)(\:\d+|\(\d+\))\:', 'FILE:#:', output)
90 
91 
def RemoveLocations(output)
def gmock_output_test.RemoveMemoryAddresses (   output)
Removes memory addresses from the test output.

Definition at line 98 of file gmock_output_test.py.

Referenced by GetNormalizedOutputAndLeakyTests().

99  """Removes memory addresses from the test output."""
100 
101  return re.sub(r'@\w+', '@0x#', output)
102 
103 
def RemoveMemoryAddresses(output)
def gmock_output_test.RemoveReportHeaderAndFooter (   output)
Removes Google Test result report's header and footer from the output.

Definition at line 65 of file gmock_output_test.py.

Referenced by GetNormalizedOutputAndLeakyTests().

66  """Removes Google Test result report's header and footer from the output."""
67 
68  output = re.sub(r'.*gtest_main.*\n', '', output)
69  output = re.sub(r'\[.*\d+ tests.*\n', '', output)
70  output = re.sub(r'\[.* test environment .*\n', '', output)
71  output = re.sub(r'\[=+\] \d+ tests .* ran.*', '', output)
72  output = re.sub(r'.* FAILED TESTS\n', '', output)
73  return output
74 
75 
def RemoveReportHeaderAndFooter(output)
def gmock_output_test.RemoveTestNamesOfLeakedMocks (   output)
Removes the test names of leaked mock objects from the test output.

Definition at line 104 of file gmock_output_test.py.

Referenced by GetNormalizedOutputAndLeakyTests().

105  """Removes the test names of leaked mock objects from the test output."""
106 
107  return re.sub(r'\(used in test .+\) ', '', output)
108 
109 
def RemoveTestNamesOfLeakedMocks(output)
def gmock_output_test.ToUnixLineEnding (   s)
Changes all Windows/Mac line endings in s to UNIX line endings.

Definition at line 59 of file gmock_output_test.py.

References replace().

Referenced by GetNormalizedOutputAndLeakyTests().

60  """Changes all Windows/Mac line endings in s to UNIX line endings."""
61 
62  return s.replace('\r\n', '\n').replace('\r', '\n')
63 
64 
void BENCHFUN() replace(size_t iters, size_t arg)

Variable Documentation

gmock_output_test._
private

Definition at line 175 of file gmock_output_test.py.

string gmock_output_test.__author__ = 'wan@google.com (Zhanyong Wan)'
private

Definition at line 41 of file gmock_output_test.py.

list gmock_output_test.COMMAND = [PROGRAM_PATH, '--gtest_stack_trace_depth=0', '--gtest_print_time=0']

Definition at line 54 of file gmock_output_test.py.

string gmock_output_test.GENGOLDEN_FLAG = '--gengolden'

Definition at line 51 of file gmock_output_test.py.

gmock_output_test.golden_file = open(GOLDEN_PATH, 'wb')

Definition at line 176 of file gmock_output_test.py.

string gmock_output_test.GOLDEN_NAME = 'gmock_output_test_golden.txt'

Definition at line 55 of file gmock_output_test.py.

gmock_output_test.GOLDEN_PATH = os.path.join(gmock_test_utils.GetSourceDir(), GOLDEN_NAME)

Definition at line 56 of file gmock_output_test.py.

gmock_output_test.output

Definition at line 175 of file gmock_output_test.py.

Referenced by proxygen::ZlibServerFilterFactory.acceptsSupportedCompressionType(), folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >.apply(), folly.backslashify(), BENCHMARK(), testing::InitGoogleTestTest.CheckFlags(), folly::io::test.compressSome(), proxygen::StructuredHeadersStandardTest.convertBase32ToBinary(), testing::internal.CopyElements(), fizz::detail.decFuncBlocks(), proxygen::ZstdStreamDecompressor.decompress(), folly::io::StreamCodec.doCompress(), folly::io::Codec.doCompressString(), folly::io::StreamCodec.doUncompress(), folly::io::Codec.doUncompressString(), fizz::detail.encFuncBlocks(), testing::internal::XmlUnitTestResultPrinter.EscapeXmlText(), fizz::detail.evpDecrypt(), fizz::detail.evpEncrypt(), folly::gen::detail::Parallel< Ops >::Generator< Input, Source, InputDecayed, Composed, Output, OutputDecayed >.foreach(), testing::internal::UnitTestOptions.GetAbsolutePathToOutputFile(), testing.GetDefaultFilter(), getNoteRawContent(), testing::internal::UnitTestOptions.GetOutputFormat(), getSynStream(), testing::internal::GTestFlagSaver.GTestFlagSaver(), proxygen::CodecUtil.hasGzipAndDeflate(), folly.hexlify(), folly.humanify(), folly.join(), testing::Flags.Output(), folly::CustomLogFormatter.parseFormatString(), testing::internal.ParseGoogleTestFlag(), testing::internal::InvokeMethodAction< Class, MethodPtr >.Perform(), testing.PrintFlag(), testing::internal::XmlUnitTestResultPrinter.RemoveInvalidXmlCharacters(), folly.rtrimWhitespace(), testing::InitGoogleTestTest.SetUp(), testing::internal.ShouldRunTestCase(), folly::detail.singletonPrintDestructionStackTrace(), folly.stringVAppendf(), fizz::test.TEST(), folly::io::test.TEST(), TEST(), proxygen.TEST_F(), TEST_F(), proxygen.TEST_P(), fizz::test.TEST_P(), folly::io::test.TEST_P(), testing::Flags.ThrowOnFailure(), fizz.transformBufferBlocks(), folly::io::test.uncompressSome(), folly.unhexlify(), testing::internal::UnitTestRecordPropertyTestHelper.UnitTestRecordProperty(), folly.uriUnescape(), and testing::internal::GTestFlagSaver.~GTestFlagSaver().

gmock_output_test.PROGRAM_PATH = gmock_test_utils.GetTestExecutablePath('gmock_output_test_')

Definition at line 53 of file gmock_output_test.py.