mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Fix several pylint warnings. (#1659)
Fixed all of the remaining warnings in 'build.py', 'run-tests.py' and 'check-license.py'. Related issue: #1600 JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
This commit is contained in:
parent
78e4dcf6c2
commit
fa5d5febcc
129
tools/build.py
129
tools/build.py
@ -14,6 +14,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import multiprocessing
|
||||
import os
|
||||
@ -30,60 +32,101 @@ DEFAULT_PROFILE = 'es5.1'
|
||||
|
||||
def default_toolchain():
|
||||
(sysname, _, _, _, machine) = os.uname()
|
||||
toolchain = os.path.join(settings.PROJECT_DIR, 'cmake', 'toolchain_%s_%s.cmake' % (sysname.lower(), machine.lower()))
|
||||
toolchain = os.path.join(settings.PROJECT_DIR,
|
||||
'cmake',
|
||||
'toolchain_%s_%s.cmake' % (sysname.lower(), machine.lower()))
|
||||
return toolchain if os.path.isfile(toolchain) else None
|
||||
|
||||
def get_arguments():
|
||||
devhelp_preparser = argparse.ArgumentParser(add_help=False)
|
||||
devhelp_preparser.add_argument('--devhelp', action='store_true', default=False, help='show help with all options (including those, which are useful for developers only)')
|
||||
devhelp_preparser.add_argument('--devhelp', action='store_true', default=False,
|
||||
help='show help with all options '
|
||||
'(including those, which are useful for developers only)')
|
||||
|
||||
devhelp_arguments, args = devhelp_preparser.parse_known_args()
|
||||
if devhelp_arguments.devhelp:
|
||||
args.append('--devhelp')
|
||||
|
||||
def devhelp(help):
|
||||
return help if devhelp_arguments.devhelp else argparse.SUPPRESS
|
||||
def devhelp(helpstring):
|
||||
return helpstring if devhelp_arguments.devhelp else argparse.SUPPRESS
|
||||
|
||||
parser = argparse.ArgumentParser(parents=[devhelp_preparser])
|
||||
parser.add_argument('--all-in-one', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='all-in-one build (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--builddir', metavar='DIR', action='store', default=BUILD_DIR, help='specify output directory (default: %(default)s)')
|
||||
parser.add_argument('--all-in-one', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
|
||||
help='all-in-one build (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--builddir', metavar='DIR', action='store', default=BUILD_DIR,
|
||||
help='specify output directory (default: %(default)s)')
|
||||
parser.add_argument('--clean', action='store_true', default=False, help='clean build')
|
||||
parser.add_argument('--cmake-param', metavar='OPT', action='append', default=[], help='add custom argument to CMake')
|
||||
parser.add_argument('--compile-flag', metavar='OPT', action='append', default=[], help='add custom compile flag')
|
||||
parser.add_argument('--cpointer-32bit', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='enable 32 bit compressed pointers (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--debug', action='store_const', const='Debug', default='MinSizeRel', dest='build_type', help='debug build')
|
||||
parser.add_argument('--error-messages', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='enable error messages (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('-j', '--jobs', metavar='N', action='store', type=int, default=multiprocessing.cpu_count() + 1, help='Allowed N build jobs at once (default: %(default)s)')
|
||||
parser.add_argument('--jerry-cmdline', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='build jerry command line tool (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--jerry-cmdline-minimal', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='build minimal version of the jerry command line tool (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--jerry-debugger', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='enable the jerry debugger (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--jerry-debugger-port', metavar='N', action='store', type=int, default=5001, help='add custom port number (default: %(default)s)')
|
||||
parser.add_argument('--jerry-libc', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='build and use jerry-libc (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--jerry-libm', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='build and use jerry-libm (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--js-parser', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='enable js-parser (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--link-lib', metavar='OPT', action='append', default=[], help='add custom library to be linked')
|
||||
parser.add_argument('--linker-flag', metavar='OPT', action='append', default=[], help='add custom linker flag')
|
||||
parser.add_argument('--lto', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='enable link-time optimizations (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--mem-heap', metavar='SIZE', action='store', type=int, default=512, help='size of memory heap, in kilobytes (default: %(default)s)')
|
||||
parser.add_argument('--port-dir', metavar='DIR', action='store', default=DEFAULT_PORT_DIR, help='add port directory (default: %(default)s)')
|
||||
parser.add_argument('--profile', metavar='FILE', action='store', default=DEFAULT_PROFILE, help='specify profile file (default: %(default)s)')
|
||||
parser.add_argument('--snapshot-exec', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='enable executing snapshot files (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--snapshot-save', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='enable saving snapshot files (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--system-allocator', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help='enable system allocator (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--static-link', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='enable static linking of binaries (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--strip', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper, help='strip release binaries (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--toolchain', metavar='FILE', action='store', default=default_toolchain(), help='add toolchain file (default: %(default)s)')
|
||||
parser.add_argument('--unittests', action='store_const', const='ON', default='OFF', help='build unittests')
|
||||
parser.add_argument('-v', '--verbose', action='store_const', const='ON', default='OFF', help='increase verbosity')
|
||||
parser.add_argument('--cmake-param', metavar='OPT', action='append', default=[],
|
||||
help='add custom argument to CMake')
|
||||
parser.add_argument('--compile-flag', metavar='OPT', action='append', default=[],
|
||||
help='add custom compile flag')
|
||||
parser.add_argument('--cpointer-32bit', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
|
||||
help='enable 32 bit compressed pointers (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--debug', action='store_const', const='Debug', default='MinSizeRel', dest='build_type',
|
||||
help='debug build')
|
||||
parser.add_argument('--error-messages', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
|
||||
help='enable error messages (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('-j', '--jobs', metavar='N', action='store', type=int, default=multiprocessing.cpu_count() + 1,
|
||||
help='Allowed N build jobs at once (default: %(default)s)')
|
||||
parser.add_argument('--jerry-cmdline', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper,
|
||||
help='build jerry command line tool (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--jerry-cmdline-minimal', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
|
||||
help='build minimal version of the jerry command line tool (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--jerry-debugger', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
|
||||
help='enable the jerry debugger (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--jerry-debugger-port', metavar='N', action='store', type=int, default=5001,
|
||||
help='add custom port number (default: %(default)s)')
|
||||
parser.add_argument('--jerry-libc', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper,
|
||||
help='build and use jerry-libc (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--jerry-libm', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper,
|
||||
help='build and use jerry-libm (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--js-parser', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper,
|
||||
help='enable js-parser (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--link-lib', metavar='OPT', action='append', default=[],
|
||||
help='add custom library to be linked')
|
||||
parser.add_argument('--linker-flag', metavar='OPT', action='append', default=[],
|
||||
help='add custom linker flag')
|
||||
parser.add_argument('--lto', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper,
|
||||
help='enable link-time optimizations (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--mem-heap', metavar='SIZE', action='store', type=int, default=512,
|
||||
help='size of memory heap, in kilobytes (default: %(default)s)')
|
||||
parser.add_argument('--port-dir', metavar='DIR', action='store', default=DEFAULT_PORT_DIR,
|
||||
help='add port directory (default: %(default)s)')
|
||||
parser.add_argument('--profile', metavar='FILE', action='store', default=DEFAULT_PROFILE,
|
||||
help='specify profile file (default: %(default)s)')
|
||||
parser.add_argument('--snapshot-exec', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
|
||||
help='enable executing snapshot files (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--snapshot-save', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
|
||||
help='enable saving snapshot files (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--system-allocator', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
|
||||
help='enable system allocator (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--static-link', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper,
|
||||
help='enable static linking of binaries (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--strip', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper,
|
||||
help='strip release binaries (%(choices)s; default: %(default)s)')
|
||||
parser.add_argument('--toolchain', metavar='FILE', action='store', default=default_toolchain(),
|
||||
help='add toolchain file (default: %(default)s)')
|
||||
parser.add_argument('--unittests', action='store_const', const='ON', default='OFF',
|
||||
help='build unittests')
|
||||
parser.add_argument('-v', '--verbose', action='store_const', const='ON', default='OFF',
|
||||
help='increase verbosity')
|
||||
|
||||
devgroup = parser.add_argument_group('developer options')
|
||||
devgroup.add_argument('--link-map', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable the generation of a link map file for jerry command line tool (%(choices)s; default: %(default)s)'))
|
||||
devgroup.add_argument('--mem-stats', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable memory statistics (%(choices)s; default: %(default)s)'))
|
||||
devgroup.add_argument('--mem-stress-test', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable mem-stress test (%(choices)s; default: %(default)s)'))
|
||||
devgroup.add_argument('--show-opcodes', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable parser byte-code dumps (%(choices)s; default: %(default)s)'))
|
||||
devgroup.add_argument('--show-regexp-opcodes', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable regexp byte-code dumps (%(choices)s; default: %(default)s)'))
|
||||
devgroup.add_argument('--valgrind', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable Valgrind support (%(choices)s; default: %(default)s)'))
|
||||
devgroup.add_argument('--valgrind-freya', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper, help=devhelp('enable Valgrind-Freya support (%(choices)s; default: %(default)s)'))
|
||||
devgroup.add_argument('--link-map', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
|
||||
help=devhelp('enable the generation of a link map file for jerry command line tool '
|
||||
'(%(choices)s; default: %(default)s)'))
|
||||
devgroup.add_argument('--mem-stats', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
|
||||
help=devhelp('enable memory statistics (%(choices)s; default: %(default)s)'))
|
||||
devgroup.add_argument('--mem-stress-test', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
|
||||
help=devhelp('enable mem-stress test (%(choices)s; default: %(default)s)'))
|
||||
devgroup.add_argument('--show-opcodes', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
|
||||
help=devhelp('enable parser byte-code dumps (%(choices)s; default: %(default)s)'))
|
||||
devgroup.add_argument('--show-regexp-opcodes', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
|
||||
help=devhelp('enable regexp byte-code dumps (%(choices)s; default: %(default)s)'))
|
||||
devgroup.add_argument('--valgrind', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
|
||||
help=devhelp('enable Valgrind support (%(choices)s; default: %(default)s)'))
|
||||
devgroup.add_argument('--valgrind-freya', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
|
||||
help=devhelp('enable Valgrind-Freya support (%(choices)s; default: %(default)s)'))
|
||||
|
||||
arguments = parser.parse_args(args)
|
||||
if arguments.devhelp:
|
||||
@ -113,11 +156,11 @@ def generate_build_options(arguments):
|
||||
build_options.append('-DPORT_DIR=%s' % arguments.port_dir)
|
||||
|
||||
if os.path.isabs(arguments.profile):
|
||||
PROFILE = arguments.profile
|
||||
profile = arguments.profile
|
||||
else:
|
||||
PROFILE = os.path.join(PROFILE_DIR, arguments.profile + '.profile')
|
||||
profile = os.path.join(PROFILE_DIR, arguments.profile + '.profile')
|
||||
|
||||
build_options.append('-DFEATURE_PROFILE=%s' % PROFILE)
|
||||
build_options.append('-DFEATURE_PROFILE=%s' % profile)
|
||||
|
||||
build_options.append('-DFEATURE_DEBUGGER=%s' % arguments.jerry_debugger)
|
||||
build_options.append('-DFEATURE_DEBUGGER_PORT=%d' % arguments.jerry_debugger_port)
|
||||
|
||||
@ -14,28 +14,30 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import settings
|
||||
|
||||
LICENSE = re.compile(
|
||||
r'((#|//|\*) Copyright .*\n'
|
||||
r')+\s?\2\n'
|
||||
r'\s?\2 Licensed under the Apache License, Version 2.0 \(the "License"\);\n'
|
||||
r'\s?\2 you may not use this file except in compliance with the License.\n'
|
||||
r'\s?\2 You may obtain a copy of the License at\n'
|
||||
r'\s?\2\n'
|
||||
r'\s?\2 http://www.apache.org/licenses/LICENSE-2.0\n'
|
||||
r'\s?\2\n'
|
||||
r'\s?\2 Unless required by applicable law or agreed to in writing, software\n'
|
||||
r'\s?\2 distributed under the License is distributed on an "AS IS" BASIS\n'
|
||||
r'\s?\2 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n'
|
||||
r'\s?\2 See the License for the specific language governing permissions and\n'
|
||||
r'\s?\2 limitations under the License.\n'
|
||||
)
|
||||
|
||||
license = re.compile(
|
||||
u"""((#|//|\*) Copyright .*
|
||||
)+\s?\\2
|
||||
\s?\\2 Licensed under the Apache License, Version 2.0 \(the "License"\);
|
||||
\s?\\2 you may not use this file except in compliance with the License.
|
||||
\s?\\2 You may obtain a copy of the License at
|
||||
\s?\\2
|
||||
\s?\\2 http://www.apache.org/licenses/LICENSE-2.0
|
||||
\s?\\2
|
||||
\s?\\2 Unless required by applicable law or agreed to in writing, software
|
||||
\s?\\2 distributed under the License is distributed on an "AS IS" BASIS
|
||||
\s?\\2 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
\s?\\2 See the License for the specific language governing permissions and
|
||||
\s?\\2 limitations under the License.""")
|
||||
|
||||
dirs = [
|
||||
INCLUDE_DIRS = [
|
||||
'cmake',
|
||||
'jerry-core',
|
||||
'jerry-libc',
|
||||
@ -46,12 +48,12 @@ dirs = [
|
||||
'tools',
|
||||
]
|
||||
|
||||
exclude_dirs = [
|
||||
EXCLUDE_DIRS = [
|
||||
'targets/esp8266',
|
||||
os.path.relpath (settings.TEST262_TEST_SUITE_DIR, settings.PROJECT_DIR),
|
||||
os.path.relpath(settings.TEST262_TEST_SUITE_DIR, settings.PROJECT_DIR),
|
||||
]
|
||||
|
||||
exts = [
|
||||
EXTENSIONS = [
|
||||
'.c',
|
||||
'.cpp',
|
||||
'.h',
|
||||
@ -67,15 +69,15 @@ exts = [
|
||||
def main():
|
||||
is_ok = True
|
||||
|
||||
for dname in dirs:
|
||||
for dname in INCLUDE_DIRS:
|
||||
for root, _, files in os.walk(dname):
|
||||
if any(root.startswith(exclude) for exclude in exclude_dirs):
|
||||
if any(root.startswith(exclude) for exclude in EXCLUDE_DIRS):
|
||||
continue
|
||||
for fname in files:
|
||||
if any(fname.endswith(ext) for ext in exts):
|
||||
if any(fname.endswith(ext) for ext in EXTENSIONS):
|
||||
fpath = os.path.join(root, fname)
|
||||
with open(fpath) as f:
|
||||
if not license.search(f.read()):
|
||||
with open(fpath) as curr_file:
|
||||
if not LICENSE.search(curr_file.read()):
|
||||
print('%s: incorrect license' % fpath)
|
||||
is_ok = False
|
||||
|
||||
|
||||
@ -14,6 +14,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
@ -22,39 +24,7 @@ import settings
|
||||
|
||||
OUTPUT_DIR = os.path.join(settings.PROJECT_DIR, 'build', 'tests')
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--toolchain', action='store', default='', help='Add toolchain file')
|
||||
parser.add_argument('--buildoptions', action='store', default='', help='Add a comma separated list of extra build options to each test')
|
||||
parser.add_argument('--skip-list', action='store', default='', help='Add a comma separated list of patterns of the excluded JS-tests')
|
||||
parser.add_argument('--outdir', action='store', default=OUTPUT_DIR, help='Specify output directory (default: %(default)s)')
|
||||
parser.add_argument('--check-signed-off', action='store_true', default=False, help='Run signed-off check')
|
||||
parser.add_argument('--check-signed-off-tolerant', action='store_true', default=False, help='Run signed-off check in tolerant mode')
|
||||
parser.add_argument('--check-signed-off-travis', action='store_true', default=False, help='Run signed-off check in tolerant mode if on Travis CI and not checking a pull request')
|
||||
parser.add_argument('--check-cppcheck', action='store_true', default=False, help='Run cppcheck')
|
||||
parser.add_argument('--check-doxygen', action='store_true', default=False, help='Run doxygen')
|
||||
parser.add_argument('--check-pylint', action='store_true', default=False, help='Run pylint')
|
||||
parser.add_argument('--check-vera', action='store_true', default=False, help='Run vera check')
|
||||
parser.add_argument('--check-license', action='store_true', default=False, help='Run license check')
|
||||
parser.add_argument('--buildoption-test', action='store_true', default=False, help='Run buildoption-test')
|
||||
parser.add_argument('--jerry-debugger', action='store_true', default=False, help='Run jerry-debugger tests')
|
||||
parser.add_argument('--jerry-tests', action='store_true', default=False, help='Run jerry-tests')
|
||||
parser.add_argument('--jerry-test-suite', action='store_true', default=False, help='Run jerry-test-suite')
|
||||
parser.add_argument('--unittests', action='store_true', default=False, help='Run unittests')
|
||||
parser.add_argument('--precommit', action='store_true', default=False, dest='all', help='Run all test')
|
||||
parser.add_argument('--test262', action='store_true', default=False, help='Run test262')
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
script_args = parser.parse_args()
|
||||
|
||||
if os.path.isabs(script_args.outdir):
|
||||
OUTPUT_DIR = script_args.outdir
|
||||
else:
|
||||
OUTPUT_DIR = os.path.join(settings.PROJECT_DIR, script_args.outdir)
|
||||
|
||||
class Options:
|
||||
class Options(object):
|
||||
def __init__(self, name='', build_args=None, test_args=None):
|
||||
if build_args is None:
|
||||
build_args = []
|
||||
@ -62,20 +32,31 @@ class Options:
|
||||
if test_args is None:
|
||||
test_args = []
|
||||
|
||||
self.out_dir = os.path.join(OUTPUT_DIR, name)
|
||||
self.build_args = build_args
|
||||
self.build_args.append('--builddir=%s' % self.out_dir)
|
||||
self._build_args = build_args
|
||||
self._name = name
|
||||
self.test_args = test_args
|
||||
|
||||
def get_build_args(self, outdir):
|
||||
return self._build_args + ['--builddir=%s' % os.path.join(outdir, self._name)]
|
||||
|
||||
def get_bin_dir_path(self, outdir):
|
||||
return os.path.join(os.path.join(outdir, self._name), 'bin')
|
||||
|
||||
def get_binary_path(self, outdir):
|
||||
return os.path.join(self.get_bin_dir_path(outdir), 'jerry')
|
||||
|
||||
# Test options for unittests
|
||||
jerry_unittests_options = [
|
||||
JERRY_UNITTESTS_OPTIONS = [
|
||||
Options('unittests', ['--unittests', '--error-messages=on', '--snapshot-save=on', '--snapshot-exec=on']),
|
||||
Options('unittests-debug', ['--unittests', '--debug', '--error-messages=on', '--snapshot-save=on', '--snapshot-exec=on']),
|
||||
Options('unittests-debug', ['--unittests',
|
||||
'--debug',
|
||||
'--error-messages=on',
|
||||
'--snapshot-save=on',
|
||||
'--snapshot-exec=on'])
|
||||
]
|
||||
|
||||
# Test options for jerry-tests
|
||||
jerry_tests_options = [
|
||||
JERRY_TESTS_OPTIONS = [
|
||||
Options('jerry_tests'),
|
||||
Options('jerry_tests-debug', ['--debug']),
|
||||
Options('jerry_tests-debug', ['--debug', '--cpointer-32bit=on', '--mem-heap=1024']),
|
||||
@ -85,25 +66,43 @@ jerry_tests_options = [
|
||||
]
|
||||
|
||||
# Test options for jerry-test-suite
|
||||
jerry_test_suite_options = jerry_tests_options[:]
|
||||
jerry_test_suite_options.append(Options('jerry_test_suite-minimal', ['--profile=minimal']))
|
||||
jerry_test_suite_options.append(Options('jerry_test_suite-minimal-snapshot', ['--profile=minimal', '--snapshot-save=on', '--snapshot-exec=on'], ['--snapshot']))
|
||||
jerry_test_suite_options.append(Options('jerry_test_suite-minimal-debug', ['--debug', '--profile=minimal']))
|
||||
jerry_test_suite_options.append(Options('jerry_test_suite-minimal-debug-snapshot', ['--debug', '--profile=minimal', '--snapshot-save=on', '--snapshot-exec=on'], ['--snapshot']))
|
||||
jerry_test_suite_options.append(Options('jerry_test_suite-es2015-subset', ['--profile=es2015-subset']))
|
||||
jerry_test_suite_options.append(Options('jerry_test_suite-es2015-subset-snapshot', ['--profile=es2015-subset', '--snapshot-save=on', '--snapshot-exec=on'], ['--snapshot']))
|
||||
jerry_test_suite_options.append(Options('jerry_test_suite-es2015-subset-debug-snapshot', ['--debug', '--profile=es2015-subset', '--snapshot-save=on', '--snapshot-exec=on'], ['--snapshot']))
|
||||
JERRY_TEST_SUITE_OPTIONS = JERRY_TESTS_OPTIONS[:]
|
||||
JERRY_TEST_SUITE_OPTIONS.append(Options('jerry_test_suite-minimal', ['--profile=minimal']))
|
||||
JERRY_TEST_SUITE_OPTIONS.append(Options('jerry_test_suite-minimal-snapshot',
|
||||
['--profile=minimal',
|
||||
'--snapshot-save=on',
|
||||
'--snapshot-exec=on'],
|
||||
['--snapshot']))
|
||||
JERRY_TEST_SUITE_OPTIONS.append(Options('jerry_test_suite-minimal-debug', ['--debug', '--profile=minimal']))
|
||||
JERRY_TEST_SUITE_OPTIONS.append(Options('jerry_test_suite-minimal-debug-snapshot',
|
||||
['--debug',
|
||||
'--profile=minimal',
|
||||
'--snapshot-save=on',
|
||||
'--snapshot-exec=on'],
|
||||
['--snapshot']))
|
||||
JERRY_TEST_SUITE_OPTIONS.append(Options('jerry_test_suite-es2015-subset', ['--profile=es2015-subset']))
|
||||
JERRY_TEST_SUITE_OPTIONS.append(Options('jerry_test_suite-es2015-subset-snapshot',
|
||||
['--profile=es2015-subset',
|
||||
'--snapshot-save=on',
|
||||
'--snapshot-exec=on'],
|
||||
['--snapshot']))
|
||||
JERRY_TEST_SUITE_OPTIONS.append(Options('jerry_test_suite-es2015-subset-debug-snapshot',
|
||||
['--debug',
|
||||
'--profile=es2015-subset',
|
||||
'--snapshot-save=on',
|
||||
'--snapshot-exec=on'],
|
||||
['--snapshot']))
|
||||
|
||||
# Test options for test262
|
||||
test262_test_suite_options = [Options('test262_tests')]
|
||||
TEST262_TEST_SUITE_OPTIONS = [Options('test262_tests')]
|
||||
|
||||
# Test options for jerry-debugger
|
||||
debugger_test_options = [
|
||||
DEBUGGER_TEST_OPTIONS = [
|
||||
Options('jerry_debugger_tests', ['--debug', '--jerry-debugger=on', '--jerry-libc=off'])
|
||||
]
|
||||
|
||||
# Test options for buildoption-test
|
||||
jerry_buildoptions = [
|
||||
JERRY_BUILDOPTIONS = [
|
||||
Options('buildoption_test-lto', ['--lto=on']),
|
||||
Options('buildoption_test-error_messages', ['--error-messages=on']),
|
||||
Options('buildoption_test-all_in_one', ['--all-in-one=on']),
|
||||
@ -113,31 +112,64 @@ jerry_buildoptions = [
|
||||
Options('buildoption_test-show_opcodes', ['--show-opcodes=on']),
|
||||
Options('buildoption_test-show_regexp_opcodes', ['--show-regexp-opcodes=on']),
|
||||
Options('buildoption_test-compiler_default_libc', ['--jerry-libc=off']),
|
||||
Options('buildoption_test-cpointer_32bit', ['--jerry-libc=off', '--compile-flag=-m32', '--cpointer-32bit=on', '--system-allocator=on']),
|
||||
Options('buildoption_test-cpointer_32bit', ['--jerry-libc=off',
|
||||
'--compile-flag=-m32',
|
||||
'--cpointer-32bit=on',
|
||||
'--system-allocator=on']),
|
||||
]
|
||||
|
||||
def get_bin_dir_path(out_dir):
|
||||
return os.path.join(out_dir, 'bin')
|
||||
def get_arguments():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--toolchain', action='store', default='', help='Add toolchain file')
|
||||
parser.add_argument('--buildoptions', action='store', default='',
|
||||
help='Add a comma separated list of extra build options to each test')
|
||||
parser.add_argument('--skip-list', action='store', default='',
|
||||
help='Add a comma separated list of patterns of the excluded JS-tests')
|
||||
parser.add_argument('--outdir', action='store', default=OUTPUT_DIR,
|
||||
help='Specify output directory (default: %(default)s)')
|
||||
parser.add_argument('--check-signed-off', action='store_true', default=False,
|
||||
help='Run signed-off check')
|
||||
parser.add_argument('--check-signed-off-tolerant', action='store_true', default=False,
|
||||
help='Run signed-off check in tolerant mode')
|
||||
parser.add_argument('--check-signed-off-travis', action='store_true', default=False,
|
||||
help='Run signed-off check in tolerant mode if on Travis CI and not checking a pull request')
|
||||
parser.add_argument('--check-cppcheck', action='store_true', default=False, help='Run cppcheck')
|
||||
parser.add_argument('--check-doxygen', action='store_true', default=False, help='Run doxygen')
|
||||
parser.add_argument('--check-pylint', action='store_true', default=False, help='Run pylint')
|
||||
parser.add_argument('--check-vera', action='store_true', default=False, help='Run vera check')
|
||||
parser.add_argument('--check-license', action='store_true', default=False, help='Run license check')
|
||||
parser.add_argument('--buildoption-test', action='store_true', default=False, help='Run buildoption-test')
|
||||
parser.add_argument('--jerry-debugger', action='store_true', default=False, help='Run jerry-debugger tests')
|
||||
parser.add_argument('--jerry-tests', action='store_true', default=False, help='Run jerry-tests')
|
||||
parser.add_argument('--jerry-test-suite', action='store_true', default=False, help='Run jerry-test-suite')
|
||||
parser.add_argument('--unittests', action='store_true', default=False, help='Run unittests')
|
||||
parser.add_argument('--precommit', action='store_true', default=False, dest='all', help='Run all test')
|
||||
parser.add_argument('--test262', action='store_true', default=False, help='Run test262')
|
||||
|
||||
def get_binary_path(out_dir):
|
||||
return os.path.join(get_bin_dir_path(out_dir), 'jerry')
|
||||
if len(sys.argv) == 1:
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
|
||||
def create_binary(buildoptions):
|
||||
script_args = parser.parse_args()
|
||||
|
||||
return script_args
|
||||
|
||||
def create_binary(buildoptions, options):
|
||||
build_cmd = [settings.BUILD_SCRIPT]
|
||||
build_cmd.extend(buildoptions)
|
||||
|
||||
if script_args.toolchain:
|
||||
build_cmd.append('--toolchain=%s' % script_args.toolchain)
|
||||
if options.toolchain:
|
||||
build_cmd.append('--toolchain=%s' % options.toolchain)
|
||||
|
||||
if script_args.buildoptions:
|
||||
build_cmd.extend(script_args.buildoptions.split(','))
|
||||
if options.buildoptions:
|
||||
build_cmd.extend(options.buildoptions.split(','))
|
||||
|
||||
sys.stderr.write('Build command: %s\n' % ' '.join(build_cmd))
|
||||
|
||||
try:
|
||||
script_output = subprocess.check_output(build_cmd)
|
||||
except subprocess.CalledProcessError as e:
|
||||
return e.returncode
|
||||
subprocess.check_output(build_cmd)
|
||||
except subprocess.CalledProcessError as err:
|
||||
return err.returncode
|
||||
|
||||
return 0
|
||||
|
||||
@ -146,27 +178,27 @@ def run_check(runnable):
|
||||
|
||||
try:
|
||||
ret = subprocess.check_call(runnable)
|
||||
except subprocess.CalledProcessError as e:
|
||||
return e.returncode
|
||||
except subprocess.CalledProcessError as err:
|
||||
return err.returncode
|
||||
|
||||
return ret
|
||||
|
||||
def run_jerry_debugger_tests():
|
||||
def run_jerry_debugger_tests(options):
|
||||
ret_build = ret_test = 0
|
||||
for job in debugger_test_options:
|
||||
ret_build = create_binary(job.build_args)
|
||||
for job in DEBUGGER_TEST_OPTIONS:
|
||||
ret_build = create_binary(job.get_build_args(options.outdir), options)
|
||||
if ret_build:
|
||||
break
|
||||
|
||||
for file in os.listdir(settings.DEBUGGER_TESTS_DIR):
|
||||
if file.endswith(".js"):
|
||||
test_case, _ = os.path.splitext(file)
|
||||
for test_file in os.listdir(settings.DEBUGGER_TESTS_DIR):
|
||||
if test_file.endswith(".js"):
|
||||
test_case, _ = os.path.splitext(test_file)
|
||||
test_case_path = os.path.join(settings.DEBUGGER_TESTS_DIR, test_case)
|
||||
test_cmd = [
|
||||
settings.DEBUGGER_TEST_RUNNER_SCRIPT,
|
||||
get_binary_path(job.out_dir),
|
||||
job.get_binary_path(options.outdir),
|
||||
settings.DEBUGGER_CLIENT_SCRIPT,
|
||||
os.path.relpath(test_case_path, settings.PROJECT_DIR),
|
||||
os.path.relpath(test_case_path, settings.PROJECT_DIR)
|
||||
]
|
||||
|
||||
if job.test_args:
|
||||
@ -176,25 +208,25 @@ def run_jerry_debugger_tests():
|
||||
|
||||
return ret_build | ret_test
|
||||
|
||||
def run_jerry_tests():
|
||||
def run_jerry_tests(options):
|
||||
ret_build = ret_test = 0
|
||||
for job in jerry_tests_options:
|
||||
ret_build = create_binary(job.build_args)
|
||||
for job in JERRY_TESTS_OPTIONS:
|
||||
ret_build = create_binary(job.get_build_args(options.outdir), options)
|
||||
if ret_build:
|
||||
break
|
||||
|
||||
test_cmd = [
|
||||
settings.TEST_RUNNER_SCRIPT,
|
||||
get_binary_path(job.out_dir),
|
||||
job.get_binary_path(options.outdir),
|
||||
settings.JERRY_TESTS_DIR
|
||||
]
|
||||
skip_list = []
|
||||
|
||||
if '--profile=es2015-subset' not in job.build_args:
|
||||
skip_list.append("es2015\/")
|
||||
if '--profile=es2015-subset' not in job.get_build_args(options.outdir):
|
||||
skip_list.append(r"es2015\/")
|
||||
|
||||
if script_args.skip_list:
|
||||
skip_list.append(script_args.skip_list)
|
||||
if options.skip_list:
|
||||
skip_list.append(options.skip_list)
|
||||
|
||||
if skip_list:
|
||||
test_cmd.append("--skip-list=" + ",".join(skip_list))
|
||||
@ -206,24 +238,24 @@ def run_jerry_tests():
|
||||
|
||||
return ret_build | ret_test
|
||||
|
||||
def run_jerry_test_suite():
|
||||
def run_jerry_test_suite(options):
|
||||
ret_build = ret_test = 0
|
||||
for job in jerry_test_suite_options:
|
||||
ret_build = create_binary(job.build_args)
|
||||
for job in JERRY_TEST_SUITE_OPTIONS:
|
||||
ret_build = create_binary(job.get_build_args(options.outdir), options)
|
||||
if ret_build:
|
||||
break
|
||||
|
||||
test_cmd = [settings.TEST_RUNNER_SCRIPT, get_binary_path(job.out_dir)]
|
||||
test_cmd = [settings.TEST_RUNNER_SCRIPT, job.get_binary_path(options.outdir)]
|
||||
|
||||
if '--profile=minimal' in job.build_args:
|
||||
if '--profile=minimal' in job.get_build_args(options.outdir):
|
||||
test_cmd.append(settings.JERRY_TEST_SUITE_MINIMAL_LIST)
|
||||
elif '--profile=es2015-subset' in job.build_args:
|
||||
elif '--profile=es2015-subset' in job.get_build_args(options.outdir):
|
||||
test_cmd.append(settings.JERRY_TEST_SUITE_DIR)
|
||||
else:
|
||||
test_cmd.append(settings.JERRY_TEST_SUITE_ES51_LIST)
|
||||
|
||||
if script_args.skip_list:
|
||||
test_cmd.append("--skip-list=" + script_args.skip_list)
|
||||
if options.skip_list:
|
||||
test_cmd.append("--skip-list=" + options.skip_list)
|
||||
|
||||
if job.test_args:
|
||||
test_cmd.extend(job.test_args)
|
||||
@ -232,16 +264,16 @@ def run_jerry_test_suite():
|
||||
|
||||
return ret_build | ret_test
|
||||
|
||||
def run_test262_test_suite():
|
||||
def run_test262_test_suite(options):
|
||||
ret_build = ret_test = 0
|
||||
for job in test262_test_suite_options:
|
||||
ret_build = create_binary(job.build_args)
|
||||
for job in TEST262_TEST_SUITE_OPTIONS:
|
||||
ret_build = create_binary(job.get_build_args(options.outdir), options)
|
||||
if ret_build:
|
||||
break
|
||||
|
||||
test_cmd = [
|
||||
settings.TEST262_RUNNER_SCRIPT,
|
||||
get_binary_path(job.out_dir),
|
||||
job.get_binary_path(options.outdir),
|
||||
settings.TEST262_TEST_SUITE_DIR
|
||||
]
|
||||
|
||||
@ -252,75 +284,75 @@ def run_test262_test_suite():
|
||||
|
||||
return ret_build | ret_test
|
||||
|
||||
def run_unittests():
|
||||
def run_unittests(options):
|
||||
ret_build = ret_test = 0
|
||||
for job in jerry_unittests_options:
|
||||
ret_build = create_binary(job.build_args)
|
||||
for job in JERRY_UNITTESTS_OPTIONS:
|
||||
ret_build = create_binary(job.get_build_args(options.outdir), options)
|
||||
if ret_build:
|
||||
break
|
||||
|
||||
ret_test |= run_check([
|
||||
settings.UNITTEST_RUNNER_SCRIPT,
|
||||
get_bin_dir_path(job.out_dir)
|
||||
job.get_bin_dir_path(options.outdir)
|
||||
])
|
||||
|
||||
return ret_build | ret_test
|
||||
|
||||
def run_buildoption_test():
|
||||
for job in jerry_buildoptions:
|
||||
ret = create_binary(job.build_args)
|
||||
def run_buildoption_test(options):
|
||||
for job in JERRY_BUILDOPTIONS:
|
||||
ret = create_binary(job.get_build_args(options.outdir), options)
|
||||
if ret:
|
||||
break
|
||||
|
||||
return ret
|
||||
|
||||
def main():
|
||||
def main(options):
|
||||
ret = 0
|
||||
|
||||
if script_args.check_signed_off_tolerant:
|
||||
if options.check_signed_off_tolerant:
|
||||
ret = run_check([settings.SIGNED_OFF_SCRIPT, '--tolerant'])
|
||||
|
||||
if not ret and script_args.check_signed_off_travis:
|
||||
if not ret and options.check_signed_off_travis:
|
||||
ret = run_check([settings.SIGNED_OFF_SCRIPT, '--travis'])
|
||||
|
||||
if not ret and (script_args.all or script_args.check_signed_off):
|
||||
if not ret and (options.all or options.check_signed_off):
|
||||
ret = run_check([settings.SIGNED_OFF_SCRIPT])
|
||||
|
||||
if not ret and (script_args.all or script_args.check_cppcheck):
|
||||
if not ret and (options.all or options.check_cppcheck):
|
||||
ret = run_check([settings.CPPCHECK_SCRIPT])
|
||||
|
||||
if not ret and (script_args.all or script_args.check_doxygen):
|
||||
if not ret and (options.all or options.check_doxygen):
|
||||
ret = run_check([settings.DOXYGEN_SCRIPT])
|
||||
|
||||
if not ret and (script_args.all or script_args.check_pylint):
|
||||
if not ret and (options.all or options.check_pylint):
|
||||
ret = run_check([settings.PYLINT_SCRIPT])
|
||||
|
||||
if not ret and (script_args.all or script_args.check_vera):
|
||||
if not ret and (options.all or options.check_vera):
|
||||
ret = run_check([settings.VERA_SCRIPT])
|
||||
|
||||
if not ret and (script_args.all or script_args.check_license):
|
||||
if not ret and (options.all or options.check_license):
|
||||
ret = run_check([settings.LICENSE_SCRIPT])
|
||||
|
||||
if not ret and (script_args.all or script_args.jerry_debugger):
|
||||
ret = run_jerry_debugger_tests()
|
||||
if not ret and (options.all or options.jerry_debugger):
|
||||
ret = run_jerry_debugger_tests(options)
|
||||
|
||||
if not ret and (script_args.all or script_args.jerry_tests):
|
||||
ret = run_jerry_tests()
|
||||
if not ret and (options.all or options.jerry_tests):
|
||||
ret = run_jerry_tests(options)
|
||||
|
||||
if not ret and (script_args.all or script_args.jerry_test_suite):
|
||||
ret = run_jerry_test_suite()
|
||||
if not ret and (options.all or options.jerry_test_suite):
|
||||
ret = run_jerry_test_suite(options)
|
||||
|
||||
if not ret and (script_args.all or script_args.test262):
|
||||
ret = run_test262_test_suite()
|
||||
if not ret and (options.all or options.test262):
|
||||
ret = run_test262_test_suite(options)
|
||||
|
||||
if not ret and (script_args.all or script_args.unittests):
|
||||
ret = run_unittests()
|
||||
if not ret and (options.all or options.unittests):
|
||||
ret = run_unittests(options)
|
||||
|
||||
if not ret and (script_args.all or script_args.buildoption_test):
|
||||
ret = run_buildoption_test()
|
||||
if not ret and (options.all or options.buildoption_test):
|
||||
ret = run_buildoption_test(options)
|
||||
|
||||
sys.exit(ret)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main(get_arguments())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user