From b72d96b26e63a2d060e1bf5d8111cafba5ff13be Mon Sep 17 00:00:00 2001 From: SivaLee Date: Mon, 30 May 2022 19:52:22 +0800 Subject: [PATCH] add ark test262 for windows Signed-off-by: SivaLee Change-Id: Ibc12c7d32d1c67c4c8349f15b9ed908c5a564a6b --- test262/run_sunspider.py | 11 ++++++++--- test262/run_test262.py | 19 +++++++++++++++---- test262/utils.py | 6 +++++- ts2panda/BUILD.gn | 7 +++++++ 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/test262/run_sunspider.py b/test262/run_sunspider.py index e1562ac1a7..cb59b4f508 100755 --- a/test262/run_sunspider.py +++ b/test262/run_sunspider.py @@ -67,6 +67,8 @@ def parse_args(): ICU_PATH = f"--icu-data-path={CODE_ROOT}/third_party/icu/ohos_icu4j/data" +if platform.system() == "Windows" : + ICU_PATH = ICU_PATH.replace("/","\\") ARK_TOOL = DEFAULT_ARK_TOOL ARK_FRONTEND_TOOL = DEFAULT_ARK_FRONTEND_TOOL LIBS_DIR = DEFAULT_LIBS_DIR @@ -182,13 +184,16 @@ class ArkProgram(): if file_name in self.module_list: cmd_args.insert(mod_opt_index, "-m") - retcode = exec_command(cmd_args) return retcode def execute(self): - - os.environ["LD_LIBRARY_PATH"] = self.libs_dir + if platform.system() == "Windows" : + os.environ["PATH"] = self.libs_dir + ";" + os.environ["PATH"] + elif platform.system() == "Linux" : + os.environ["LD_LIBRARY_PATH"] = self.libs_dir + else : + sys.exit(f" test262 on {platform.system()} not supported"); file_name_pre = os.path.splitext(self.js_file)[0] cmd_args = [] if self.arch == ARK_ARCH_LIST[1]: diff --git a/test262/run_test262.py b/test262/run_test262.py index 1ab65ab091..86acb436c6 100755 --- a/test262/run_test262.py +++ b/test262/run_test262.py @@ -26,7 +26,8 @@ import os import sys import subprocess from multiprocessing import Pool -from utils import * +import platform +from utils import * from config import * @@ -245,7 +246,12 @@ class TestPrepare(): dstdir = os.path.join(TEST_ES2015_DIR, file) elif self.args.ci_build: dstdir = os.path.join(TEST_CI_DIR, file) - subprocess.getstatusoutput("cp %s %s" % (srcdir, dstdir)) + if platform.system() == "Windows" : + proc = subprocess.Popen("cp %s %s" % (srcdir, dstdir)) + proc.wait() + else : + subprocess.getstatusoutput("cp %s %s" % (srcdir, dstdir)) + def collect_tests(self): files = [] @@ -258,7 +264,7 @@ class TestPrepare(): esid = "es6id" for file_name in file_names: - with open(file_name, 'r') as file: + with open(file_name, 'r', encoding='utf-8') as file: content = file.read() if esid in content: files.append(file_name.split(origin_dir)[1]) @@ -444,13 +450,18 @@ def run_test262_test(args): test_cmd.append(f"--threads={threads}") test_cmd.append(f"--mode={run_test262_mode(args)}") test_cmd.append(f"--timeout={timeout}") + if platform.system() == "Windows" : + global BASE_OUT_DIR + global DATA_DIR + BASE_OUT_DIR = BASE_OUT_DIR.replace("/","\\") + DATA_DIR = DATA_DIR.replace("/","\\") + execute_args = execute_args.replace("/","\\") test_cmd.append(f"--tempDir={BASE_OUT_DIR}") test_cmd.append(f"--test262Dir={DATA_DIR}") if args.babel: test_cmd.append("--preprocessor='test262/babel-preprocessor.js'") test_cmd.append(DEFAULT_OTHER_ARGS) - test_cmd.append(execute_args) run_check(test_cmd) diff --git a/test262/utils.py b/test262/utils.py index 93225c3b89..3263aef7f4 100755 --- a/test262/utils.py +++ b/test262/utils.py @@ -24,6 +24,7 @@ import subprocess import datetime import time import shutil +import platform TERM_NORMAL = '\033[0m' TERM_YELLOW = '\033[1;33m' @@ -80,7 +81,10 @@ class CommandCwd(): def run(self): cmd = " ".join(self.cmds) LOGGING.debug("command: " + cmd + " | " + "dir: " + self.cwd) - proc = subprocess.Popen(self.cmds, cwd=self.cwd) + if platform.system() == "Windows" : + proc = subprocess.Popen(self.cmds, cwd=self.cwd ,shell=True) + else : + proc = subprocess.Popen(self.cmds, cwd=self.cwd) return proc.wait() diff --git a/ts2panda/BUILD.gn b/ts2panda/BUILD.gn index 5406a765d0..411b0ff37b 100755 --- a/ts2panda/BUILD.gn +++ b/ts2panda/BUILD.gn @@ -234,6 +234,13 @@ group("ark_ts2abc_build") { } } +group("ark_ts2abc_build_win") { + deps = [ + "${ts2abc_root}:ts2abc_build_win(${buildtool_win})", + "${ts2abc_root}:ts2abc_build_win_ets(${buildtool_win})", + ] +} + ohos_copy("copy_ts2abc_tests") { sources = [ "${ts2abc_root}/tests" ] deps = [ ":npm_run_build" ] -- Gitee