proxygen
gtest_xml_output_unittest.GTestXMLOutputUnitTest Class Reference
Inheritance diagram for gtest_xml_output_unittest.GTestXMLOutputUnitTest:
gtest_xml_test_utils.GTestXMLTestCase gtest_xml_test_utils.GTestXMLTestCase gtest_xml_test_utils.GTestXMLTestCase

Public Member Functions

def testNonEmptyXmlOutput (self)
 
def testEmptyXmlOutput (self)
 
def testTimestampValue (self)
 
def testDefaultOutputFile (self)
 
def testSuppressedXmlOutput (self)
 
def testFilteredTestXmlOutput (self)
 
def testNonEmptyXmlOutput (self)
 
def testEmptyXmlOutput (self)
 
def testTimestampValue (self)
 
def testDefaultOutputFile (self)
 
def testSuppressedXmlOutput (self)
 
def testFilteredTestXmlOutput (self)
 
def testNonEmptyXmlOutput (self)
 
def testEmptyXmlOutput (self)
 
def testTimestampValue (self)
 
def testDefaultOutputFile (self)
 
def testSuppressedXmlOutput (self)
 
def testFilteredTestXmlOutput (self)
 
- Public Member Functions inherited from gtest_xml_test_utils.GTestXMLTestCase
def AssertEquivalentNodes (self, expected_node, actual_node)
 
def NormalizeXml (self, element)
 
def AssertEquivalentNodes (self, expected_node, actual_node)
 
def NormalizeXml (self, element)
 
def AssertEquivalentNodes (self, expected_node, actual_node)
 
def NormalizeXml (self, element)
 

Private Member Functions

def _GetXmlOutput (self, gtest_prog_name, extra_args, expected_exit_code)
 
def _TestXmlOutput (self, gtest_prog_name, expected_xml, expected_exit_code, extra_args=None)
 
def _GetXmlOutput (self, gtest_prog_name, extra_args, expected_exit_code)
 
def _TestXmlOutput (self, gtest_prog_name, expected_xml, expected_exit_code, extra_args=None)
 
def _GetXmlOutput (self, gtest_prog_name, extra_args, expected_exit_code)
 
def _TestXmlOutput (self, gtest_prog_name, expected_xml, expected_exit_code, extra_args=None)
 

Additional Inherited Members

- Static Public Attributes inherited from gtest_xml_test_utils.GTestXMLTestCase
dictionary identifying_attribute
 

Detailed Description

Unit test for Google Test's XML output functionality.

Definition at line 152 of file gtest_xml_output_unittest.py.

Member Function Documentation

def gtest_xml_output_unittest.GTestXMLOutputUnitTest._GetXmlOutput (   self,
  gtest_prog_name,
  extra_args,
  expected_exit_code 
)
private
Returns the xml output generated by running the program gtest_prog_name.
Furthermore, the program's exit code must be expected_exit_code.

Definition at line 263 of file gtest_xml_output_unittest.py.

References gtest_xml_output_unittest.GTestXMLOutputUnitTest._TestXmlOutput(), gtest_test_utils.GetTempDir(), and gtest_test_utils.GetTestExecutablePath().

Referenced by gtest_xml_output_unittest.GTestXMLOutputUnitTest._GetXmlOutput(), gtest_xml_output_unittest.GTestXMLOutputUnitTest._TestXmlOutput(), and gtest_xml_output_unittest.GTestXMLOutputUnitTest.testTimestampValue().

263  def _GetXmlOutput(self, gtest_prog_name, extra_args, expected_exit_code):
264  """
265  Returns the xml output generated by running the program gtest_prog_name.
266  Furthermore, the program's exit code must be expected_exit_code.
267  """
268  xml_path = os.path.join(gtest_test_utils.GetTempDir(),
269  gtest_prog_name + 'out.xml')
270  gtest_prog_path = gtest_test_utils.GetTestExecutablePath(gtest_prog_name)
271 
272  command = ([gtest_prog_path, '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path)] +
273  extra_args)
274  p = gtest_test_utils.Subprocess(command)
275  if p.terminated_by_signal:
276  self.assert_(False,
277  '%s was killed by signal %d' % (gtest_prog_name, p.signal))
278  else:
279  self.assert_(p.exited)
280  self.assertEquals(expected_exit_code, p.exit_code,
281  "'%s' exited with code %s, which doesn't match "
282  'the expected exit code %s.'
283  % (command, p.exit_code, expected_exit_code))
284  actual = minidom.parse(xml_path)
285  return actual
286 
def GetTestExecutablePath(executable_name, build_dir=None)
def _GetXmlOutput(self, gtest_prog_name, extra_args, expected_exit_code)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest._GetXmlOutput (   self,
  gtest_prog_name,
  extra_args,
  expected_exit_code 
)
private
Returns the xml output generated by running the program gtest_prog_name.
Furthermore, the program's exit code must be expected_exit_code.

Definition at line 263 of file gtest_xml_output_unittest.py.

References gtest_xml_output_unittest.GTestXMLOutputUnitTest._GetXmlOutput(), gtest_xml_output_unittest.GTestXMLOutputUnitTest._TestXmlOutput(), gtest_test_utils.GetTempDir(), and gtest_test_utils.GetTestExecutablePath().

263  def _GetXmlOutput(self, gtest_prog_name, extra_args, expected_exit_code):
264  """
265  Returns the xml output generated by running the program gtest_prog_name.
266  Furthermore, the program's exit code must be expected_exit_code.
267  """
268  xml_path = os.path.join(gtest_test_utils.GetTempDir(),
269  gtest_prog_name + 'out.xml')
270  gtest_prog_path = gtest_test_utils.GetTestExecutablePath(gtest_prog_name)
271 
272  command = ([gtest_prog_path, '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path)] +
273  extra_args)
274  p = gtest_test_utils.Subprocess(command)
275  if p.terminated_by_signal:
276  self.assert_(False,
277  '%s was killed by signal %d' % (gtest_prog_name, p.signal))
278  else:
279  self.assert_(p.exited)
280  self.assertEquals(expected_exit_code, p.exit_code,
281  "'%s' exited with code %s, which doesn't match "
282  'the expected exit code %s.'
283  % (command, p.exit_code, expected_exit_code))
284  actual = minidom.parse(xml_path)
285  return actual
286 
def GetTestExecutablePath(executable_name, build_dir=None)
def _GetXmlOutput(self, gtest_prog_name, extra_args, expected_exit_code)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest._GetXmlOutput (   self,
  gtest_prog_name,
  extra_args,
  expected_exit_code 
)
private
Returns the xml output generated by running the program gtest_prog_name.
Furthermore, the program's exit code must be expected_exit_code.

Definition at line 263 of file gtest_xml_output_unittest.py.

References gtest_xml_output_unittest.GTestXMLOutputUnitTest._GetXmlOutput(), gtest_xml_output_unittest.GTestXMLOutputUnitTest._TestXmlOutput(), gtest_test_utils.GetTempDir(), and gtest_test_utils.GetTestExecutablePath().

263  def _GetXmlOutput(self, gtest_prog_name, extra_args, expected_exit_code):
264  """
265  Returns the xml output generated by running the program gtest_prog_name.
266  Furthermore, the program's exit code must be expected_exit_code.
267  """
268  xml_path = os.path.join(gtest_test_utils.GetTempDir(),
269  gtest_prog_name + 'out.xml')
270  gtest_prog_path = gtest_test_utils.GetTestExecutablePath(gtest_prog_name)
271 
272  command = ([gtest_prog_path, '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path)] +
273  extra_args)
274  p = gtest_test_utils.Subprocess(command)
275  if p.terminated_by_signal:
276  self.assert_(False,
277  '%s was killed by signal %d' % (gtest_prog_name, p.signal))
278  else:
279  self.assert_(p.exited)
280  self.assertEquals(expected_exit_code, p.exit_code,
281  "'%s' exited with code %s, which doesn't match "
282  'the expected exit code %s.'
283  % (command, p.exit_code, expected_exit_code))
284  actual = minidom.parse(xml_path)
285  return actual
286 
def GetTestExecutablePath(executable_name, build_dir=None)
def _GetXmlOutput(self, gtest_prog_name, extra_args, expected_exit_code)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest._TestXmlOutput (   self,
  gtest_prog_name,
  expected_xml,
  expected_exit_code,
  extra_args = None 
)
private
Asserts that the XML document generated by running the program
gtest_prog_name matches expected_xml, a string containing another
XML document.  Furthermore, the program's exit code must be
expected_exit_code.

Definition at line 288 of file gtest_xml_output_unittest.py.

References gtest_xml_output_unittest.GTestXMLOutputUnitTest._GetXmlOutput(), gtest_xml_test_utils.GTestXMLTestCase.AssertEquivalentNodes(), gtest_test_utils.Main(), and gtest_xml_test_utils.GTestXMLTestCase.NormalizeXml().

288  expected_exit_code, extra_args=None):
289  """
290  Asserts that the XML document generated by running the program
291  gtest_prog_name matches expected_xml, a string containing another
292  XML document. Furthermore, the program's exit code must be
293  expected_exit_code.
294  """
295 
296  actual = self._GetXmlOutput(gtest_prog_name, extra_args or [],
297  expected_exit_code)
298  expected = minidom.parseString(expected_xml)
299  self.NormalizeXml(actual.documentElement)
300  self.AssertEquivalentNodes(expected.documentElement,
301  actual.documentElement)
302  expected.unlink()
303  actual.unlink()
304 
305 
def AssertEquivalentNodes(self, expected_node, actual_node)
def _GetXmlOutput(self, gtest_prog_name, extra_args, expected_exit_code)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest._TestXmlOutput (   self,
  gtest_prog_name,
  expected_xml,
  expected_exit_code,
  extra_args = None 
)
private
Asserts that the XML document generated by running the program
gtest_prog_name matches expected_xml, a string containing another
XML document.  Furthermore, the program's exit code must be
expected_exit_code.

Definition at line 288 of file gtest_xml_output_unittest.py.

References gtest_xml_output_unittest.GTestXMLOutputUnitTest._GetXmlOutput(), gtest_xml_test_utils.GTestXMLTestCase.AssertEquivalentNodes(), gtest_test_utils.Main(), and gtest_xml_test_utils.GTestXMLTestCase.NormalizeXml().

Referenced by gtest_xml_output_unittest.GTestXMLOutputUnitTest._GetXmlOutput(), gtest_xml_output_unittest.GTestXMLOutputUnitTest.testEmptyXmlOutput(), gtest_xml_output_unittest.GTestXMLOutputUnitTest.testFilteredTestXmlOutput(), and gtest_xml_output_unittest.GTestXMLOutputUnitTest.testNonEmptyXmlOutput().

288  expected_exit_code, extra_args=None):
289  """
290  Asserts that the XML document generated by running the program
291  gtest_prog_name matches expected_xml, a string containing another
292  XML document. Furthermore, the program's exit code must be
293  expected_exit_code.
294  """
295 
296  actual = self._GetXmlOutput(gtest_prog_name, extra_args or [],
297  expected_exit_code)
298  expected = minidom.parseString(expected_xml)
299  self.NormalizeXml(actual.documentElement)
300  self.AssertEquivalentNodes(expected.documentElement,
301  actual.documentElement)
302  expected.unlink()
303  actual.unlink()
304 
305 
def AssertEquivalentNodes(self, expected_node, actual_node)
def _GetXmlOutput(self, gtest_prog_name, extra_args, expected_exit_code)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest._TestXmlOutput (   self,
  gtest_prog_name,
  expected_xml,
  expected_exit_code,
  extra_args = None 
)
private
Asserts that the XML document generated by running the program
gtest_prog_name matches expected_xml, a string containing another
XML document.  Furthermore, the program's exit code must be
expected_exit_code.

Definition at line 288 of file gtest_xml_output_unittest.py.

References gtest_xml_output_unittest.GTestXMLOutputUnitTest._GetXmlOutput(), gtest_xml_test_utils.GTestXMLTestCase.AssertEquivalentNodes(), gtest_test_utils.Main(), and gtest_xml_test_utils.GTestXMLTestCase.NormalizeXml().

288  expected_exit_code, extra_args=None):
289  """
290  Asserts that the XML document generated by running the program
291  gtest_prog_name matches expected_xml, a string containing another
292  XML document. Furthermore, the program's exit code must be
293  expected_exit_code.
294  """
295 
296  actual = self._GetXmlOutput(gtest_prog_name, extra_args or [],
297  expected_exit_code)
298  expected = minidom.parseString(expected_xml)
299  self.NormalizeXml(actual.documentElement)
300  self.AssertEquivalentNodes(expected.documentElement,
301  actual.documentElement)
302  expected.unlink()
303  actual.unlink()
304 
305 
def AssertEquivalentNodes(self, expected_node, actual_node)
def _GetXmlOutput(self, gtest_prog_name, extra_args, expected_exit_code)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest.testDefaultOutputFile (   self)
Confirms that Google Test produces an XML output file with the expected
default name if no name is explicitly specified.

Definition at line 201 of file gtest_xml_output_unittest.py.

References gtest_test_utils.GetTempDir(), gtest_test_utils.GetTestExecutablePath(), and gtest_xml_output_unittest.GTestXMLOutputUnitTest.testDefaultOutputFile().

202  """
203  Confirms that Google Test produces an XML output file with the expected
204  default name if no name is explicitly specified.
205  """
206  output_file = os.path.join(gtest_test_utils.GetTempDir(),
207  GTEST_DEFAULT_OUTPUT_FILE)
208  gtest_prog_path = gtest_test_utils.GetTestExecutablePath(
209  'gtest_no_test_unittest')
210  try:
211  os.remove(output_file)
212  except OSError:
213  e = sys.exc_info()[1]
214  if e.errno != errno.ENOENT:
215  raise
216 
218  [gtest_prog_path, '%s=xml' % GTEST_OUTPUT_FLAG],
219  working_dir=gtest_test_utils.GetTempDir())
220  self.assert_(p.exited)
221  self.assertEquals(0, p.exit_code)
222  self.assert_(os.path.isfile(output_file))
223 
def GetTestExecutablePath(executable_name, build_dir=None)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest.testDefaultOutputFile (   self)
Confirms that Google Test produces an XML output file with the expected
default name if no name is explicitly specified.

Definition at line 201 of file gtest_xml_output_unittest.py.

References gtest_test_utils.GetTempDir(), gtest_test_utils.GetTestExecutablePath(), and gtest_xml_output_unittest.GTestXMLOutputUnitTest.testDefaultOutputFile().

202  """
203  Confirms that Google Test produces an XML output file with the expected
204  default name if no name is explicitly specified.
205  """
206  output_file = os.path.join(gtest_test_utils.GetTempDir(),
207  GTEST_DEFAULT_OUTPUT_FILE)
208  gtest_prog_path = gtest_test_utils.GetTestExecutablePath(
209  'gtest_no_test_unittest')
210  try:
211  os.remove(output_file)
212  except OSError:
213  e = sys.exc_info()[1]
214  if e.errno != errno.ENOENT:
215  raise
216 
218  [gtest_prog_path, '%s=xml' % GTEST_OUTPUT_FLAG],
219  working_dir=gtest_test_utils.GetTempDir())
220  self.assert_(p.exited)
221  self.assertEquals(0, p.exit_code)
222  self.assert_(os.path.isfile(output_file))
223 
def GetTestExecutablePath(executable_name, build_dir=None)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest.testDefaultOutputFile (   self)
Confirms that Google Test produces an XML output file with the expected
default name if no name is explicitly specified.

Definition at line 201 of file gtest_xml_output_unittest.py.

References gtest_test_utils.GetTempDir(), and gtest_test_utils.GetTestExecutablePath().

Referenced by gtest_xml_output_unittest.GTestXMLOutputUnitTest.testDefaultOutputFile().

202  """
203  Confirms that Google Test produces an XML output file with the expected
204  default name if no name is explicitly specified.
205  """
206  output_file = os.path.join(gtest_test_utils.GetTempDir(),
207  GTEST_DEFAULT_OUTPUT_FILE)
208  gtest_prog_path = gtest_test_utils.GetTestExecutablePath(
209  'gtest_no_test_unittest')
210  try:
211  os.remove(output_file)
212  except OSError:
213  e = sys.exc_info()[1]
214  if e.errno != errno.ENOENT:
215  raise
216 
218  [gtest_prog_path, '%s=xml' % GTEST_OUTPUT_FLAG],
219  working_dir=gtest_test_utils.GetTempDir())
220  self.assert_(p.exited)
221  self.assertEquals(0, p.exit_code)
222  self.assert_(os.path.isfile(output_file))
223 
def GetTestExecutablePath(executable_name, build_dir=None)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest.testEmptyXmlOutput (   self)
Verifies XML output for a Google Test binary without actual tests.

Runs a test program that generates an empty XML output, and
tests that the XML output is expected.

Definition at line 167 of file gtest_xml_output_unittest.py.

References gtest_xml_output_unittest.GTestXMLOutputUnitTest._TestXmlOutput().

Referenced by gtest_xml_output_unittest.GTestXMLOutputUnitTest.testEmptyXmlOutput().

168  """Verifies XML output for a Google Test binary without actual tests.
169 
170  Runs a test program that generates an empty XML output, and
171  tests that the XML output is expected.
172  """
173 
174  self._TestXmlOutput('gtest_no_test_unittest', EXPECTED_EMPTY_XML, 0)
175 
def _TestXmlOutput(self, gtest_prog_name, expected_xml, expected_exit_code, extra_args=None)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest.testEmptyXmlOutput (   self)
Verifies XML output for a Google Test binary without actual tests.

Runs a test program that generates an empty XML output, and
tests that the XML output is expected.

Definition at line 167 of file gtest_xml_output_unittest.py.

References gtest_xml_output_unittest.GTestXMLOutputUnitTest._TestXmlOutput(), and gtest_xml_output_unittest.GTestXMLOutputUnitTest.testEmptyXmlOutput().

168  """Verifies XML output for a Google Test binary without actual tests.
169 
170  Runs a test program that generates an empty XML output, and
171  tests that the XML output is expected.
172  """
173 
174  self._TestXmlOutput('gtest_no_test_unittest', EXPECTED_EMPTY_XML, 0)
175 
def _TestXmlOutput(self, gtest_prog_name, expected_xml, expected_exit_code, extra_args=None)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest.testEmptyXmlOutput (   self)
Verifies XML output for a Google Test binary without actual tests.

Runs a test program that generates an empty XML output, and
tests that the XML output is expected.

Definition at line 167 of file gtest_xml_output_unittest.py.

References gtest_xml_output_unittest.GTestXMLOutputUnitTest._TestXmlOutput(), and gtest_xml_output_unittest.GTestXMLOutputUnitTest.testEmptyXmlOutput().

168  """Verifies XML output for a Google Test binary without actual tests.
169 
170  Runs a test program that generates an empty XML output, and
171  tests that the XML output is expected.
172  """
173 
174  self._TestXmlOutput('gtest_no_test_unittest', EXPECTED_EMPTY_XML, 0)
175 
def _TestXmlOutput(self, gtest_prog_name, expected_xml, expected_exit_code, extra_args=None)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest.testFilteredTestXmlOutput (   self)
Verifies XML output when a filter is applied.

Runs a test program that executes only some tests and verifies that
non-selected tests do not show up in the XML output.

Definition at line 253 of file gtest_xml_output_unittest.py.

References gtest_xml_output_unittest.GTestXMLOutputUnitTest._TestXmlOutput().

Referenced by gtest_xml_output_unittest.GTestXMLOutputUnitTest.testFilteredTestXmlOutput().

254  """Verifies XML output when a filter is applied.
255 
256  Runs a test program that executes only some tests and verifies that
257  non-selected tests do not show up in the XML output.
258  """
259 
260  self._TestXmlOutput(GTEST_PROGRAM_NAME, EXPECTED_FILTERED_TEST_XML, 0,
261  extra_args=['%s=SuccessfulTest.*' % GTEST_FILTER_FLAG])
262 
def _TestXmlOutput(self, gtest_prog_name, expected_xml, expected_exit_code, extra_args=None)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest.testFilteredTestXmlOutput (   self)
Verifies XML output when a filter is applied.

Runs a test program that executes only some tests and verifies that
non-selected tests do not show up in the XML output.

Definition at line 253 of file gtest_xml_output_unittest.py.

References gtest_xml_output_unittest.GTestXMLOutputUnitTest._TestXmlOutput(), and gtest_xml_output_unittest.GTestXMLOutputUnitTest.testFilteredTestXmlOutput().

254  """Verifies XML output when a filter is applied.
255 
256  Runs a test program that executes only some tests and verifies that
257  non-selected tests do not show up in the XML output.
258  """
259 
260  self._TestXmlOutput(GTEST_PROGRAM_NAME, EXPECTED_FILTERED_TEST_XML, 0,
261  extra_args=['%s=SuccessfulTest.*' % GTEST_FILTER_FLAG])
262 
def _TestXmlOutput(self, gtest_prog_name, expected_xml, expected_exit_code, extra_args=None)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest.testFilteredTestXmlOutput (   self)
Verifies XML output when a filter is applied.

Runs a test program that executes only some tests and verifies that
non-selected tests do not show up in the XML output.

Definition at line 253 of file gtest_xml_output_unittest.py.

References gtest_xml_output_unittest.GTestXMLOutputUnitTest._TestXmlOutput(), and gtest_xml_output_unittest.GTestXMLOutputUnitTest.testFilteredTestXmlOutput().

254  """Verifies XML output when a filter is applied.
255 
256  Runs a test program that executes only some tests and verifies that
257  non-selected tests do not show up in the XML output.
258  """
259 
260  self._TestXmlOutput(GTEST_PROGRAM_NAME, EXPECTED_FILTERED_TEST_XML, 0,
261  extra_args=['%s=SuccessfulTest.*' % GTEST_FILTER_FLAG])
262 
def _TestXmlOutput(self, gtest_prog_name, expected_xml, expected_exit_code, extra_args=None)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest.testNonEmptyXmlOutput (   self)
Runs a test program that generates a non-empty XML output, and
tests that the XML output is expected.

Definition at line 160 of file gtest_xml_output_unittest.py.

References gtest_xml_output_unittest.GTestXMLOutputUnitTest._TestXmlOutput().

Referenced by gtest_xml_output_unittest.GTestXMLOutputUnitTest.testNonEmptyXmlOutput().

161  """
162  Runs a test program that generates a non-empty XML output, and
163  tests that the XML output is expected.
164  """
165  self._TestXmlOutput(GTEST_PROGRAM_NAME, EXPECTED_NON_EMPTY_XML, 1)
166 
def _TestXmlOutput(self, gtest_prog_name, expected_xml, expected_exit_code, extra_args=None)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest.testNonEmptyXmlOutput (   self)
Runs a test program that generates a non-empty XML output, and
tests that the XML output is expected.

Definition at line 160 of file gtest_xml_output_unittest.py.

References gtest_xml_output_unittest.GTestXMLOutputUnitTest._TestXmlOutput(), and gtest_xml_output_unittest.GTestXMLOutputUnitTest.testNonEmptyXmlOutput().

161  """
162  Runs a test program that generates a non-empty XML output, and
163  tests that the XML output is expected.
164  """
165  self._TestXmlOutput(GTEST_PROGRAM_NAME, EXPECTED_NON_EMPTY_XML, 1)
166 
def _TestXmlOutput(self, gtest_prog_name, expected_xml, expected_exit_code, extra_args=None)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest.testNonEmptyXmlOutput (   self)
Runs a test program that generates a non-empty XML output, and
tests that the XML output is expected.

Definition at line 160 of file gtest_xml_output_unittest.py.

References gtest_xml_output_unittest.GTestXMLOutputUnitTest._TestXmlOutput(), and gtest_xml_output_unittest.GTestXMLOutputUnitTest.testNonEmptyXmlOutput().

161  """
162  Runs a test program that generates a non-empty XML output, and
163  tests that the XML output is expected.
164  """
165  self._TestXmlOutput(GTEST_PROGRAM_NAME, EXPECTED_NON_EMPTY_XML, 1)
166 
def _TestXmlOutput(self, gtest_prog_name, expected_xml, expected_exit_code, extra_args=None)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest.testSuppressedXmlOutput (   self)
Tests that no XML file is generated if the default XML listener is
shut down before RUN_ALL_TESTS is invoked.

Definition at line 224 of file gtest_xml_output_unittest.py.

References gtest_test_utils.GetTempDir(), and gtest_xml_output_unittest.GTestXMLOutputUnitTest.testSuppressedXmlOutput().

225  """
226  Tests that no XML file is generated if the default XML listener is
227  shut down before RUN_ALL_TESTS is invoked.
228  """
229 
230  xml_path = os.path.join(gtest_test_utils.GetTempDir(),
231  GTEST_PROGRAM_NAME + 'out.xml')
232  if os.path.isfile(xml_path):
233  os.remove(xml_path)
234 
235  command = [GTEST_PROGRAM_PATH,
236  '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path),
237  '--shut_down_xml']
238  p = gtest_test_utils.Subprocess(command)
239  if p.terminated_by_signal:
240  # p.signal is avalable only if p.terminated_by_signal is True.
241  self.assertFalse(
242  p.terminated_by_signal,
243  '%s was killed by signal %d' % (GTEST_PROGRAM_NAME, p.signal))
244  else:
245  self.assert_(p.exited)
246  self.assertEquals(1, p.exit_code,
247  "'%s' exited with code %s, which doesn't match "
248  'the expected exit code %s.'
249  % (command, p.exit_code, 1))
250 
251  self.assert_(not os.path.isfile(xml_path))
252 
def gtest_xml_output_unittest.GTestXMLOutputUnitTest.testSuppressedXmlOutput (   self)
Tests that no XML file is generated if the default XML listener is
shut down before RUN_ALL_TESTS is invoked.

Definition at line 224 of file gtest_xml_output_unittest.py.

References gtest_test_utils.GetTempDir(), and gtest_xml_output_unittest.GTestXMLOutputUnitTest.testSuppressedXmlOutput().

225  """
226  Tests that no XML file is generated if the default XML listener is
227  shut down before RUN_ALL_TESTS is invoked.
228  """
229 
230  xml_path = os.path.join(gtest_test_utils.GetTempDir(),
231  GTEST_PROGRAM_NAME + 'out.xml')
232  if os.path.isfile(xml_path):
233  os.remove(xml_path)
234 
235  command = [GTEST_PROGRAM_PATH,
236  '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path),
237  '--shut_down_xml']
238  p = gtest_test_utils.Subprocess(command)
239  if p.terminated_by_signal:
240  # p.signal is avalable only if p.terminated_by_signal is True.
241  self.assertFalse(
242  p.terminated_by_signal,
243  '%s was killed by signal %d' % (GTEST_PROGRAM_NAME, p.signal))
244  else:
245  self.assert_(p.exited)
246  self.assertEquals(1, p.exit_code,
247  "'%s' exited with code %s, which doesn't match "
248  'the expected exit code %s.'
249  % (command, p.exit_code, 1))
250 
251  self.assert_(not os.path.isfile(xml_path))
252 
def gtest_xml_output_unittest.GTestXMLOutputUnitTest.testSuppressedXmlOutput (   self)
Tests that no XML file is generated if the default XML listener is
shut down before RUN_ALL_TESTS is invoked.

Definition at line 224 of file gtest_xml_output_unittest.py.

References gtest_test_utils.GetTempDir().

Referenced by gtest_xml_output_unittest.GTestXMLOutputUnitTest.testSuppressedXmlOutput().

225  """
226  Tests that no XML file is generated if the default XML listener is
227  shut down before RUN_ALL_TESTS is invoked.
228  """
229 
230  xml_path = os.path.join(gtest_test_utils.GetTempDir(),
231  GTEST_PROGRAM_NAME + 'out.xml')
232  if os.path.isfile(xml_path):
233  os.remove(xml_path)
234 
235  command = [GTEST_PROGRAM_PATH,
236  '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path),
237  '--shut_down_xml']
238  p = gtest_test_utils.Subprocess(command)
239  if p.terminated_by_signal:
240  # p.signal is avalable only if p.terminated_by_signal is True.
241  self.assertFalse(
242  p.terminated_by_signal,
243  '%s was killed by signal %d' % (GTEST_PROGRAM_NAME, p.signal))
244  else:
245  self.assert_(p.exited)
246  self.assertEquals(1, p.exit_code,
247  "'%s' exited with code %s, which doesn't match "
248  'the expected exit code %s.'
249  % (command, p.exit_code, 1))
250 
251  self.assert_(not os.path.isfile(xml_path))
252 
def gtest_xml_output_unittest.GTestXMLOutputUnitTest.testTimestampValue (   self)
Checks whether the timestamp attribute in the XML output is valid.

Runs a test program that generates an empty XML output, and checks if
the timestamp attribute in the testsuites tag is valid.

Definition at line 176 of file gtest_xml_output_unittest.py.

References gtest_xml_output_unittest.GTestXMLOutputUnitTest._GetXmlOutput(), and gtest_xml_output_unittest.GTestXMLOutputUnitTest.testTimestampValue().

177  """Checks whether the timestamp attribute in the XML output is valid.
178 
179  Runs a test program that generates an empty XML output, and checks if
180  the timestamp attribute in the testsuites tag is valid.
181  """
182  actual = self._GetXmlOutput('gtest_no_test_unittest', [], 0)
183  date_time_str = actual.documentElement.getAttributeNode('timestamp').value
184  # datetime.strptime() is only available in Python 2.5+ so we have to
185  # parse the expected datetime manually.
186  match = re.match(r'(\d+)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)', date_time_str)
187  self.assertTrue(
188  re.match,
189  'XML datettime string %s has incorrect format' % date_time_str)
190  date_time_from_xml = datetime.datetime(
191  year=int(match.group(1)), month=int(match.group(2)),
192  day=int(match.group(3)), hour=int(match.group(4)),
193  minute=int(match.group(5)), second=int(match.group(6)))
194 
195  time_delta = abs(datetime.datetime.now() - date_time_from_xml)
196  # timestamp value should be near the current local time
197  self.assertTrue(time_delta < datetime.timedelta(seconds=600),
198  'time_delta is %s' % time_delta)
199  actual.unlink()
200 
def _GetXmlOutput(self, gtest_prog_name, extra_args, expected_exit_code)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest.testTimestampValue (   self)
Checks whether the timestamp attribute in the XML output is valid.

Runs a test program that generates an empty XML output, and checks if
the timestamp attribute in the testsuites tag is valid.

Definition at line 176 of file gtest_xml_output_unittest.py.

References gtest_xml_output_unittest.GTestXMLOutputUnitTest._GetXmlOutput().

Referenced by gtest_xml_output_unittest.GTestXMLOutputUnitTest.testTimestampValue().

177  """Checks whether the timestamp attribute in the XML output is valid.
178 
179  Runs a test program that generates an empty XML output, and checks if
180  the timestamp attribute in the testsuites tag is valid.
181  """
182  actual = self._GetXmlOutput('gtest_no_test_unittest', [], 0)
183  date_time_str = actual.documentElement.getAttributeNode('timestamp').value
184  # datetime.strptime() is only available in Python 2.5+ so we have to
185  # parse the expected datetime manually.
186  match = re.match(r'(\d+)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)', date_time_str)
187  self.assertTrue(
188  re.match,
189  'XML datettime string %s has incorrect format' % date_time_str)
190  date_time_from_xml = datetime.datetime(
191  year=int(match.group(1)), month=int(match.group(2)),
192  day=int(match.group(3)), hour=int(match.group(4)),
193  minute=int(match.group(5)), second=int(match.group(6)))
194 
195  time_delta = abs(datetime.datetime.now() - date_time_from_xml)
196  # timestamp value should be near the current local time
197  self.assertTrue(time_delta < datetime.timedelta(seconds=600),
198  'time_delta is %s' % time_delta)
199  actual.unlink()
200 
def _GetXmlOutput(self, gtest_prog_name, extra_args, expected_exit_code)
def gtest_xml_output_unittest.GTestXMLOutputUnitTest.testTimestampValue (   self)
Checks whether the timestamp attribute in the XML output is valid.

Runs a test program that generates an empty XML output, and checks if
the timestamp attribute in the testsuites tag is valid.

Definition at line 176 of file gtest_xml_output_unittest.py.

References gtest_xml_output_unittest.GTestXMLOutputUnitTest._GetXmlOutput(), and gtest_xml_output_unittest.GTestXMLOutputUnitTest.testTimestampValue().

177  """Checks whether the timestamp attribute in the XML output is valid.
178 
179  Runs a test program that generates an empty XML output, and checks if
180  the timestamp attribute in the testsuites tag is valid.
181  """
182  actual = self._GetXmlOutput('gtest_no_test_unittest', [], 0)
183  date_time_str = actual.documentElement.getAttributeNode('timestamp').value
184  # datetime.strptime() is only available in Python 2.5+ so we have to
185  # parse the expected datetime manually.
186  match = re.match(r'(\d+)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)', date_time_str)
187  self.assertTrue(
188  re.match,
189  'XML datettime string %s has incorrect format' % date_time_str)
190  date_time_from_xml = datetime.datetime(
191  year=int(match.group(1)), month=int(match.group(2)),
192  day=int(match.group(3)), hour=int(match.group(4)),
193  minute=int(match.group(5)), second=int(match.group(6)))
194 
195  time_delta = abs(datetime.datetime.now() - date_time_from_xml)
196  # timestamp value should be near the current local time
197  self.assertTrue(time_delta < datetime.timedelta(seconds=600),
198  'time_delta is %s' % time_delta)
199  actual.unlink()
200 
def _GetXmlOutput(self, gtest_prog_name, extra_args, expected_exit_code)

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