Skip to content

Commit 8b0a90f

Browse files
committed
Enable safari automated testing
1 parent e3c6373 commit 8b0a90f

File tree

6 files changed

+60
-2
lines changed

6 files changed

+60
-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 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 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
@@ -570,6 +570,14 @@ jobs:
570570
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html
571571
echo "Running DynamicLibraryManagerTests in Google Chrome"
572572
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html
573+
sudo safaridriver --enable
574+
python -m pip install selenium
575+
echo "Running CppInterOpTests in Safari"
576+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html &
577+
python browser_tests_safari.py CppInterOpTests.html
578+
echo "Running DynamicLibraryManagerTests in Safari"
579+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html &
580+
python browser_tests_safari.py DynamicLibraryManagerTests.html
573581
else
574582
export ARCHITECHURE=$(uname -m)
575583
if [[ "$ARCHITECHURE" != "aarch64" ]]; then
@@ -705,6 +713,12 @@ jobs:
705713
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html
706714
echo "Running DynamicLibraryManagerTests in Google Chrome"
707715
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html
716+
echo "Running CppInterOpTests in Safari"
717+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html &
718+
python browser_tests_safari.py CppInterOpTests.html
719+
echo "Running DynamicLibraryManagerTests in Safari"
720+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html &
721+
python browser_tests_safari.py DynamicLibraryManagerTests.html
708722
else
709723
export ARCHITECHURE=$(uname -m)
710724
if [[ "$ARCHITECHURE" != "aarch64" ]]; then

Emscripten-build-instructions.md

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

224-
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
224+
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
225225

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

251+
To run tests in Safari you can make use of safaridriver. How to enable this will depend on
252+
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
253+
python package. This only needs to be enable once, and then you can execute the following to run the tests in Safari
254+
255+
```bash
256+
echo "Running CppInterOpTests in Safari"
257+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html &
258+
python browser_tests_safari.py CppInterOpTests.html
259+
echo "Running DynamicLibraryManagerTests in Safari"
260+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html &
261+
python browser_tests_safari.py DynamicLibraryManagerTests.html
262+
```
263+
251264
To do this on Ubuntu x86 execute the following
252265

253266
```bash

docs/Emscripten-build-instructions.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ It is possible to run the Emscripten tests in a headless browser. To do this we
244244
245245
cd ./unittests/CppInterOp/
246246
247-
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
247+
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
248248

249249
.. code:: bash
250250
@@ -271,6 +271,19 @@ We will run our tests in a fresh installed browser. Installing the browsers, and
271271
echo "Running DynamicLibraryManagerTests in Google Chrome"
272272
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html
273273
274+
To run tests in Safari you can make use of safaridriver. How to enable this will depend on
275+
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
276+
python package. This only needs to be enable once, and then you can execute the following to run the tests in Safari
277+
278+
.. code:: bash
279+
280+
echo "Running CppInterOpTests in Safari"
281+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html &
282+
python browser_tests_safari.py CppInterOpTests.html
283+
echo "Running DynamicLibraryManagerTests in Safari"
284+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html &
285+
python browser_tests_safari.py DynamicLibraryManagerTests.html
286+
274287
To do this on Ubuntu x86 execute the following
275288

276289
.. 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()

unittests/CppInterOp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
file(COPY ${CMAKE_SOURCE_DIR}/scripts/browser_tests_safari.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
12
if (EMSCRIPTEN)
23
# So we create a html file, as well as the javascript file
34
set(CMAKE_EXECUTABLE_SUFFIX ".html")

0 commit comments

Comments
 (0)