25
25
26
26
npm_checked = False
27
27
28
- EMTEST_SKIP_PYTHON_DEV_PACKAGES = int (os .getenv ('EMTEST_SKIP_PYTHON_DEV_PACKAGES' , '0' ))
29
28
EMTEST_SKIP_NODE_DEV_PACKAGES = int (os .getenv ('EMTEST_SKIP_NODE_DEV_PACKAGES' , '0' ))
30
29
31
30
32
- def requires_python_dev_packages (func ):
33
- assert callable (func )
34
-
35
- @common .wraps (func )
36
- def decorated (self , * args , ** kwargs ):
37
- if EMTEST_SKIP_PYTHON_DEV_PACKAGES :
38
- return self .skipTest ('python websockify based tests are disabled by EMTEST_SKIP_PYTHON_DEV_PACKAGES=1' )
39
- return func (self , * args , ** kwargs )
40
-
41
- return decorated
42
-
43
-
44
31
def clean_processes (processes ):
45
32
for p in processes :
46
33
if getattr (p , 'exitcode' , None ) is None and getattr (p , 'returncode' , None ) is None :
@@ -57,6 +44,15 @@ def clean_processes(processes):
57
44
pass
58
45
59
46
47
+ def import_websockify ():
48
+ sys .path .append (path_from_root ('out/python_deps' ))
49
+ try :
50
+ import websockify # type: ignore
51
+ return websockify
52
+ except ModuleNotFoundError :
53
+ raise Exception ('Unable to import module websockify. Run "./bootstrap" (or "python3 -m pip -r requirements-dev.txt --target out/python_deps" to install' ) from None
54
+
55
+
60
56
class WebsockifyServerHarness :
61
57
def __init__ (self , filename , args , listen_port , do_server_check = True ):
62
58
self .processes = []
@@ -77,10 +73,7 @@ def __enter__(self):
77
73
process = Popen ([os .path .abspath ('server' )])
78
74
self .processes .append (process )
79
75
80
- try :
81
- import websockify # type: ignore
82
- except ModuleNotFoundError :
83
- raise Exception ('Unable to import module websockify. Run "python3 -m pip install websockify" or set environment variable EMTEST_SKIP_PYTHON_DEV_PACKAGES=1 to skip this test.' ) from None
76
+ websockify = import_websockify ()
84
77
85
78
# start the websocket proxy
86
79
print ('running websockify on %d, forward to tcp %d' % (self .listen_port , self .target_port ), file = sys .stderr )
@@ -202,8 +195,6 @@ def setUpClass(cls):
202
195
def test_sockets_echo (self , harness_class , port , args ):
203
196
if harness_class == WebsockifyServerHarness and common .EMTEST_LACKS_NATIVE_CLANG :
204
197
self .skipTest ('requires native clang' )
205
- if harness_class == WebsockifyServerHarness and EMTEST_SKIP_PYTHON_DEV_PACKAGES :
206
- self .skipTest ('requires python websockify and EMTEST_SKIP_PYTHON_DEV_PACKAGES=1' )
207
198
if harness_class == CompiledServerHarness and EMTEST_SKIP_NODE_DEV_PACKAGES :
208
199
self .skipTest ('requires node ws and EMTEST_SKIP_NODE_DEV_PACKAGES=1' )
209
200
@@ -230,8 +221,6 @@ def test_sdl2_sockets_echo(self):
230
221
def test_sockets_async_echo (self , harness_class , port , args ):
231
222
if harness_class == WebsockifyServerHarness and common .EMTEST_LACKS_NATIVE_CLANG :
232
223
self .skipTest ('requires native clang' )
233
- if harness_class == WebsockifyServerHarness and EMTEST_SKIP_PYTHON_DEV_PACKAGES :
234
- self .skipTest ('requires python websockify and EMTEST_SKIP_PYTHON_DEV_PACKAGES=1' )
235
224
if harness_class == CompiledServerHarness and EMTEST_SKIP_NODE_DEV_PACKAGES :
236
225
self .skipTest ('requires node ws and EMTEST_SKIP_NODE_DEV_PACKAGES=1' )
237
226
@@ -252,8 +241,6 @@ def test_sockets_async_bad_port(self):
252
241
def test_sockets_echo_bigdata (self , harness_class , port , args ):
253
242
if harness_class == WebsockifyServerHarness and common .EMTEST_LACKS_NATIVE_CLANG :
254
243
self .skipTest ('requires native clang' )
255
- if harness_class == WebsockifyServerHarness and EMTEST_SKIP_PYTHON_DEV_PACKAGES :
256
- self .skipTest ('requires python websockify and EMTEST_SKIP_PYTHON_DEV_PACKAGES=1' )
257
244
if harness_class == CompiledServerHarness and EMTEST_SKIP_NODE_DEV_PACKAGES :
258
245
self .skipTest ('requires node ws and EMTEST_SKIP_NODE_DEV_PACKAGES=1' )
259
246
sockets_include = '-I' + test_file ('sockets' )
@@ -271,7 +258,6 @@ def test_sockets_echo_bigdata(self, harness_class, port, args):
271
258
self .btest_exit ('test_sockets_echo_bigdata.c' , cflags = [sockets_include , '-DSOCKK=%d' % harness .listen_port ] + args )
272
259
273
260
@no_windows ('This test is Unix-specific.' )
274
- @requires_python_dev_packages
275
261
@requires_dev_dependency ('ws' )
276
262
def test_sockets_partial (self ):
277
263
for harness in [
@@ -282,7 +268,6 @@ def test_sockets_partial(self):
282
268
self .btest_exit ('sockets/test_sockets_partial_client.c' , assert_returncode = 165 , cflags = ['-DSOCKK=%d' % harness .listen_port ])
283
269
284
270
@no_windows ('This test is Unix-specific.' )
285
- @requires_python_dev_packages
286
271
@requires_dev_dependency ('ws' )
287
272
def test_sockets_select_server_down (self ):
288
273
for harness in [
@@ -293,7 +278,6 @@ def test_sockets_select_server_down(self):
293
278
self .btest_exit ('sockets/test_sockets_select_server_down_client.c' , cflags = ['-DSOCKK=%d' % harness .listen_port ])
294
279
295
280
@no_windows ('This test is Unix-specific.' )
296
- @requires_python_dev_packages
297
281
@requires_dev_dependency ('ws' )
298
282
def test_sockets_select_server_closes_connection_rw (self ):
299
283
for harness in [
@@ -326,8 +310,6 @@ def test_enet(self):
326
310
def test_nodejs_sockets_echo (self , harness_class , port , args ):
327
311
if harness_class == WebsockifyServerHarness and common .EMTEST_LACKS_NATIVE_CLANG :
328
312
self .skipTest ('requires native clang' )
329
- if harness_class == WebsockifyServerHarness and EMTEST_SKIP_PYTHON_DEV_PACKAGES :
330
- self .skipTest ('requires python websockify and EMTEST_SKIP_PYTHON_DEV_PACKAGES=1' )
331
313
if harness_class == CompiledServerHarness and EMTEST_SKIP_NODE_DEV_PACKAGES :
332
314
self .skipTest ('requires node ws and EMTEST_SKIP_NODE_DEV_PACKAGES=1' )
333
315
@@ -340,7 +322,6 @@ def test_nodejs_sockets_connect_failure(self):
340
322
self .do_runf ('sockets/test_sockets_echo_client.c' , r'connect failed: (Connection refused|Host is unreachable)' , regex = True , cflags = ['-DSOCKK=666' ], assert_returncode = NON_ZERO )
341
323
342
324
@requires_native_clang
343
- @requires_python_dev_packages
344
325
def test_nodejs_sockets_echo_subprotocol (self ):
345
326
# Test against a Websockified server with compile time configured WebSocket subprotocol. We use a Websockified
346
327
# server because as long as the subprotocol list contains binary it will configure itself to accept binary
@@ -353,7 +334,6 @@ def test_nodejs_sockets_echo_subprotocol(self):
353
334
self .assertContained (['connect: ws://127.0.0.1:59168, base64,binary' , 'connect: ws://127.0.0.1:59168/, base64,binary' ], out )
354
335
355
336
@requires_native_clang
356
- @requires_python_dev_packages
357
337
def test_nodejs_sockets_echo_subprotocol_runtime (self ):
358
338
# Test against a Websockified server with runtime WebSocket configuration. We specify both url and subprotocol.
359
339
# In this test we have *deliberately* used the wrong port '-DSOCKK=12345' to configure the echo_client.c, so
0 commit comments