Skip to content

Commit 3e661c0

Browse files
ossy-szegedrerobika
authored andcommitted
Make run-tests --test262 work on Windows too (#3029)
JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác [email protected]
1 parent a315a65 commit 3e661c0

File tree

4 files changed

+101
-109
lines changed

4 files changed

+101
-109
lines changed

tools/run-tests.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ def create_binary(job, options):
283283
return ret, build_dir_path
284284

285285
def get_binary_path(build_dir_path):
286-
return os.path.join(build_dir_path, 'local', 'bin', 'jerry')
286+
executable_extension = '.exe' if sys.platform == 'win32' else ''
287+
return os.path.join(build_dir_path, 'local', 'bin', 'jerry' + executable_extension)
287288

288289
def hash_binary(bin_path):
289290
blocksize = 65536
@@ -428,7 +429,7 @@ def run_test262_test_suite(options):
428429
print("\n%sBuild failed%s\n" % (TERM_RED, TERM_NORMAL))
429430
break
430431

431-
test_cmd = [
432+
test_cmd = get_platform_cmd_prefix() + [
432433
settings.TEST262_RUNNER_SCRIPT,
433434
get_binary_path(build_dir_path),
434435
settings.TEST262_TEST_SUITE_DIR
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/usr/bin/env python
2+
3+
# Copyright JS Foundation and other contributors, http://js.foundation
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
from __future__ import print_function
18+
import sys
19+
import os
20+
import subprocess
21+
import shutil
22+
23+
def get_platform_cmd_prefix():
24+
if sys.platform == 'win32':
25+
return ['cmd', '/S', '/C']
26+
return ['python2'] # The official test262.py isn't python3 compatible, but has python shebang.
27+
28+
29+
def run_test262_tests(runtime, engine, path_to_test262):
30+
if not os.path.isdir(os.path.join(path_to_test262, '.git')):
31+
return_code = subprocess.call(['git', 'clone', 'https://github.com/tc39/test262.git',
32+
'-b', 'es5-tests', path_to_test262])
33+
if return_code:
34+
print('Cloning test262 repository failed.')
35+
return return_code
36+
37+
path_to_remove = os.path.join(path_to_test262, 'test', 'suite', 'bestPractice')
38+
if os.path.isdir(path_to_remove):
39+
shutil.rmtree(path_to_remove)
40+
41+
path_to_remove = os.path.join(path_to_test262, 'test', 'suite', 'intl402')
42+
if os.path.isdir(path_to_remove):
43+
shutil.rmtree(path_to_remove)
44+
45+
proc = subprocess.Popen(get_platform_cmd_prefix() +
46+
[os.path.join(path_to_test262, 'tools/packaging/test262.py'),
47+
'--command', (runtime + ' ' + engine).strip(),
48+
'--tests', path_to_test262,
49+
'--summary'],
50+
stdout=subprocess.PIPE)
51+
52+
return_code = 0
53+
with open(os.path.join(os.path.dirname(engine), 'test262.report'), 'w') as output_file:
54+
counter = 0
55+
summary_found = False
56+
while True:
57+
counter += 1
58+
output = proc.stdout.readline()
59+
if not output:
60+
break
61+
output_file.write(output)
62+
if (counter % 100) == 0:
63+
print("\rExecuted approx %d tests..." % counter, end='')
64+
65+
if output.startswith('=== Summary ==='):
66+
summary_found = True
67+
print('')
68+
69+
if summary_found:
70+
print(output, end='')
71+
if ('Failed tests' in output) or ('Expected to fail but passed' in output):
72+
return_code = 1
73+
74+
proc.wait()
75+
return return_code
76+
77+
78+
def main():
79+
if len(sys.argv) != 3:
80+
print ("This script performs test262 compliance testing of the specified engine.")
81+
print ("")
82+
print ("Usage:")
83+
print (" 1st parameter: JavaScript engine to be tested.")
84+
print (" 2nd parameter: path to the directory with official test262 testsuite.")
85+
print ("")
86+
print ("Example:")
87+
print (" ./run-test-suite-test262.py <engine> <test262_dir>")
88+
sys.exit(1)
89+
90+
runtime = os.environ.get('RUNTIME', '')
91+
engine = sys.argv[1]
92+
path_to_test262 = sys.argv[2]
93+
94+
sys.exit(run_test262_tests(runtime, engine, path_to_test262))
95+
96+
if __name__ == "__main__":
97+
main()

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

Lines changed: 0 additions & 106 deletions
This file was deleted.

tools/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@
3535
PYLINT_SCRIPT = path.join(TOOLS_DIR, 'check-pylint.sh')
3636
SIGNED_OFF_SCRIPT = path.join(TOOLS_DIR, 'check-signed-off.sh')
3737
TEST_RUNNER_SCRIPT = path.join(TOOLS_DIR, 'runners/run-test-suite.sh')
38-
TEST262_RUNNER_SCRIPT = path.join(TOOLS_DIR, 'runners/run-test-suite-test262.sh')
38+
TEST262_RUNNER_SCRIPT = path.join(TOOLS_DIR, 'runners/run-test-suite-test262.py')
3939
VERA_SCRIPT = path.join(TOOLS_DIR, 'check-vera.sh')
4040
UNITTEST_RUNNER_SCRIPT = path.join(TOOLS_DIR, 'runners/run-unittests.py')

0 commit comments

Comments
 (0)