Commit a91d043d authored by Michal Majewski's avatar Michal Majewski Committed by Commit Bot

[test] Move GoogleTestSuite to a separate testcfg.

Since we have only unittests that are under GoogleTestSuite there
is no need to keep it as a default suite and we can make it
specific for unittests.

Bug: v8:6917
Change-Id: Ie2d57342773f228dea72184ab0f2abfc9d2daa70
Reviewed-on: https://chromium-review.googlesource.com/819253
Commit-Queue: Michał Majewski <majeski@google.com>
Reviewed-by: 's avatarSergiy Byelozyorov <sergiyb@chromium.org>
Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50011}
parent 4a8d1e79
# Copyright 2017 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
from testrunner.local import command
from testrunner.local import utils
from testrunner.local.testsuite import TestSuite, StandardVariantGenerator
from testrunner.objects import testcase
class GoogleTestSuite(TestSuite):
def __init__(self, name, root):
super(GoogleTestSuite, self).__init__(name, root)
def ListTests(self, context):
shell = os.path.abspath(
os.path.join(context.shell_dir, self.GetShellForTestCase(None)))
if utils.IsWindows():
shell += ".exe"
output = None
for i in xrange(3): # Try 3 times in case of errors.
cmd = command.Command(
cmd_prefix=context.command_prefix,
shell=shell,
args=['--gtest_list_tests'] + context.extra_flags)
output = cmd.execute()
if output.exit_code == 0:
break
print "Test executable failed to list the tests (try %d).\n\nCmd:" % i
print cmd
print "\nStdout:"
print output.stdout
print "\nStderr:"
print output.stderr
print "\nExit code: %d" % output.exit_code
else:
raise Exception("Test executable failed to list the tests.")
tests = []
test_case = ''
for line in output.stdout.splitlines():
test_desc = line.strip().split()[0]
if test_desc.endswith('.'):
test_case = test_desc
elif test_case and test_desc:
test = testcase.TestCase(self, test_case + test_desc)
tests.append(test)
tests.sort(key=lambda t: t.path)
return tests
def GetParametersForTestCase(self, testcase, context):
flags = (
testcase.flags +
["--gtest_filter=" + testcase.path] +
["--gtest_random_seed=%s" % context.random_seed] +
["--gtest_print_time=0"] +
context.mode_flags)
return [], flags, {}
def _VariantGeneratorFactory(self):
return StandardVariantGenerator
def GetShellForTestCase(self, testcase):
return self.name
def GetSuite(name, root):
return GoogleTestSuite(name, root)
......@@ -5,6 +5,7 @@
'variables': {
'files': [
'<(PRODUCT_DIR)/unittests<(EXECUTABLE_SUFFIX)',
'./testcfg.py',
'./unittests.status',
],
},
......@@ -12,4 +13,4 @@
'../../src/base.isolate',
'../../tools/testrunner/testrunner.isolate',
],
}
\ No newline at end of file
}
......@@ -76,9 +76,6 @@ class TestSuite(object):
(f, pathname, description) = imp.find_module("testcfg", [root])
module = imp.load_module(name + "_testcfg", f, pathname, description)
return module.GetSuite(name, root)
except ImportError:
# Use default if no testcfg is present.
return GoogleTestSuite(name, root)
finally:
if f:
f.close()
......@@ -406,60 +403,3 @@ class TestSuite(object):
class StandardVariantGenerator(VariantGenerator):
def FilterVariantsByTest(self, testcase):
return self.standard_variant
class GoogleTestSuite(TestSuite):
def __init__(self, name, root):
super(GoogleTestSuite, self).__init__(name, root)
def ListTests(self, context):
shell = os.path.abspath(
os.path.join(context.shell_dir, self.GetShellForTestCase(None)))
if utils.IsWindows():
shell += ".exe"
output = None
for i in xrange(3): # Try 3 times in case of errors.
cmd = command.Command(
cmd_prefix=context.command_prefix,
shell=shell,
args=['--gtest_list_tests'] + context.extra_flags)
output = cmd.execute()
if output.exit_code == 0:
break
print "Test executable failed to list the tests (try %d).\n\nCmd:" % i
print cmd
print "\nStdout:"
print output.stdout
print "\nStderr:"
print output.stderr
print "\nExit code: %d" % output.exit_code
else:
raise Exception("Test executable failed to list the tests.")
tests = []
test_case = ''
for line in output.stdout.splitlines():
test_desc = line.strip().split()[0]
if test_desc.endswith('.'):
test_case = test_desc
elif test_case and test_desc:
test = testcase.TestCase(self, test_case + test_desc)
tests.append(test)
tests.sort(key=lambda t: t.path)
return tests
def GetParametersForTestCase(self, testcase, context):
flags = (
testcase.flags +
["--gtest_filter=" + testcase.path] +
["--gtest_random_seed=%s" % context.random_seed] +
["--gtest_print_time=0"] +
context.mode_flags)
return [], flags, {}
def _VariantGeneratorFactory(self):
return StandardVariantGenerator
def GetShellForTestCase(self, testcase):
return self.name
......@@ -116,6 +116,8 @@ class StandardTestRunner(base_runner.BaseTestRunner):
suites = []
for root in suite_paths:
if options.verbose:
print '>>> Loading test suite: %s' % root
suite = testsuite.TestSuite.LoadTestSuite(
os.path.join(base_runner.BASE_DIR, "test", root))
if suite:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment