summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorojan@google.com <ojan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-24 19:05:43 +0000
committerojan@google.com <ojan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-24 19:05:43 +0000
commitf93d5507d91af9372f29321829527390c4bd8660 (patch)
tree81c9f7de0abee302b05df8b8e258674b9cf65240 /webkit
parentdeaa2b89a8457e90c034ae1f96399bd5ba1b5e8f (diff)
downloadchromium_src-f93d5507d91af9372f29321829527390c4bd8660.zip
chromium_src-f93d5507d91af9372f29321829527390c4bd8660.tar.gz
chromium_src-f93d5507d91af9372f29321829527390c4bd8660.tar.bz2
Reverting 24120.
Review URL: http://codereview.chromium.org/173280 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24124 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/tools/layout_tests/layout_package/json_results_generator.py49
-rw-r--r--webkit/tools/layout_tests/layout_package/test_expectations.py23
-rwxr-xr-xwebkit/tools/layout_tests/run_webkit_tests.py13
3 files changed, 32 insertions, 53 deletions
diff --git a/webkit/tools/layout_tests/layout_package/json_results_generator.py b/webkit/tools/layout_tests/layout_package/json_results_generator.py
index abcf1ac..9682473 100644
--- a/webkit/tools/layout_tests/layout_package/json_results_generator.py
+++ b/webkit/tools/layout_tests/layout_package/json_results_generator.py
@@ -5,13 +5,14 @@
import logging
import os
import re
-import sys
from layout_package import path_utils
from layout_package import test_failures
-sys.path.append(path_utils.PathFromBase('third_party'))
-import simplejson
+class ResultAndTime:
+ """A holder for a single result and runtime for a test."""
+ time = 0
+ result = "N"
class JSONResultsGenerator:
@@ -22,11 +23,9 @@ class JSONResultsGenerator:
JSON_SUFFIX = ");"
WEBKIT_PATH = "WebKit"
LAYOUT_TESTS_PATH = "layout_tests"
- PASS_RESULT = "P"
- NO_DATA_RESULT = "N"
def __init__(self, failures, individual_test_timings, builder_name,
- build_number, results_file_path, all_tests):
+ build_number, results_file_path):
"""
failures: Map of test name to list of failures.
individual_test_times: Map of test name to a tuple containing the
@@ -34,7 +33,6 @@ class JSONResultsGenerator:
builder_name: The name of the builder the tests are being run on.
build_number: The build number for this run.
results_file_path: Absolute path to the results json file.
- all_tests: List of all the tests that were run.
"""
# Make sure all test paths are relative to the layout test root directory.
self._failures = {}
@@ -42,9 +40,6 @@ class JSONResultsGenerator:
test_path = self._GetPathRelativeToLayoutTestRoot(test)
self._failures[test_path] = failures[test]
- self._all_tests = [self._GetPathRelativeToLayoutTestRoot(test)
- for test in all_tests]
-
self._test_timings = {}
for test_tuple in individual_test_timings:
test_path = self._GetPathRelativeToLayoutTestRoot(test_tuple.filename)
@@ -81,12 +76,12 @@ class JSONResultsGenerator:
"""Gets the results for the results.json file."""
failures_for_json = {}
for test in self._failures:
- failures_for_json[test] = ResultAndTime(test, self._all_tests)
+ failures_for_json[test] = ResultAndTime()
failures_for_json[test].result = self._GetResultsCharForFailure(test)
for test in self._test_timings:
if not test in failures_for_json:
- failures_for_json[test] = ResultAndTime(test, self._all_tests)
+ failures_for_json[test] = ResultAndTime()
# Floor for now to get time in seconds.
# TODO(ojan): As we make tests faster, reduce to tenth of a second
# granularity.
@@ -99,7 +94,7 @@ class JSONResultsGenerator:
# Strip the prefix and suffix so we can get the actual JSON object.
old_results = old_results[
len(self.JSON_PREFIX) : len(old_results) - len(self.JSON_SUFFIX)]
- results_json = simplejson.loads(old_results)
+ results_json = eval(old_results)
if self._builder_name not in results_json:
logging.error("Builder name (%s) is not in the results.json file." %
@@ -121,7 +116,7 @@ class JSONResultsGenerator:
if test in failures_for_json:
result_and_time = failures_for_json[test]
else:
- result_and_time = ResultAndTime(test, self._all_tests)
+ result_and_time = ResultAndTime()
if test not in tests:
tests[test] = self._CreateResultsAndTimesJSON()
@@ -135,9 +130,11 @@ class JSONResultsGenerator:
results_json[self._builder_name]["buildNumbers"].insert(0,
self._build_number)
- # Specify separators in order to get compact encoding.
- results_str = simplejson.dumps(results_json, separators=(',', ':'))
- return self.JSON_PREFIX + results_str + self.JSON_SUFFIX
+ # Generate the JSON and strip whitespace to keep filesize down.
+ # TODO(ojan): Generate the JSON using a JSON library should someone ever
+ # add a non-primitive type to results_json.
+ results_str = self.JSON_PREFIX + repr(results_json) + self.JSON_SUFFIX
+ return re.sub(r'\s+', '', results_str)
def _CreateResultsAndTimesJSON(self):
results_and_times = {}
@@ -196,7 +193,7 @@ class JSONResultsGenerator:
times = times[:self.MAX_NUMBER_OF_BUILD_RESULTS_TO_LOG]
elif num_results < self.MAX_NUMBER_OF_BUILD_RESULTS_TO_LOG:
num_to_pad = self.MAX_NUMBER_OF_BUILD_RESULTS_TO_LOG - num_results
- results = results + num_to_pad * self.NO_DATA_RESULT
+ results = results + num_to_pad * 'N'
times.extend(num_to_pad * [0])
test["results"] = results
@@ -206,10 +203,8 @@ class JSONResultsGenerator:
# times that take less than a second, remove it from the results to reduce
# noise and filesize.
if (max(times) >= self.MIN_TIME and num_results and
- (results == self.MAX_NUMBER_OF_BUILD_RESULTS_TO_LOG *
- self.PASS_RESULT or
- results == self.MAX_NUMBER_OF_BUILD_RESULTS_TO_LOG *
- self.NO_DATA_RESULT)):
+ (results == self.MAX_NUMBER_OF_BUILD_RESULTS_TO_LOG * 'P' or
+ results == self.MAX_NUMBER_OF_BUILD_RESULTS_TO_LOG * 'N')):
del tests[test_path]
# Remove tests that don't exist anymore.
@@ -217,13 +212,3 @@ class JSONResultsGenerator:
full_path = os.path.normpath(full_path)
if not os.path.exists(full_path):
del tests[test_path]
-
-class ResultAndTime:
- """A holder for a single result and runtime for a test."""
- def __init__(self, test, all_tests):
- self.time = 0
- # If the test was run, then we don't want to default the result to nodata.
- if test in all_tests:
- self.result = JSONResultsGenerator.PASS_RESULT
- else:
- self.result = JSONResultsGenerator.NO_DATA_RESULT
diff --git a/webkit/tools/layout_tests/layout_package/test_expectations.py b/webkit/tools/layout_tests/layout_package/test_expectations.py
index d3beea8..f6831fb 100644
--- a/webkit/tools/layout_tests/layout_package/test_expectations.py
+++ b/webkit/tools/layout_tests/layout_package/test_expectations.py
@@ -14,8 +14,6 @@ import time
import path_utils
import compare_failures
-sys.path.append(path_utils.PathFromBase('third_party'))
-import simplejson
# Test expectation and modifier constants.
(PASS, FAIL, TIMEOUT, CRASH, SKIP, WONTFIX, DEFER, SLOW, REBASELINE, NONE) = \
@@ -38,8 +36,8 @@ class TestExpectations:
# TODO(ojan): Replace the Get* calls here with the more sane API exposed
# by TestExpectationsFile below. Maybe merge the two classes entirely?
- def GetExpectationsJsonForAllPlatforms(self):
- return self._expected_failures.GetExpectationsJsonForAllPlatforms()
+ def GetExpectationsForAllPlatforms(self):
+ return self._expected_failures.GetExpectationsForAllPlatforms()
def GetFixable(self):
return self._expected_failures.GetTestSet(NONE)
@@ -156,14 +154,9 @@ class ModifiersAndExpectations:
self.modifiers = modifiers
self.expectations = expectations
-class ExpectationsJsonEncoder(simplejson.JSONEncoder):
- """JSON encoder that can handle ModifiersAndExpectations objects.
- """
- def default(self, obj):
- if isinstance(obj, ModifiersAndExpectations):
- return {"modifiers": obj.modifiers, "expectations": obj.expectations}
- else:
- return JSONEncoder.default(self, obj)
+ def __repr__(self):
+ return ("{modifiers:'" + self.modifiers + "', expectations:'" +
+ self.expectations + "'}")
class TestExpectationsFile:
"""Test expectation files consist of lines with specifications of what
@@ -287,10 +280,8 @@ class TestExpectationsFile:
def GetExpectations(self, test):
return self._test_to_expectations[test]
- def GetExpectationsJsonForAllPlatforms(self):
- # Specify separators in order to get compact encoding.
- return ExpectationsJsonEncoder(separators=(',', ':')).encode(
- self._all_expectations)
+ def GetExpectationsForAllPlatforms(self):
+ return self._all_expectations
def Contains(self, test):
return test in self._test_to_expectations
diff --git a/webkit/tools/layout_tests/run_webkit_tests.py b/webkit/tools/layout_tests/run_webkit_tests.py
index 449cc68..c157ac9 100755
--- a/webkit/tools/layout_tests/run_webkit_tests.py
+++ b/webkit/tools/layout_tests/run_webkit_tests.py
@@ -585,7 +585,11 @@ class TestRunner:
# dashboard.
expectations_file = open(os.path.join(self._options.results_directory,
"expectations.json"), "w")
- expectations_json = self._expectations.GetExpectationsJsonForAllPlatforms()
+ # TODO(ojan): Generate JSON using a JSON library instead of relying on
+ # GetExpectationsForAllPlatforms returning an object that only uses
+ # primitive types.
+ expectations_json = repr(
+ self._expectations.GetExpectationsForAllPlatforms())
expectations_file.write(("ADD_EXPECTATIONS(" + expectations_json + ");"))
expectations_file.close()
@@ -594,8 +598,7 @@ class TestRunner:
builder_name = self._options.builder_name # "WebKitBuilder"
build_number = self._options.build_number # "12346"
json_generator = json_results_generator.JSONResultsGenerator(failures,
- individual_test_timings, builder_name, build_number,
- results_file_path, self._test_files_list)
+ individual_test_timings, builder_name, build_number, results_file_path)
results_json = json_generator.GetJSON()
results_file = open(results_file_path, "w")
@@ -1172,10 +1175,10 @@ if '__main__' == __name__:
help=("Run a the tests in batches (n), after every "
"n tests, the test shell is relaunched."))
option_parser.add_option("", "--builder-name",
- default="DUMMY_BUILDER_NAME",
+ default=None,
help="The name of the builder running this script.")
option_parser.add_option("", "--build-number",
- default="DUMMY_BUILD_NUMBER",
+ default=None,
help=("The build number of the builder running"
"this script."))
option_parser.add_option("", "--find-baselines", action="store_true",