Skip to content

Commit 4bf921d

Browse files
committed
[tests-syncer] Rename fuzz files in the whole archive
1 parent b613d80 commit 4bf921d

1 file changed

Lines changed: 39 additions & 28 deletions

File tree

src/clusterfuzz/_internal/cron/chrome_tests_syncer.py

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -123,23 +123,6 @@ def unpack_crash_testcases(crash_testcases_directory):
123123

124124
shell.remove_directory(directory_path)
125125

126-
# Rename all fuzzed testcase files as regular files.
127-
logs.info('Renaming testcase files.')
128-
for root, _, files in os.walk(crash_testcases_directory):
129-
for filename in files:
130-
if not filename.startswith(testcase_manager.FUZZ_PREFIX):
131-
continue
132-
133-
file_path = os.path.join(root, filename)
134-
stripped_file_name = os.path.basename(file_path)[len(
135-
testcase_manager.FUZZ_PREFIX):]
136-
stripped_file_path = os.path.join(
137-
os.path.dirname(file_path), stripped_file_name)
138-
try:
139-
os.rename(file_path, stripped_file_path)
140-
except Exception as e:
141-
raise RuntimeError(f'Failed to rename testcase {file_path}') from e
142-
143126
# Remove empty files and dirs to avoid the case where a fuzzer randomly
144127
# chooses an empty dir/file and generates zero testcases.
145128
shell.remove_empty_files(crash_testcases_directory)
@@ -253,6 +236,30 @@ def filter_members(member, path):
253236
shell.remove_file(local_archive)
254237

255238

239+
def rename_testcase_files(directory):
240+
# Rename all fuzzed testcase files as regular files.
241+
for root, _, files in os.walk(directory):
242+
for filename in files:
243+
if not filename.startswith(testcase_manager.FUZZ_PREFIX):
244+
continue
245+
246+
file_path = os.path.join(root, filename)
247+
stripped_file_name = os.path.basename(file_path)[len(
248+
testcase_manager.FUZZ_PREFIX):]
249+
stripped_file_path = os.path.join(
250+
os.path.dirname(file_path), stripped_file_name)
251+
try:
252+
os.rename(file_path, stripped_file_path)
253+
except Exception as e:
254+
raise RuntimeError(f'Failed to rename testcase {file_path}') from e
255+
256+
257+
def clean_up_filenames(tests_directory, test_folders):
258+
for folder in test_folders:
259+
logs.info(f'Renaming testcase files in {folder}')
260+
rename_testcase_files(os.path.join(tests_directory, folder))
261+
262+
256263
def sync_tests(tests_archive_bucket: str, tests_archive_name: str,
257264
tests_directory: str):
258265
"""Main sync routine."""
@@ -301,22 +308,26 @@ def sync_tests(tests_archive_bucket: str, tests_archive_name: str,
301308
create_symbolic_link(tests_directory, 'src/third_party/blink/web_tests',
302309
'LayoutTests')
303310

311+
test_folders = [
312+
'CrashTests',
313+
'LayoutTests',
314+
'WebKit/JSTests/es6',
315+
'WebKit/JSTests/stress',
316+
'WebKit/LayoutTests',
317+
'fuzzilli',
318+
'gecko-tests',
319+
'v8/test/mjsunit',
320+
'spidermonkey',
321+
'chakra',
322+
'webgl-conformance-tests',
323+
]
324+
304325
subprocess.check_call(
305326
[
306327
'zip',
307328
'-r',
308329
tests_archive_local,
309-
'CrashTests',
310-
'LayoutTests',
311-
'WebKit/JSTests/es6',
312-
'WebKit/JSTests/stress',
313-
'WebKit/LayoutTests',
314-
'fuzzilli',
315-
'gecko-tests',
316-
'v8/test/mjsunit',
317-
'spidermonkey',
318-
'chakra',
319-
'webgl-conformance-tests',
330+
] + test_folders + [
320331
'-x',
321332
'*.cc',
322333
'-x',

0 commit comments

Comments
 (0)