Skip to content

Commit 27adc2d

Browse files
committed
Enable safari automated testing
1 parent 82f08c6 commit 27adc2d

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
@@ -564,6 +564,14 @@ jobs:
564564
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html
565565
echo "Running DynamicLibraryManagerTests in Google Chrome"
566566
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html
567+
sudo safaridriver --enable
568+
python -m pip install selenium
569+
echo "Running CppInterOpTests in Safari"
570+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html &
571+
python browser_tests_safari.py CppInterOpTests.html
572+
echo "Running DynamicLibraryManagerTests in Safari"
573+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html &
574+
python browser_tests_safari.py DynamicLibraryManagerTests.html
567575
else
568576
export ARCHITECHURE=$(uname -m)
569577
if [[ "$ARCHITECHURE" != "aarch64" ]]; then
@@ -699,6 +707,12 @@ jobs:
699707
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html
700708
echo "Running DynamicLibraryManagerTests in Google Chrome"
701709
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html
710+
echo "Running CppInterOpTests in Safari"
711+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html &
712+
python browser_tests_safari.py CppInterOpTests.html
713+
echo "Running DynamicLibraryManagerTests in Safari"
714+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html &
715+
python browser_tests_safari.py DynamicLibraryManagerTests.html
702716
else
703717
export ARCHITECHURE=$(uname -m)
704718
if [[ "$ARCHITECHURE" != "aarch64" ]]; then

Emscripten-build-instructions.md

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

218-
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
218+
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
219219

220220
```bash
221221
wget "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" -O Firefox-latest.dmg
@@ -242,6 +242,19 @@ echo "Running DynamicLibraryManagerTests in Google Chrome"
242242
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html
243243
```
244244

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

247260
```bash

docs/Emscripten-build-instructions.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ It is possible to run the Emscripten tests in a headless browser. To do this we
238238
239239
cd ./unittests/CppInterOp/
240240
241-
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
241+
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
242242

243243
.. code:: bash
244244
@@ -265,6 +265,19 @@ We will run our tests in a fresh installed browser. Installing the browsers, and
265265
echo "Running DynamicLibraryManagerTests in Google Chrome"
266266
emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html
267267
268+
To run tests in Safari you can make use of safaridriver. How to enable this will depend on
269+
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
270+
python package. This only needs to be enable once, and then you can execute the following to run the tests in Safari
271+
272+
.. code:: bash
273+
274+
echo "Running CppInterOpTests in Safari"
275+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html &
276+
python browser_tests_safari.py CppInterOpTests.html
277+
echo "Running DynamicLibraryManagerTests in Safari"
278+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html &
279+
python browser_tests_safari.py DynamicLibraryManagerTests.html
280+
268281
To do this on Ubuntu x86 execute the following
269282

270283
.. 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)