Skip to content

Commit e66cbd5

Browse files
authored
[test] Use cflags rather than emcc_args. NFC (#24578)
This has a few advantages: 1. It paves the way for separating out `ldflags`. 2. It the commonly used name for compiler flags. 3. Its slightly short and easier to type (important only because its repeated in many places)
1 parent 1aa6dfa commit e66cbd5

File tree

8 files changed

+1547
-1548
lines changed

8 files changed

+1547
-1548
lines changed

test/common.py

Lines changed: 69 additions & 69 deletions
Large diffs are not rendered by default.

test/test_benchmark.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ def output_parser(output):
977977
self.do_benchmark('matrix_multiply', read_file(test_file('matrix_multiply.cpp')), 'Total elapsed:', output_parser=output_parser, shared_args=['-I' + test_file('benchmark')])
978978

979979
def lua(self, benchmark, expected, output_parser=None, args_processor=None):
980-
self.emcc_args.remove('-Werror')
980+
self.cflags.remove('-Werror')
981981
shutil.copyfile(test_file(f'third_party/lua/{benchmark}.lua'), benchmark + '.lua')
982982

983983
def lib_builder(name, native, env_init):
@@ -1002,7 +1002,7 @@ def test_zzz_lua_binarytrees(self):
10021002
self.lua('binarytrees', 'long lived tree of depth')
10031003

10041004
def test_zzz_zlib(self):
1005-
self.emcc_args.remove('-Werror')
1005+
self.cflags.remove('-Werror')
10061006
src = read_file(test_file('benchmark/test_zlib_benchmark.c'))
10071007

10081008
def lib_builder(name, native, env_init):
@@ -1032,8 +1032,8 @@ def lib_builder(name, native, env_init):
10321032
self.do_benchmark('box2d', src, 'frame averages', shared_args=['-I' + test_file('third_party/box2d')], lib_builder=lib_builder)
10331033

10341034
def test_zzz_bullet(self):
1035-
self.emcc_args.remove('-Werror')
1036-
self.emcc_args += ['-Wno-c++11-narrowing', '-Wno-deprecated-register', '-Wno-writable-strings']
1035+
self.cflags.remove('-Werror')
1036+
self.cflags += ['-Wno-c++11-narrowing', '-Wno-deprecated-register', '-Wno-writable-strings']
10371037
src = read_file(test_file('third_party/bullet/Demos/Benchmarks/BenchmarkDemo.cpp'))
10381038
src += read_file(test_file('third_party/bullet/Demos/Benchmarks/main.cpp'))
10391039

test/test_browser.py

Lines changed: 583 additions & 583 deletions
Large diffs are not rendered by default.

test/test_core.py

Lines changed: 456 additions & 456 deletions
Large diffs are not rendered by default.

test/test_interactive.py

Lines changed: 55 additions & 55 deletions
Large diffs are not rendered by default.

test/test_other.py

Lines changed: 362 additions & 363 deletions
Large diffs are not rendered by default.

test/test_posixtest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def f(self):
172172
if browser:
173173
self.btest_exit(testfile, args=args)
174174
else:
175-
self.do_runf(testfile, emcc_args=args, output_basename=name)
175+
self.do_runf(testfile, cflags=args, output_basename=name)
176176

177177
if name in expect_fail:
178178
f = unittest.expectedFailure(f)

test/test_sockets.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def PythonTcpEchoServerProcess(port):
158158

159159

160160
class sockets(BrowserCore):
161-
emcc_args: List[str] = []
161+
cflags: List[str] = []
162162

163163
@classmethod
164164
def setUpClass(cls):
@@ -185,15 +185,15 @@ def test_sockets_echo(self, harness_class, port, args):
185185
self.skipTest('requires native clang')
186186

187187
with harness_class(test_file('sockets/test_sockets_echo_server.c'), args, port) as harness:
188-
self.btest_exit('sockets/test_sockets_echo_client.c', emcc_args=['-DSOCKK=%d' % harness.listen_port] + args)
188+
self.btest_exit('sockets/test_sockets_echo_client.c', cflags=['-DSOCKK=%d' % harness.listen_port] + args)
189189

190190
def test_sockets_echo_pthreads(self):
191191
with CompiledServerHarness(test_file('sockets/test_sockets_echo_server.c'), [], 49161) as harness:
192-
self.btest_exit('sockets/test_sockets_echo_client.c', emcc_args=['-pthread', '-sPROXY_TO_PTHREAD', '-DSOCKK=%d' % harness.listen_port])
192+
self.btest_exit('sockets/test_sockets_echo_client.c', cflags=['-pthread', '-sPROXY_TO_PTHREAD', '-DSOCKK=%d' % harness.listen_port])
193193

194194
def test_sdl2_sockets_echo(self):
195195
with CompiledServerHarness('sockets/sdl2_net_server.c', ['-sUSE_SDL=2', '-sUSE_SDL_NET=2'], 49164) as harness:
196-
self.btest_exit('sockets/sdl2_net_client.c', emcc_args=['-sUSE_SDL=2', '-sUSE_SDL_NET=2', '-DSOCKK=%d' % harness.listen_port])
196+
self.btest_exit('sockets/sdl2_net_client.c', cflags=['-sUSE_SDL=2', '-sUSE_SDL_NET=2', '-DSOCKK=%d' % harness.listen_port])
197197

198198
@parameterized({
199199
'websockify': [WebsockifyServerHarness, 49166, ['-DTEST_DGRAM=0']],
@@ -208,12 +208,12 @@ def test_sockets_async_echo(self, harness_class, port, args):
208208

209209
args.append('-DTEST_ASYNC=1')
210210
with harness_class(test_file('sockets/test_sockets_echo_server.c'), args, port) as harness:
211-
self.btest_exit('sockets/test_sockets_echo_client.c', emcc_args=['-DSOCKK=%d' % harness.listen_port] + args)
211+
self.btest_exit('sockets/test_sockets_echo_client.c', cflags=['-DSOCKK=%d' % harness.listen_port] + args)
212212

213213
def test_sockets_async_bad_port(self):
214214
# Deliberately attempt a connection on a port that will fail to test the error callback and
215215
# getsockopt
216-
self.btest_exit('sockets/test_sockets_echo_client.c', emcc_args=['-DSOCKK=49169', '-DTEST_ASYNC=1'])
216+
self.btest_exit('sockets/test_sockets_echo_client.c', cflags=['-DSOCKK=49169', '-DTEST_ASYNC=1'])
217217

218218
@parameterized({
219219
'websockify': [WebsockifyServerHarness, 49171, ['-DTEST_DGRAM=0']],
@@ -235,7 +235,7 @@ def test_sockets_echo_bigdata(self, harness_class, port, args):
235235
create_file('test_sockets_echo_bigdata.c', src.replace('#define MESSAGE "pingtothepong"', '#define MESSAGE "%s"' % message))
236236

237237
with harness_class(test_file('sockets/test_sockets_echo_server.c'), args, port) as harness:
238-
self.btest_exit('test_sockets_echo_bigdata.c', emcc_args=[sockets_include, '-DSOCKK=%d' % harness.listen_port] + args)
238+
self.btest_exit('test_sockets_echo_bigdata.c', cflags=[sockets_include, '-DSOCKK=%d' % harness.listen_port] + args)
239239

240240
@no_windows('This test is Unix-specific.')
241241
def test_sockets_partial(self):
@@ -244,7 +244,7 @@ def test_sockets_partial(self):
244244
CompiledServerHarness(test_file('sockets/test_sockets_partial_server.c'), [], 49181),
245245
]:
246246
with harness:
247-
self.btest_exit('sockets/test_sockets_partial_client.c', assert_returncode=165, emcc_args=['-DSOCKK=%d' % harness.listen_port])
247+
self.btest_exit('sockets/test_sockets_partial_client.c', assert_returncode=165, cflags=['-DSOCKK=%d' % harness.listen_port])
248248

249249
@no_windows('This test is Unix-specific.')
250250
def test_sockets_select_server_down(self):
@@ -253,7 +253,7 @@ def test_sockets_select_server_down(self):
253253
CompiledServerHarness(test_file('sockets/test_sockets_select_server_down_server.c'), [], 49191),
254254
]:
255255
with harness:
256-
self.btest_exit('sockets/test_sockets_select_server_down_client.c', emcc_args=['-DSOCKK=%d' % harness.listen_port])
256+
self.btest_exit('sockets/test_sockets_select_server_down_client.c', cflags=['-DSOCKK=%d' % harness.listen_port])
257257

258258
@no_windows('This test is Unix-specific.')
259259
def test_sockets_select_server_closes_connection_rw(self):
@@ -262,7 +262,7 @@ def test_sockets_select_server_closes_connection_rw(self):
262262
CompiledServerHarness(test_file('sockets/test_sockets_echo_server.c'), ['-DCLOSE_CLIENT_AFTER_ECHO'], 49201),
263263
]:
264264
with harness:
265-
self.btest_exit('sockets/test_sockets_select_server_closes_connection_client_rw.c', emcc_args=['-DSOCKK=%d' % harness.listen_port])
265+
self.btest_exit('sockets/test_sockets_select_server_closes_connection_client_rw.c', cflags=['-DSOCKK=%d' % harness.listen_port])
266266

267267
@no_windows('This test uses Unix-specific build architecture.')
268268
def test_enet(self):
@@ -274,7 +274,7 @@ def test_enet(self):
274274
enet = [self.in_dir('enet', '.libs', 'libenet.a'), '-I' + self.in_dir('enet', 'include')]
275275

276276
with CompiledServerHarness(test_file('sockets/test_enet_server.c'), enet, 49210) as harness:
277-
self.btest_exit('sockets/test_enet_client.c', emcc_args=enet + ['-DSOCKK=%d' % harness.listen_port])
277+
self.btest_exit('sockets/test_enet_client.c', cflags=enet + ['-DSOCKK=%d' % harness.listen_port])
278278

279279
@crossplatform
280280
@parameterized({
@@ -290,10 +290,10 @@ def test_nodejs_sockets_echo(self, harness_class, port, args):
290290
# Basic test of node client against both a Websockified and compiled echo server.
291291
with harness_class(test_file('sockets/test_sockets_echo_server.c'), args, port) as harness:
292292
expected = 'do_msg_read: read 14 bytes'
293-
self.do_runf('sockets/test_sockets_echo_client.c', expected, emcc_args=['-DSOCKK=%d' % harness.listen_port] + args)
293+
self.do_runf('sockets/test_sockets_echo_client.c', expected, cflags=['-DSOCKK=%d' % harness.listen_port] + args)
294294

295295
def test_nodejs_sockets_connect_failure(self):
296-
self.do_runf('sockets/test_sockets_echo_client.c', 'connect failed: Connection refused', emcc_args=['-DSOCKK=666'], assert_returncode=NON_ZERO)
296+
self.do_runf('sockets/test_sockets_echo_client.c', 'connect failed: Connection refused', cflags=['-DSOCKK=666'], assert_returncode=NON_ZERO)
297297

298298
@requires_native_clang
299299
def test_nodejs_sockets_echo_subprotocol(self):
@@ -336,7 +336,7 @@ def test_nodejs_sockets_echo_subprotocol_runtime(self):
336336
})
337337
def test_websocket_send(self, args):
338338
with NodeJsWebSocketEchoServerProcess():
339-
self.btest_exit('websocket/test_websocket_send.c', emcc_args=['-lwebsocket', '-sNO_EXIT_RUNTIME', '-sWEBSOCKET_DEBUG'] + args)
339+
self.btest_exit('websocket/test_websocket_send.c', cflags=['-lwebsocket', '-sNO_EXIT_RUNTIME', '-sWEBSOCKET_DEBUG'] + args)
340340

341341
# Test that native POSIX sockets API can be used by proxying calls to an intermediate WebSockets
342342
# -> POSIX sockets bridge server
@@ -352,17 +352,17 @@ def test_posix_proxy_sockets(self):
352352
with BackgroundServerProcess([proxy_server, '8080']):
353353
with PythonTcpEchoServerProcess('7777'):
354354
# Build and run the TCP echo client program with Emscripten
355-
self.btest_exit('websocket/tcp_echo_client.c', emcc_args=['-lwebsocket', '-sPROXY_POSIX_SOCKETS', '-pthread', '-sPROXY_TO_PTHREAD'])
355+
self.btest_exit('websocket/tcp_echo_client.c', cflags=['-lwebsocket', '-sPROXY_POSIX_SOCKETS', '-pthread', '-sPROXY_TO_PTHREAD'])
356356

357357
# Test that calling send() right after a socket connect() works.
358358
def test_sockets_send_while_connecting(self):
359359
with NodeJsWebSocketEchoServerProcess():
360-
self.btest('sockets/test_sockets_send_while_connecting.c', emcc_args=['-DSOCKET_DEBUG'], expected='0')
360+
self.btest('sockets/test_sockets_send_while_connecting.c', cflags=['-DSOCKET_DEBUG'], expected='0')
361361

362362

363363
class sockets64(sockets):
364364
def setUp(self):
365365
super().setUp()
366366
self.set_setting('MEMORY64')
367-
self.emcc_args.append('-Wno-experimental')
367+
self.cflags.append('-Wno-experimental')
368368
self.require_wasm64()

0 commit comments

Comments
 (0)