v8/tools/testrunner/local/testsuite_unittest.py
Tamer Tas d6c915189f [testrunner] use selection sort generator instead of timsort for test cases
V8 testrunner is loading every test it has to run into memory greedily in order
to sort by slowness of the test case. The memory and CPU overhead for loading
the test-suites are non-trivial.

This CL restructures it by changing the sorting method.

R=machenbach@chromium.org
CC=​​sergiyb@chromium.org,yangguo@chromium.org

Bug: v8:8174
Change-Id: I08331182147b92cf4ac54823eea0e2b472f51e84
Reviewed-on: https://chromium-review.googlesource.com/c/1406684
Commit-Queue: Tamer Tas <tmrts@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Sergiy Belozorov <sergiyb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58821}
2019-01-15 11:27:19 +00:00

68 lines
2.1 KiB
Python
Executable File

#!/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.
import os
import sys
import tempfile
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)
from testrunner.local.testsuite import TestSuite
from testrunner.objects.testcase import TestCase
from testrunner.test_config import TestConfig
class TestSuiteTest(unittest.TestCase):
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,
)
self.suite = TestSuite.Load(self.test_root, self.test_config)
def testLoadingTestSuites(self):
self.assertEquals(self.suite.name, "fake_testsuite")
self.assertEquals(self.suite.test_config, self.test_config)
# Verify that the components of the TestSuite aren't loaded yet.
self.assertIsNone(self.suite.tests)
self.assertIsNone(self.suite.statusfile)
def testLoadingTestsFromDisk(self):
slow_tests, fast_tests = self.suite.load_tests_from_disk(
statusfile_variables={})
def is_generator(iterator):
return iterator == iter(iterator)
self.assertTrue(is_generator(slow_tests))
self.assertTrue(is_generator(fast_tests))
slow_tests, fast_tests = list(slow_tests), list(fast_tests)
# Verify that the components of the TestSuite are loaded.
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))
self.assertIsNotNone(self.suite.statusfile)
if __name__ == '__main__':
unittest.main()