summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authordpranke@google.com <dpranke@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-16 21:27:33 +0000
committerdpranke@google.com <dpranke@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-16 21:27:33 +0000
commitb8f0ba23089a7e5741df7245722759a9a42529ab (patch)
treea72530c5322a43c5b4e2cd7d4cf6d9f4df0a9c54 /webkit
parentd957d4051d058efc08b0ec2fdcd0c1b3a994e729 (diff)
downloadchromium_src-b8f0ba23089a7e5741df7245722759a9a42529ab.zip
chromium_src-b8f0ba23089a7e5741df7245722759a9a42529ab.tar.gz
chromium_src-b8f0ba23089a7e5741df7245722759a9a42529ab.tar.bz2
Modify run_webkit_tests to run in a single thread when num-test-shells==1.
This makes debugging the test harness a lot easier. BUG=none TEST=none R=ojan@chromium.org Review URL: http://codereview.chromium.org/500037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34753 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/tools/layout_tests/layout_package/test_shell_thread.py19
-rwxr-xr-xwebkit/tools/layout_tests/run_webkit_tests.py27
2 files changed, 35 insertions, 11 deletions
diff --git a/webkit/tools/layout_tests/layout_package/test_shell_thread.py b/webkit/tools/layout_tests/layout_package/test_shell_thread.py
index f39b453..a091062 100644
--- a/webkit/tools/layout_tests/layout_package/test_shell_thread.py
+++ b/webkit/tools/layout_tests/layout_package/test_shell_thread.py
@@ -261,7 +261,7 @@ class TestShellThread(threading.Thread):
self._num_tests = 0
try:
logging.debug('thread %s starting' % (self.getName()))
- self._Run()
+ self._Run(test_runner=None, result_summary=None)
logging.debug('thread %s done (%d tests)' % (self.getName(),
self.GetNumTests()))
except:
@@ -274,9 +274,19 @@ class TestShellThread(threading.Thread):
raise
self._stop_time = time.time()
- def _Run(self):
+ def RunInMainThread(self, test_runner, result_summary):
+ """This hook allows us to run the tests from the main thread if
+ --num-test-shells==1, instead of having to always run two or more
+ threads. This allows us to debug the test harness without having to
+ do multi-threaded debugging."""
+ self._Run(test_runner, result_summary)
+
+ def _Run(self, test_runner, result_summary):
"""Main work entry point of the thread. Basically we pull urls from the
- filename queue and run the tests until we run out of urls."""
+ filename queue and run the tests until we run out of urls.
+
+ If test_runner is not None, then we call test_runner.UpdateSummary()
+ with the results of each test."""
batch_size = 0
batch_count = 0
if self._options.batch_size:
@@ -346,6 +356,9 @@ class TestShellThread(threading.Thread):
self._KillTestShell()
batch_count = 0
+ if test_runner:
+ test_runner.UpdateSummary(result_summary)
+
def _RunTestSingly(self, test_info):
"""Run a test in a separate thread, enforcing a hard time limit.
diff --git a/webkit/tools/layout_tests/run_webkit_tests.py b/webkit/tools/layout_tests/run_webkit_tests.py
index 05d8e21..c19e524 100755
--- a/webkit/tools/layout_tests/run_webkit_tests.py
+++ b/webkit/tools/layout_tests/run_webkit_tests.py
@@ -411,7 +411,8 @@ class TestRunner:
The Queue of lists of TestInfo objects.
"""
- if self._options.experimental_fully_parallel:
+ if (self._options.experimental_fully_parallel or
+ self._IsSingleThreaded()):
filename_queue = Queue.Queue()
for test_file in test_files:
filename_queue.put(('.', [self._GetTestInfoForFile(test_file)]))
@@ -481,7 +482,8 @@ class TestRunner:
return True
return False
- def _InstantiateTestShellThreads(self, test_shell_binary, test_files):
+ def _InstantiateTestShellThreads(self, test_shell_binary, test_files,
+ result_summary):
"""Instantitates and starts the TestShellThread(s).
Return:
@@ -515,7 +517,10 @@ class TestRunner:
test_args,
shell_args,
self._options)
- thread.start()
+ if self._IsSingleThreaded():
+ thread.RunInMainThread(self, result_summary)
+ else:
+ thread.start()
threads.append(thread)
return threads
@@ -528,6 +533,10 @@ class TestRunner:
proc.stdin.close()
proc.wait()
+ def _IsSingleThreaded(self):
+ """Returns whether we should run all the tests in the main thread."""
+ return int(self._options.num_test_shells) == 1
+
def _RunTests(self, test_shell_binary, file_list, result_summary):
"""Runs the tests in the file_list.
@@ -542,7 +551,8 @@ class TestRunner:
{filename:filename, test_run_time:test_run_time}
result_summary: summary object to populate with the results
"""
- threads = self._InstantiateTestShellThreads(test_shell_binary, file_list)
+ threads = self._InstantiateTestShellThreads(test_shell_binary, file_list,
+ result_summary)
# Wait for the threads to finish and collect test failures.
failures = {}
@@ -557,7 +567,7 @@ class TestRunner:
# suffices to not use an indefinite blocking join for it to
# be interruptible by KeyboardInterrupt.
thread.join(0.1)
- self._UpdateSummary(result_summary)
+ self.UpdateSummary(result_summary)
thread_timings.append({ 'name': thread.getName(),
'num_tests': thread.GetNumTests(),
'total_time': thread.GetTotalTime()});
@@ -578,7 +588,7 @@ class TestRunner:
raise exception_info[0], exception_info[1], exception_info[2]
# Make sure we pick up any remaining tests.
- self._UpdateSummary(result_summary)
+ self.UpdateSummary(result_summary)
return (thread_timings, test_timings, individual_test_timings)
def Run(self, result_summary):
@@ -693,7 +703,7 @@ class TestRunner:
# bot red for those.
return unexpected_results['num_regressions']
- def _UpdateSummary(self, result_summary):
+ def UpdateSummary(self, result_summary):
"""Update the summary while running tests."""
while True:
try:
@@ -702,7 +712,8 @@ class TestRunner:
expected = self._expectations.MatchesAnExpectedResult(test, result)
result_summary.Add(test, fail_list, result, expected)
if (LOG_DETAILED_PROGRESS in self._options.log and
- self._options.experimental_fully_parallel):
+ (self._options.experimental_fully_parallel or
+ self._IsSingleThreaded())):
self._DisplayDetailedProgress(result_summary)
else:
if not expected and LOG_UNEXPECTED in self._options.log: