Skip to content

Commit b7ab5ae

Browse files
authored
Run browser tests in safari (#684)
1 parent 7902b82 commit b7ab5ae

File tree

5 files changed

+59
-2
lines changed

5 files changed

+59
-2
lines changed

.github/workflows/deploy-pages.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@ jobs:
168168
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html
169169
echo "Running DynamicLibraryManagerTests in Google Chrome"
170170
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html
171+
sudo safaridriver --enable
172+
python -m pip install selenium
173+
echo "Running CppInterOpTests in Safari"
174+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html &
175+
python ../../../scripts/browser_tests_safari.py CppInterOpTests.html
176+
echo "Running DynamicLibraryManagerTests in Safari"
177+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html &
178+
python ../../../scripts/browser_tests_safari.py DynamicLibraryManagerTests.html
171179
172180
cd ../../
173181
emmake make -j ${{ env.ncpus }} install

.github/workflows/emscripten.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,14 @@ jobs:
571571
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html
572572
echo "Running DynamicLibraryManagerTests in Google Chrome"
573573
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html
574+
sudo safaridriver --enable
575+
python -m pip install selenium
576+
echo "Running CppInterOpTests in Safari"
577+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html &
578+
python ../../../scripts/browser_tests_safari.py CppInterOpTests.html
579+
echo "Running DynamicLibraryManagerTests in Safari"
580+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html &
581+
python ../../../scripts/browser_tests_safari.py DynamicLibraryManagerTests.html
574582
else
575583
export ARCHITECHURE=$(uname -m)
576584
if [[ "$ARCHITECHURE" != "aarch64" ]]; then
@@ -706,6 +714,12 @@ jobs:
706714
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html
707715
echo "Running DynamicLibraryManagerTests in Google Chrome"
708716
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html
717+
echo "Running CppInterOpTests in Safari"
718+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html &
719+
python ../../../scripts/browser_tests_safari.py CppInterOpTests.html
720+
echo "Running DynamicLibraryManagerTests in Safari"
721+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html &
722+
python ../../../scripts/browser_tests_safari.py DynamicLibraryManagerTests.html
709723
else
710724
export ARCHITECHURE=$(uname -m)
711725
if [[ "$ARCHITECHURE" != "aarch64" ]]; then

Emscripten-build-instructions.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ It is possible to run the Emscripten tests in a headless browser. To do this we
222222
cd ./unittests/CppInterOp/
223223
```
224224

225-
We will run our tests in a fresh installed browser. Installing the browsers, and running the tests within the installed browsers will be platform dependent. To do this on MacOS execute the following
225+
We will run our tests in a fresh installed browser. Installing the browsers, and running the tests within the installed browsers will be platform dependent. To do this for Chrome and Firefox on MacOS execute the following
226226

227227
```bash
228228
wget "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" -O Firefox-latest.dmg
@@ -249,6 +249,19 @@ echo "Running DynamicLibraryManagerTests in Google Chrome"
249249
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html
250250
```
251251

252+
To run tests in Safari you can make use of safaridriver. How to enable this will depend on
253+
your MacOS operating system, and is best to consult [safaridriver](https://developer.apple.com/documentation/webkit/testing-with-webdriver-in-safari). You will also need to install the Selenium
254+
python package. This only needs to be enable once, and then you can execute the following to run the tests in Safari
255+
256+
```bash
257+
echo "Running CppInterOpTests in Safari"
258+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html &
259+
python ../../../scripts/browser_tests_safari.py CppInterOpTests.html
260+
echo "Running DynamicLibraryManagerTests in Safari"
261+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html &
262+
python ../../../scripts/browser_tests_safari.py DynamicLibraryManagerTests.html
263+
```
264+
252265
To do this on Ubuntu x86 execute the following
253266

254267
```bash

docs/Emscripten-build-instructions.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ It is possible to run the Emscripten tests in a headless browser. To do this we
245245
246246
cd ./unittests/CppInterOp/
247247
248-
We will run our tests in a fresh installed browser. Installing the browsers, and running the tests within the installed browsers will be platform dependent. To do this on MacOS execute the following
248+
We will run our tests in a fresh installed browser. Installing the browsers, and running the tests within the installed browsers will be platform dependent. To do this for Chrome and Firefox on MacOS execute the following
249249

250250
.. code:: bash
251251
@@ -272,6 +272,19 @@ We will run our tests in a fresh installed browser. Installing the browsers, and
272272
echo "Running DynamicLibraryManagerTests in Google Chrome"
273273
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html
274274
275+
To run tests in Safari you can make use of safaridriver. How to enable this will depend on
276+
your MacOS operating system, and is best to consult `safaridriver <https://developer.apple.com/documentation/webkit/testing-with-webdriver-in-safari>`_. You will also need to install the Selenium
277+
python package. This only needs to be enable once, and then you can execute the following to run the tests in Safari
278+
279+
.. code:: bash
280+
281+
echo "Running CppInterOpTests in Safari"
282+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html &
283+
python ../../../scripts/browser_tests_safari.py CppInterOpTests.html
284+
echo "Running DynamicLibraryManagerTests in Safari"
285+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html &
286+
python ../../../scripts/browser_tests_safari.py DynamicLibraryManagerTests.html
287+
275288
To do this on Ubuntu x86 execute the following
276289

277290
.. code:: bash

scripts/browser_tests_safari.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import sys
2+
import time
3+
from selenium import webdriver
4+
5+
driver = webdriver.Safari()
6+
driver.get("http://localhost:6931/" + sys.argv[1])
7+
8+
time.sleep(60)
9+
driver.quit()

0 commit comments

Comments
 (0)