code merge
This commit is contained in:
parent
62ba5d91d0
commit
8d707dfe81
|
@ -36,7 +36,6 @@ __author__ = 'wan@google.com (Zhanyong Wan)'
|
||||||
import os
|
import os
|
||||||
import gtest_test_utils
|
import gtest_test_utils
|
||||||
|
|
||||||
|
|
||||||
IS_WINDOWS = os.name = 'nt'
|
IS_WINDOWS = os.name = 'nt'
|
||||||
|
|
||||||
COLOR_ENV_VAR = 'GTEST_COLOR'
|
COLOR_ENV_VAR = 'GTEST_COLOR'
|
||||||
|
|
|
@ -44,12 +44,8 @@ __author__ = 'wan@google.com (Zhanyong Wan)'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
try:
|
import sets
|
||||||
from sets import Set as set # For Python 2.3 compatibility
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import gtest_test_utils
|
import gtest_test_utils
|
||||||
|
|
||||||
# Constants.
|
# Constants.
|
||||||
|
@ -59,9 +55,11 @@ import gtest_test_utils
|
||||||
# script in a subprocess to print whether the variable is STILL in
|
# 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
|
# 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'.
|
# exception is thrown if the input is anything other than 'True' nor 'False'.
|
||||||
|
CAN_PASS_EMPTY_ENV = False
|
||||||
|
if sys.executable:
|
||||||
os.environ['EMPTY_VAR'] = ''
|
os.environ['EMPTY_VAR'] = ''
|
||||||
child = gtest_test_utils.Subprocess(
|
child = gtest_test_utils.Subprocess(
|
||||||
[sys.executable, '-c', 'import os; print(\'EMPTY_VAR\' in os.environ)'])
|
[sys.executable, '-c', 'import os; print \'EMPTY_VAR\' in os.environ'])
|
||||||
CAN_PASS_EMPTY_ENV = eval(child.output)
|
CAN_PASS_EMPTY_ENV = eval(child.output)
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,10 +69,13 @@ CAN_PASS_EMPTY_ENV = eval(child.output)
|
||||||
# is NO LONGER in os.environ.
|
# is NO LONGER in os.environ.
|
||||||
# We use 'eval' to parse the child's output so that an exception
|
# We use 'eval' to parse the child's output so that an exception
|
||||||
# is thrown if the input is neither 'True' nor 'False'.
|
# is thrown if the input is neither 'True' nor 'False'.
|
||||||
|
CAN_UNSET_ENV = False
|
||||||
|
if sys.executable:
|
||||||
os.environ['UNSET_VAR'] = 'X'
|
os.environ['UNSET_VAR'] = 'X'
|
||||||
del os.environ['UNSET_VAR']
|
del os.environ['UNSET_VAR']
|
||||||
child = gtest_test_utils.Subprocess(
|
child = gtest_test_utils.Subprocess(
|
||||||
[sys.executable, '-c', 'import os; print(\'UNSET_VAR\' not in os.environ)'])
|
[sys.executable, '-c', 'import os; print \'UNSET_VAR\' not in os.environ'
|
||||||
|
])
|
||||||
CAN_UNSET_ENV = eval(child.output)
|
CAN_UNSET_ENV = eval(child.output)
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,7 +98,7 @@ SHARD_STATUS_FILE_ENV_VAR = 'GTEST_SHARD_STATUS_FILE'
|
||||||
FILTER_FLAG = 'gtest_filter'
|
FILTER_FLAG = 'gtest_filter'
|
||||||
|
|
||||||
# The command line flag for including disabled tests.
|
# 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 to run the gtest_filter_unittest_ program.
|
||||||
COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_filter_unittest_')
|
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:
|
for slice_var in list_of_sets:
|
||||||
full_partition.extend(slice_var)
|
full_partition.extend(slice_var)
|
||||||
self.assertEqual(len(set_var), len(full_partition))
|
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):
|
def AdjustForParameterizedTests(self, tests_to_run):
|
||||||
"""Adjust tests_to_run in case value parameterized tests are disabled."""
|
"""Adjust tests_to_run in case value parameterized tests are disabled."""
|
||||||
|
|
||||||
global param_tests_present
|
global param_tests_present
|
||||||
if not 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:
|
else:
|
||||||
return tests_to_run
|
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
|
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
|
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.
|
on each shard should be identical to tests_to_run, without duplicates.
|
||||||
|
If check_exit_0, .
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
gtest_filter: A filter to apply to the tests.
|
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)
|
tests_to_run = self.AdjustForParameterizedTests(tests_to_run)
|
||||||
|
|
||||||
# Construct the command line.
|
# Construct the command line.
|
||||||
args = ['--%s' % ALSO_RUN_DISABED_TESTS_FLAG]
|
args = ['--%s' % ALSO_RUN_DISABLED_TESTS_FLAG]
|
||||||
if gtest_filter is not None:
|
if gtest_filter is not None:
|
||||||
args.append('--%s=%s' % (FILTER_FLAG, gtest_filter))
|
args.append('--%s=%s' % (FILTER_FLAG, gtest_filter))
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,8 @@ Google Test) the command line flags.
|
||||||
|
|
||||||
__author__ = 'phanna@google.com (Patrick Hanna)'
|
__author__ = 'phanna@google.com (Patrick Hanna)'
|
||||||
|
|
||||||
import gtest_test_utils
|
|
||||||
import re
|
import re
|
||||||
|
import gtest_test_utils
|
||||||
|
|
||||||
# Constants.
|
# Constants.
|
||||||
|
|
||||||
|
@ -71,7 +70,7 @@ FooTest\.
|
||||||
TypedTest/0\. # TypeParam = (VeryLo{245}|class VeryLo{239})\.\.\.
|
TypedTest/0\. # TypeParam = (VeryLo{245}|class VeryLo{239})\.\.\.
|
||||||
TestA
|
TestA
|
||||||
TestB
|
TestB
|
||||||
TypedTest/1\. # TypeParam = int\s*\*( __ptr64)?
|
TypedTest/1\. # TypeParam = int\s*\*
|
||||||
TestA
|
TestA
|
||||||
TestB
|
TestB
|
||||||
TypedTest/2\. # TypeParam = .*MyArray<bool,\s*42>
|
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})\.\.\.
|
My/TypeParamTest/0\. # TypeParam = (VeryLo{245}|class VeryLo{239})\.\.\.
|
||||||
TestA
|
TestA
|
||||||
TestB
|
TestB
|
||||||
My/TypeParamTest/1\. # TypeParam = int\s*\*( __ptr64)?
|
My/TypeParamTest/1\. # TypeParam = int\s*\*
|
||||||
TestA
|
TestA
|
||||||
TestB
|
TestB
|
||||||
My/TypeParamTest/2\. # TypeParam = .*MyArray<bool,\s*42>
|
My/TypeParamTest/2\. # TypeParam = .*MyArray<bool,\s*42>
|
||||||
|
@ -123,6 +122,7 @@ def Run(args):
|
||||||
|
|
||||||
# The unit test.
|
# The unit test.
|
||||||
|
|
||||||
|
|
||||||
class GTestListTestsUnitTest(gtest_test_utils.TestCase):
|
class GTestListTestsUnitTest(gtest_test_utils.TestCase):
|
||||||
"""Tests using the --gtest_list_tests flag to list all tests."""
|
"""Tests using the --gtest_list_tests flag to list all tests."""
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
"""Tests the text output of Google C++ Testing Framework.
|
"""Tests the text output of Google C++ Testing Framework.
|
||||||
|
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
gtest_output_test.py --build_dir=BUILD/DIR --gengolden
|
gtest_output_test.py --build_dir=BUILD/DIR --gengolden
|
||||||
# where BUILD/DIR contains the built gtest_output_test_ file.
|
# where BUILD/DIR contains the built gtest_output_test_ file.
|
||||||
|
@ -51,6 +52,7 @@ import gtest_test_utils
|
||||||
GENGOLDEN_FLAG = '--gengolden'
|
GENGOLDEN_FLAG = '--gengolden'
|
||||||
CATCH_EXCEPTIONS_ENV_VAR_NAME = 'GTEST_CATCH_EXCEPTIONS'
|
CATCH_EXCEPTIONS_ENV_VAR_NAME = 'GTEST_CATCH_EXCEPTIONS'
|
||||||
|
|
||||||
|
IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
|
||||||
IS_WINDOWS = os.name == 'nt'
|
IS_WINDOWS = os.name == 'nt'
|
||||||
|
|
||||||
# TODO(vladl@google.com): remove the _lin suffix.
|
# 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_DEATH_TESTS = 'DeathTest' in test_list
|
||||||
SUPPORTS_TYPED_TESTS = 'TypedTest' in test_list
|
SUPPORTS_TYPED_TESTS = 'TypedTest' in test_list
|
||||||
SUPPORTS_THREADS = 'ExpectFailureWithThreadsTest' 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
|
CAN_GENERATE_GOLDEN_FILE = (SUPPORTS_DEATH_TESTS and
|
||||||
SUPPORTS_TYPED_TESTS and
|
SUPPORTS_TYPED_TESTS and
|
||||||
SUPPORTS_THREADS and
|
SUPPORTS_THREADS and
|
||||||
|
SUPPORTS_STACK_TRACES and
|
||||||
not IS_WINDOWS)
|
not IS_WINDOWS)
|
||||||
|
|
||||||
class GTestOutputTest(gtest_test_utils.TestCase):
|
class GTestOutputTest(gtest_test_utils.TestCase):
|
||||||
|
@ -280,7 +283,7 @@ class GTestOutputTest(gtest_test_utils.TestCase):
|
||||||
def testOutput(self):
|
def testOutput(self):
|
||||||
output = GetOutputOfAllCommands()
|
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
|
# A mis-configured source control system can cause \r appear in EOL
|
||||||
# sequences when we read the golden file irrespective of an operating
|
# sequences when we read the golden file irrespective of an operating
|
||||||
# system used. Therefore, we need to strip those \r's from newlines
|
# system used. Therefore, we need to strip those \r's from newlines
|
||||||
|
@ -331,9 +334,9 @@ if __name__ == '__main__':
|
||||||
else:
|
else:
|
||||||
message = (
|
message = (
|
||||||
"""Unable to write a golden file when compiled in an environment
|
"""Unable to write a golden file when compiled in an environment
|
||||||
that does not support all the required features (death tests, typed tests,
|
that does not support all the required features (death tests,
|
||||||
and multiple threads). Please generate the golden file using a binary built
|
typed tests, stack traces, and multiple threads).
|
||||||
with those features enabled.""")
|
Please build this test and generate the golden file using Blaze on Linux.""")
|
||||||
|
|
||||||
sys.stderr.write(message)
|
sys.stderr.write(message)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
#
|
|
||||||
# Copyright 2006, Google Inc.
|
# Copyright 2006, Google Inc.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
|
@ -33,10 +31,15 @@
|
||||||
|
|
||||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||||
|
|
||||||
import atexit
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
|
||||||
import sys
|
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 tempfile
|
||||||
import unittest
|
import unittest
|
||||||
_test_module = unittest
|
_test_module = unittest
|
||||||
|
@ -53,9 +56,6 @@ except:
|
||||||
|
|
||||||
GTEST_OUTPUT_VAR_NAME = 'GTEST_OUTPUT'
|
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.
|
# The environment variable for specifying the path to the premature-exit file.
|
||||||
PREMATURE_EXIT_FILE_ENV_VAR = 'TEST_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'
|
'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'
|
'a path to the binary via the --build_dir flag or the BUILD_DIR\n'
|
||||||
'environment variable.' % path)
|
'environment variable.' % path)
|
||||||
sys.stdout.write(message)
|
print >> sys.stderr, message
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
return path
|
return path
|
||||||
|
|
|
@ -70,7 +70,7 @@ def SetEnvVar(env_var, value):
|
||||||
def Run(command):
|
def Run(command):
|
||||||
"""Runs a command; returns True/False if its exit code is/isn't 0."""
|
"""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)
|
p = gtest_test_utils.Subprocess(command)
|
||||||
return p.exited and p.exit_code == 0
|
return p.exited and p.exit_code == 0
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||||
|
|
||||||
|
import os
|
||||||
import gtest_test_utils
|
import gtest_test_utils
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,8 +47,8 @@ def Assert(condition):
|
||||||
|
|
||||||
def AssertEq(expected, actual):
|
def AssertEq(expected, actual):
|
||||||
if expected != actual:
|
if expected != actual:
|
||||||
print('Expected: %s' % (expected,))
|
print 'Expected: %s' % (expected,)
|
||||||
print(' Actual: %s' % (actual,))
|
print ' Actual: %s' % (actual,)
|
||||||
raise AssertionError
|
raise AssertionError
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,15 +31,11 @@
|
||||||
|
|
||||||
"""Unit test for the gtest_xml_output module."""
|
"""Unit test for the gtest_xml_output module."""
|
||||||
|
|
||||||
__author__ = "keith.ray@gmail.com (Keith Ray)"
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from xml.dom import minidom, Node
|
from xml.dom import minidom, Node
|
||||||
|
|
||||||
import gtest_test_utils
|
import gtest_test_utils
|
||||||
import gtest_xml_test_utils
|
import gtest_xml_test_utils
|
||||||
|
|
||||||
|
|
||||||
GTEST_OUTPUT_SUBDIR = "xml_outfiles"
|
GTEST_OUTPUT_SUBDIR = "xml_outfiles"
|
||||||
GTEST_OUTPUT_1_TEST = "gtest_xml_outfile1_test_"
|
GTEST_OUTPUT_1_TEST = "gtest_xml_outfile1_test_"
|
||||||
GTEST_OUTPUT_2_TEST = "gtest_xml_outfile2_test_"
|
GTEST_OUTPUT_2_TEST = "gtest_xml_outfile2_test_"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user