Skip to content

Commit 34e8bf8

Browse files
committed
Run browser tests in safari
1 parent 23e11aa commit 34e8bf8

File tree

7 files changed

+53
-3
lines changed

7 files changed

+53
-3
lines changed

.github/workflows/deploy-github-page.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ jobs:
113113
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="firefox" --kill_exit --browser-args="--headless" test_xeus_cpp.html
114114
echo "Running test_xeus_cpp in Google Chrome"
115115
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="Google Chrome" --kill_exit --browser-args="--headless" test_xeus_cpp.html
116+
sudo safaridriver --enable
117+
python -m pip install selenium
118+
echo "Running test_xeus_cpp in Safari"
119+
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html &
120+
python browser_tests_safari.py test_xeus_cpp.html
116121
else
117122
# Install Google Chrome
118123
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

.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 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: 11 additions & 1 deletion
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+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html &
134+
python browser_tests_safari.py test_xeus_cpp.html
135+
```
136+
127137
To do this on Ubuntu x86 execute the following
128138

129139
```bash

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+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html &
146+
python 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+
emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html &
116+
python 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()

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ set(XEUS_CPP_TESTS
5151
add_executable(test_xeus_cpp ${XEUS_CPP_TESTS})
5252

5353
if(EMSCRIPTEN)
54+
file(COPY ${CMAKE_SOURCE_DIR}/scripts/browser_tests_safari.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
5455
target_link_libraries(test_xeus_cpp PRIVATE xeus-cpp-static doctest::doctest)
5556

5657
target_compile_options(test_xeus_cpp

0 commit comments

Comments
 (0)