|
13 | 13 | # N_PROCESSES as best suits |
14 | 14 | # Finally, simply run the script |
15 | 15 |
|
16 | | -PROJECTS_BUILDS_DIR = os.path.abspath('/Users/nhoca/Trabalho/auto-builds-paper/bytecode-analysis/java-builds') |
| 16 | +PROJECTS_BUILDS_DIR = os.path.abspath('some-path/builds') |
17 | 17 | # Need sources to grab local jar files |
18 | | -PROJECTS_SOURCES_DIR = os.path.abspath('/Users/nhoca/Trabalho/auto-builds-paper/bytecode-analysis/java-projects') |
19 | | -JARS_DIR = '/Users/nhoca/Trabalho/auto-builds-paper/bytecode-analysis/jars' |
| 18 | +PROJECTS_SOURCES_DIR = os.path.abspath('some-path/java-projects') |
| 19 | +JARS_DIR = 'some-path/jars' |
20 | 20 | N_PROCESSES = 2 |
21 | 21 |
|
22 | 22 | #### SHOULD not need to touch anything below #### |
@@ -119,18 +119,23 @@ def handle_dependencies(proj_path, pid): |
119 | 119 | proj_zip_path = None |
120 | 120 | jar_paths = list() |
121 | 121 |
|
| 122 | + print(proj_path) |
| 123 | + |
122 | 124 | with open(os.path.join(proj_path, 'build-result.json'), 'r') as file: |
123 | 125 | json_file = json.load(file) |
124 | | - for dep in json_file['depends']: |
125 | | - if dep[5]: |
126 | | - if proj_zip_path is None: |
127 | | - proj_zip_path = os.path.join(PROJECTS_SOURCES_DIR, json_file['file'] + '.zip') |
128 | | - # print(proj_zip_path) |
129 | | - with ZipFile(proj_zip_path, 'r') as proj_zip: |
130 | | - proj_zip.extract(member=dep[4], path=pid) |
131 | | - jar_paths.append(os.path.join(pid, dep[4])) |
132 | | - else: |
133 | | - jar_paths.append(os.path.join(JARS_DIR, dep[4])) |
| 126 | + if 'depends' in json_file: |
| 127 | + for dep in json_file['depends']: |
| 128 | + if dep[5]: |
| 129 | + if proj_zip_path is None: |
| 130 | + proj_zip_path = os.path.join(PROJECTS_SOURCES_DIR, json_file['file'] + '.zip') |
| 131 | + # print(proj_zip_path) |
| 132 | + with ZipFile(proj_zip_path, 'r') as proj_zip: |
| 133 | + proj_zip.extract(member=dep[4], path=pid) |
| 134 | + jar_paths.append(os.path.join(pid, dep[4])) |
| 135 | + else: |
| 136 | + jar_paths.append(os.path.join(JARS_DIR, dep[4])) |
| 137 | + else: |
| 138 | + return ' ' |
134 | 139 |
|
135 | 140 | # print(jar_paths) |
136 | 141 | return ':'.join(jar_paths) |
@@ -179,20 +184,20 @@ def process(list_projs): |
179 | 184 | full_filename = os.path.join(root, filename) |
180 | 185 | # print('Analyzing file', full_filename) |
181 | 186 |
|
182 | | - n_class_files += 1 |
183 | | - ci = unpack_classfile(full_filename) |
184 | | - |
185 | | - # Search for main methods and run the respective class files |
186 | | - main_methods = main_search_string in [m.get_name() for m in ci.methods] |
187 | | - if main_methods: |
188 | | - # print('Has main:', full_filename) |
189 | | - reachable_mains += 1 |
190 | | - res = reachable_methods_from_main(root, filename, jar_paths, str(pid)) |
191 | | - # res = run_main(root, filename) |
192 | | - reachable_methods += res |
193 | | - |
194 | | - # Search for junit and run the respective class files |
195 | 187 | try: |
| 188 | + n_class_files += 1 |
| 189 | + ci = unpack_classfile(full_filename) |
| 190 | + |
| 191 | + # Search for main methods and run the respective class files |
| 192 | + main_methods = main_search_string in [m.get_name() for m in ci.methods] |
| 193 | + if main_methods: |
| 194 | + # print('Has main:', full_filename) |
| 195 | + reachable_mains += 1 |
| 196 | + res = 0 # reachable_methods_from_main(root, filename, jar_paths, str(pid)) |
| 197 | + # res = run_main(root, filename) |
| 198 | + reachable_methods += res |
| 199 | + |
| 200 | + # Search for junit and run the respective class files |
196 | 201 | junit_imports = [m for m in ci.get_requires() if junit_search_string in m] |
197 | 202 | if len(junit_imports) > 0: |
198 | 203 | # print('Has junit:', full_filename) |
|
0 commit comments