Skip to content

Commit 81b1116

Browse files
committed
Improve test262 ES2015 runner
Changes: - Add options to the test runner to be able to update exclude list - Update the exclude list - Make Travis CI signal if the exclude list isn't up-to-date JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác [email protected]
1 parent 01e9670 commit 81b1116

File tree

4 files changed

+89
-12
lines changed

4 files changed

+89
-12
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ matrix:
6767

6868
- name: "Conformance Tests - ES2015"
6969
env:
70-
- OPTS="--test262-es2015"
70+
- OPTS="--test262-es2015 update"
7171

7272
- name: "Unit Tests"
7373
env:

tests/test262-es6-excludelist.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<excludeList>
3-
<test id="annexB/B.2.2.1.2.js"><reason></reason></test>
43
<test id="annexB/B.2.3.10.js"><reason></reason></test>
54
<test id="annexB/B.2.3.11.js"><reason></reason></test>
65
<test id="annexB/B.2.3.12.js"><reason></reason></test>
@@ -417,7 +416,6 @@
417416
<test id="language/statements/class/definition/this-check-ordering.js"><reason></reason></test>
418417
<test id="language/statements/class/name-binding/in-extends-expression-assigned.js"><reason></reason></test>
419418
<test id="language/statements/class/name-binding/in-extends-expression.js"><reason></reason></test>
420-
<test id="language/statements/class/strict-mode/arguments-caller.js"><reason></reason></test>
421419
<test id="language/statements/class/syntax/early-errors/class-body-static-method-get-propname-prototype.js"><reason></reason></test>
422420
<test id="language/statements/continue/labeled-continue.js"><reason></reason></test>
423421
<test id="language/statements/continue/nested-let-bound-for-loops-labeled-continue.js"><reason></reason></test>

tools/run-tests.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,10 @@ def get_arguments():
219219
help='Run jerry-test-suite')
220220
parser.add_argument('--test262', action='store_true',
221221
help='Run test262 - ES5.1')
222-
parser.add_argument('--test262-es2015', action='store_true',
223-
help='Run test262 - ES2015')
222+
parser.add_argument('--test262-es2015', default=False, const='default',
223+
nargs='?', choices=['default', 'all', 'update'],
224+
help='Run test262 - ES2015. default: all tests except excludelist, ' +
225+
'all: all tests, update: all tests and update excludelist')
224226
parser.add_argument('--unittests', action='store_true',
225227
help='Run unittests (including doctests)')
226228
parser.add_argument('--buildoption-test', action='store_true',
@@ -472,6 +474,7 @@ def run_test262_test_suite(options):
472474

473475
if '--profile=es2015-subset' in job.build_args:
474476
test_cmd.append('--es2015')
477+
test_cmd.append(options.test262_es2015)
475478
else:
476479
test_cmd.append('--es51')
477480

tools/runners/run-test-suite-test262.py

Lines changed: 83 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from __future__ import print_function
1818
import argparse
1919
import os
20+
import re
2021
import shutil
2122
import subprocess
2223
import sys
@@ -41,8 +42,10 @@ def get_arguments():
4142
group = parser.add_mutually_exclusive_group(required=True)
4243
group.add_argument('--es51', action='store_true',
4344
help='Run test262 ES5.1 version')
44-
group.add_argument('--es2015', action='store_true',
45-
help='Run test262 ES2015 version')
45+
group.add_argument('--es2015', default=False, const='default',
46+
nargs='?', choices=['default', 'all', 'update'],
47+
help='Run test262 - ES2015. default: all tests except excludelist, ' +
48+
'all: all tests, update: all tests and update excludelist')
4649

4750
args = parser.parse_args()
4851

@@ -75,15 +78,11 @@ def prepare_test262_test_suite(args):
7578
return return_code
7679

7780
if args.es2015:
78-
shutil.copyfile(os.path.join('tests', 'test262-es6-excludelist.xml'),
79-
os.path.join(args.test_dir, 'excludelist.xml'))
80-
8181
return_code = subprocess.call(['git', 'apply', os.path.join('..', '..', 'test262-es6.patch')],
8282
cwd=args.test_dir)
8383
if return_code:
8484
print('Applying test262-es6.patch failed')
8585
return return_code
86-
8786
else:
8887
path_to_remove = os.path.join(args.test_dir, 'test', 'suite', 'bestPractice')
8988
if os.path.isdir(path_to_remove):
@@ -95,19 +94,93 @@ def prepare_test262_test_suite(args):
9594

9695
return 0
9796

97+
98+
def update_exclude_list(args):
99+
assert args.es2015 == 'update', "Only --es2015 option supports updating excludelist"
100+
101+
print("=== Summary - updating excludelist ===\n")
102+
failing_tests = set()
103+
new_passing_tests = set()
104+
with open(os.path.join(os.path.dirname(args.engine), 'test262.report'), 'r') as report_file:
105+
summary_found = False
106+
for line in report_file:
107+
if summary_found:
108+
match = re.match(r" (\S*) ", line)
109+
if match:
110+
failing_tests.add(match.group(1) + '.js')
111+
elif line.startswith('Failed Tests'):
112+
summary_found = True
113+
114+
with open(os.path.join('tests', 'test262-es6-excludelist.xml'), 'r+') as exclude_file:
115+
lines = exclude_file.readlines()
116+
exclude_file.seek(0)
117+
exclude_file.truncate()
118+
exclude_file.write('<?xml version="1.0" encoding="utf-8" ?>\n')
119+
exclude_file.write('<excludeList>\n')
120+
121+
for line in lines:
122+
match = re.match(r" <test id=\"(\S*)\">", line)
123+
if match:
124+
test = match.group(1)
125+
if test in failing_tests:
126+
failing_tests.remove(test)
127+
exclude_file.write(line)
128+
else:
129+
new_passing_tests.add(test)
130+
131+
if failing_tests:
132+
print("New failing tests added to the excludelist")
133+
for test in sorted(failing_tests):
134+
exclude_file.write(' <test id="' + test + '"><reason></reason></test>\n')
135+
print(" " + test)
136+
print("")
137+
138+
exclude_file.write('</excludeList>\n')
139+
140+
if new_passing_tests:
141+
print("New passing tests removed from the excludelist")
142+
for test in sorted(new_passing_tests):
143+
print(" " + test)
144+
print("")
145+
146+
if failing_tests or new_passing_tests:
147+
print("Excludelist was updated succesfully.")
148+
return 1
149+
150+
print("Excludelist was already up-to-date.")
151+
return 0
152+
153+
98154
def main(args):
99155
return_code = prepare_test262_test_suite(args)
100156
if return_code:
101157
return return_code
102158

159+
if args.es2015 == 'all' or args.es2015 == 'update':
160+
return_code = subprocess.call(['git', 'checkout', 'excludelist.xml'], cwd=args.test_dir)
161+
if return_code:
162+
print('Reverting excludelist.xml failed')
163+
return return_code
164+
elif args.es2015 == 'default':
165+
shutil.copyfile(os.path.join('tests', 'test262-es6-excludelist.xml'),
166+
os.path.join(args.test_dir, 'excludelist.xml'))
167+
103168
if sys.platform == 'win32':
104169
original_timezone = util.get_timezone()
105170
util.set_sighdl_to_reset_timezone(original_timezone)
106171
util.set_timezone('Pacific Standard Time')
107172

173+
command = args.engine
174+
if args.es2015:
175+
try:
176+
subprocess.check_output(["timeout", "--version"])
177+
command = "timeout 3 " + args.engine
178+
except subprocess.CalledProcessError:
179+
pass
180+
108181
proc = subprocess.Popen(get_platform_cmd_prefix() +
109182
[os.path.join(args.test_dir, 'tools/packaging/test262.py'),
110-
'--command', (args.runtime + ' ' + args.engine).strip(),
183+
'--command', command,
111184
'--tests', args.test_dir,
112185
'--summary'],
113186
universal_newlines=True,
@@ -140,6 +213,9 @@ def main(args):
140213
if sys.platform == 'win32':
141214
util.set_timezone(original_timezone)
142215

216+
if args.es2015 == 'update':
217+
return_code = update_exclude_list(args)
218+
143219
return return_code
144220

145221

0 commit comments

Comments
 (0)