Skip to content

Commit 4e47051

Browse files
committed
[tests] Fix version test determinism
The dictionary source files were taken from the `dev` branch before this commit, which could introduce non-determinism on PR jobs. Instead take the sources from the PR checkout. This PR also adds stderr logging, and verbose output for the jobs that are failing, to help catch the failure if it occurs again.
1 parent 23a356c commit 4e47051

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

tests/test-zstd-versions.py

+25-6
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,19 @@
2929
test_dat = 'test_dat'
3030
head = 'vdevel'
3131
dict_source = 'dict_source'
32-
dict_files = './zstd/programs/*.c ./zstd/lib/common/*.c ./zstd/lib/compress/*.c ./zstd/lib/decompress/*.c ./zstd/lib/dictBuilder/*.c ./zstd/lib/legacy/*.c '
33-
dict_files += './zstd/programs/*.h ./zstd/lib/common/*.h ./zstd/lib/compress/*.h ./zstd/lib/dictBuilder/*.h ./zstd/lib/legacy/*.h'
32+
dict_globs = [
33+
'programs/*.c',
34+
'lib/common/*.c',
35+
'lib/compress/*.c',
36+
'lib/decompress/*.c',
37+
'lib/dictBuilder/*.c',
38+
'lib/legacy/*.c',
39+
'programs/*.h',
40+
'lib/common/*.h',
41+
'lib/compress/*.h',
42+
'lib/dictBuilder/*.h',
43+
'lib/legacy/*.h'
44+
]
3445

3546

3647
def execute(command, print_output=False, print_error=True, param_shell=False):
@@ -85,6 +96,7 @@ def create_dict(tag, dict_source_path):
8596
result = execute('./zstd.' + tag + ' -f --train ' + ' '.join(cFiles) + ' ' + ' '.join(hFiles) + ' -o ' + dict_name, print_output=False, param_shell=True)
8697
if result == 0:
8798
print(dict_name + ' created')
99+
assert os.path.isfile(dict_name)
88100
else:
89101
raise RuntimeError('ERROR: creating of ' + dict_name + ' failed')
90102
else:
@@ -103,12 +115,15 @@ def zstd(tag, args, input_file, output_file):
103115
print("Running: '{}', input={}, output={}" .format(
104116
' '.join(cmd), input_file, output_file
105117
))
106-
subprocess.check_call(cmd, stdin=i, stdout=o)
118+
result = subprocess.run(cmd, stdin=i, stdout=o, stderr=subprocess.PIPE)
119+
print("Stderr: {}".format(result.stderr.decode("ascii")))
120+
result.check_returncode()
107121

108122

109123
def dict_compress_sample(tag, sample):
110124
dict_name = 'dict.' + tag
111-
zstd(tag, ['-D', dict_name, '-1'], sample, sample + '_01_64_' + tag + '_dictio.zst')
125+
verbose = ['-v', '-v', '-v']
126+
zstd(tag, ['-D', dict_name, '-1'] + verbose, sample, sample + '_01_64_' + tag + '_dictio.zst')
112127
zstd(tag, ['-D', dict_name, '-3'], sample, sample + '_03_64_' + tag + '_dictio.zst')
113128
zstd(tag, ['-D', dict_name, '-5'], sample, sample + '_05_64_' + tag + '_dictio.zst')
114129
zstd(tag, ['-D', dict_name, '-9'], sample, sample + '_09_64_' + tag + '_dictio.zst')
@@ -246,8 +261,12 @@ def decompress_dict(tag):
246261
# copy *.c and *.h to a temporary directory ("dict_source")
247262
if not os.path.isdir(dict_source_path):
248263
os.mkdir(dict_source_path)
249-
print('cp ' + dict_files + ' ' + dict_source_path)
250-
execute('cp ' + dict_files + ' ' + dict_source_path, param_shell=True)
264+
for dict_glob in dict_globs:
265+
files = glob.glob(dict_glob, root_dir=base_dir)
266+
for file in files:
267+
file = os.path.join(base_dir, file)
268+
print("copying " + file + " to " + dict_source_path)
269+
shutil.copy(file, dict_source_path)
251270

252271
print('-----------------------------------------------')
253272
print('Compress test.dat by all released zstd')

0 commit comments

Comments
 (0)