From c760d87a8b8d5f2301161ba593099a34496e5a4d Mon Sep 17 00:00:00 2001 From: Viktoria Shirunova Date: Tue, 2 Jul 2024 18:08:55 +0300 Subject: [PATCH 1/2] More detailed time report Testing: All required pre-merge tests passed. Results are available in the ggwatcher. Signed-off-by: Viktoria Shirunova Change-Id: Ieae24fd356d6e3c628ef847d03a8b7302ff8f5b5 --- build/compile_script/ark.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/build/compile_script/ark.py b/build/compile_script/ark.py index 7eadf1bd..bca9c933 100755 --- a/build/compile_script/ark.py +++ b/build/compile_script/ark.py @@ -499,7 +499,7 @@ class ArkPy: " python3 ark.py \033[92m[os_cpu].[mode] [test262] [none or --baseline-jit] [none or --threads=X]\033[0m\n" " python3 ark.py \033[92m[os_cpu].[mode] [unittest] [option]\033[0m\n" " python3 ark.py \033[92m[os_cpu].[mode] [regresstest] [none, file or dir] " \ - "[none or --processes=X]\033[0m\n") + "[none or --processes=X and/or --test-list=TEST_LIST_NAME]\033[0m\n") # Command examples help_msg += "\033[32mCommand examples:\033[0m\n{}\n\n".format( " python3 ark.py \033[92mx64.release\033[0m\n" @@ -608,8 +608,7 @@ class ArkPy: return " ".join(args_to_test262_cmd) def build_for_test262(self, out_path, timeout, gn_args: list, arg_list: list, log_file_name: str, - aot_mode: bool, run_pgo=False, enable_litecg=False, run_jit=False, - run_baseline_jit=False): + aot_mode: bool, run_pgo=False, enable_litecg=False, run_jit=False, run_baseline_jit=False): args_to_test262_cmd = self.build_args_to_test262_cmd(arg_list) x64_out_path = "" if any('target_cpu="arm64"' in arg for arg in gn_args): @@ -663,6 +662,11 @@ class ArkPy: args_to_regress_cmd.extend(processes) arg_list.remove(processes[0]) + test_list = [arg for arg in arg_list if arg.startswith("--test-list=")] + if test_list: + args_to_regress_cmd.extend(test_list) + arg_list.remove(test_list[0]) + if len(arg_list) == 1: arg = arg_list[0] if ".js" in arg: @@ -876,4 +880,7 @@ class ArkPy: if __name__ == "__main__": ark_py = ArkPy() + start_time = datetime.now() ark_py.__main__(sys.argv[1:]) + end_time = datetime.now() + print(f"Total duration: {(end_time-start_time).total_seconds()} seconds") -- Gitee From 927930cd986cd9ae4e99a6c12917a26c3294ff4e Mon Sep 17 00:00:00 2001 From: Viktoria Shirunova Date: Tue, 9 Jul 2024 19:55:22 +0300 Subject: [PATCH 2/2] ark.py: support --test-list option for regress tests. Issue: Testing: All required pre-merge tests passed. Results are available in the ggwatcher. Signed-off-by: Viktoria Shirunova Change-Id: I97c1240cb49c25acc03d4b5d7fc04eabcd069762 --- build/compile_script/ark.py | 114 ++++++++++++++++++++++++------------ 1 file changed, 76 insertions(+), 38 deletions(-) diff --git a/build/compile_script/ark.py b/build/compile_script/ark.py index bca9c933..f090f1ab 100755 --- a/build/compile_script/ark.py +++ b/build/compile_script/ark.py @@ -24,6 +24,7 @@ import os import platform import subprocess import sys +from typing import List, Tuple, Union, Optional CURRENT_FILENAME = os.path.basename(__file__) @@ -588,10 +589,10 @@ class ArkPy: args_to_test262_cmd.append("--disable-force-gc") arg_list.remove(disable_force_gc[0]) - threads = [arg for arg in arg_list if arg.startswith("--threads=")] - if threads: - args_to_test262_cmd.extend(threads) - arg_list.remove(threads[0]) + threads_name = "--threads" + threads_value, arg_list = ArkPy.parse_option(arg_list, option_name=threads_name, default_value=None) + if threads_value: + args_to_test262_cmd.extend([threads_name, threads_value]) if len(arg_list) == 0: args_to_test262_cmd.append("--es2021 all") @@ -657,15 +658,15 @@ class ArkPy: def build_args_to_regress_cmd(arg_list): args_to_regress_cmd = [] - processes = [arg for arg in arg_list if arg.startswith("--processes=")] - if processes: - args_to_regress_cmd.extend(processes) - arg_list.remove(processes[0]) + processes_name = "--processes" + processes_value, arg_list = ArkPy.parse_option(arg_list, option_name=processes_name, default_value=1) + args_to_regress_cmd.extend([processes_name, processes_value]) - test_list = [arg for arg in arg_list if arg.startswith("--test-list=")] - if test_list: - args_to_regress_cmd.extend(test_list) - arg_list.remove(test_list[0]) + test_list_name = "--test-list" + test_list_value, arg_list = ArkPy.parse_option(arg_list, option_name=test_list_name, default_value=None) + if test_list_value is None: + print(f"Option {test_list_name} should have value") + args_to_regress_cmd.extend([test_list_name, test_list_value]) if len(arg_list) == 1: arg = arg_list[0] @@ -746,39 +747,76 @@ class ArkPy: sys.exit(0) self.build_for_unittest(out_path, gn_args, self.UNITTEST_LOG_FILE_NAME) elif self.is_dict_flags_match_arg(self.ARG_DICT["target"]["regresstest"], arg_list[0]): - timeout = 200 - if '--timeout' in arg_list: - timeout_index = arg_list.index('--timeout') - if len(arg_list) > timeout_index + 1: - try: - timeout = int(arg_list[timeout_index + 1]) - arg_list = arg_list[:timeout_index] + arg_list[timeout_index + 2:] - except ValueError: - print("Invalid timeout value.") - sys.exit(1) - else: - print("Missing timeout value.") - sys.exit(1) + timeout, arg_list = self.parse_option(arg_list, option_name="--timeout", default_value=200) self.build_for_regress_test(out_path, gn_args, arg_list[1:], self.REGRESS_TEST_LOG_FILE_NAME, timeout) else: self.build_for_gn_target(out_path, gn_args, arg_list, self.GN_TARGET_LOG_FILE_NAME) return - def parse_timeout(self, arg_list): - timeout = 400000 - if '--timeout' in arg_list: - timeout_index = arg_list.index('--timeout') - if len(arg_list) > timeout_index + 1: - try: - timeout = int(arg_list[timeout_index + 1]) - arg_list = arg_list[:timeout_index] + arg_list[timeout_index + 2:] - except ValueError: - print("Invalid timeout value.") - sys.exit(1) + def parse_timeout(self, arg_list) -> Tuple[Optional[Union[str, int]], List[str]]: + return self.parse_option(arg_list, option_name="--timeout", default_value=400000) + + @staticmethod + def __is_option_value_int(value: Optional[Union[str, int]]) -> Tuple[bool, Optional[int]]: + if isinstance(value, int): + return True, int(value) + else: + return False, None + + @staticmethod + def __is_option_value_str(value: Optional[Union[str, int]]) -> Tuple[bool, Optional[str]]: + if isinstance(value, str): + return True, str(value) + else: + return False, None + + @staticmethod + def __get_option_value(option_name: str, value: Optional[Union[str, int]]) -> Union[str, int]: + result, res_value = ArkPy.__is_option_value_int(value) + if result: + return res_value + result, res_value = ArkPy.__is_option_value_str(value) + if result: + return res_value + print(f"Invalid '{option_name}' value.") + sys.exit(1) + + @staticmethod + def __parse_option_with_space(arg_list: List[str], option_name: str) \ + -> Tuple[Optional[Union[str, int]], List[str]]: + if option_name in arg_list: + option_index = arg_list.index(option_name) + if len(arg_list) > option_index + 1: + option_value = ArkPy.__get_option_value(option_name, arg_list[option_index + 1]) + arg_list = arg_list[:option_index] + arg_list[option_index + 2:] else: - print("Missing timeout value.") + print(f"Missing {option_name} value.") sys.exit(1) - return timeout, arg_list + + return option_value, arg_list + return None, arg_list + + @staticmethod + def __parse_option_with_equal(arg_list: List[str], option_name: str) \ + -> Tuple[Optional[Union[str, int]], List[str]]: + for index, arg in enumerate(arg_list): + local_option_name = f"{option_name}=" + if arg.startswith(local_option_name): + option_value = arg[len(local_option_name):] + option_value = ArkPy.__get_option_value(option_name, option_value) + arg_list = arg_list[:index] + arg_list[index + 1:] + return option_value, arg_list + return None, arg_list + + @staticmethod + def parse_option(arg_list: List[str], option_name: str, default_value: Optional[Union[str, int]]) \ + -> Tuple[Optional[Union[str, int]], List[str]]: + option_value, arg_list = ArkPy.__parse_option_with_space(arg_list,option_name) + if option_value is None: + option_value, arg_list = ArkPy.__parse_option_with_equal(arg_list, option_name) + elif option_value is None: + option_value = default_value + return option_value, arg_list def match_options(self, arg_list: list, out_path: str) -> [list, list]: arg_list_ret = [] -- Gitee