2016-08-04 14:41:09 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# Copyright 2016 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.
|
|
|
|
|
2019-02-12 15:30:16 +00:00
|
|
|
import itertools
|
2016-08-04 14:41:09 +00:00
|
|
|
import os
|
|
|
|
import sys
|
2019-01-04 17:47:26 +00:00
|
|
|
import tempfile
|
2016-08-04 14:41:09 +00:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
# Needed because the test runner contains relative imports.
|
|
|
|
TOOLS_PATH = os.path.dirname(os.path.dirname(os.path.dirname(
|
|
|
|
os.path.abspath(__file__))))
|
|
|
|
sys.path.append(TOOLS_PATH)
|
|
|
|
|
2019-02-12 15:30:16 +00:00
|
|
|
from testrunner.local.testsuite import TestSuite, TestGenerator
|
2016-08-04 14:41:09 +00:00
|
|
|
from testrunner.objects.testcase import TestCase
|
2019-01-04 17:47:26 +00:00
|
|
|
from testrunner.test_config import TestConfig
|
2016-08-04 14:41:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestSuiteTest(unittest.TestCase):
|
2019-01-04 17:47:26 +00:00
|
|
|
def setUp(self):
|
|
|
|
test_dir = os.path.dirname(__file__)
|
|
|
|
self.test_root = os.path.join(test_dir, "fake_testsuite")
|
|
|
|
self.test_config = TestConfig(
|
|
|
|
command_prefix=[],
|
|
|
|
extra_flags=[],
|
|
|
|
isolates=False,
|
|
|
|
mode_flags=[],
|
|
|
|
no_harness=False,
|
|
|
|
noi18n=False,
|
|
|
|
random_seed=0,
|
|
|
|
run_skipped=False,
|
|
|
|
shell_dir='fake_testsuite/fake_d8',
|
|
|
|
timeout=10,
|
|
|
|
verbose=False,
|
|
|
|
)
|
|
|
|
|
2019-04-12 11:46:38 +00:00
|
|
|
self.suite = TestSuite.Load(
|
|
|
|
self.test_root, self.test_config, "standard_runner")
|
2019-01-04 17:47:26 +00:00
|
|
|
|
2019-01-11 11:29:15 +00:00
|
|
|
def testLoadingTestSuites(self):
|
|
|
|
self.assertEquals(self.suite.name, "fake_testsuite")
|
|
|
|
self.assertEquals(self.suite.test_config, self.test_config)
|
2019-01-04 17:47:26 +00:00
|
|
|
|
2019-01-11 11:29:15 +00:00
|
|
|
# Verify that the components of the TestSuite aren't loaded yet.
|
|
|
|
self.assertIsNone(self.suite.tests)
|
|
|
|
self.assertIsNone(self.suite.statusfile)
|
|
|
|
|
|
|
|
def testLoadingTestsFromDisk(self):
|
2019-02-12 15:30:16 +00:00
|
|
|
tests = self.suite.load_tests_from_disk(
|
2019-01-15 10:43:02 +00:00
|
|
|
statusfile_variables={})
|
|
|
|
def is_generator(iterator):
|
|
|
|
return iterator == iter(iterator)
|
2019-01-11 11:29:15 +00:00
|
|
|
|
2019-02-12 15:30:16 +00:00
|
|
|
self.assertTrue(is_generator(tests))
|
|
|
|
self.assertEquals(tests.test_count_estimate, 2)
|
2019-01-15 10:43:02 +00:00
|
|
|
|
2019-02-12 15:30:16 +00:00
|
|
|
slow_tests, fast_tests = list(tests.slow_tests), list(tests.fast_tests)
|
2019-01-11 11:29:15 +00:00
|
|
|
# Verify that the components of the TestSuite are loaded.
|
2019-01-15 10:43:02 +00:00
|
|
|
self.assertTrue(len(slow_tests) == len(fast_tests) == 1)
|
|
|
|
self.assertTrue(all(test.is_slow for test in slow_tests))
|
|
|
|
self.assertFalse(any(test.is_slow for test in fast_tests))
|
2019-01-11 11:29:15 +00:00
|
|
|
self.assertIsNotNone(self.suite.statusfile)
|
2017-11-24 02:03:32 +00:00
|
|
|
|
2019-02-12 15:30:16 +00:00
|
|
|
def testMergingTestGenerators(self):
|
|
|
|
tests = self.suite.load_tests_from_disk(
|
|
|
|
statusfile_variables={})
|
|
|
|
more_tests = self.suite.load_tests_from_disk(
|
|
|
|
statusfile_variables={})
|
|
|
|
|
|
|
|
# Merge the test generators
|
|
|
|
tests.merge(more_tests)
|
|
|
|
self.assertEquals(tests.test_count_estimate, 4)
|
|
|
|
|
|
|
|
# Check the tests are sorted by speed
|
|
|
|
test_speeds = []
|
|
|
|
for test in tests:
|
|
|
|
test_speeds.append(test.is_slow)
|
|
|
|
|
|
|
|
self.assertEquals(test_speeds, [True, True, False, False])
|
|
|
|
|
2016-08-04 14:41:09 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|