Skip to content

Commit 3c1bd95

Browse files
authored
Cleanup zlib tests. NFC (#16903)
Use `get_zlib_library` in both tests. Document all `-W` flags and remove unnecessary ones.
1 parent 4610a85 commit 3c1bd95

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

tests/common.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,15 +1227,23 @@ def get_poppler_library(self, env_init=None):
12271227

12281228
return poppler + freetype
12291229

1230-
def get_zlib_library(self):
1231-
# TODO: remove -Wno-unknown-warning-option when clang rev 11da1b53 rolls into emscripten
1232-
self.emcc_args += ['-Wno-deprecated-non-prototype', '-Wno-unknown-warning-option']
1233-
if WINDOWS:
1234-
return self.get_library(os.path.join('third_party', 'zlib'), os.path.join('libz.a'),
1235-
configure=['cmake', '.'],
1236-
make=['cmake', '--build', '.'],
1237-
make_args=[])
1238-
return self.get_library(os.path.join('third_party', 'zlib'), os.path.join('libz.a'), make_args=['libz.a'])
1230+
def get_zlib_library(self, cmake):
1231+
assert cmake or not WINDOWS, 'on windows, get_zlib_library only supports cmake'
1232+
1233+
old_args = self.emcc_args.copy()
1234+
# inflate.c does -1L << 16
1235+
self.emcc_args.append('-Wno-shift-negative-value')
1236+
# adler32.c uses K&R sytyle function declarations
1237+
self.emcc_args.append('-Wno-deprecated-non-prototype')
1238+
if cmake:
1239+
rtn = self.get_library(os.path.join('third_party', 'zlib'), os.path.join('libz.a'),
1240+
configure=['cmake', '.'],
1241+
make=['cmake', '--build', '.', '--'],
1242+
make_args=[])
1243+
else:
1244+
rtn = self.get_library(os.path.join('third_party', 'zlib'), os.path.join('libz.a'), make_args=['libz.a'])
1245+
self.emcc_args = old_args
1246+
return rtn
12391247

12401248

12411249
# Run a server and a web page. When a test runs, we tell the server about it,

tests/test_core.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4920,9 +4920,11 @@ def test_dylink_spaghetti(self):
49204920
@needs_make('mingw32-make')
49214921
@needs_dylink
49224922
def test_dylink_zlib(self):
4923-
self.emcc_args += ['-Wno-shift-negative-value', '-I' + test_file('third_party/zlib')]
49244923
self.set_setting('RELOCATABLE')
4925-
zlib_archive = self.get_zlib_library()
4924+
zlib_archive = self.get_zlib_library(cmake=WINDOWS)
4925+
# example.c uses K&R style function declarations
4926+
self.emcc_args.append('-Wno-deprecated-non-prototype')
4927+
self.emcc_args.append('-I' + test_file('third_party/zlib'))
49264928
self.dylink_test(main=read_file(test_file('third_party/zlib/example.c')),
49274929
side=zlib_archive,
49284930
expected=read_file(test_file('core/test_zlib.out')),
@@ -6579,27 +6581,18 @@ def test_zlib(self, use_cmake):
65796581
self.skipTest("Windows cannot run configure sh scripts")
65806582

65816583
self.maybe_closure()
6582-
6583-
self.emcc_args.append('-Wno-shift-negative-value')
6584-
self.emcc_args.append('-Wno-pointer-sign')
6585-
65866584
if '-g' in self.emcc_args:
65876585
self.emcc_args.append('-gsource-map') # more source maps coverage
65886586

6589-
if use_cmake:
6590-
make_args = []
6591-
configure = ['cmake', '.']
6592-
else:
6593-
make_args = ['libz.a']
6594-
configure = ['sh', './configure']
6587+
zlib = self.get_zlib_library(use_cmake)
65956588

6596-
# TODO: remove Wno-unknown-warning-option when clang rev 11da1b53 rolls into emscripten
6597-
self.emcc_args += ['-Wno-deprecated-non-prototype', '-Wno-unknown-warning-option']
6589+
# example.c uses K&R style function declarations
6590+
self.emcc_args += ['-Wno-deprecated-non-prototype']
65986591
self.do_run_from_file(
65996592
test_file('third_party/zlib/example.c'),
66006593
test_file('core/test_zlib.out'),
6601-
libraries=self.get_library('third_party/zlib', 'libz.a', make_args=make_args, configure=configure),
6602-
includes=[test_file('third_party/zlib'), 'building', 'zlib'])
6594+
libraries=zlib,
6595+
includes=[test_file('third_party/zlib')])
66036596

66046597
@needs_make('make')
66056598
@is_slow_test

0 commit comments

Comments
 (0)