Skip to content

Make run-tests --test262 work on Windows too #3029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tools/run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ def create_binary(job, options):
return ret, build_dir_path

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

def hash_binary(bin_path):
blocksize = 65536
Expand Down Expand Up @@ -425,7 +426,7 @@ def run_test262_test_suite(options):
print("\n%sBuild failed%s\n" % (TERM_RED, TERM_NORMAL))
break

test_cmd = [
test_cmd = get_platform_cmd_prefix() + [
settings.TEST262_RUNNER_SCRIPT,
get_binary_path(build_dir_path),
settings.TEST262_TEST_SUITE_DIR
Expand Down
97 changes: 97 additions & 0 deletions tools/runners/run-test-suite-test262.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env python

# Copyright JS Foundation and other contributors, http://js.foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function
import sys
import os
import subprocess
import shutil

def get_platform_cmd_prefix():
if sys.platform == 'win32':
return ['cmd', '/S', '/C']
return ['python2'] # The official test262.py isn't python3 compatible, but has python shebang.


def run_test262_tests(runtime, engine, path_to_test262):
if not os.path.isdir(os.path.join(path_to_test262, '.git')):
return_code = subprocess.call(['git', 'clone', 'https://github.com/tc39/test262.git',
'-b', 'es5-tests', path_to_test262])
if return_code:
print('Cloning test262 repository failed.')
return return_code

path_to_remove = os.path.join(path_to_test262, 'test', 'suite', 'bestPractice')
if os.path.isdir(path_to_remove):
shutil.rmtree(path_to_remove)

path_to_remove = os.path.join(path_to_test262, 'test', 'suite', 'intl402')
if os.path.isdir(path_to_remove):
shutil.rmtree(path_to_remove)

proc = subprocess.Popen(get_platform_cmd_prefix() +
[os.path.join(path_to_test262, 'tools/packaging/test262.py'),
'--command', (runtime + ' ' + engine).strip(),
'--tests', path_to_test262,
'--summary'],
stdout=subprocess.PIPE)

return_code = 0
with open(os.path.join(os.path.dirname(engine), 'test262.report'), 'w') as output_file:
counter = 0
summary_found = False
while True:
counter += 1
output = proc.stdout.readline()
if not output:
break
output_file.write(output)
if (counter % 100) == 0:
print("\rExecuted approx %d tests..." % counter, end='')

if output.startswith('=== Summary ==='):
summary_found = True
print('')

if summary_found:
print(output, end='')
if ('Failed tests' in output) or ('Expected to fail but passed' in output):
return_code = 1

proc.wait()
return return_code


def main():
if len(sys.argv) != 3:
print ("This script performs test262 compliance testing of the specified engine.")
print ("")
print ("Usage:")
print (" 1st parameter: JavaScript engine to be tested.")
print (" 2nd parameter: path to the directory with official test262 testsuite.")
print ("")
print ("Example:")
print (" ./run-test-suite-test262.py <engine> <test262_dir>")
sys.exit(1)

runtime = os.environ.get('RUNTIME', '')
engine = sys.argv[1]
path_to_test262 = sys.argv[2]

sys.exit(run_test262_tests(runtime, engine, path_to_test262))

if __name__ == "__main__":
main()
106 changes: 0 additions & 106 deletions tools/runners/run-test-suite-test262.sh

This file was deleted.

2 changes: 1 addition & 1 deletion tools/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
PYLINT_SCRIPT = path.join(TOOLS_DIR, 'check-pylint.sh')
SIGNED_OFF_SCRIPT = path.join(TOOLS_DIR, 'check-signed-off.sh')
TEST_RUNNER_SCRIPT = path.join(TOOLS_DIR, 'runners/run-test-suite.sh')
TEST262_RUNNER_SCRIPT = path.join(TOOLS_DIR, 'runners/run-test-suite-test262.sh')
TEST262_RUNNER_SCRIPT = path.join(TOOLS_DIR, 'runners/run-test-suite-test262.py')
VERA_SCRIPT = path.join(TOOLS_DIR, 'check-vera.sh')
UNITTEST_RUNNER_SCRIPT = path.join(TOOLS_DIR, 'runners/run-unittests.py')