Skip to content

Commit 42090f6

Browse files
committed
Run Emscripten tests in a browser
1 parent 66510a4 commit 42090f6

File tree

6 files changed

+258
-13
lines changed

6 files changed

+258
-13
lines changed

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

+55
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
pushd build
5252
5353
export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-build
54+
echo "BUILD_PREFIX=$BUILD_PREFIX" >> $GITHUB_ENV
5455
export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-host
5556
echo "PREFIX=$PREFIX" >> $GITHUB_ENV
5657
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot
@@ -64,6 +65,60 @@ jobs:
6465
..
6566
emmake make -j ${{ env.ncpus }} install
6667
68+
- name: Test xeus-cpp C++ Emscripten
69+
shell: bash -l {0}
70+
run: |
71+
set -e
72+
micromamba create -n xeus-lite-host jupyterlite-core
73+
micromamba activate xeus-lite-host
74+
cd build/test
75+
os="${{ matrix.os }}"
76+
if [[ "${os}" == "macos"* ]]; then
77+
# Install Firefox
78+
wget "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" -O Firefox-latest.dmg
79+
hdiutil attach Firefox-latest.dmg
80+
cp -r /Volumes/Firefox/Firefox.app $PWD
81+
hdiutil detach /Volumes/Firefox
82+
cd ./Firefox.app/Contents/MacOS/
83+
export PATH="$PWD:$PATH"
84+
cd –
85+
86+
# Install Google Chrome
87+
wget https://dl.google.com/chrome/mac/stable/accept_tos%3Dhttps%253A%252F%252Fwww.google.com%252Fintl%252Fen_ph%252Fchrome%252Fterms%252F%26_and_accept_tos%3Dhttps%253A%252F%252Fpolicies.google.com%252Fterms/googlechrome.pkg
88+
pkgutil --expand-full googlechrome.pkg google-chrome
89+
cd ./google-chrome/GoogleChrome.pkg/Payload/Google\ Chrome.app/Contents/MacOS/
90+
export PATH="$PWD:$PATH"
91+
cd –
92+
93+
# Run tests in browsers
94+
echo "Running test_xeus_cpp in Firefox"
95+
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="firefox" --kill_exit --browser-args="--headless" test_xeus_cpp.html
96+
echo "Running test_xeus_cpp in Google Chrome"
97+
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="Google Chrome" --kill_exit --browser-args="--headless" test_xeus_cpp.html
98+
else
99+
# Install Google Chrome
100+
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
101+
dpkg-deb -x google-chrome-stable_current_amd64.deb $PWD/chrome
102+
cd ./chrome/opt/google/chrome/
103+
export PATH="$PWD:$PATH"
104+
cd -
105+
106+
# Install Firefox
107+
wget https://ftp.mozilla.org/pub/firefox/releases/138.0.1/linux-x86_64/en-GB/firefox-138.0.1.tar.xz
108+
tar -xJf firefox-138.0.1.tar.xz
109+
cd ./firefox
110+
export PATH="$PWD:$PATH"
111+
cd -
112+
113+
# Run tests in browsers
114+
echo "Running test_xeus_cpp in Firefox"
115+
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="firefox" --kill_exit --timeout 60 --browser-args="--headless" test_xeus_cpp.html
116+
echo "Running test_xeus_cpp in Google Chrome"
117+
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="google-chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html
118+
fi
119+
node test_xeus_cpp.js
120+
timeout-minutes: 4
121+
67122
- name: Jupyter Lite integration
68123
shell: bash -l {0}
69124
run: |

.github/workflows/main.yml

+46
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ jobs:
234234
pushd build
235235
236236
export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-build
237+
echo "BUILD_PREFIX=$BUILD_PREFIX" >> $GITHUB_ENV
237238
export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-host
238239
echo "PREFIX=$PREFIX" >> $GITHUB_ENV
239240
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot
@@ -250,10 +251,55 @@ jobs:
250251
- name: Test xeus-cpp C++ Emscripten
251252
shell: bash -l {0}
252253
run: |
254+
export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-build
253255
set -e
254256
micromamba create -n xeus-lite-host jupyterlite-core
255257
micromamba activate xeus-lite-host
256258
cd build/test
259+
os="${{ matrix.os }}"
260+
if [[ "${os}" == "macos"* ]]; then
261+
# Install Firefox
262+
wget "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" -O Firefox-latest.dmg
263+
hdiutil attach Firefox-latest.dmg
264+
cp -r /Volumes/Firefox/Firefox.app $PWD
265+
hdiutil detach /Volumes/Firefox
266+
cd ./Firefox.app/Contents/MacOS/
267+
export PATH="$PWD:$PATH"
268+
cd -
269+
270+
# Install Google Chrome
271+
wget https://dl.google.com/chrome/mac/stable/accept_tos%3Dhttps%253A%252F%252Fwww.google.com%252Fintl%252Fen_ph%252Fchrome%252Fterms%252F%26_and_accept_tos%3Dhttps%253A%252F%252Fpolicies.google.com%252Fterms/googlechrome.pkg
272+
pkgutil --expand-full googlechrome.pkg google-chrome
273+
cd ./google-chrome/GoogleChrome.pkg/Payload/Google\ Chrome.app/Contents/MacOS/
274+
export PATH="$PWD:$PATH"
275+
cd -
276+
277+
# Run tests in browsers
278+
echo "Running test_xeus_cpp in Firefox"
279+
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="firefox" --kill_exit --timeout 60 --browser-args="--headless" test_xeus_cpp.html
280+
echo "Running test_xeus_cpp in Google Chrome"
281+
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless" test_xeus_cpp.html
282+
else
283+
# Install Google Chrome
284+
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
285+
dpkg-deb -x google-chrome-stable_current_amd64.deb $PWD/chrome
286+
cd ./chrome/opt/google/chrome/
287+
export PATH="$PWD:$PATH"
288+
cd -
289+
290+
# Install Firefox
291+
wget https://ftp.mozilla.org/pub/firefox/releases/138.0.1/linux-x86_64/en-GB/firefox-138.0.1.tar.xz
292+
tar -xJf firefox-138.0.1.tar.xz
293+
cd ./firefox
294+
export PATH="$PWD:$PATH"
295+
cd -
296+
297+
# Run tests in browsers
298+
echo "Running test_xeus_cpp in Firefox"
299+
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="firefox" --kill_exit --timeout 60 --browser-args="--headless" test_xeus_cpp.html
300+
echo "Running test_xeus_cpp in Google Chrome"
301+
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="google-chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html
302+
fi
257303
node test_xeus_cpp.js
258304
timeout-minutes: 4
259305

CONTRIBUTING.md

+51-6
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,57 @@ emcmake cmake \
9494
emmake make install
9595
```
9696

97+
To test the lite build you can execute the following to run the C++ tests built against emscripten in node
98+
99+
```bash
100+
cd test
101+
node test_xeus_cpp.js
102+
```
103+
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
105+
106+
```bash
107+
wget "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" -O Firefox-latest.dmg
108+
hdiutil attach Firefox-latest.dmg
109+
cp -r /Volumes/Firefox/Firefox.app $PWD
110+
hdiutil detach /Volumes/Firefox
111+
cd ./Firefox.app/Contents/MacOS/
112+
export PATH="$PWD:$PATH"
113+
cd
114+
115+
wget https://dl.google.com/chrome/mac/stable/accept_tos%3Dhttps%253A%252F%252Fwww.google.com%252Fintl%252Fen_ph%252Fchrome%252Fterms%252F%26_and_accept_tos%3Dhttps%253A%252F%252Fpolicies.google.com%252Fterms/googlechrome.pkg
116+
pkgutil --expand-full googlechrome.pkg google-chrome
117+
cd ./google-chrome/GoogleChrome.pkg/Payload/Google\ Chrome.app/Contents/MacOS/
118+
export PATH="$PWD:$PATH"
119+
cd
120+
121+
echo "Running test_xeus_cpp in Firefox"
122+
python $BUILD_PREFIX/bin/emrun.py --browser="firefox" --kill_exit --browser-args="--headless" test_xeus_cpp.html
123+
echo "Running test_xeus_cpp in Google Chrome"
124+
python $BUILD_PREFIX/bin/emrun.py --browser="Google Chrome" --kill_exit --browser-args="--headless" test_xeus_cpp.html
125+
```
126+
127+
To do this on Ubuntu x86 execute the following
128+
129+
```bash
130+
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
131+
dpkg-deb -x google-chrome-stable_current_amd64.deb $PWD/chrome
132+
cd ./chrome/opt/google/chrome/
133+
export PATH="$PWD:$PATH"
134+
cd -
135+
136+
wget https://ftp.mozilla.org/pub/firefox/releases/138.0.1/linux-x86_64/en-GB/firefox-138.0.1.tar.xz
137+
tar -xJf firefox-138.0.1.tar.xz
138+
cd ./firefox
139+
export PATH="$PWD:$PATH"
140+
cd -
141+
142+
echo "Running test_xeus_cpp in Firefox"
143+
python $BUILD_PREFIX/bin/emrun.py --browser="firefox" --kill_exit --timeout 60 --browser-args="--headless" test_xeus_cpp.html
144+
echo "Running test_xeus_cpp in Google Chrome"
145+
python $BUILD_PREFIX/bin/emrun.py --browser="google-chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html
146+
```
147+
97148
To build Jupyter Lite with this kernel without creating a website you can execute the following
98149
```bash
99150
micromamba create -n xeus-lite-host jupyterlite-core -c conda-forge
@@ -106,9 +157,3 @@ Once the Jupyter Lite site has built you can test the website locally by executi
106157
```bash
107158
jupyter lite serve --XeusAddon.prefix=$PREFIX
108159
```
109-
110-
To test the lite build you can execute the following to run the C++ tests built against emscripten
111-
```bash
112-
cd test
113-
node test_xeus_cpp.js
114-
```

README.md

+51-6
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,57 @@ emcmake cmake \
9595
emmake make install
9696
```
9797

98+
To test the lite build you can execute the following to run the C++ tests built against emscripten in node
99+
100+
```bash
101+
cd test
102+
node test_xeus_cpp.js
103+
```
104+
105+
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
106+
107+
```bash
108+
wget "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" -O Firefox-latest.dmg
109+
hdiutil attach Firefox-latest.dmg
110+
cp -r /Volumes/Firefox/Firefox.app $PWD
111+
hdiutil detach /Volumes/Firefox
112+
cd ./Firefox.app/Contents/MacOS/
113+
export PATH="$PWD:$PATH"
114+
cd -
115+
116+
wget https://dl.google.com/chrome/mac/stable/accept_tos%3Dhttps%253A%252F%252Fwww.google.com%252Fintl%252Fen_ph%252Fchrome%252Fterms%252F%26_and_accept_tos%3Dhttps%253A%252F%252Fpolicies.google.com%252Fterms/googlechrome.pkg
117+
pkgutil --expand-full googlechrome.pkg google-chrome
118+
cd ./google-chrome/GoogleChrome.pkg/Payload/Google\ Chrome.app/Contents/MacOS/
119+
export PATH="$PWD:$PATH"
120+
cd -
121+
122+
echo "Running test_xeus_cpp in Firefox"
123+
python $BUILD_PREFIX/bin/emrun.py --browser="firefox" --kill_exit --timeout 60 --browser-args="--headless" test_xeus_cpp.html
124+
echo "Running test_xeus_cpp in Google Chrome"
125+
python python $BUILD_PREFIX/bin/emrun.py --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless" test_xeus_cpp.html
126+
```
127+
128+
To do this on Ubuntu x86 execute the following
129+
130+
```bash
131+
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
132+
dpkg-deb -x google-chrome-stable_current_amd64.deb $PWD/chrome
133+
cd ./chrome/opt/google/chrome/
134+
export PATH="$PWD:$PATH"
135+
cd -
136+
137+
wget https://ftp.mozilla.org/pub/firefox/releases/138.0.1/linux-x86_64/en-GB/firefox-138.0.1.tar.xz
138+
tar -xJf firefox-138.0.1.tar.xz
139+
cd ./firefox
140+
export PATH="$PWD:$PATH"
141+
cd -
142+
143+
echo "Running test_xeus_cpp in Firefox"
144+
python $BUILD_PREFIX/bin/emrun.py --browser="firefox" --kill_exit --timeout 60 --browser-args="--headless" test_xeus_cpp.html
145+
echo "Running test_xeus_cpp in Google Chrome"
146+
python $BUILD_PREFIX/bin/emrun.py --browser="google-chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html
147+
```
148+
98149
To build Jupyter Lite with this kernel without creating a website you can execute the following
99150
```bash
100151
micromamba create -n xeus-lite-host jupyterlite-core -c conda-forge
@@ -108,12 +159,6 @@ Once the Jupyter Lite site has built you can test the website locally by executi
108159
jupyter lite serve --XeusAddon.prefix=$PREFIX
109160
```
110161

111-
To test the lite build you can execute the following to run the C++ tests built against emscripten
112-
```bash
113-
cd test
114-
node test_xeus_cpp.js
115-
```
116-
117162
## Trying it online
118163

119164
To try out xeus-cpp interactively in your web browser, just click on the binder link:

docs/source/InstallationAndUsage.rst

+51
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,57 @@ You are now in a position to build the xeus-cpp kernel. You build it by executin
8282
emmake make install
8383
8484
85+
To test the lite build you can execute the following to run the C++ tests built against emscripten in node
86+
87+
.. code-block:: bash
88+
89+
cd test
90+
node test_xeus_cpp.js
91+
92+
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
93+
94+
.. code-block:: bash
95+
96+
wget "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" -O Firefox-latest.dmg
97+
hdiutil attach Firefox-latest.dmg
98+
cp -r /Volumes/Firefox/Firefox.app $PWD
99+
hdiutil detach /Volumes/Firefox
100+
cd ./Firefox.app/Contents/MacOS/
101+
export PATH="$PWD:$PATH"
102+
cd -
103+
104+
wget https://dl.google.com/chrome/mac/stable/accept_tos%3Dhttps%253A%252F%252Fwww.google.com%252Fintl%252Fen_ph%252Fchrome%252Fterms%252F%26_and_accept_tos%3Dhttps%253A%252F%252Fpolicies.google.com%252Fterms/googlechrome.pkg
105+
pkgutil --expand-full googlechrome.pkg google-chrome
106+
cd ./google-chrome/GoogleChrome.pkg/Payload/Google\ Chrome.app/Contents/MacOS/
107+
export PATH="$PWD:$PATH"
108+
cd -
109+
110+
echo "Running test_xeus_cpp in Firefox"
111+
python $BUILD_PREFIX/bin/emrun.py --browser="firefox" --kill_exit --timeout 60 --browser-args="--headless" test_xeus_cpp.html
112+
echo "Running test_xeus_cpp in Google Chrome"
113+
python $BUILD_PREFIX/bin/emrun.py --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless" test_xeus_cpp.html
114+
115+
To do this on Ubuntu x86 execute the following
116+
117+
.. code-block:: bash
118+
119+
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
120+
dpkg-deb -x google-chrome-stable_current_amd64.deb $PWD/chrome
121+
cd ./chrome/opt/google/chrome/
122+
export PATH="$PWD:$PATH"
123+
cd -
124+
125+
wget https://ftp.mozilla.org/pub/firefox/releases/138.0.1/linux-x86_64/en-GB/firefox-138.0.1.tar.xz
126+
tar -xJf firefox-138.0.1.tar.xz
127+
cd ./firefox
128+
export PATH="$PWD:$PATH"
129+
cd -
130+
131+
echo "Running test_xeus_cpp in Firefox"
132+
python $BUILD_PREFIX/bin/emrun.py --browser="firefox" --kill_exit --timeout 60 --browser-args="--headless" test_xeus_cpp.html
133+
echo "Running test_xeus_cpp in Google Chrome"
134+
python $BUILD_PREFIX/bin/emrun.py --browser="google-chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html
135+
85136
To build Jupyter Lite with this kernel without creating a website you can execute the following
86137

87138
.. code-block:: bash

test/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ if(EMSCRIPTEN)
5656
target_compile_options(test_xeus_cpp
5757
PUBLIC "SHELL: -fexceptions"
5858
)
59-
59+
set_target_properties(test_xeus_cpp PROPERTIES
60+
SUFFIX ".html"
61+
)
6062
target_link_options(test_xeus_cpp
6163
PUBLIC "SHELL: -fexceptions"
6264
PUBLIC "SHELL: -s MAIN_MODULE=1"
@@ -69,6 +71,7 @@ if(EMSCRIPTEN)
6971
PUBLIC "SHELL: --preload-file ${SYSROOT_PATH}/include@/include"
7072
PUBLIC "SHELL: --preload-file ../${XEUS_CPP_DATA_DIR}@/share/xeus-cpp"
7173
PUBLIC "SHELL: --preload-file ../${XEUS_CPP_CONF_DIR}@/etc/xeus-cpp"
74+
PUBLIC "SHELL: --emrun"
7275
)
7376

7477
target_include_directories(test_xeus_cpp PRIVATE ${XEUS_CPP_INCLUDE_DIR})

0 commit comments

Comments
 (0)