Files
jerryscript/tools/runners/run-unittests.py
T
Yonggang Luo d2d30df420 Revise tools scripts to be python3 compatible on win32 (#4856)
We introduce setup_stdio function to setup stdout/stderr properly.
For python <-> python pipe, we always use 'utf8'/'ignore' encoding for not lost characters.
For tty <-> python, we using native encoding with xmlcharrefreplace to encode, to preserve maximal information.
For python <-> native program, we use naive encoding with 'ignore' to not cause error

update_exclude_list with binary mode so that on win32 would not generate \r\n

run-test-suite.py: Handling skiplist properly on win32

Fixes #4854

Fixes test262-harness.py complain cannot use a string pattern on a bytes-like object with running test262 with python3

For reading/writing to file, we use 'utf8' /'ignore' encoding for not lost characters.
For decoding from process stdout, using native encoding with decoding error ignored for not lost data.
Execute commands also ignore errors
Fixes #4853

Fixes running test262-esnext failed with installed python3.9 on win32 with space in path
Fixes #4852

support both / \ in --test262-test-list arg

On win32.
python tools/run-tests.py  --test262-es2015=update --test262-test-list=built-ins/decodeURI/
python tools/run-tests.py  --test262-es2015=update --test262-test-list=built-ins\decodeURI\
should be both valid,
currently only --test262-test-list=built-ins\decodeURI\ are valid.

Support snapshot-tests-skiplist.txt on win32 by use os.path.normpath

Guard run-tests.py with timer.

All run-tests.py are finished in 30 minutes in normal situation.
May change the timeout by command line option

Move Windows CI to github actions
Define TERM colors for win32 properly

flush stderr.write stdout.write

On CI, the stderr are redirect to stdout, and if we don't flush stderr and stdout,
The output from stderr/stdout would out of sync.

`Testing new Date(-8640000000000000) and fixes date for win32`
So that the CI can passed

if sys.version_info.major >= 3: remove, as we do not support python2 anymore

Fixes compiling warnings/errors for mingw/gcc

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
2024-12-17 10:41:12 +01:00

88 lines
2.7 KiB
Python
Executable File

#!/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.
import argparse
import glob
import os
import subprocess
import sys
import util
def get_arguments():
runtime = os.environ.get('RUNTIME')
parser = argparse.ArgumentParser()
parser.add_argument('-q', '--quiet', action='store_true',
help='Only print out failing tests')
parser.add_argument('--runtime', metavar='FILE', default=runtime,
help='Execution runtime (e.g. qemu)')
parser.add_argument('path',
help='Path of test binaries')
script_args = parser.parse_args()
return script_args
def get_unittests(path):
unittests = []
files = glob.glob(os.path.join(path, 'unit-*'))
for testfile in files:
if os.path.isfile(testfile) and os.access(testfile, os.X_OK):
if sys.platform != 'win32' or testfile.endswith(".exe"):
unittests.append(testfile)
unittests.sort()
return unittests
def main(args):
util.setup_stdio()
unittests = get_unittests(args.path)
total = len(unittests)
if total == 0:
print("%s: no unit-* test to execute", args.path)
return 1
test_cmd = [args.runtime] if args.runtime else []
tested = 0
passed = 0
failed = 0
for test in unittests:
tested += 1
test_path = os.path.relpath(test)
try:
subprocess.check_output(test_cmd + [test], stderr=subprocess.STDOUT, universal_newlines=True)
passed += 1
if not args.quiet:
util.print_test_result(tested, total, True, 'PASS', test_path)
except subprocess.CalledProcessError as err:
failed += 1
util.print_test_result(tested, total, False, f'FAIL ({err.returncode})', test_path)
print("================================================")
print(err.output)
print("================================================")
util.print_test_summary(os.path.join(os.path.relpath(args.path), "unit-*"), total, passed, failed)
if failed > 0:
return 1
return 0
if __name__ == "__main__":
sys.exit(main(get_arguments()))