Repository: jerryscript-project/jerryscript
File: tools/run-tests.py (Python)

Code before:
                        help='Run jerry-tests')
    parser.add_argument('--test262', default=False, const='default',
                        nargs='?', choices=['default', 'all', 'update'],
                        help='Run test262 - default: all tests except excludelist, ' +
                        'all: all tests, update: all tests and update excludelist')
    parser.add_argument('--test262-test-list', metavar='LIST',
                        help='Add a comma separated list of tests or directories to run in test262 test suite')
    parser.add_argument('--unittests', action='store_true',
                        help='Run unittests (including doctests)')
    parser.add_argument('--buildoption-test', action='store_true',
                        help='Run buildoption-test')
    parser.add_argument('--all', '--precommit', action='store_true',
                        help='Run all tests')

    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit(1)

    script_args = parser.parse_args()

    return script_args

BINARY_CACHE = {}

def report_command(cmd_type, cmd, env=None):
    sys.stderr.write(f'{util.TERM_BLUE}{cmd_type}{util.TERM_NORMAL}\n')
    if env is not None:
        sys.stderr.write(''.join(f'{util.TERM_BLUE}{var}={val!r} \\{util.TERM_NORMAL}\n'
                                 for var, val in sorted(env.items())))
    sys.stderr.write(f"{util.TERM_BLUE}" +
                     f" \\{util.TERM_NORMAL}\n\t{util.TERM_BLUE}".join(cmd) +
                     f"{util.TERM_NORMAL}\n")
    sys.stderr.flush()

def report_skip(job):
    sys.stderr.write(f'{util.TERM_YELLOW}Skipping: {job.name}')
    if job.skip:
        sys.stderr.write(f' ({job.skip})')
    sys.stderr.write(f'{util.TERM_NORMAL}\n')
    sys.stderr.flush()

def create_binary(job, options):
    build_args = job.build_args[:]
    build_dir_path = os.path.join(options.outdir, job.name)
    if options.build_debug:
        build_args.extend(OPTIONS_DEBUG)
        build_dir_path = os.path.join(options.outdir, job.name + '-debug')
    if options.buildoptions:
        for option in options.buildoptions.split(','):
            if option not in build_args:
                build_args.append(option)

Review comment (suggestion):
I'd prefer to import these like,

`from runners.util import TERM_NORMAL, TERM_YELLOW, TERM_BLUE, TERM_RED`

or something like that.

Code after:
                        nargs='?', choices=['default', 'all', 'update'],
                        help='Run test262 - default: all tests except excludelist, ' +
                        'all: all tests, update: all tests and update excludelist')
    parser.add_argument('--test262-test-list', metavar='LIST',
                        help='Add a comma separated list of tests or directories to run in test262 test suite')
    parser.add_argument('--unittests', action='store_true',
                        help='Run unittests (including doctests)')
    parser.add_argument('--buildoption-test', action='store_true',
                        help='Run buildoption-test')
    parser.add_argument('--all', '--precommit', action='store_true',
                        help='Run all tests')

    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit(1)

    script_args = parser.parse_args()

    return script_args

BINARY_CACHE = {}

def report_command(cmd_type, cmd, env=None):
    sys.stderr.write(f'{TERM_BLUE}{cmd_type}{TERM_NORMAL}\n')
    if env is not None:
        sys.stderr.write(''.join(f'{TERM_BLUE}{var}={val!r} \\{TERM_NORMAL}\n'
                                 for var, val in sorted(env.items())))
    sys.stderr.write(f"{TERM_BLUE}" +
                     f" \\{TERM_NORMAL}\n\t{TERM_BLUE}".join(cmd) +
                     f"{TERM_NORMAL}\n")
    sys.stderr.flush()

def report_skip(job):
    sys.stderr.write(f'{TERM_YELLOW}Skipping: {job.name}')
    if job.skip:
        sys.stderr.write(f' ({job.skip})')
    sys.stderr.write(f'{TERM_NORMAL}\n')
    sys.stderr.flush()

def create_binary(job, options):
    build_args = job.build_args[:]
    build_dir_path = os.path.join(options.outdir, job.name)
    if options.build_debug:
        build_args.extend(OPTIONS_DEBUG)
        build_dir_path = os.path.join(options.outdir, job.name + '-debug')
    if options.buildoptions:
        for option in options.buildoptions.split(','):
            if option not in build_args:
                build_args.append(option)

    build_cmd = util.get_python_cmd_prefix()