1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3 4""" 5Copyright (c) 2021 Huawei Device Co., Ltd. 6Licensed under the Apache License, Version 2.0 (the "License"); 7you may not use this file except in compliance with the License. 8You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12Unless required by applicable law or agreed to in writing, software 13distributed under the License is distributed on an "AS IS" BASIS, 14WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15See the License for the specific language governing permissions and 16limitations under the License. 17 18Description: Use ark to execute test 262 test suite 19""" 20 21import argparse 22import datetime 23import collections 24import json 25import os 26import shutil 27import sys 28import subprocess 29from multiprocessing import Pool 30import platform 31from utils import * 32from config import * 33 34 35def parse_args(): 36 parser = argparse.ArgumentParser() 37 parser.add_argument('--dir', metavar='DIR', 38 help='Directory to test ') 39 parser.add_argument('--file', metavar='FILE', 40 help='File to test') 41 parser.add_argument('--mode', 42 nargs='?', choices=[1, 2, 3], type=int, 43 help='selection information as: ' + 44 '1: only default \n ' + 45 '2: only strict mode \n' + 46 '3: both default and strict mode\n') 47 parser.add_argument('--es51', action='store_true', 48 help='Run test262 ES5.1 version') 49 parser.add_argument('--es2021', default=False, const='all', 50 nargs='?', choices=['all', 'only'], 51 help='Run test262 - ES2021. ' + 52 'all: Contains all use cases for es5_tests and es2015_tests and es2021_tests and intl_tests' + 53 'only: Only include use cases for ES2021') 54 parser.add_argument('--es2022', default=False, const='all', 55 nargs='?', choices=['all', 'only'], 56 help='Run test262 - ES2022. ' + 57 'all: Contains all use cases for es5_tests and es2015_tests and es2021_tests and es2022_tests and intl_tests' + 58 'only: Only include use cases for ES2022') 59 parser.add_argument('--es2023', default=False, const='all', 60 nargs='?', choices=['all', 'only'], 61 help='Run test262 - ES2023. ' + 62 'all: Contains all use cases for es5_tests and es2015_tests and es2021_tests and es2022_tests and es2023_tests and intl_tests' + 63 'only: Only include use cases for ES2023') 64 parser.add_argument('--intl', default=False, const='intl', 65 nargs='?', choices=['intl'], 66 help='Run test262 - Intltest. ' + 67 'intl: Only include use cases for intlcsae') 68 parser.add_argument('--es2015', default=False, const='es2015', 69 nargs='?', choices=['es2015'], 70 help='Run test262 - es2015. ' + 71 'es2015: Only include use cases for es2015') 72 parser.add_argument('--ci-build', action='store_true', 73 help='Run test262 ES2015 filter cases for build version') 74 parser.add_argument('--esnext', action='store_true', 75 help='Run test262 - ES.next.') 76 parser.add_argument('--engine', metavar='FILE', 77 help='Other engine binarys to run tests(as:d8,qjs...)') 78 parser.add_argument('--babel', action='store_true', 79 help='Whether to use Babel conversion') 80 parser.add_argument('--timeout', default=DEFAULT_TIMEOUT, type=int, 81 help='Set a custom test timeout in milliseconds !!!\n') 82 parser.add_argument('--threads', default=DEFAULT_THREADS, type=int, 83 help="Run this many tests in parallel.") 84 parser.add_argument('--hostArgs', 85 help="command-line arguments to pass to eshost host\n") 86 parser.add_argument('--ark-tool', 87 help="ark's binary tool") 88 parser.add_argument('--ark-aot', action='store_true', 89 help="Run test262 with aot") 90 parser.add_argument('--ark-aot-tool', 91 help="ark's aot tool") 92 parser.add_argument("--libs-dir", 93 help="The path collection of dependent so has been divided by':'") 94 parser.add_argument('--ark-frontend', 95 nargs='?', choices=ARK_FRONTEND_LIST, type=str, 96 help="Choose one of them") 97 parser.add_argument('--ark-frontend-binary', 98 help="ark frontend conversion binary tool") 99 parser.add_argument('--ark-arch', 100 default=DEFAULT_ARK_ARCH, 101 nargs='?', choices=ARK_ARCH_LIST, type=str, 102 help="Choose one of them") 103 parser.add_argument('--ark-arch-root', 104 default=DEFAULT_ARK_ARCH, 105 help="the root path for qemu-aarch64 or qemu-arm") 106 parser.add_argument('--opt-level', 107 default=DEFAULT_OPT_LEVEL, 108 help="the opt level for es2abc") 109 parser.add_argument('--es2abc-thread-count', 110 default=DEFAULT_ES2ABC_THREAD_COUNT, 111 help="the thread count for es2abc") 112 parser.add_argument('--merge-abc-binary', 113 help="frontend merge abc binary tool") 114 parser.add_argument('--merge-abc-mode', 115 help="run test for merge abc mode") 116 parser.add_argument('--product-name', 117 default=DEFAULT_PRODUCT_NAME, 118 help="ark's product name") 119 return parser.parse_args() 120 121 122def run_check(runnable, env=None): 123 report_command('Test command:', runnable, env=env) 124 125 if env is not None: 126 full_env = dict(os.environ) 127 full_env.update(env) 128 env = full_env 129 130 proc = subprocess.Popen(runnable, env=env) 131 proc.wait() 132 return proc.returncode 133 134 135def excuting_npm_install(args): 136 ark_frontend = DEFAULT_ARK_FRONTEND 137 if args.ark_frontend: 138 ark_frontend = args.ark_frontend 139 140 if ark_frontend != ARK_FRONTEND_LIST[0]: 141 return 142 143 ark_frontend_binary = os.path.join(ARK_FRONTEND_BINARY_LIST[0]) 144 if args.ark_frontend_binary: 145 ark_frontend_binary = os.path.join(args.ark_frontend_binary) 146 147 ts2abc_build_dir = os.path.join(os.path.dirname( 148 os.path.realpath(ark_frontend_binary)), "..") 149 150 if not os.path.exists(os.path.join(ts2abc_build_dir, "package.json")) and \ 151 not os.path.exists(os.path.join(ts2abc_build_dir, "..", "package.json")): 152 return 153 154 if os.path.exists(os.path.join(ts2abc_build_dir, "..", "package.json")) and \ 155 not os.path.exists(os.path.join(ts2abc_build_dir, "package.json")): 156 ts2abc_build_dir = os.path.join(ts2abc_build_dir, "..") 157 # copy deps/ohos-typescript 158 deps_dir = os.path.join(ts2abc_build_dir, "deps") 159 mkdir(deps_dir) 160 161 shutil.copyfile(OHOS_TYPESCRIPT_TGZ_PATH, os.path.join(deps_dir, OHOS_TYPESCRIPT)) 162 163 npm_install(ts2abc_build_dir) 164 165 166def init(args): 167 remove_dir(BASE_OUT_DIR) 168 remove_dir(TEST_ES5_DIR) 169 remove_dir(TEST_ES2015_DIR) 170 remove_dir(TEST_INTL_DIR) 171 remove_dir(TEST_ES2021_DIR) 172 remove_dir(TEST_ES2022_DIR) 173 remove_dir(TEST_ES2023_DIR) 174 remove_dir(TEST_CI_DIR) 175 get_all_skip_tests(args) 176 excuting_npm_install(args) 177 178 179def get_all_skip_tests(args): 180 # !!! plz correct the condition when changing the default frontend 181 if args.ark_frontend and args.ark_frontend == ARK_FRONTEND_LIST[1]: 182 SKIP_LIST_FILES.append(ES2ABC_SKIP_LIST_FILE) 183 else: 184 SKIP_LIST_FILES.append(TS2ABC_SKIP_LIST_FILE) 185 186 for file in SKIP_LIST_FILES: 187 with open(file) as jsonfile: 188 json_data = json.load(jsonfile) 189 for key in json_data: 190 ALL_SKIP_TESTS.extend(key["files"]) 191 192 193def collect_files(path): 194 if os.path.isfile(path): 195 yield path 196 return 197 198 if not os.path.isdir(path): 199 raise ValueError(f'Not found: "{path}"') 200 201 for root, _, file_names in os.walk(path): 202 for file_name in file_names: 203 if file_name.startswith('.') or not file_name.endswith(".js"): 204 continue 205 206 yield os.path.join(root, file_name) 207 208 209def mkdstdir(file, src_dir, dist_dir): 210 idx = file.rfind(src_dir) 211 if idx == -1: 212 raise SystemExit(f'{file} can not found in {src_dir}') 213 214 fpath, fname = os.path.split(file[idx:]) 215 fpath = fpath.replace(src_dir, dist_dir) 216 mkdir(fpath) 217 218 219class TestPrepare(): 220 def __init__(self, args): 221 self.args = args 222 self.out_dir = BASE_OUT_DIR 223 224 225 def prepare_test262_code(self): 226 if not os.path.isdir(os.path.join(DATA_DIR, '.git')): 227 git_clone(TEST262_GIT_URL, DATA_DIR) 228 git_checkout(TEST262_GIT_HASH, DATA_DIR) 229 230 if not os.path.isdir(os.path.join(ESHOST_DIR, '.git')): 231 git_clone(ESHOST_GIT_URL, ESHOST_DIR) 232 git_checkout(ESHOST_GIT_HASH, ESHOST_DIR) 233 git_apply('../eshost.patch', ESHOST_DIR) 234 235 npm_install(ESHOST_DIR) 236 237 if not os.path.isdir(os.path.join(HARNESS_DIR, '.git')): 238 git_clone(HARNESS_GIT_URL, HARNESS_DIR) 239 git_checkout(HARNESS_GIT_HASH, HARNESS_DIR) 240 git_apply('../harness.patch', HARNESS_DIR) 241 242 npm_install(HARNESS_DIR) 243 244 def prepare_clean_data(self): 245 git_clean(DATA_DIR) 246 git_checkout(TEST262_GIT_HASH, DATA_DIR) 247 248 def patching_the_plugin(self): 249 remove_file(os.path.join(ESHOST_DIR, "lib/agents/panda.js")) 250 remove_file(os.path.join(ESHOST_DIR, "runtimes/panda.js")) 251 252 git_clean(ESHOST_DIR) 253 git_apply("../eshost.patch", ESHOST_DIR) 254 git_clean(HARNESS_DIR) 255 git_apply("../harness.patch", HARNESS_DIR) 256 257 def prepare_args_es51_es2021(self): 258 if self.args.dir: 259 if TEST_ES5_DIR in self.args.dir: 260 self.args.es51 = True 261 elif TEST_ES2015_DIR in self.args.dir: 262 self.args.es2015 = "es2015" 263 elif TEST_INTL_DIR in self.args.dir: 264 self.args.intl = "intl" 265 elif TEST_ES2021_DIR in self.args.dir: 266 self.args.es2021 = "all" 267 elif TEST_ES2022_DIR in self.args.dir: 268 self.args.es2022 = "all" 269 elif TEST_ES2023_DIR in self.args.dir: 270 self.args.es2023 = "all" 271 272 if self.args.file: 273 if TEST_ES5_DIR in self.args.file: 274 self.args.es51 = True 275 elif TEST_ES2015_DIR in self.args.file: 276 self.args.es2015 = "es2015" 277 elif TEST_INTL_DIR in self.args.file: 278 self.args.intl = "intl" 279 elif TEST_ES2021_DIR in self.args.file: 280 self.args.es2021 = "all" 281 elif TEST_ES2022_DIR in self.args.file: 282 self.args.es2022 = "all" 283 elif TEST_ES2023_DIR in self.args.file: 284 self.args.es2023 = "all" 285 286 def prepare_out_dir(self): 287 if self.args.es51: 288 self.out_dir = os.path.join(BASE_OUT_DIR, "test_es51") 289 elif self.args.es2015: 290 self.out_dir = os.path.join(BASE_OUT_DIR, "test_es2015") 291 elif self.args.intl: 292 self.out_dir = os.path.join(BASE_OUT_DIR, "test_intl") 293 elif self.args.es2021: 294 self.out_dir = os.path.join(BASE_OUT_DIR, "test_es2021") 295 elif self.args.es2022: 296 self.out_dir = os.path.join(BASE_OUT_DIR, "test_es2022") 297 elif self.args.es2023: 298 self.out_dir = os.path.join(BASE_OUT_DIR, "test_es2023") 299 elif self.args.ci_build: 300 self.out_dir = os.path.join(BASE_OUT_DIR, "test_CI") 301 else: 302 self.out_dir = os.path.join(BASE_OUT_DIR, "test") 303 304 def prepare_args_testdir(self): 305 if self.args.dir: 306 return 307 308 if self.args.es51: 309 self.args.dir = TEST_ES5_DIR 310 elif self.args.es2015: 311 self.args.dir = TEST_ES2015_DIR 312 elif self.args.intl: 313 self.args.dir = TEST_INTL_DIR 314 elif self.args.es2021: 315 self.args.dir = TEST_ES2021_DIR 316 elif self.args.es2022: 317 self.args.dir = TEST_ES2022_DIR 318 elif self.args.es2023: 319 self.args.dir = TEST_ES2023_DIR 320 elif self.args.ci_build: 321 self.args.dir = TEST_CI_DIR 322 else: 323 self.args.dir = os.path.join(DATA_DIR, "test") 324 325 def copyfile(self, file, all_skips): 326 dstdir = os.path.join(DATA_DIR, "test") 327 file = file.strip() 328 file = file.strip('\n') 329 file = file.replace("\\", "/") 330 if file in all_skips: 331 return 332 333 srcdir = os.path.join(DATA_DIR, "test", file) 334 if self.args.es51: 335 dstdir = os.path.join(TEST_ES5_DIR, file) 336 elif self.args.es2015: 337 dstdir = os.path.join(TEST_ES2015_DIR, file) 338 elif self.args.intl: 339 dstdir = os.path.join(TEST_INTL_DIR, file) 340 elif self.args.es2021: 341 dstdir = os.path.join(TEST_ES2021_DIR, file) 342 elif self.args.es2022: 343 dstdir = os.path.join(TEST_ES2022_DIR, file) 344 elif self.args.es2023: 345 dstdir = os.path.join(TEST_ES2023_DIR, file) 346 elif self.args.ci_build: 347 dstdir = os.path.join(TEST_CI_DIR, file) 348 349 if os.path.isfile(srcdir): 350 shutil.copyfile(srcdir, dstdir) 351 352 353 def collect_tests(self): 354 files = [] 355 origin_dir = os.path.join(DATA_DIR, "test/") 356 file_names = collect_files(origin_dir) 357 esid = "" 358 if self.args.es51: 359 esid = "es5id" 360 elif self.args.es2021 or self.args.es2022 or self.args.es2023: 361 esid = "es6id" 362 363 for file_name in file_names: 364 with open(file_name, 'r', encoding='utf-8') as file: 365 file_content = file.read() 366 if esid in file_content: 367 files.append(file_name.split(origin_dir)[1]) 368 return files 369 370 def get_tests_from_file(self, file): 371 with open(file) as fopen: 372 files = fopen.readlines() 373 return files 374 375 def prepare_es2021_tests(self): 376 files = [] 377 files = self.collect_tests() 378 files.extend(self.get_tests_from_file(ES2021_LIST_FILE)) 379 if self.args.es2021 == "all": 380 files.extend(self.get_tests_from_file(ES5_LIST_FILE)) 381 files.extend(self.get_tests_from_file(INTL_LIST_FILE)) 382 files.extend(self.get_tests_from_file(ES2015_LIST_FILE)) 383 return files 384 385 def prepare_es2022_tests(self): 386 files = [] 387 files.extend(self.get_tests_from_file(ES2022_LIST_FILE)) 388 if self.args.es2022 == "all": 389 files.extend(self.get_tests_from_file(ES5_LIST_FILE)) 390 files.extend(self.get_tests_from_file(INTL_LIST_FILE)) 391 files.extend(self.get_tests_from_file(ES2015_LIST_FILE)) 392 files.extend(self.collect_tests()) 393 files.extend(self.get_tests_from_file(ES2021_LIST_FILE)) 394 return files 395 396 def prepare_es2023_tests(self): 397 files = [] 398 files.extend(self.get_tests_from_file(ES2023_LIST_FILE)) 399 if self.args.es2023 == "all": 400 files.extend(self.get_tests_from_file(ES5_LIST_FILE)) 401 files.extend(self.get_tests_from_file(INTL_LIST_FILE)) 402 files.extend(self.get_tests_from_file(ES2015_LIST_FILE)) 403 files.extend(self.collect_tests()) 404 files.extend(self.get_tests_from_file(ES2021_LIST_FILE)) 405 files.extend(self.get_tests_from_file(ES2022_LIST_FILE)) 406 return files 407 408 def prepare_intl_tests(self): 409 files = [] 410 files = self.collect_tests() 411 if self.args.intl: 412 files = self.get_tests_from_file(INTL_LIST_FILE) 413 return files 414 415 def prepare_es2015_tests(self): 416 files = [] 417 files = self.collect_tests() 418 if self.args.es2015: 419 files = self.get_tests_from_file(ES2015_LIST_FILE) 420 return files 421 422 def prepare_test_suit(self): 423 files = [] 424 test_dir = "" 425 if self.args.es51: 426 test_dir = TEST_ES5_DIR 427 files = self.get_tests_from_file(ES5_LIST_FILE) 428 elif self.args.es2015: 429 test_dir = TEST_ES2015_DIR 430 files = self.prepare_es2015_tests() 431 elif self.args.intl: 432 test_dir = TEST_INTL_DIR 433 files = self.prepare_intl_tests() 434 elif self.args.es2021: 435 test_dir = TEST_ES2021_DIR 436 files = self.prepare_es2021_tests() 437 elif self.args.es2022: 438 test_dir = TEST_ES2022_DIR 439 files = self.prepare_es2022_tests() 440 elif self.args.es2023: 441 test_dir = TEST_ES2023_DIR 442 files = self.prepare_es2023_tests() 443 elif self.args.ci_build: 444 test_dir = TEST_CI_DIR 445 files = self.get_tests_from_file(CI_LIST_FILE) 446 447 for file in files: 448 path = os.path.split(file)[0] 449 path = os.path.join(test_dir, path) 450 mkdir(path) 451 452 self.copyfile(file, ALL_SKIP_TESTS) 453 454 def prepare_test262_test(self): 455 src_dir = TEST_FULL_DIR 456 if self.args.es51: 457 self.prepare_test_suit() 458 src_dir = TEST_ES5_DIR 459 elif self.args.es2015: 460 self.prepare_test_suit() 461 src_dir = TEST_ES2015_DIR 462 elif self.args.intl: 463 self.prepare_test_suit() 464 src_dir = TEST_INTL_DIR 465 elif self.args.es2021: 466 self.prepare_test_suit() 467 src_dir = TEST_ES2021_DIR 468 elif self.args.es2022: 469 self.prepare_test_suit() 470 src_dir = TEST_ES2022_DIR 471 elif self.args.es2023: 472 self.prepare_test_suit() 473 src_dir = TEST_ES2023_DIR 474 elif self.args.ci_build: 475 self.prepare_test_suit() 476 src_dir = TEST_CI_DIR 477 elif self.args.esnext: 478 git_checkout(ESNEXT_GIT_HASH, DATA_DIR) 479 else: 480 git_checkout(TEST262_GIT_HASH, DATA_DIR) 481 482 if self.args.file: 483 mkdstdir(self.args.file, src_dir, self.out_dir) 484 return 485 486 files = collect_files(self.args.dir) 487 for file in files: 488 mkdstdir(file, src_dir, self.out_dir) 489 490 def run(self): 491 self.prepare_test262_code() 492 self.prepare_clean_data() 493 self.patching_the_plugin() 494 self.prepare_args_es51_es2021() 495 self.prepare_out_dir() 496 self.prepare_args_testdir() 497 self.prepare_test262_test() 498 499 500def run_test262_prepare(args): 501 init(args) 502 503 test_prepare = TestPrepare(args) 504 test_prepare.run() 505 506 507def modetype_to_string(mode): 508 if mode == 1: 509 return "only default" 510 if mode == 2: 511 return "only strict mode" 512 return "both default and strict mode" 513 514 515def run_test262_mode(args): 516 if args.mode: 517 return modetype_to_string(args.mode) 518 return modetype_to_string(DEFAULT_MODE) 519 520 521def get_execute_arg(args): 522 execute_args = "" 523 524 if args.file: 525 execute_args = args.file 526 else: 527 execute_args = os.path.join(args.dir, "**", "*.js") 528 return execute_args 529 530 531def get_host_path_type(args): 532 host_path = DEFAULT_HOST_PATH 533 host_type = DEFAULT_HOST_TYPE 534 if args.engine: 535 host_path = args.engine 536 host_type = os.path.split(args.engine.strip())[1] 537 return host_path, host_type 538 539 540def get_timeout(args, threads): 541 timeout = DEFAULT_TIMEOUT * threads 542 if args.timeout: 543 timeout = args.timeout 544 return timeout 545 546 547def get_threads(args): 548 threads = DEFAULT_THREADS 549 if args.threads: 550 threads = args.threads 551 return threads 552 553 554def get_host_args(args, host_type): 555 host_args = "" 556 ark_tool = DEFAULT_ARK_TOOL 557 ark_aot_tool = DEFAULT_ARK_AOT_TOOL 558 libs_dir = DEFAULT_LIBS_DIR 559 ark_frontend = DEFAULT_ARK_FRONTEND 560 ark_frontend_binary = DEFAULT_ARK_FRONTEND_BINARY 561 ark_arch = DEFAULT_ARK_ARCH 562 opt_level = DEFAULT_OPT_LEVEL 563 es2abc_thread_count = DEFAULT_ES2ABC_THREAD_COUNT 564 merge_abc_binary = DEFAULT_MERGE_ABC_BINARY 565 merge_abc_mode = DEFAULT_MERGE_ABC_MODE 566 product_name = DEFAULT_PRODUCT_NAME 567 568 if args.product_name: 569 product_name = args.product_name 570 ark_dir = f"{ARGS_PREFIX}{product_name}{ARK_DIR_SUFFIX}" 571 icui_dir = f"{ARGS_PREFIX}{product_name}{ICUI_DIR_SUFFIX}" 572 ark_js_runtime_dir = f"{ARGS_PREFIX}{product_name}{ARK_JS_RUNTIME_DIR_SUFFIX}" 573 zlib_dir = f"{ARGS_PREFIX}{product_name}{ZLIB_DIR_SUFFIX}" 574 575 ark_tool = os.path.join(ark_js_runtime_dir, "ark_js_vm") 576 libs_dir = f"{icui_dir}:{LLVM_DIR}:{ark_js_runtime_dir}:{zlib_dir}" 577 ark_aot_tool = os.path.join(ark_js_runtime_dir, "ark_aot_compiler") 578 merge_abc_binary = os.path.join(ark_dir, "merge_abc") 579 580 if args.hostArgs: 581 host_args = args.hostArgs 582 583 if args.ark_tool: 584 ark_tool = args.ark_tool 585 586 if args.ark_aot_tool: 587 ark_aot_tool = args.ark_aot_tool 588 589 if args.libs_dir: 590 libs_dir = args.libs_dir 591 592 if args.ark_frontend: 593 ark_frontend = args.ark_frontend 594 595 if args.ark_frontend_binary: 596 ark_frontend_binary = args.ark_frontend_binary 597 598 if args.opt_level: 599 opt_level = args.opt_level 600 601 if args.es2abc_thread_count: 602 es2abc_thread_count = args.es2abc_thread_count 603 604 if args.merge_abc_binary: 605 merge_abc_binary = args.merge_abc_binary 606 607 if args.merge_abc_mode: 608 merge_abc_mode = args.merge_abc_mode 609 610 if host_type == DEFAULT_HOST_TYPE: 611 host_args = f"-B test262/run_sunspider.py " 612 host_args += f"--ark-tool={ark_tool} " 613 if args.ark_aot: 614 host_args += f"--ark-aot " 615 host_args += f"--ark-aot-tool={ark_aot_tool} " 616 host_args += f"--libs-dir={libs_dir} " 617 host_args += f"--ark-frontend={ark_frontend} " 618 host_args += f"--ark-frontend-binary={ark_frontend_binary} " 619 host_args += f"--opt-level={opt_level} " 620 host_args += f"--es2abc-thread-count={es2abc_thread_count} " 621 host_args += f"--merge-abc-binary={merge_abc_binary} " 622 host_args += f"--merge-abc-mode={merge_abc_mode} " 623 host_args += f"--product-name={product_name} " 624 625 if args.ark_arch != ark_arch: 626 host_args += f"--ark-arch={args.ark_arch} " 627 host_args += f"--ark-arch-root={args.ark_arch_root} " 628 629 return host_args 630 631 632def run_test262_test(args): 633 execute_args = get_execute_arg(args) 634 host_path, host_type = get_host_path_type(args) 635 host_args = get_host_args(args, host_type) 636 threads = get_threads(args) 637 timeout = get_timeout(args, threads) 638 639 test_cmd = ["node", TEST262_RUNNER_SCRIPT] 640 test_cmd.append(f"--hostType={host_type}") 641 test_cmd.append(f"--hostPath={host_path}") 642 if host_args != "": 643 test_cmd.append(f"--hostArgs='{host_args}'") 644 test_cmd.append(f"--threads={threads}") 645 test_cmd.append(f"--mode={run_test262_mode(args)}") 646 test_cmd.append(f"--timeout={timeout}") 647 if platform.system() == "Windows" : 648 global BASE_OUT_DIR 649 global DATA_DIR 650 BASE_OUT_DIR = BASE_OUT_DIR.replace("/","\\") 651 DATA_DIR = DATA_DIR.replace("/","\\") 652 execute_args = execute_args.replace("/","\\") 653 test_cmd.append(f"--tempDir={BASE_OUT_DIR}") 654 test_cmd.append(f"--test262Dir={DATA_DIR}") 655 656 if args.babel: 657 test_cmd.append("--preprocessor='test262/babel-preprocessor.js'") 658 test_cmd.append(DEFAULT_OTHER_ARGS) 659 test_cmd.append(execute_args) 660 661 run_check(test_cmd) 662 663 664Check = collections.namedtuple('Check', ['enabled', 'runner', 'arg']) 665 666 667def main(args): 668 print("\nWait a moment..........\n") 669 starttime = datetime.datetime.now() 670 run_test262_prepare(args) 671 check = Check(True, run_test262_test, args) 672 ret = check.runner(check.arg) 673 if ret: 674 sys.exit(ret) 675 endtime = datetime.datetime.now() 676 print(f"used time is: {str(endtime - starttime)}") 677 678 679if __name__ == "__main__": 680 sys.exit(main(parse_args())) 681