From 532dc2de35f2cef191bc91c3587a9f8f4974756f Mon Sep 17 00:00:00 2001 From: "zhanyong.wan" Date: Wed, 17 Jun 2009 21:06:27 +0000 Subject: Implements a subset of TR1 tuple needed by gtest and gmock (by Zhanyong Wan); cleaned up the Python tests (by Vlad Losev); made run_tests.py invokable from any directory (by Vlad Losev). --- test/gtest_xml_output_unittest.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'test/gtest_xml_output_unittest.py') diff --git a/test/gtest_xml_output_unittest.py b/test/gtest_xml_output_unittest.py index 622251ea..a0cd4d09 100755 --- a/test/gtest_xml_output_unittest.py +++ b/test/gtest_xml_output_unittest.py @@ -34,19 +34,24 @@ __author__ = 'eefacm@gmail.com (Sean Mcafee)' import errno -import gtest_test_utils import os import sys -import tempfile -import unittest - from xml.dom import minidom, Node +import gtest_test_utils import gtest_xml_test_utils + GTEST_OUTPUT_FLAG = "--gtest_output" GTEST_DEFAULT_OUTPUT_FILE = "test_detail.xml" +SUPPORTS_STACK_TRACES = False + +if SUPPORTS_STACK_TRACES: + STACK_TRACE_TEMPLATE = "\nStack trace:\n*" +else: + STACK_TRACE_TEMPLATE = "" + EXPECTED_NON_EMPTY_XML = """ @@ -56,7 +61,7 @@ EXPECTED_NON_EMPTY_XML = """ +Expected: 1%(stack)s]]> @@ -64,10 +69,10 @@ Expected: 1]]> +Expected: 1%(stack)s]]> +Expected: 2%(stack)s]]> @@ -85,7 +90,7 @@ Expected: 2]]> -""" +""" % {'stack': STACK_TRACE_TEMPLATE} EXPECTED_EMPTY_XML = """ @@ -120,8 +125,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): Confirms that Google Test produces an XML output file with the expected default name if no name is explicitly specified. """ - temp_dir = tempfile.mkdtemp() - output_file = os.path.join(temp_dir, GTEST_DEFAULT_OUTPUT_FILE) + output_file = os.path.join(gtest_test_utils.GetTempDir(), + GTEST_DEFAULT_OUTPUT_FILE) gtest_prog_path = gtest_test_utils.GetTestExecutablePath( "gtest_no_test_unittest") try: @@ -132,7 +137,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): p = gtest_test_utils.Subprocess( [gtest_prog_path, "%s=xml" % GTEST_OUTPUT_FLAG], - working_dir=temp_dir) + working_dir=gtest_test_utils.GetTempDir()) self.assert_(p.exited) self.assertEquals(0, p.exit_code) self.assert_(os.path.isfile(output_file)) @@ -145,8 +150,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): XML document. Furthermore, the program's exit code must be expected_exit_code. """ - - xml_path = os.path.join(tempfile.mkdtemp(), gtest_prog_name + "out.xml") + xml_path = os.path.join(gtest_test_utils.GetTempDir(), + gtest_prog_name + "out.xml") gtest_prog_path = gtest_test_utils.GetTestExecutablePath(gtest_prog_name) command = [gtest_prog_path, "%s=xml:%s" % (GTEST_OUTPUT_FLAG, xml_path)] -- cgit v1.2.3