Skip to content

Commit adcf86a

Browse files
committed
Run browser tests in safari
1 parent 3f5166e commit adcf86a

File tree

5 files changed

+48
-4
lines changed

5 files changed

+48
-4
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ jobs:
297297
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="firefox" --kill_exit --timeout 60 --browser-args="--headless" test_xeus_cpp.html
298298
echo "Running test_xeus_cpp in Google Chrome"
299299
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html
300+
sudo safaridriver --enable
301+
python -m pip install selenium
302+
echo "Running test_xeus_cpp in Safari"
303+
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html &
304+
python ../../scripts/browser_tests_safari.py test_xeus_cpp.html
300305
else
301306
# Install Google Chrome
302307
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

CONTRIBUTING.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ cd test
101101
node test_xeus_cpp.js
102102
```
103103

104-
It is possible to run the Emscripten tests in a headless browser. 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
104+
It is possible to run the Emscripten tests in a headless browser. 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
105105

106106
```bash
107107
wget "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" -O Firefox-latest.dmg
@@ -124,6 +124,16 @@ echo "Running test_xeus_cpp in Google Chrome"
124124
python $BUILD_PREFIX/bin/emrun.py --browser="Google Chrome" --kill_exit --browser-args="--headless --no-sandbox" test_xeus_cpp.html
125125
```
126126

127+
To run tests in Safari you can make use of safaridriver. How to enable this will depend on
128+
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
129+
python package. This only needs to be enable once, and then you can execute the following to run the tests in Safari
130+
131+
```bash
132+
echo "Running test_xeus_cpp in Safari"
133+
python $BUILD_PREFIX/bin/emrun.py --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html &
134+
python ../../scripts/browser_tests_safari.py test_xeus_cpp.html
135+
```
136+
127137
To do this on Ubuntu x86 execute the following
128138

129139
```bash
@@ -157,4 +167,4 @@ jupyter lite serve --XeusAddon.prefix=$PREFIX \
157167
--contents notebooks/smallpt.ipynb \
158168
--contents notebooks/images/marie.png \
159169
--contents notebooks/audio/audio.wav
160-
```
170+
```

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ cd test
113113
node test_xeus_cpp.js
114114
```
115115

116-
It is possible to run the Emscripten tests in a headless browser. 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
116+
It is possible to run the Emscripten tests in a headless browser. 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
117117

118118
```bash
119119
wget "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" -O Firefox-latest.dmg
@@ -136,6 +136,16 @@ echo "Running test_xeus_cpp in Google Chrome"
136136
python python $BUILD_PREFIX/bin/emrun.py --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html
137137
```
138138

139+
To run tests in Safari you can make use of safaridriver. How to enable this will depend on
140+
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
141+
python package. This only needs to be enable once, and then you can execute the following to run the tests in Safari
142+
143+
```bash
144+
echo "Running test_xeus_cpp in Safari"
145+
python $BUILD_PREFIX/bin/emrun.py --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html &
146+
python ../../scripts/browser_tests_safari.py test_xeus_cpp.html
147+
```
148+
139149
To do this on Ubuntu x86 execute the following
140150

141151
```bash

docs/source/InstallationAndUsage.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ To test the lite build you can execute the following to run the C++ tests built
8282
cd test
8383
node test_xeus_cpp.js
8484
85-
It is possible to run the Emscripten tests in a headless browser. 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
85+
It is possible to run the Emscripten tests in a headless browser. 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
8686

8787
.. code-block:: bash
8888
@@ -105,6 +105,16 @@ It is possible to run the Emscripten tests in a headless browser. We will run ou
105105
echo "Running test_xeus_cpp in Google Chrome"
106106
python $BUILD_PREFIX/bin/emrun.py --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html
107107
108+
To run tests in Safari you can make use of safaridriver. How to enable this will depend on
109+
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
110+
python package. This only needs to be enable once, and then you can execute the following to run the tests in Safari
111+
112+
.. code-block:: bash
113+
114+
echo "Running test_xeus_cpp in Safari"
115+
python $BUILD_PREFIX/bin/emrun.py --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html &
116+
python ../../scripts/browser_tests_safari.py test_xeus_cpp.html
117+
108118
To do this on Ubuntu x86 execute the following
109119

110120
.. code-block:: 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)