Lines Matching refs:task

41     def prepare_full_task(task, test_name):
42 if test_name in task.full_compilation_info:
43 full_task = task.full_compilation_info[test_name]
47 task.full_compilation_info[test_name] = full_task
51 def full_compile(task, is_debug):
53 logging.info(f"==========> Running {test_name} for task: {task.name}")
54 clean_compile(task)
56 full_task = FullTest.prepare_full_task(task, test_name)
57 [stdout, stderr] = compile_project(task, is_debug)
58 passed = validate(full_task, task, is_debug, stdout, stderr, f'{test_name}')
60 backup_compile_output(task, is_debug)
65 def compile_full_import_ordinary_ohpm_package(task, is_debug):
67 clean_compile(task)
68 full_task = FullTest.prepare_full_task(task, test_name)
70 logging.info(f"==========> Running {test_name} for task: {task.name}")
73 modify_file = os.path.join(task.path, *task.inc_modify_file)
79 build_passed, build_time = is_build_module_successful(task, is_debug, info,
84 is_included = is_npm_txt_included_ohpm_package(info, task, is_debug, package_name)
92 def compile_full_import_special_ohpm_package(task, is_debug):
94 clean_compile(task)
95 full_task = FullTest.prepare_full_task(task, test_name)
97 logging.info(f"==========> Running {test_name} for task: {task.name}")
100 modify_file = os.path.join(task.path, *task.inc_modify_file)
106 build_passed, build_time = is_build_module_successful(task, is_debug, info,
112 disasm_file_path = get_disasm_abc_file(task, info, 'Hap')
121 def compile_full_import_static_library(task, is_debug):
123 clean_compile(task)
124 full_task = FullTest.prepare_full_task(task, test_name)
126 logging.info(f"==========> Running {test_name} for task: {task.name}")
128 with manage_module_import_and_export_handle(task, 'Har'):
129 build_passed, build_time = is_build_module_successful(task, is_debug, info, '',
134 pa_file = get_disasm_abc_file(task, info, 'Hap')
137 is_packaged = is_package_modules_to_module_abc(task, pa_file, task.har_module)
146 def compile_full_import_share_library(task, is_debug):
148 clean_compile(task)
149 full_task = FullTest.prepare_full_task(task, test_name)
151 logging.info(f"==========> Running {test_name} for task: {task.name}")
153 with manage_module_import_and_export_handle(task, 'Hsp'):
154 build_passed, build_time = is_build_module_successful(task, is_debug, info, '',
159 pa_file = get_disasm_abc_file(task, info, 'Hap')
162 is_packaged = is_package_modules_to_module_abc(task, pa_file, task.hsp_module)
171 def compile_full_import_so_file(task, is_debug):
173 clean_compile(task)
174 full_task = FullTest.prepare_full_task(task, test_name)
176 logging.info(f"==========> Running {test_name} for task: {task.name}")
178 with manage_module_import_and_export_handle(task, 'Cpp'):
179 [stdout, stderr] = compile_project(task, is_debug)
186 validate(full_task, task, is_debug, stdout, stderr)
189 def compile_full_has_syntax_error_in_js(task, is_debug):
191 clean_compile(task)
192 full_task = FullTest.prepare_full_task(task, test_name)
194 logging.info(f"==========> Running {test_name} for task: {task.name}")
197 add_or_delete_js_file(task, 1, True)
200 [stdout, stderr] = compile_project(task, is_debug)
206 add_or_delete_js_file(task, 0)
209 def compile_full_use_normalize_ohmurl(task, is_debug):
211 clean_compile(task)
212 full_task = FullTest.prepare_full_task(task, test_name)
214 logging.info(f"==========> Running {test_name} for task: {task.name}")
216 modify_normalize_ohmurl_options(task, 1)
218 with manage_module_import_and_export_handle(task, 'Har'):
219 is_build_passed, build_time = is_build_module_successful(task, is_debug, info,
224 is_passed = is_normalized_ohm_url(task, is_debug, info)
229 modify_normalize_ohmurl_options(task, 0)
232 def compile_full_module_name_is_inconsistent(task, is_debug):
234 clean_compile(task)
235 full_task = FullTest.prepare_full_task(task, test_name)
237 logging.info(f"==========> Running {test_name} for task: {task.name}")
239 oh_package_json_path = os.path.join(task.path, *task.hap_module_path, 'oh-package.json5')
248 module_name = task.har_module.capitalize()
253 sync_project(task)
255 with manage_module_import_and_export_handle(task, 'Har'):
256 is_build_successful, build_time = is_build_module_successful(task, is_debug, info,
264 sync_project(task)
269 def validate_module_name_change(task, inc_task, is_debug, stdout, stderr, new_module_name):
270 output_file = get_compile_output_file_path(task, is_debug, options.OutputType.unsigned)
282 passed = validate(inc_task, task, is_debug, stdout,
299 modules_pa = disasm_abc(task, modules_abc_path)
337 def validate_compile_incremental_file(task, inc_task, is_debug, modified_files, module=''):
338 module_path = utils.get_module_path(task, module)
341 task.path, *module_path, *task.build_path, *task.cache_path, 'debug')
342 backup_path = task.backup_info.cache_debug
346 task.path, *module_path, *task.build_path, *task.cache_path, 'release')
347 backup_path = task.backup_info.cache_release
350 validate_cache_file(task, inc_info, modified_files, cache_path, backup_path)
353 def prepare_incremental_task(task, test_name):
354 if test_name in task.incre_compilation_info:
355 inc_task = task.incre_compilation_info[test_name]
359 task.incre_compilation_info[test_name] = inc_task
363 def compile_incremental_no_modify(task, is_debug):
365 inc_task = IncrementalTest.prepare_incremental_task(task, test_name)
367 logging.info(f"==========> Running {test_name} for task: {task.name}")
368 [stdout, stderr] = compile_project(task, is_debug)
369 passed = validate(inc_task, task, is_debug, stdout, stderr, 'incremental_compile_no_change')
372 task, inc_task, is_debug, [])
375 def compile_incremental_add_oneline(task, is_debug):
377 inc_task = IncrementalTest.prepare_incremental_task(task, test_name)
379 logging.info(f"==========> Running {test_name} for task: {task.name}")
380 modify_file_item = task.inc_modify_file
381 modify_file = os.path.join(task.path, *modify_file_item)
389 [stdout, stderr] = compile_project(task, is_debug)
390 passed = validate(inc_task, task, is_debug, stdout, stderr, 'incremental_compile_add_oneline')
394 task, inc_task, is_debug, modified_files)
399 def compile_incremental_add_file(task, is_debug):
401 inc_task = IncrementalTest.prepare_incremental_task(task, test_name)
403 logging.info(f"==========> Running {test_name} for task: {task.name}")
404 modify_file_item = task.inc_modify_file
405 modify_file = os.path.join(task.path, *modify_file_item)
410 if 'js' in task.type:
434 [stdout, stderr] = compile_project(task, is_debug)
435 passed = validate(inc_task, task, is_debug, stdout, stderr, 'incremental_compile_add_file')
439 task, inc_task, is_debug, modified_files)
445 def compile_incremental_add_nonexistent_file(task, is_debug):
447 inc_task = IncrementalTest.prepare_incremental_task(task, test_name)
449 logging.info(f"==========> Running {test_name} for task: {task.name}")
451 modify_file_item = task.inc_modify_file
452 modify_file = os.path.join(task.path, *modify_file_item)
467 [stdout, stderr] = compile_project(task, is_debug)
473 if 'js' in task.type:
488 [stdout, stderr] = compile_project(task, is_debug)
489 passed = validate(inc_task, task, is_debug, stdout, stderr, 'incremental_compile_add_nonexistent_file')
493 task, inc_task, is_debug, modified_files)
498 def compile_incremental_delete_file(task, is_debug):
500 inc_task = IncrementalTest.prepare_incremental_task(task, test_name)
502 logging.info(f"==========> Running {test_name} for task: {task.name}")
505 [stdout, stderr] = compile_project(task, is_debug)
506 passed = validate(inc_task, task, is_debug, stdout, stderr, 'incremental_compile_delete_file')
508 modify_file_item = task.inc_modify_file
511 task, inc_task, is_debug, modified_files)
514 def compile_incremental_reverse_hap_mode(task, is_debug):
516 inc_task = IncrementalTest.prepare_incremental_task(task, test_name)
518 logging.info(f"==========> Running {test_name} for task: {task.name}")
520 [stdout, stderr] = compile_project(task, hap_mode)
521 validate(inc_task, task, hap_mode, stdout, stderr, 'incremental_compile_reverse_hap_mode')
524 def compile_incremental_modify_module_name(task, is_debug):
525 if 'stage' not in task.type:
529 inc_task = IncrementalTest.prepare_incremental_task(task, test_name)
531 logging.info(f"==========> Running {test_name} for task: {task.name}")
533 profile_file = os.path.join(task.path, 'build-profile.json5')
542 if module['name'] == task.hap_module:
549 config_file_dir = os.path.join(task.path, *task.hap_module_path, 'src', 'main')
561 cmd = get_hvigor_compile_cmd(task, is_debug, 'Hap', new_module_name)
562 [stdout, stderr] = compile_project(task, is_debug, cmd)
564 task, inc_task, is_debug, stdout, stderr, new_module_name)
572 def compile_incremental_build_modify_error_then_fix(task, is_debug):
574 inc_task = IncrementalTest.prepare_incremental_task(task, test_name)
576 logging.info(f"==========> Running {test_name} for task: {task.name}")
578 modify_file = os.path.join(task.path, *task.inc_modify_file)
585 [stdout, stderr] = compile_project(task, is_debug)
588 logging.error(f"task: {task.name}failed to get expected error, skip second build")
593 is_build_successful, build_time = is_build_module_successful(task, is_debug,
598 modify_file_item = task.inc_modify_file
601 task, inc_task, is_debug, modified_files)
604 def compile_incremental_build_add_error_page(task, is_debug):
606 inc_task = IncrementalTest.prepare_incremental_task(task, test_name)
608 logging.info(f"==========> Running {test_name} for task: {task.name}")
610 add_or_delete_page(task, 1, True)
613 [stdout, stderr] = compile_project(task, is_debug)
616 add_or_delete_page(task, 0, True)
617 second_incremental, build_time = is_build_module_successful(task, is_debug, info,
623 modify_file_item = task.inc_modify_file
626 task, inc_task, is_debug, modified_files)
628 add_or_delete_page(task, 0)
631 def compile_incremental_build_add_error_non_page(task, is_debug):
633 inc_task = IncrementalTest.prepare_incremental_task(task, test_name)
635 logging.info(f"==========> Running {test_name} for task: {task.name}")
637 add_or_delete_js_file(task, 1, True)
640 [stdout, stderr] = compile_project(task, is_debug)
643 add_or_delete_js_file(task, 0, True)
644 second_incremental, build_time = is_build_module_successful(task, is_debug, info,
650 modify_file_item = task.inc_modify_file
653 task, inc_task, is_debug, modified_files)
655 add_or_delete_js_file(task, 0)
658 def compile_incremental_build_modify_sdk_version(task, is_debug):
660 inc_task = IncrementalTest.prepare_incremental_task(task, test_name)
662 logging.info(f"==========> Running {test_name} for task: {task.name}")
665 first_incremental, first_build_time = is_build_module_successful(task, is_debug, info)
669 modify_sdk_version(task, 11)
670 second_incremental, second_build_time = is_build_module_successful(task, is_debug, info,
677 modify_sdk_version(task, 12)
680 def compile_incremental_build_entry_then_har(task, is_debug):
682 inc_task = IncrementalTest.prepare_incremental_task(task, test_name)
684 logging.info(f"==========> Running {test_name} for task: {task.name}")
686 with manage_module_import_and_export_handle(task, 'Har'):
687 first_incremental, first_build_time = is_build_module_successful(task, is_debug, info)
690 second_incremental, second_build_time = is_build_module_successful(task, is_debug, info,
696 modify_file_item = task.inc_modify_file
699 task, inc_task, is_debug, modified_files)
702 def compile_incremental_build_har_then_entry(task, is_debug):
704 inc_task = IncrementalTest.prepare_incremental_task(task, test_name)
706 logging.info(f"==========> Running {test_name} for task: {task.name}")
708 with manage_module_import_and_export_handle(task, 'Har'):
709 first_incremental, first_build_time = is_build_module_successful(task, is_debug, info, 'Har')
712 second_incremental, second_build_time = is_build_module_successful(task, is_debug, info,
718 modify_file_item = task.inc_modify_file
721 task, inc_task, is_debug, modified_files)
724 def compile_incremental_build_entry_then_hsp(task, is_debug):
726 inc_task = IncrementalTest.prepare_incremental_task(task, test_name)
728 logging.info(f"==========> Running {test_name} for task: {task.name}")
730 with manage_module_import_and_export_handle(task, 'Hsp'):
731 first_incremental, first_build_time = is_build_module_successful(task, is_debug, info)
734 second_incremental, second_build_time = is_build_module_successful(task, is_debug, info,
740 modify_file_item = task.inc_modify_file
743 task, inc_task, is_debug, modified_files)
746 def compile_incremental_build_hsp_then_entry(task, is_debug):
748 inc_task = IncrementalTest.prepare_incremental_task(task, test_name)
750 logging.info(f"==========> Running {test_name} for task: {task.name}")
752 with manage_module_import_and_export_handle(task, 'Hsp'):
753 first_incremental, first_build_time = is_build_module_successful(task, is_debug, info, 'Hsp')
756 second_incremental, second_build_time = is_build_module_successful(task, is_debug, info,
762 modify_file_item = task.inc_modify_file
765 task, inc_task, is_debug, modified_files)
768 def compile_incremental_build_hsp_then_ohos(task, is_debug):
769 if not is_debug or 'ohosTest' not in task.type:
772 inc_task = IncrementalTest.prepare_incremental_task(task, test_name)
774 logging.info(f"==========> Running {test_name} for task: {task.name}")
776 with manage_module_import_and_export_handle(task, 'Hsp'):
777 first_incremental, first_build_time = is_build_module_successful(task, is_debug, info, 'Hsp')
780 second_incremental, second_build_time = is_build_ohos_test_successful(task, info)
785 modify_file_item = task.inc_modify_file
788 task, inc_task, is_debug, modified_files)
791 def compile_incremental_build_entry_then_ohos(task, is_debug):
795 inc_task = IncrementalTest.prepare_incremental_task(task, test_name)
797 logging.info(f"==========> Running {test_name} for task: {task.name}")
799 first_incremental, first_build_time = is_build_module_successful(task, is_debug, info)
802 second_incremental, second_build_time = is_build_ohos_test_successful(task, info)
807 modify_file_item = task.inc_modify_file
810 task, inc_task, is_debug, modified_files)
813 def compile_incremental_build_entry_then_preview_build(task, is_debug):
815 inc_task = IncrementalTest.prepare_incremental_task(task, test_name)
817 logging.info(f"==========> Running {test_name} for task: {task.name}")
819 first_incremental, first_build_time = is_build_module_successful(task, is_debug, inc_task)
822 second_incremental, second_build_time = preview_mode_build(info, task, is_debug)
827 modify_file_item = task.inc_modify_file
830 task, inc_task, is_debug, modified_files)
835 def prepare_bytecode_har_task(task, test_name):
836 if test_name in task.bytecode_har_compilation_info:
837 bytecode_har_task = task.bytecode_har_compilation_info[test_name]
841 task.bytecode_har_compilation_info[test_name] = bytecode_har_task
845 def build_bytecode_har(task, is_debug):
847 clean_compile(task)
848 bytecode_har_task = BytecodeHarTest.prepare_bytecode_har_task(task, test_name)
850 logging.info(f"==========> Running {test_name} for task: {task.name}")
852 modify_bytecode_har_config(task, 1)
854 is_passed, build_time = is_build_module_successful(task, is_debug, info, 'BytecodeHar')
859 modify_bytecode_har_config(task, 0)
862 def build_har_then_bytecode_har(task, is_debug):
866 clean_compile(task)
867 bytecode_har_task = BytecodeHarTest.prepare_bytecode_har_task(task, test_name)
869 logging.info(f"==========> Running {test_name} for task: {task.name}")
871 is_passed, build_time = is_build_module_successful(task, is_debug, info, 'Har')
873 logging.error(f'build {task.har_module} failed')
876 modify_bytecode_har_config(task, 1)
878 is_passed, build_time = is_build_module_successful(task, is_debug, info, 'BytecodeHar')
883 modify_bytecode_har_config(task, 0)
886 def import_bytecode_static_library(task, is_debug):
888 clean_compile(task)
889 bytecode_har_task = BytecodeHarTest.prepare_bytecode_har_task(task, test_name)
891 logging.info(f"==========> Running {test_name} for task: {task.name}")
893 modify_bytecode_har_config(task, 1)
895 with manage_bytecode_har_dependency(task, is_debug, info, 'Har'):
896 cmd = get_hvigor_compile_cmd(task, is_debug)
897 [stdout, stderr] = compile_project(task, is_debug, cmd)
901 info.error_message = f'Full compile failed due to build {task.hap_module} module.'
902 logging.error(f'build {task.hap_module} failed')
908 runtime_passed = run_compile_output(info, task, is_debug, 'import_bytecode_static_library')
910 modify_bytecode_har_config(task, 0)
915 def prepare_current_task(task, test_name):
916 if test_name in task.external_compilation_info:
917 current_task = task.external_compilation_info[test_name]
921 task.external_compilation_info[test_name] = current_task
930 def import_external_share_library(task, is_debug):
933 clean_compile(task)
935 current_task = ExternalTest.prepare_current_task(task, test_name)
937 logging.info(f"==========> Running {test_name} for task: {task.name}")
939 with manage_module_import_and_export_handle(task, 'ExternalHsp'):
940 cmd = get_hvigor_compile_cmd(task, is_debug, '')
941 [stdout, stderr] = compile_project(task, is_debug, cmd)
945 info.error_message = f'Full compile failed due to {task.hap_module} module'
946 logging.error(f'Full compile failed due to {task.hap_module} module')
948 passed = validate_compile_output(info, task, is_debug, '', '')
951 info.error_message = f'Validate failed due to {task.hap_module} module'
952 logging.error(f'Validate failed due to {task.hap_module} module')
954 pa_file = get_disasm_abc_file(task, info, 'Hap')
957 is_packaged = is_package_modules_to_module_abc(task, pa_file, external_task.hsp_module)
966 runtime_passed = run_compile_output(info, task, is_debug, 'import_external_share_library')
969 def import_external_static_library(task, is_debug):
972 clean_compile(task)
974 current_task = ExternalTest.prepare_current_task(task, test_name)
976 logging.info(f"==========> Running {test_name} for task: {task.name}")
978 with manage_module_import_and_export_handle(task, 'ExternalHar'):
979 cmd = get_hvigor_compile_cmd(task, is_debug, '')
980 [stdout, stderr] = compile_project(task, is_debug, cmd)
984 info.error_message = f'Full compile failed due to {task.hap_module} module'
985 logging.error(f'Full compile failed due to {task.hap_module} module')
987 passed = validate_compile_output(info, task, is_debug, '', '')
990 info.error_message = f'Validate failed due to {task.hap_module} module'
991 logging.error(f'Validate failed due to {task.hap_module} module')
993 pa_file = get_disasm_abc_file(task, info, 'Hap')
996 is_packaged = is_package_modules_to_module_abc(task, pa_file, external_task.har_module)
1005 runtime_passed = run_compile_output(info, task, is_debug, 'import_external_static_library')
1008 def full_compile_external_static_library(task, is_debug):
1013 clean_compile(task)
1015 current_task = ExternalTest.prepare_current_task(task, test_name)
1017 logging.info(f"==========> Running {test_name} for task: {task.name}")
1019 with manage_module_import_and_export_handle(task, 'ExternalHar'):
1038 def full_compile_external_share_library(task, is_debug):
1041 clean_compile(task)
1043 current_task = ExternalTest.prepare_current_task(task, test_name)
1045 logging.info(f"==========> Running {test_name} for task: {task.name}")
1047 with manage_module_import_and_export_handle(task, 'ExternalHsp'):
1068 def validate_preview_incremental_file(task, preview_task_info, is_debug, modified_files, module=''):
1069 module_path = utils.get_module_path(task, module)
1071 task.path, *module_path, *task.build_path, *task.preview_cache_path, 'debug')
1072 backup_path = task.backup_info.cache_debug
1074 passed = validate_cache_file(task, preview_task_info, modified_files, cache_path, backup_path)
1078 def preview_compile(task, is_debug):
1081 task.preview_compilation_info[test_name] = preview_task_info
1082 clean_preview_cache(task)
1083 logging.info(f"==========> Running {test_name} for task: {task.name}")
1085 passed, build_time = preview_mode_build(preview_task_info, task, is_debug, f'preview_compile_{test_name}')
1093 def compile_preview_build_entry_then_preview(task, is_debug):
1096 task.preview_compilation_info[test_name] = preview_task_info
1097 logging.info(f"==========> Running {test_name} for task: {task.name}")
1099 build_entry, build_module_time = is_build_module_successful(task, is_debug, preview_task_info)
1102 build_preview, preview_build_time = preview_mode_build(preview_task_info, task, is_debug)
1109 def compile_preview_build_modify_file_name(task, is_debug):
1112 task.preview_compilation_info[test_name] = preview_task_info
1113 logging.info(f"==========> Running {test_name} for task: {task.name}")
1115 modify_file = os.path.join(task.path, *task.inc_modify_file)
1132 first_build_passed, first_build_time = is_build_module_successful(task, is_debug, preview_task_info)
1138 second_build_passed, second_build_time = is_build_module_successful(task, is_debug, preview_task_info)
1147 def compile_preview_build_generate_sourcemap(task, is_debug):
1150 task.preview_compilation_info[test_name] = preview_task_info
1151 logging.info(f"==========> Running {test_name} for task: {task.name}")
1153 build_preview, preview_build_time = preview_mode_build(preview_task_info, task, is_debug)
1157 preview_path = os.path.join(task.path, *task.hap_module_path, *task.preview_path)
1158 preview_cache_path = os.path.join(preview_path, *task.preview_cache_path)
1163 logging.error(f'task: {task.name},source map not found in {source_map_path}')
1172 def compile_preview_build_tigger_incremental_build(task, is_debug):
1175 task.preview_compilation_info[test_name] = preview_task_info
1176 logging.info(f"==========> Running {test_name} for task: {task.name}")
1178 backup_preview_cache(task, is_debug)
1179 inc_modify_file = os.path.join(task.path, *task.inc_modify_file)
1184 build_preview, preview_build_time = preview_mode_build(preview_task_info, task, is_debug)
1188 passed = PreviewTest.validate_preview_incremental_file(task, preview_task_info, is_debug, inc_modify_file)
1196 def compile_preview_build_has_arkui_error(task, is_debug):
1199 task.preview_compilation_info[test_name] = preview_task_info
1200 logging.info(f"==========> Running {test_name} for task: {task.name}")
1202 add_or_delete_arkui_component(task, 1, True)
1204 preview_mode_build(preview_task_info, task, is_debug)
1205 cmd = get_preview_mode_compile_cmd(task, is_debug)
1206 [stdout, stderr] = compile_project(task, is_debug, cmd)
1212 add_or_delete_arkui_component(task, 0)
1215 def compile_preview_build_sdk_path_has_special_char(task, is_debug):
1218 task.preview_compilation_info[test_name] = preview_task_info
1219 logging.info(f"==========> Running {test_name} for task: {task.name}")
1222 profile_file = os.path.join(task.path, 'build-profile.json5')
1240 passed, build_time = preview_mode_build(preview_task_info, task, is_debug)
1252 def compile_preview_build_modify_error_then_fix(task, is_debug):
1255 task.preview_compilation_info[test_name] = preview_task_info
1256 logging.info(f"==========> Running {test_name} for task: {task.name}")
1258 add_or_delete_arkui_component(task, 1)
1263 preview_modify_file = os.path.join(task.path, *task.inc_modify_file)
1270 cmd = get_preview_mode_compile_cmd(task, is_debug)
1271 [stdout, stderr] = compile_project(task, is_debug, cmd)
1275 logging.error(f'task: {task.name}, first build did not get expected errors, skip second build')
1283 is_build_successful, build_time = preview_mode_build(preview_task_info, task, is_debug)
1288 add_or_delete_arkui_component(task, 0)
1320 def verify_binary_consistency(task):
1323 task.other_tests[test_name] = test_info
1327 logging.info(f"==========> Running {test_name} for task: {task.name}")
1330 if len(task.backup_info.output_release) == 1:
1331 compile_project(task, False)
1332 backup_compile_output(task, False)
1334 if len(task.backup_info.output_release) == 2:
1335 release_consistency = OtherTest.is_abc_same_in_haps(task.backup_info.output_release[0],
1336 task.backup_info.output_release[1])
1342 if len(task.backup_info.output_debug) == 1:
1343 compile_project(task, True)
1344 backup_compile_output(task, True)
1346 if len(task.backup_info.output_debug) == 2:
1347 debug_consistency = OtherTest.is_abc_same_in_haps(task.backup_info.output_debug[0],
1348 task.backup_info.output_debug[1])
1359 def execute_break_compile(task, is_debug):
1362 task.other_tests[test_name] = test_info
1364 logging.info(f"==========> Running {test_name} for task: {task.name}")
1365 clean_compile(task)
1366 cmd = get_hvigor_compile_cmd(task, is_debug)
1368 logging.debug(f"cmd execution path {task.path}")
1369 process = subprocess.Popen(cmd, shell=False, cwd=task.path,
1386 [stdout, stderr] = compile_project(task, is_debug)
1393 passed = validate_compile_output(test_info, task, is_debug)
1397 run_compile_output(test_info, task, True, 'other_tests_break_continue_compile')
1400 def compile_full_with_error(task, is_debug):
1403 task.other_tests[test_name] = test_info
1405 logging.info(f"==========> Running {test_name} for task: {task.name}")
1406 modify_file_item = task.inc_modify_file
1407 modify_file = os.path.join(task.path, *modify_file_item)
1416 [stdout, stderr] = compile_project(task, is_debug)
1434 def compile_with_exceed_length(task, is_debug):
1437 task.other_tests[test_name] = test_info
1439 logging.info(f"==========> Running {test_name} for task: {task.name}")
1442 task.path, *task.hap_module_path, 'build-profile.json5')
1457 cmd = get_hvigor_compile_cmd(task, is_debug, task.hap_module, long_str)
1458 [stdout, stderr] = compile_project(task, is_debug, cmd)
1474 passed = validate_compile_output(test_info, task, is_debug)
1481 def compile_ohos_test(task):
1484 task.other_tests[test_name] = test_info
1486 logging.info(f"==========> Running {test_name} for task: {task.name}")
1490 [stdout, stderr] = compile_project(task, True, cmd)
1496 output_file = get_compile_output_file_path(task, '', options.OutputType.unsigned)
1518 test_info, task, True, ohos_test_output_file)
1523 def disasm_abc(task, abc_file):
1524 if not os.path.exists(task.ark_disasm_path):
1529 cmd = [task.ark_disasm_path, '--verbose', abc_file, pa_file]
1544 def is_abc_debug_info_correct(task, abc_file, is_debug):
1545 pa_file = disasm_abc(task, abc_file)
1566 def validate_output_for_jsbundle(info, task, uncompressed_output_path, is_debug):
1577 if 'compatible8' not in task.type and not is_abc_debug_info_correct(task, file, is_debug):
1601 def validate_output_for_esmodule(info, task, uncompressed_output_path, is_debug, module = ''):
1615 if not is_abc_debug_info_correct(task, modules_abc_path, is_debug):
1621 if 'widget' in task.type:
1633 if not is_abc_debug_info_correct(task, widget_abc_path, is_debug):
1643 task.path, *task.hsp_module_path, *(task.build_path), *(task.cache_path), 'release')
1646 task.path, *task.hap_module_path, *(task.build_path), *(task.cache_path), 'release')
1673 def get_compile_output_file_path(task, module, output_type):
1674 module_path = utils.get_module_path(task, module)
1675 output_path = utils.get_output_path(task, module, output_type)
1676 output_file = os.path.join(task.path, *module_path, *task.build_path, *output_path)
1681 def validate_compile_output_har(info, task, is_debug, output_file='', module=''):
1682 uncompressed_output_file = get_output_uncompressed_file(task, info, module, options.OutputType.har)
1690 def validate_compile_file_bytecode_har(task, info, module):
1691 module_path = utils.get_module_path(task, module)
1692 uncompressed_path = get_output_uncompressed_file(task, info, module, options.OutputType.har)
1700 ets_path = os.path.join(task.path, *module_path, 'src', 'main', 'ets')
1702 relative_path = os.path.relpath(root, os.path.join(task.path, *module_path))
1716 def validate_compile_file_har(task, info, module):
1717 module_path = utils.get_module_path(task, module)
1718 uncompressed_path = get_output_uncompressed_file(task, info, module, options.OutputType.har)
1723 ets_path = os.path.join(task.path, *module_path, 'src', 'main', 'ets')
1725 relative_path = os.path.relpath(root, os.path.join(task.path, *module_path))
1751 def validate_compile_output(info, task, is_debug, output_file='', module=''):
1755 output_file = get_compile_output_file_path(task, module, options.OutputType.unsigned)
1761 return validate_compile_file_bytecode_har(task, info, module)
1765 return validate_compile_file_har(task, info, module)
1769 logging.error("output file for task %s not exists: %s",
1770 task.name, output_file)
1782 f"uncompressed output file for task {task.name} failed. output file: {output_file}")
1789 if utils.is_esmodule(task.type):
1791 info, task, uncompressed_output_file, is_debug, module)
1794 info, task, uncompressed_output_file, is_debug)
1801 def run_compile_output(info, task, is_debug, picture_name='', module=''):
1802 hsp_output_path = task.backup_info.hsp_signed_output_debug if is_debug \
1803 else task.backup_info.hsp_signed_output_release
1805 backup_hsp_module_compile_signed_package(task, is_debug)
1816 utils.get_running_screenshot(task, picture_name, is_debug, module)
1818 if utils.verify_runtime(task, picture_name):
1825 logging.error(f'The runtime of the {task.name} is inconsistent with the reference screenshot,'
1836 def verify_preview_picture(info, task, is_debug, picture_name, module=''):
1849 def validate(compilation_info, task, is_debug, stdout, stderr, picture_name='', output_file=''):
1863 passed = validate_compile_output(info, task, is_debug, output_file)
1866 runtime_passed = run_compile_output(info, task, is_debug, picture_name)
1889 def get_hvigor_compile_cmd(task, is_debug, module='', module_name='', module_target='default'):
1897 module_name = utils.get_module_name(task, module)
1904 def get_preview_mode_compile_cmd(task, is_debug, module='', module_target='default'):
1907 module_name = utils.get_module_name(task, module)
1908 page = os.path.join(*task.inc_modify_file)
1910 page = os.path.join(task.har_modify_file)
1912 page = os.path.join(task.hsp_modify_file)
1923 def compile_project(task, is_debug, cmd=None):
1925 cmd = get_hvigor_compile_cmd(task, is_debug)
1928 logging.debug(f"cmd execution path {task.path}")
1929 process = subprocess.Popen(cmd, shell=False, cwd=task.path,
1941 def preview_mode_build(info, task, is_debug, picture_name='', module=''):
1942 cmd = get_preview_mode_compile_cmd(task, is_debug, module)
1943 [stdout, stderr] = compile_project(task, is_debug, cmd)
1948 info.error_message = f'task: {task.name}, Preview compile failed'
1949 logging.error(f'task: {task.name}, Preview compile failed')
1952 is_get_correct_pic = verify_preview_picture(info, task, is_debug, picture_name, module)
1955 info.error_message = f'task: {task.name}, Get incorrect picture'
1956 logging.error(f'task: {task.name}, Get incorrect picture')
1963 def clean_compile(task):
1966 logging.debug(f"cmd execution path {task.path}")
1967 process = subprocess.Popen(cmd, shell=False, cwd=task.path,
1972 def clean_preview_cache(task, module=''):
1973 module_path = utils.get_module_path(task, module)
1975 preview_cache_path = os.path.join(task.path, *module_path, '.preview')
1981 def sync_project(task):
1987 logging.debug(f"cmd execution path {task.path}")
1989 subprocess.Popen(ohpm_install_cmd, shell=False, cwd=task.path,
1992 subprocess.Popen(cmd, shell=False, cwd=task.path,
1998 def compile_full(task, is_debug):
1999 if not FullTest.full_compile(task, is_debug):
2002 FullTest.compile_full_import_ordinary_ohpm_package(task, is_debug)
2003 FullTest.compile_full_import_special_ohpm_package(task, is_debug)
2004 FullTest.compile_full_import_static_library(task, is_debug)
2005 FullTest.compile_full_import_share_library(task, is_debug)
2006 FullTest.compile_full_import_so_file(task, is_debug)
2007 FullTest.compile_full_has_syntax_error_in_js(task, is_debug)
2008 FullTest.compile_full_use_normalize_ohmurl(task, is_debug)
2009 FullTest.compile_full_module_name_is_inconsistent(task, is_debug)
2014 def compile_incremental(task, is_debug):
2016 f"==========> Running task: {task.name} in incremental compilation")
2017 clean_compile(task)
2018 [stdout, stderr] = compile_project(task, is_debug)
2027 passed = validate(task.full_compilation_info,
2028 task, is_debug, stdout, stderr, 'incremental_compile_first')
2034 backup_compile_output(task, is_debug)
2035 backup_compile_cache(task, is_debug)
2037 IncrementalTest.compile_incremental_no_modify(task, is_debug)
2038 IncrementalTest.compile_incremental_add_oneline(task, is_debug)
2039 IncrementalTest.compile_incremental_add_file(task, is_debug)
2040 IncrementalTest.compile_incremental_add_nonexistent_file(task, is_debug)
2041 IncrementalTest.compile_incremental_delete_file(task, is_debug)
2043 IncrementalTest.compile_incremental_build_modify_error_then_fix(task, is_debug)
2044 IncrementalTest.compile_incremental_build_add_error_page(task, is_debug)
2045 IncrementalTest.compile_incremental_build_add_error_non_page(task, is_debug)
2046 IncrementalTest.compile_incremental_build_entry_then_har(task, is_debug)
2047 IncrementalTest.compile_incremental_build_har_then_entry(task, is_debug)
2048 IncrementalTest.compile_incremental_build_entry_then_hsp(task, is_debug)
2049 IncrementalTest.compile_incremental_build_hsp_then_entry(task, is_debug)
2050 IncrementalTest.compile_incremental_build_hsp_then_ohos(task, is_debug)
2051 IncrementalTest.compile_incremental_build_entry_then_ohos(task, is_debug)
2052 IncrementalTest.compile_incremental_build_entry_then_preview_build(task, is_debug)
2056 IncrementalTest.compile_incremental_reverse_hap_mode(task, is_debug)
2057 IncrementalTest.compile_incremental_modify_module_name(task, is_debug)
2058 IncrementalTest.compile_incremental_build_modify_sdk_version(task, is_debug)
2061 def compile_bytecode_har(task, is_debug):
2062 logging.info(f"==========> Running task: {task.name} in bytecode har compilation")
2063 clean_compile(task)
2065 BytecodeHarTest.build_bytecode_har(task, is_debug)
2066 BytecodeHarTest.build_har_then_bytecode_har(task, is_debug)
2067 BytecodeHarTest.import_bytecode_static_library(task, is_debug)
2070 def compile_external(task, is_debug):
2071 logging.info(f"==========> Running task: {task.name} in external compilation")
2072 clean_compile(task)
2074 ExternalTest.import_external_share_library(task, is_debug)
2075 ExternalTest.import_external_static_library(task, is_debug)
2076 ExternalTest.full_compile_external_static_library(task, is_debug)
2077 ExternalTest.full_compile_external_share_library(task, is_debug)
2080 def compile_preview(task, is_debug):
2081 clean_preview_cache(task)
2082 if not PreviewTest.preview_compile(task, is_debug):
2086 PreviewTest.compile_preview_build_entry_then_preview(task, is_debug)
2087 PreviewTest.compile_preview_build_modify_file_name(task, is_debug)
2088 PreviewTest.compile_preview_build_generate_sourcemap(task, is_debug)
2089 PreviewTest.compile_preview_build_tigger_incremental_build(task, is_debug)
2090 PreviewTest.compile_preview_build_has_arkui_error(task, is_debug)
2091 PreviewTest.compile_preview_build_sdk_path_has_special_char(task, is_debug)
2092 PreviewTest.compile_preview_build_modify_error_then_fix(task, is_debug)
2095 def backup_compile_output(task, is_debug):
2096 backup_path = task.backup_info.cache_path
2101 if len(task.backup_info.output_debug) == 2:
2109 if len(task.backup_info.output_release) == 2:
2116 output_file = get_compile_output_file_path(task, '', options.OutputType.unsigned)
2124 task.backup_info.output_debug.append(backup_time_output)
2126 task.backup_info.output_release.append(backup_time_output)
2129 def backup_hsp_module_compile_signed_package(task, is_debug):
2133 backup_path = task.backup_info.cache_path
2137 cmd = get_hvigor_compile_cmd(task, is_debug, 'Hsp')
2138 stdout, stderr = compile_project(task, is_debug, cmd)
2142 logging.debug(f"cmd execution path {task.path}")
2147 stdout, stderr = compile_project(task, is_debug, cmd)
2151 logging.debug(f"cmd execution path {task.path}")
2158 output_file = get_compile_output_file_path(task, 'Hsp', options.OutputType.signed)
2166 task.backup_info.hsp_signed_output_debug = backup_output
2167 task.backup_info.external_hsp_signed_output_debug = external_hsp_backup_output
2169 task.backup_info.hsp_signed_output_release = backup_output
2170 task.backup_info.external_hsp_signed_output_release = external_hsp_backup_output
2173 def backup_preview_output(task, is_debug, module):
2174 backup_path = task.backup_info.cache_path
2180 if len(task.backup_info.preview_output_debug) == 2:
2188 if len(task.backup_info.preview_output_release) == 2:
2195 preview_output_path = os.path.join((task.path, module, '.preview'))
2202 task.backup_info.output_debug.append(preview_backup_time_out)
2204 task.backup_info.output_release.append(preview_backup_time_out)
2207 def backup_compile_cache(task, is_debug):
2208 backup_path = task.backup_info.cache_path
2216 task.path, *task.hap_module_path, *(task.build_path), *(task.cache_path))
2219 if task.backup_info.cache_debug != '':
2225 task.backup_info.cache_debug = backup_cache_file
2227 if task.backup_info.cache_release != '':
2233 task.backup_info.cache_release = backup_cache_file
2236 def backup_preview_cache(task, is_debug, module=''):
2237 backup_path = task.backup_info.cache_path
2244 module_path = utils.get_module_path(task, module)
2246 task.path, *module_path, *task.preview_path, *task.preview_cache_path)
2249 if task.backup_info.preview_cache_debug != '':
2255 task.backup_info.preview_cache_debug = preview_backup_cache_file
2257 if task.backup_info.preview_cache_release != '':
2263 task.backup_info.preview_cache_release = preview_backup_cache_file
2266 def execute_full_compile(task):
2268 f"==========> Running task: {task.name} in full compilation")
2271 passed = passed and compile_full(task, False)
2272 clean_compile(task)
2274 passed = passed and compile_full(task, True)
2275 clean_compile(task)
2279 def execute_incremental_compile(task):
2281 f"==========> Running task: {task.name} in incremental compilation")
2283 compile_incremental(task, False)
2284 clean_compile(task)
2286 compile_incremental(task, True)
2287 clean_compile(task)
2290 def execute_bytecode_har_compile(task):
2292 f"==========> Running task: {task.name} in bytecode har compilation")
2294 compile_bytecode_har(task, False)
2295 clean_compile(task)
2297 compile_bytecode_har(task, True)
2298 clean_compile(task)
2301 def execute_external_compile(task):
2303 f"==========> Running task: {task.name} in external compilation")
2305 compile_external(task, False)
2306 clean_compile(task)
2308 compile_external(task, True)
2309 clean_compile(task)
2312 def execute_preview_compile(task):
2314 f"==========> Running task: {task.name} in preview compilation")
2315 compile_preview(task, True)
2316 clean_compile(task)
2319 def clean_backup(task):
2320 if os.path.exists(task.backup_info.cache_path):
2321 shutil.rmtree(task.backup_info.cache_path)
2325 def is_build_module_successful(task, is_debug, info, module='', picture_name=''):
2326 cmd = get_hvigor_compile_cmd(task, is_debug, module)
2327 [stdout, stderr] = compile_project(task, is_debug, cmd)
2331 module_name = utils.get_module_name(task, module)
2336 passed = validate_compile_output(info, task, is_debug, '', module)
2339 runtime_passed = run_compile_output(info, task, is_debug, picture_name)
2360 def is_build_ohos_test_successful(task, info):
2363 [stdout, stderr] = compile_project(task, True, cmd)
2376 def modify_main_pages_json(task, page_path, reverse):
2377 main_pages_json_path = os.path.join(task.path, *task.main_pages_json_path)
2394 sync_project(task)
2397 def add_or_delete_page(task, reverse, is_error=False):
2405 new_file_directory = os.path.dirname(os.path.join(task.path, *task.inc_modify_file))
2409 modify_main_pages_json(task, page_path, 1)
2419 modify_main_pages_json(task, page_path, 0)
2423 def add_or_delete_js_file(task, reverse, is_error=False):
2424 modify_file = os.path.join(task.path, *task.inc_modify_file)
2451 def modify_normalize_ohmurl_options(task, reverse):
2452 oh_package_json_path = os.path.join(task.path, 'build-profile.json5')
2471 sync_project(task)
2474 def modify_module_import_handle(task, module, reverse):
2475 modify_file = os.path.join(task.path, *task.inc_modify_file)
2486 def manage_module_import_and_export_handle(task, module_name):
2487 modify_module_import_handle(task, module_name, 1)
2491 modify_module_import_handle(task, module_name, 0)
2495 def manage_bytecode_har_dependency(task, is_debug, info, module):
2496 modify_module_import_handle(task, module, 1)
2497 is_build_module_successful(task, is_debug, info, 'BytecodeHar')
2498 modify_bytecode_module_dependency(task, module, 1)
2502 modify_bytecode_module_dependency(task, module, 0)
2503 modify_module_import_handle(task, module, 0)
2506 def modify_bytecode_module_dependency(task, module, reverse):
2507 oh_package_json_path = os.path.join(task.path, task.hap_module, 'oh-package.json5')
2514 dependency_path = os.path.join(task.har_module, *task.build_path, *task.har_output_path_har)
2516 dependency_path = utils.get_module_name(task, module)
2521 sync_project(task)
2524 def modify_bytecode_har_config(task, reverse):
2525 modify_normalize_ohmurl_options(task, reverse)
2526 module_path = utils.get_module_path(task, 'Har')
2527 har_build_profile_json_path = os.path.join(task.path, *module_path, 'build-profile.json5')
2538 sync_project(task)
2541 def validate_cache_file(task, info, modified_files, cache_path, backup_path):
2542 cache_extension = utils.get_cache_extension(task.type)
2566 task.type, file_relative_path, modified_cache_files)
2578 def get_output_uncompressed_file(task, info, module, output_type=options.OutputType.unsigned):
2579 output_file = get_compile_output_file_path(task, module, output_type)
2582 logging.error(f"outputfile: {output_file} for task: {task.name} not found")
2595 f"task: {task.name},not the expected file type for output file: {output_file}")
2601 f"uncompressed output file for task {task.name} failed. output file: {output_file}")
2609 def get_disasm_abc_file(task, info, module, uncompressed_output_file=''):
2611 uncompressed_output_file = get_output_uncompressed_file(task, info, module)
2619 if utils.is_esmodule(task.type):
2633 return disasm_abc(task, abc_path)
2636 def is_package_modules_to_module_abc(task, pa_file, module):
2637 module_str = f'{task.hap_module}@{module}'
2642 def is_normalized_ohm_url(task, is_debug, info):
2643 build_path = os.path.join(task.path, *task.hap_module_path, *task.build_path)
2644 cache_path = os.path.join(build_path, *task.cache_path, 'debug') if is_debug \
2645 else os.path.join(build_path, *task.cache_path, 'release')
2646 inc_modify_file = os.path.join(*task.inc_modify_file)
2661 def is_npm_txt_included_ohpm_package(info, task, is_debug, package_name):
2662 cache_file = os.path.join(task.path, *task.hap_module_path, *task.build_path, *task.cache_path)
2679 def modify_sdk_version(task, api_version):
2680 build_profile_json_file = os.path.join(task.path, 'build-profile.json5')
2700 sync_project(task)
2705 def add_or_delete_arkui_component(task, reverse, is_error=False):
2706 preview_modify_file = os.path.join(task.path, *task.inc_modify_file)
2727 for task in test_tasks:
2729 logging.info(f"======> Running task: {task.name}")
2731 if not execute_full_compile(task):
2736 execute_incremental_compile(task)
2739 execute_bytecode_har_compile(task)
2742 execute_external_compile(task)
2745 execute_preview_compile(task)
2747 OtherTest.verify_binary_consistency(task)
2751 OtherTest.execute_break_compile(task, is_debug)
2752 if 'error' in task.type:
2753 OtherTest.compile_full_with_error(task, is_debug)
2755 if 'exceed_length_error' in task.type:
2756 OtherTest.compile_with_exceed_length(task, is_debug)
2758 if 'ohosTest' in task.type:
2759 OtherTest.compile_ohos_test(task)
2761 logging.info(f"======> Running task: {task.name} finished")
2765 clean_backup(task)