mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Update web-platform-tests to revision bf71b1f245ce34e447b7bde8ed46694574a63da7
This commit is contained in:
parent
7256d123ff
commit
e17a773b4e
35 changed files with 1567 additions and 467 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
from __future__ import print_function
|
||||
|
||||
import copy
|
||||
import os, sys, json
|
||||
from common_paths import *
|
||||
import spec_validator
|
||||
|
@ -67,10 +68,11 @@ def generate_selection(selection, spec, test_html_template_basename):
|
|||
test_html_template_basename)
|
||||
generated_disclaimer = disclaimer_template \
|
||||
% {'generating_script_filename': os.path.relpath(__file__,
|
||||
test_root_directory),
|
||||
test_root_directory),
|
||||
'html_template_filename': os.path.relpath(html_template_filename,
|
||||
test_root_directory)}
|
||||
test_root_directory)}
|
||||
|
||||
# Adjust the template for the test invoking JS. Indent it to look nice.
|
||||
selection['generated_disclaimer'] = generated_disclaimer.rstrip()
|
||||
test_description_template = \
|
||||
test_description_template.rstrip().replace("\n", "\n" + " " * 33)
|
||||
|
@ -104,6 +106,7 @@ def generate_selection(selection, spec, test_html_template_basename):
|
|||
# Write out the generated HTML file.
|
||||
write_file(test_filename, test_html_template % selection)
|
||||
|
||||
|
||||
def generate_test_source_files(spec_json, target):
|
||||
test_expansion_schema = spec_json['test_expansion_schema']
|
||||
specification = spec_json['specification']
|
||||
|
@ -116,33 +119,45 @@ def generate_test_source_files(spec_json, target):
|
|||
html_template = "test.%s.html.template" % target
|
||||
|
||||
artifact_order = test_expansion_schema.keys() + ['name']
|
||||
artifact_order.remove('expansion')
|
||||
|
||||
# Create list of excluded tests.
|
||||
exclusion_dict = {}
|
||||
for excluded_pattern in spec_json['excluded_tests']:
|
||||
excluded_expansion = \
|
||||
expand_pattern(excluded_pattern,
|
||||
test_expansion_schema)
|
||||
for excluded_selection in permute_expansion(excluded_expansion, artifact_order):
|
||||
expand_pattern(excluded_pattern, test_expansion_schema)
|
||||
for excluded_selection in permute_expansion(excluded_expansion,
|
||||
artifact_order):
|
||||
excluded_selection_path = selection_pattern % excluded_selection
|
||||
exclusion_dict[excluded_selection_path] = True
|
||||
|
||||
for spec in specification:
|
||||
# Used to make entries with expansion="override" override preceding
|
||||
# entries with the same |selection_path|.
|
||||
output_dict = {}
|
||||
|
||||
for expansion_pattern in spec['test_expansion']:
|
||||
expansion = expand_pattern(expansion_pattern,
|
||||
test_expansion_schema)
|
||||
expansion = expand_pattern(expansion_pattern, test_expansion_schema)
|
||||
for selection in permute_expansion(expansion, artifact_order):
|
||||
selection_path = selection_pattern % selection
|
||||
if not selection_path in exclusion_dict:
|
||||
generate_selection(selection,
|
||||
spec,
|
||||
html_template)
|
||||
if selection_path in output_dict:
|
||||
if expansion_pattern['expansion'] != 'override':
|
||||
print("Error: %s's expansion is default but overrides %s" % (selection['name'], output_dict[selection_path]['name']))
|
||||
sys.exit(1)
|
||||
output_dict[selection_path] = copy.deepcopy(selection)
|
||||
else:
|
||||
print('Excluding selection:', selection_path)
|
||||
|
||||
for selection_path in output_dict:
|
||||
selection = output_dict[selection_path]
|
||||
generate_selection(selection,
|
||||
spec,
|
||||
html_template)
|
||||
|
||||
|
||||
def main(target, spec_filename):
|
||||
spec_json = load_spec_json(spec_filename);
|
||||
spec_json = load_spec_json(spec_filename)
|
||||
spec_validator.assert_valid_spec_json(spec_json)
|
||||
generate_test_source_files(spec_json, target)
|
||||
|
||||
|
|
|
@ -30,17 +30,17 @@ def assert_contains(obj, field):
|
|||
assert field in obj, 'Must contain field "%s"' % field
|
||||
|
||||
|
||||
def assert_string_from(obj, field, items):
|
||||
def assert_value_from(obj, field, items):
|
||||
assert obj[field] in items, \
|
||||
'Field "%s" must be from: %s' % (field, str(items))
|
||||
|
||||
|
||||
def assert_string_or_list_items_from(obj, field, items):
|
||||
if isinstance(obj[field], basestring):
|
||||
assert_string_from(obj, field, items)
|
||||
def assert_atom_or_list_items_from(obj, field, items):
|
||||
if isinstance(obj[field], basestring) or isinstance(obj[field], int):
|
||||
assert_value_from(obj, field, items)
|
||||
return
|
||||
|
||||
assert isinstance(obj[field], list), "%s must be a list!" % field
|
||||
assert isinstance(obj[field], list), '%s must be a list' % field
|
||||
for allowed_value in obj[field]:
|
||||
assert allowed_value != '*', "Wildcard is not supported for lists!"
|
||||
assert allowed_value in items, \
|
||||
|
@ -63,8 +63,8 @@ def assert_value_unique_in(value, used_values):
|
|||
|
||||
def assert_valid_artifact(exp_pattern, artifact_key, schema):
|
||||
if isinstance(schema, list):
|
||||
assert_string_or_list_items_from(exp_pattern, artifact_key,
|
||||
["*"] + schema)
|
||||
assert_atom_or_list_items_from(exp_pattern, artifact_key,
|
||||
["*"] + schema)
|
||||
return
|
||||
|
||||
for sub_artifact_key, sub_schema in schema.iteritems():
|
||||
|
@ -110,7 +110,7 @@ def validate(spec_json, details):
|
|||
for spec_exp in spec['test_expansion']:
|
||||
details['object'] = spec_exp
|
||||
assert_non_empty_string(spec_exp, 'name')
|
||||
# The name is unique in same expansion group.
|
||||
# The name is unique in same expansion group.
|
||||
assert_value_unique_in((spec_exp['expansion'], spec_exp['name']),
|
||||
used_spec_names)
|
||||
assert_contains_only_fields(spec_exp, valid_test_expansion_fields)
|
||||
|
@ -136,7 +136,14 @@ def validate(spec_json, details):
|
|||
for excluded_test_expansion in excluded_tests:
|
||||
assert_contains_only_fields(excluded_test_expansion,
|
||||
valid_test_expansion_fields)
|
||||
|
||||
details['object'] = excluded_test_expansion
|
||||
for artifact in test_expansion_schema:
|
||||
details['test_expansion_field'] = artifact
|
||||
assert_valid_artifact(
|
||||
excluded_test_expansion,
|
||||
artifact,
|
||||
test_expansion_schema[artifact])
|
||||
del details['test_expansion_field']
|
||||
|
||||
del details['object']
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue