Skip to content

Commit a38a72a

Browse files
authored
Add launcher script for tests/runner.py (#13494)
This ensures we use the same version of python that is used by emscripten and emsdk. See emscripten-core/emsdk#706
1 parent 49d61bc commit a38a72a

File tree

12 files changed

+92
-59
lines changed

12 files changed

+92
-59
lines changed

.circleci/config.yml

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ executors:
1616
EMCC_CORES: "4"
1717
EMSDK_NOTTY: "1"
1818
EMTEST_WASI_SYSROOT: "~/wasi-sdk/wasi-sysroot"
19-
PYTHON_BIN: "python3"
2019
mac:
2120
environment:
2221
EMSDK_NOTTY: "1"
23-
PYTHON_BIN: "python3"
2422
macos:
2523
xcode: "12.2.0"
2624

@@ -74,30 +72,30 @@ commands:
7472
- run:
7573
name: clear cache
7674
command: |
77-
$PYTHON_BIN ./emcc.py --clear-cache
75+
./emcc --clear-cache
7876
build-libs-and-freeze:
7977
description: "Build all libraries, and freeze the cache"
8078
steps:
8179
- run:
8280
name: embuilder build ALL
8381
command: |
84-
$PYTHON_BIN ./embuilder.py build ALL
85-
$PYTHON_BIN tests/runner.py test_hello_world
82+
./embuilder build ALL
83+
./tests/runner test_hello_world
8684
- run:
8785
name: embuilder (LTO)
8886
command: |
89-
$PYTHON_BIN ./embuilder.py build MINIMAL --lto
90-
$PYTHON_BIN tests/runner.py test_hello_world
87+
./embuilder build MINIMAL --lto
88+
./tests/runner test_hello_world
9189
- run:
9290
name: embuilder (PIC)
9391
command: |
94-
$PYTHON_BIN ./embuilder.py build SYSTEM --pic
95-
$PYTHON_BIN tests/runner.py test_hello_world
92+
./embuilder build SYSTEM --pic
93+
./tests/runner test_hello_world
9694
- run:
9795
name: embuilder (PIC+LTO)
9896
command: |
99-
$PYTHON_BIN ./embuilder.py build MINIMAL --pic --lto
100-
$PYTHON_BIN tests/runner.py test_hello_world
97+
./embuilder build MINIMAL --pic --lto
98+
./tests/runner test_hello_world
10199
- run:
102100
name: freeze cache
103101
command: |
@@ -134,8 +132,8 @@ commands:
134132
- run:
135133
name: run tests
136134
command: |
137-
$PYTHON_BIN tests/runner.py << parameters.test_targets >>
138-
$PYTHON_BIN tools/check_clean.py
135+
./tests/runner << parameters.test_targets >>
136+
$EMSDK_PYTHON ./tools/check_clean.py
139137
run-tests-mac:
140138
description: "Runs emscripten tests"
141139
parameters:
@@ -157,8 +155,8 @@ commands:
157155
- run:
158156
name: run tests
159157
command: |
160-
python3 tests/runner.py << parameters.test_targets >>
161-
tools/check_clean.py
158+
./tests/runner << parameters.test_targets >>
159+
$EMSDK_PYTHON ./tools/check_clean.py
162160
test-firefox:
163161
description: "Runs emscripten tests under firefox"
164162
steps:
@@ -259,8 +257,8 @@ commands:
259257
EXTRA_AUTOSTART=$TMPDIR/autostart startx /usr/bin/openbox-session -- $DISPLAY -config ~/.config/X11/xorg.conf -nolisten tcp &
260258
cat $TMPDIR/fifo > /dev/null # wait until $EXTRA_AUTOSTART is spawned, which indicates the end of Openbox initialization
261259
rm -r $TMPDIR
262-
python3 tests/runner.py browser posixtest_browser.test_pthread_create_1_1 skip:browser.test_sdl2_mouse skip:browser.test_html5_webgl_create_context skip:browser.test_webgl_offscreen_canvas_in_pthread skip:browser.test_webgl_offscreen_canvas_in_mainthread_after_pthread skip:browser.test_glut_glutget
263-
python3 tests/runner.py emrun
260+
tests/runner browser posixtest_browser.test_pthread_create_1_1 skip:browser.test_sdl2_mouse skip:browser.test_html5_webgl_create_context skip:browser.test_webgl_offscreen_canvas_in_pthread skip:browser.test_webgl_offscreen_canvas_in_mainthread_after_pthread skip:browser.test_glut_glutget
261+
tests/runner emrun
264262
openbox --exit
265263
wait || true # wait for startx to shutdown cleanly, or not
266264
test-chrome:
@@ -294,8 +292,8 @@ commands:
294292
command: |
295293
export EMTEST_BROWSER="/usr/bin/google-chrome $CHROME_FLAGS_BASE $CHROME_FLAGS_HEADLESS $CHROME_FLAGS_WASM $CHROME_FLAGS_NOCACHE"
296294
# skip test_zzz_zzz_4gb_fail as it OOMs on the current bot
297-
python3 tests/runner.py browser posixtest_browser.test_pthread_create_1_1 skip:browser.test_zzz_zzz_4gb_fail
298-
python3 tests/runner.py emrun
295+
tests/runner browser posixtest_browser.test_pthread_create_1_1 skip:browser.test_zzz_zzz_4gb_fail
296+
tests/runner emrun
299297
test-sockets-chrome:
300298
description: "Runs emscripten sockets tests under chrome"
301299
steps:
@@ -323,7 +321,7 @@ commands:
323321
CHROME_FLAGS_NOCACHE: "--disk-cache-dir=/dev/null --disk-cache-size=1 --media-cache-size=1 --disable-application-cache --incognito"
324322
command: |
325323
export EMTEST_BROWSER="/usr/bin/google-chrome $CHROME_FLAGS_BASE $CHROME_FLAGS_HEADLESS $CHROME_FLAGS_WASM $CHROME_FLAGS_NOCACHE"
326-
python3 tests/runner.py sockets
324+
tests/runner sockets
327325
328326
jobs:
329327
build-docs:
@@ -446,9 +444,6 @@ jobs:
446444
name: win/vs2019
447445
shell: bash.exe -eo pipefail
448446
environment:
449-
# on windows the python binary is always called python.exe and never
450-
# python3.exe
451-
PYTHON_BIN: "python"
452447
PYTHONUNBUFFERED: "1"
453448
EMSDK_NOTTY: "1"
454449
# clang can compile but not link in the current setup, see

site/source/docs/getting_started/test-suite.rst

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,30 @@ how best to do that.
1818
Running tests
1919
=============
2020

21-
Run the test suite runner (`tests/runner.py <https://github.com/emscripten-core/emscripten/blob/master/tests/runner.py>`_) with no arguments to see the help message:
21+
Run the test suite runner (`tests/runner <https://github.com/emscripten-core/emscripten/blob/master/tests/runner.py>`_) with no arguments to see the help message:
2222

2323
.. code-block:: bash
2424
25-
python tests/runner.py
25+
tests/runner
2626
2727
The tests are divided into *modes*. You can run either an entire mode or an individual test, or use wildcards to run some tests in some modes. For example:
2828

2929
.. code-block:: bash
3030
3131
# run one test (in the default mode)
32-
python tests/runner.py test_loop
32+
tests/runner test_loop
3333
3434
# run one test in a specific mode (here, asm.js -O2)
35-
python tests/runner.py asm2.test_loop
35+
tests/runner asm2.test_loop
3636
3737
# run a test in a bunch of modes (here, all asm.js modes)
38-
python tests/runner.py asm*.test_loop
38+
tests/runner asm*.test_loop
3939
4040
# run a bunch of tests in one mode (here, all i64 tests in wasm -O3)
41-
python tests/runner.py wasm3.test_*i64*
41+
tests/runner wasm3.test_*i64*
4242
4343
# run all tests in a specific mode (here, asm.js -O1)
44-
python tests/runner.py asm1
44+
tests/runner asm1
4545
4646
The *core* test modes (defined at the bottom of `tests/test_core.py <https://github.com/emscripten-core/emscripten/blob/master/tests/test_core.py>`_) let you run a specific test in either asm.js or wasm, and with different optimization flags. There are also non-core test modes, that run tests in more special manner (in particular, in those tests it is not possible to say "run the test with a different optimization flag" - that is what the core tests are for). The non-core test modes include
4747

@@ -57,13 +57,13 @@ The wildcards we mentioned above work for non-core test modes too, for example:
5757
.. code-block:: bash
5858
5959
# run one browser test
60-
python tests/runner.py browser.test_sdl_image
60+
tests/runner browser.test_sdl_image
6161
6262
# run all SDL2 browser tests
63-
python tests/runner.py browser.test_sdl2*
63+
tests/runner browser.test_sdl2*
6464
6565
# run all browser tests
66-
python tests/runner.py browser
66+
tests/runner browser
6767
6868
Skipping Tests
6969
==============
@@ -72,13 +72,13 @@ An individual test can be skipped by passing the "skip:" prefix. E.g.
7272

7373
.. code-block:: bash
7474
75-
python tests/runner.py other skip:other.test_cmake
75+
tests/runner other skip:other.test_cmake
7676
7777
Wildcards can also be passed in skip, so
7878

7979
.. code-block:: bash
8080
81-
python tests/runner.py browser skip:browser.test_pthread_*
81+
tests/runner browser skip:browser.test_pthread_*
8282
8383
will run the whole browser suite except for all the pthread tests in it.
8484

@@ -89,7 +89,7 @@ You can run a random subset of the test suite, using something like
8989

9090
.. code-block:: bash
9191
92-
python tests/runner.py random100
92+
tests/runner random100
9393
9494
Replace ``100`` with another number as you prefer. This will run that number of random tests, and tell you the statistical likelihood of almost all the test suite passing assuming those tests do. This works just like election surveys do - given a small sample, we can predict fairly well that so-and-so percent of the public will vote for candidate A. In our case, the "candidates" are pass or fail, and we can predict how much of the test suite will pass given that sample. Assuming the sample tests all pass, we can say with high likelihood that most of the test suite will in fact pass. (Of course, this is no guarantee, and even a single test failure is serious, however, this gives a quick estimate that your patch does not cause significant and obvious breakage.)
9595

@@ -102,23 +102,23 @@ When you want to run the entire test suite locally, these are currently the impo
102102
.. code-block:: bash
103103
104104
# Run all core wasm tests
105-
python tests/runner.py wasm*
105+
tests/runner wasm*
106106
107107
# Run "other" test suite
108-
python tests/runner.py other
108+
tests/runner other
109109
110110
# Run "browser" test suite - this requires a web browser
111-
python tests/runner.py browser
111+
tests/runner browser
112112
113113
# Run "sockets" test suite - this requires a web browser too
114-
python tests/runner.py sockets
114+
tests/runner sockets
115115
116116
# Run "sanity" test suite - this tests setting up emscripten during
117117
# first run, etc., and so it modifies your .emscripten file temporarily.
118-
python tests/runner.py sanity
118+
tests/runner sanity
119119
120120
# Optionally, also run benchmarks to check for regressions
121-
python tests/runner.py benchmark
121+
tests/runner benchmark
122122
123123
.. _benchmarking:
124124

@@ -137,16 +137,16 @@ To run the benchmark suite, do:
137137
.. code-block:: bash
138138
139139
# Run all benchmarks
140-
python tests/runner.py benchmark
140+
tests/runner benchmark
141141
142142
As with all the test suites, you can also run a specific benchmark:
143143

144144
.. code-block:: bash
145145
146146
# Run one specific benchmark
147-
python tests/runner.py benchmark.test_skinning
147+
tests/runner benchmark.test_skinning
148148
149-
Usually you will want to customize the python in `tests/test_benchmark.py` to
149+
Usually you will want to customize the in `tests/test_benchmark.py` to
150150
run the benchmarks you want (there is currently no external config file). Things
151151
you may want to modify include:
152152

@@ -167,14 +167,14 @@ Setting the :ref:`debugging-EMCC_DEBUG` is useful for debugging tests, as it emi
167167
168168
# On Windows, use "set" to set and un-set the EMCC_DEBUG environment variable:
169169
set EMCC_DEBUG=1
170-
python tests/runner.py test_hello_world
170+
tests/runner test_hello_world
171171
set EMCC_DEBUG=0
172172
173173
# On Linux, you can do this all in one line
174-
EMCC_DEBUG=1 python tests/runner.py test_hello_world
174+
EMCC_DEBUG=1 tests/runner test_hello_world
175175
176176
# EMCC_DEBUG=2 generates additional debug information.
177-
EMCC_DEBUG=2 python tests/runner.py test_hello_world
177+
EMCC_DEBUG=2 tests/runner test_hello_world
178178
179179
180180
You can also specify ``EMTEST_SAVE_DIR=1`` in the environment to save the

src/library_sdl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//"use strict";
88

99
// See browser tests for examples (tests/runner.py, search for sdl_). Run with
10-
// python tests/runner.py browser
10+
// tests/runnery browser
1111

1212
// Notes:
1313
// SDL_VIDEORESIZE: This is sent when the canvas is resized. Note that the user

tests/runner

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/sh
2+
# Copyright 2020 The Emscripten Authors. All rights reserved.
3+
# Emscripten is available under two separate licenses, the MIT license and the
4+
# University of Illinois/NCSA Open Source License. Both these licenses can be
5+
# found in the LICENSE file.
6+
#
7+
# Entry point for running python scripts on UNIX systems.
8+
#
9+
# To modify this file, edit `tools/run_python.sh` and then run
10+
# `tools/create_entry_points.py`
11+
12+
if [ -z "$PYTHON" ]; then
13+
PYTHON=$EMSDK_PYTHON
14+
fi
15+
16+
if [ -z "$PYTHON" ]; then
17+
PYTHON=$(which python3 2> /dev/null)
18+
fi
19+
20+
if [ -z "$PYTHON" ]; then
21+
PYTHON=$(which python 2> /dev/null)
22+
fi
23+
24+
if [ -z "$PYTHON" ]; then
25+
echo 'unable to find python in $PATH'
26+
exit 1
27+
fi
28+
29+
exec "$PYTHON" "$0.py" "$@"

tests/runner.bat

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
:: Entry point for running python scripts on windows systems.
2+
:: To modify this file, edit `tools/run_python.bat` and then run
3+
:: `tools/create_entry_points.py`
4+
5+
@setlocal
6+
@set EM_PY=%EMSDK_PYTHON%
7+
@if "%EM_PY%"=="" (
8+
set EM_PY=python
9+
)
10+
11+
@"%EM_PY%" "%~dp0\%~n0.py" %*

tests/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""This is the Emscripten test runner. To run some tests, specify which tests
88
you want, for example
99
10-
python3 tests/runner.py asm1.test_hello_world
10+
tests/runner asm1.test_hello_world
1111
1212
There are many options for which tests to run and how to run them. For details,
1313
see

tests/test_browser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2467,7 +2467,7 @@ def test_cpuprofiler_memoryprofiler(self):
24672467
self.btest('hello_world_gles.c', expected='0', args=['-DLONGTEST=1', '-DTEST_MEMORYPROFILER_ALLOCATIONS_MAP=1', '-O2', '--cpuprofiler', '--memoryprofiler', '-lGL', '-lglut', '-DANIMATE'])
24682468

24692469
def test_uuid(self):
2470-
# Run with ./runner.py browser.test_uuid
2470+
# Run with ./runner browser.test_uuid
24712471
# We run this test in Node/SPIDERMONKEY and browser environments because we try to make use of
24722472
# high quality crypto random number generators such as crypto.getRandomValues or randomBytes (if available).
24732473

tests/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from functools import wraps
1717

1818
if __name__ == '__main__':
19-
raise Exception('do not run this file directly; do something like: tests/runner.py')
19+
raise Exception('do not run this file directly; do something like: tests/runner')
2020

2121
from tools.shared import try_delete, PIPE
2222
from tools.shared import PYTHON, EMCC, EMAR

tests/test_other.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from subprocess import PIPE, STDOUT
2727

2828
if __name__ == '__main__':
29-
raise Exception('do not run this file directly; do something like: tests/runner.py other')
29+
raise Exception('do not run this file directly; do something like: tests/runner other')
3030

3131
from tools.shared import try_delete, config
3232
from tools.shared import EMCC, EMXX, EMAR, EMRANLIB, PYTHON, FILE_PACKAGER, WINDOWS, EM_BUILD_VERBOSE
@@ -2472,7 +2472,6 @@ def test_demangle_malloc_infinite_loop_crash(self):
24722472
def test_module_exports_with_closure(self):
24732473
# This test checks that module.export is retained when JavaScript is minified by compiling with --closure 1
24742474
# This is important as if module.export is not present the Module object will not be visible to node.js
2475-
# Run with ./runner.py other.test_module_exports_with_closure
24762475

24772476
# First make sure test.js isn't present.
24782477
self.clear()

tests/test_sanity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
from runner import RunnerCore, path_from_root, env_modify
1616
from runner import create_test_file, ensure_dir, make_executable
1717
from tools.config import config_file, EM_CONFIG
18-
from tools.shared import PYTHON, EMCC
18+
from tools.shared import EMCC
1919
from tools.shared import CANONICAL_TEMP_DIR
2020
from tools.shared import try_delete, config
2121
from tools.shared import EXPECTED_LLVM_VERSION, Cache
2222
from tools import shared, system_libs, utils
2323

2424
SANITY_FILE = shared.Cache.get_path('sanity.txt')
25-
commands = [[EMCC], [PYTHON, path_from_root('tests', 'runner.py'), 'blahblah']]
25+
commands = [[EMCC], [path_from_root('tests', 'runner'), 'blahblah']]
2626

2727

2828
def restore():

0 commit comments

Comments
 (0)