(test_list: TestList, platform_type: TestPlatform)
| 119 | |
| 120 | |
| 121 | def export(test_list: TestList, platform_type: TestPlatform) -> None: |
| 122 | print("start export") |
| 123 | start_time = time.time() |
| 124 | # find all merged profile under merged_folder and sub-folders |
| 125 | g = os.walk(MERGED_FOLDER_BASE_DIR) |
| 126 | for path, dir_list, file_list in g: |
| 127 | # create corresponding merged folder in [json folder] if not exists yet |
| 128 | create_corresponding_folder( |
| 129 | path, MERGED_FOLDER_BASE_DIR, dir_list, JSON_FOLDER_BASE_DIR |
| 130 | ) |
| 131 | # check if we can find merged profile under this path's folder |
| 132 | for file_name in file_list: |
| 133 | if file_name.endswith(".merged"): |
| 134 | if not related_to_test_list(file_name, test_list): |
| 135 | continue |
| 136 | print(f"start export {file_name}") |
| 137 | # merged file |
| 138 | merged_file = os.path.join(path, file_name) |
| 139 | # json file |
| 140 | json_file_name = replace_extension(file_name, ".json") |
| 141 | json_file = os.path.join( |
| 142 | JSON_FOLDER_BASE_DIR, |
| 143 | convert_to_relative_path(path, MERGED_FOLDER_BASE_DIR), |
| 144 | json_file_name, |
| 145 | ) |
| 146 | check_platform_type(platform_type) |
| 147 | # binary file and shared library |
| 148 | binary_file = "" |
| 149 | shared_library_list = [] |
| 150 | if platform_type == TestPlatform.FBCODE: |
| 151 | from caffe2.fb.code_coverage.tool.package.fbcode.utils import ( # type: ignore[import] |
| 152 | get_fbcode_binary_folder, |
| 153 | ) |
| 154 | |
| 155 | binary_file = os.path.join( |
| 156 | get_fbcode_binary_folder(path), |
| 157 | get_test_name_from_whole_path(merged_file), |
| 158 | ) |
| 159 | elif platform_type == TestPlatform.OSS: |
| 160 | from ..oss.utils import get_oss_binary_file, get_oss_shared_library |
| 161 | |
| 162 | test_name = get_test_name_from_whole_path(merged_file) |
| 163 | # if it is python test, no need to provide binary, shared library is enough |
| 164 | binary_file = ( |
| 165 | "" |
| 166 | if test_name.endswith(".py") |
| 167 | else get_oss_binary_file(test_name, TestType.CPP) |
| 168 | ) |
| 169 | shared_library_list = get_oss_shared_library() |
| 170 | export_target( |
| 171 | merged_file, |
| 172 | json_file, |
| 173 | binary_file, |
| 174 | shared_library_list, |
| 175 | platform_type, |
| 176 | ) |
| 177 | print_time("export take time: ", start_time, summary_time=True) |
nothing calls this directly
no test coverage detected
searching dependent graphs…