summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGennadiy Civil <misterg@google.com>2018-01-22 16:47:30 (GMT)
committerGennadiy Civil <misterg@google.com>2018-01-22 16:47:30 (GMT)
commit8d707dfe817df153efd6fe7832b6149244ed7665 (patch)
tree49481950a0bc991e97ec8d9111e722e7cc4b3545
parent62ba5d91d0ceff98fbd95294bd94c97017a07f9e (diff)
downloadgoogletest-8d707dfe817df153efd6fe7832b6149244ed7665.zip
googletest-8d707dfe817df153efd6fe7832b6149244ed7665.tar.gz
googletest-8d707dfe817df153efd6fe7832b6149244ed7665.tar.bz2
code merge
-rwxr-xr-xgoogletest/test/gtest_color_test.py1
-rwxr-xr-xgoogletest/test/gtest_filter_unittest.py38
-rwxr-xr-xgoogletest/test/gtest_list_tests_unittest.py8
-rwxr-xr-xgoogletest/test/gtest_output_test.py13
-rwxr-xr-xgoogletest/test/gtest_test_utils.py16
-rwxr-xr-xgoogletest/test/gtest_throw_on_failure_test.py2
-rwxr-xr-xgoogletest/test/gtest_uninitialized_test.py5
-rwxr-xr-xgoogletest/test/gtest_xml_outfiles_test.py4
8 files changed, 44 insertions, 43 deletions
diff --git a/googletest/test/gtest_color_test.py b/googletest/test/gtest_color_test.py
index d02a53e..7d3e888 100755
--- a/googletest/test/gtest_color_test.py
+++ b/googletest/test/gtest_color_test.py
@@ -36,7 +36,6 @@ __author__ = 'wan@google.com (Zhanyong Wan)'
import os
import gtest_test_utils
-
IS_WINDOWS = os.name = 'nt'
COLOR_ENV_VAR = 'GTEST_COLOR'
diff --git a/googletest/test/gtest_filter_unittest.py b/googletest/test/gtest_filter_unittest.py
index ec0b151..92cc77c 100755
--- a/googletest/test/gtest_filter_unittest.py
+++ b/googletest/test/gtest_filter_unittest.py
@@ -44,12 +44,8 @@ __author__ = 'wan@google.com (Zhanyong Wan)'
import os
import re
-try:
- from sets import Set as set # For Python 2.3 compatibility
-except ImportError:
- pass
+import sets
import sys
-
import gtest_test_utils
# Constants.
@@ -59,10 +55,12 @@ import gtest_test_utils
# script in a subprocess to print whether the variable is STILL in
# os.environ. We then use 'eval' to parse the child's output so that an
# exception is thrown if the input is anything other than 'True' nor 'False'.
-os.environ['EMPTY_VAR'] = ''
-child = gtest_test_utils.Subprocess(
- [sys.executable, '-c', 'import os; print(\'EMPTY_VAR\' in os.environ)'])
-CAN_PASS_EMPTY_ENV = eval(child.output)
+CAN_PASS_EMPTY_ENV = False
+if sys.executable:
+ os.environ['EMPTY_VAR'] = ''
+ child = gtest_test_utils.Subprocess(
+ [sys.executable, '-c', 'import os; print \'EMPTY_VAR\' in os.environ'])
+ CAN_PASS_EMPTY_ENV = eval(child.output)
# Check if this platform can unset environment variables in child processes.
@@ -71,11 +69,14 @@ CAN_PASS_EMPTY_ENV = eval(child.output)
# is NO LONGER in os.environ.
# We use 'eval' to parse the child's output so that an exception
# is thrown if the input is neither 'True' nor 'False'.
-os.environ['UNSET_VAR'] = 'X'
-del os.environ['UNSET_VAR']
-child = gtest_test_utils.Subprocess(
- [sys.executable, '-c', 'import os; print(\'UNSET_VAR\' not in os.environ)'])
-CAN_UNSET_ENV = eval(child.output)
+CAN_UNSET_ENV = False
+if sys.executable:
+ os.environ['UNSET_VAR'] = 'X'
+ del os.environ['UNSET_VAR']
+ child = gtest_test_utils.Subprocess(
+ [sys.executable, '-c', 'import os; print \'UNSET_VAR\' not in os.environ'
+ ])
+ CAN_UNSET_ENV = eval(child.output)
# Checks if we should test with an empty filter. This doesn't
@@ -97,7 +98,7 @@ SHARD_STATUS_FILE_ENV_VAR = 'GTEST_SHARD_STATUS_FILE'
FILTER_FLAG = 'gtest_filter'
# The command line flag for including disabled tests.
-ALSO_RUN_DISABED_TESTS_FLAG = 'gtest_also_run_disabled_tests'
+ALSO_RUN_DISABLED_TESTS_FLAG = 'gtest_also_run_disabled_tests'
# Command to run the gtest_filter_unittest_ program.
COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_filter_unittest_')
@@ -246,14 +247,14 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
for slice_var in list_of_sets:
full_partition.extend(slice_var)
self.assertEqual(len(set_var), len(full_partition))
- self.assertEqual(set(set_var), set(full_partition))
+ self.assertEqual(sets.Set(set_var), sets.Set(full_partition))
def AdjustForParameterizedTests(self, tests_to_run):
"""Adjust tests_to_run in case value parameterized tests are disabled."""
global param_tests_present
if not param_tests_present:
- return list(set(tests_to_run) - set(PARAM_TESTS))
+ return list(sets.Set(tests_to_run) - sets.Set(PARAM_TESTS))
else:
return tests_to_run
@@ -294,6 +295,7 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
Runs all shards of gtest_filter_unittest_ with the given filter, and
verifies that the right set of tests were run. The union of tests run
on each shard should be identical to tests_to_run, without duplicates.
+ If check_exit_0, .
Args:
gtest_filter: A filter to apply to the tests.
@@ -339,7 +341,7 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase):
tests_to_run = self.AdjustForParameterizedTests(tests_to_run)
# Construct the command line.
- args = ['--%s' % ALSO_RUN_DISABED_TESTS_FLAG]
+ args = ['--%s' % ALSO_RUN_DISABLED_TESTS_FLAG]
if gtest_filter is not None:
args.append('--%s=%s' % (FILTER_FLAG, gtest_filter))
diff --git a/googletest/test/gtest_list_tests_unittest.py b/googletest/test/gtest_list_tests_unittest.py
index f2d2fd1..0844f98 100755
--- a/googletest/test/gtest_list_tests_unittest.py
+++ b/googletest/test/gtest_list_tests_unittest.py
@@ -39,9 +39,8 @@ Google Test) the command line flags.
__author__ = 'phanna@google.com (Patrick Hanna)'
-import gtest_test_utils
import re
-
+import gtest_test_utils
# Constants.
@@ -71,7 +70,7 @@ FooTest\.
TypedTest/0\. # TypeParam = (VeryLo{245}|class VeryLo{239})\.\.\.
TestA
TestB
-TypedTest/1\. # TypeParam = int\s*\*( __ptr64)?
+TypedTest/1\. # TypeParam = int\s*\*
TestA
TestB
TypedTest/2\. # TypeParam = .*MyArray<bool,\s*42>
@@ -80,7 +79,7 @@ TypedTest/2\. # TypeParam = .*MyArray<bool,\s*42>
My/TypeParamTest/0\. # TypeParam = (VeryLo{245}|class VeryLo{239})\.\.\.
TestA
TestB
-My/TypeParamTest/1\. # TypeParam = int\s*\*( __ptr64)?
+My/TypeParamTest/1\. # TypeParam = int\s*\*
TestA
TestB
My/TypeParamTest/2\. # TypeParam = .*MyArray<bool,\s*42>
@@ -123,6 +122,7 @@ def Run(args):
# The unit test.
+
class GTestListTestsUnitTest(gtest_test_utils.TestCase):
"""Tests using the --gtest_list_tests flag to list all tests."""
diff --git a/googletest/test/gtest_output_test.py b/googletest/test/gtest_output_test.py
index 78a0015..e431653 100755
--- a/googletest/test/gtest_output_test.py
+++ b/googletest/test/gtest_output_test.py
@@ -31,6 +31,7 @@
"""Tests the text output of Google C++ Testing Framework.
+
SYNOPSIS
gtest_output_test.py --build_dir=BUILD/DIR --gengolden
# where BUILD/DIR contains the built gtest_output_test_ file.
@@ -51,6 +52,7 @@ import gtest_test_utils
GENGOLDEN_FLAG = '--gengolden'
CATCH_EXCEPTIONS_ENV_VAR_NAME = 'GTEST_CATCH_EXCEPTIONS'
+IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
IS_WINDOWS = os.name == 'nt'
# TODO(vladl@google.com): remove the _lin suffix.
@@ -250,11 +252,12 @@ test_list = GetShellCommandOutput(COMMAND_LIST_TESTS)
SUPPORTS_DEATH_TESTS = 'DeathTest' in test_list
SUPPORTS_TYPED_TESTS = 'TypedTest' in test_list
SUPPORTS_THREADS = 'ExpectFailureWithThreadsTest' in test_list
-SUPPORTS_STACK_TRACES = False
+SUPPORTS_STACK_TRACES = IS_LINUX
CAN_GENERATE_GOLDEN_FILE = (SUPPORTS_DEATH_TESTS and
SUPPORTS_TYPED_TESTS and
SUPPORTS_THREADS and
+ SUPPORTS_STACK_TRACES and
not IS_WINDOWS)
class GTestOutputTest(gtest_test_utils.TestCase):
@@ -280,7 +283,7 @@ class GTestOutputTest(gtest_test_utils.TestCase):
def testOutput(self):
output = GetOutputOfAllCommands()
- golden_file = open(GOLDEN_PATH, 'r')
+ golden_file = open(GOLDEN_PATH, 'rb')
# A mis-configured source control system can cause \r appear in EOL
# sequences when we read the golden file irrespective of an operating
# system used. Therefore, we need to strip those \r's from newlines
@@ -331,9 +334,9 @@ if __name__ == '__main__':
else:
message = (
"""Unable to write a golden file when compiled in an environment
-that does not support all the required features (death tests, typed tests,
-and multiple threads). Please generate the golden file using a binary built
-with those features enabled.""")
+that does not support all the required features (death tests,
+typed tests, stack traces, and multiple threads).
+Please build this test and generate the golden file using Blaze on Linux.""")
sys.stderr.write(message)
sys.exit(1)
diff --git a/googletest/test/gtest_test_utils.py b/googletest/test/gtest_test_utils.py
index d2b6748..89d1469 100755
--- a/googletest/test/gtest_test_utils.py
+++ b/googletest/test/gtest_test_utils.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-#
# Copyright 2006, Google Inc.
# All rights reserved.
#
@@ -33,10 +31,15 @@
__author__ = 'wan@google.com (Zhanyong Wan)'
-import atexit
import os
-import shutil
import sys
+
+IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
+IS_WINDOWS = os.name == 'nt'
+IS_CYGWIN = os.name == 'posix' and 'CYGWIN' in os.uname()[0]
+
+import atexit
+import shutil
import tempfile
import unittest
_test_module = unittest
@@ -53,9 +56,6 @@ except:
GTEST_OUTPUT_VAR_NAME = 'GTEST_OUTPUT'
-IS_WINDOWS = os.name == 'nt'
-IS_CYGWIN = os.name == 'posix' and 'CYGWIN' in os.uname()[0]
-
# The environment variable for specifying the path to the premature-exit file.
PREMATURE_EXIT_FILE_ENV_VAR = 'TEST_PREMATURE_EXIT_FILE'
@@ -178,7 +178,7 @@ def GetTestExecutablePath(executable_name, build_dir=None):
'Unable to find the test binary "%s". Please make sure to provide\n'
'a path to the binary via the --build_dir flag or the BUILD_DIR\n'
'environment variable.' % path)
- sys.stdout.write(message)
+ print >> sys.stderr, message
sys.exit(1)
return path
diff --git a/googletest/test/gtest_throw_on_failure_test.py b/googletest/test/gtest_throw_on_failure_test.py
index 3e7740c..5678ffe 100755
--- a/googletest/test/gtest_throw_on_failure_test.py
+++ b/googletest/test/gtest_throw_on_failure_test.py
@@ -70,7 +70,7 @@ def SetEnvVar(env_var, value):
def Run(command):
"""Runs a command; returns True/False if its exit code is/isn't 0."""
- print('Running "%s". . .' % ' '.join(command))
+ print 'Running "%s". . .' % ' '.join(command)
p = gtest_test_utils.Subprocess(command)
return p.exited and p.exit_code == 0
diff --git a/googletest/test/gtest_uninitialized_test.py b/googletest/test/gtest_uninitialized_test.py
index 4358370..41bc481 100755
--- a/googletest/test/gtest_uninitialized_test.py
+++ b/googletest/test/gtest_uninitialized_test.py
@@ -33,6 +33,7 @@
__author__ = 'wan@google.com (Zhanyong Wan)'
+import os
import gtest_test_utils
@@ -46,8 +47,8 @@ def Assert(condition):
def AssertEq(expected, actual):
if expected != actual:
- print('Expected: %s' % (expected,))
- print(' Actual: %s' % (actual,))
+ print 'Expected: %s' % (expected,)
+ print ' Actual: %s' % (actual,)
raise AssertionError
diff --git a/googletest/test/gtest_xml_outfiles_test.py b/googletest/test/gtest_xml_outfiles_test.py
index 678f546..24c6ee6 100755
--- a/googletest/test/gtest_xml_outfiles_test.py
+++ b/googletest/test/gtest_xml_outfiles_test.py
@@ -31,15 +31,11 @@
"""Unit test for the gtest_xml_output module."""
-__author__ = "keith.ray@gmail.com (Keith Ray)"
-
import os
from xml.dom import minidom, Node
-
import gtest_test_utils
import gtest_xml_test_utils
-
GTEST_OUTPUT_SUBDIR = "xml_outfiles"
GTEST_OUTPUT_1_TEST = "gtest_xml_outfile1_test_"
GTEST_OUTPUT_2_TEST = "gtest_xml_outfile2_test_"