Skip to content

Commit 5b6989c

Browse files
authored
Use check-xeus-cpp target to run C++ tests for both native and Emscripten platform (+ make build instructions consistent across files) (#386)
1 parent c7628c6 commit 5b6989c

File tree

6 files changed

+85
-86
lines changed

6 files changed

+85
-86
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
run: |
4343
echo "ncpus=$(nproc --all)" >> $GITHUB_ENV
4444
45-
- name: Build xeus-cpp
45+
- name: Build and test xeus-cpp in node, then install
4646
shell: bash -l {0}
4747
run: |
4848
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
@@ -64,9 +64,10 @@ jobs:
6464
-DSYSROOT_PATH=$SYSROOT_PATH \
6565
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON \
6666
..
67+
emmake make -j ${{ env.ncpus }} check-xeus-cpp
6768
emmake make -j ${{ env.ncpus }} install
6869
69-
- name: Test xeus-cpp C++ Emscripten
70+
- name: Test Emscripten xeus-cpp in browser
7071
shell: bash -l {0}
7172
run: |
7273
set -e
@@ -134,7 +135,6 @@ jobs:
134135
echo "Running test_xeus_cpp in Google Chrome"
135136
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="google-chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html
136137
fi
137-
node test_xeus_cpp.js
138138
timeout-minutes: 4
139139

140140
- name: Jupyter Lite integration

.github/workflows/main.yml

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -113,37 +113,23 @@ jobs:
113113
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON \
114114
${{ matrix.extra_cmake_flags }}
115115
116-
- name: build & install
116+
- name: build, run C++ tests & install
117117
if: ${{ runner.os == 'windows' }}
118118
shell: cmd /C call {0}
119119
run: |
120120
call C:\Users\runneradmin\micromamba-root\condabin\micromamba.bat activate xeus-cpp
121121
cd build
122122
set CL=/MP
123+
nmake check-xeus-cpp
123124
nmake install
124125
125-
- name: build & install
126+
- name: build, run C++ tests & install
126127
if: ${{ runner.os != 'windows' }}
127128
shell: bash -l {0}
128129
run: |
129130
cd build
130131
make install -j ${{ env.ncpus }}
131-
132-
- name: Test xeus-cpp C++ Unix Systems
133-
if: ${{ runner.os != 'windows' }}
134-
shell: bash -l {0}
135-
run: |
136-
cd build/test
137-
./test_xeus_cpp
138-
timeout-minutes: 4
139-
140-
- name: Test xeus-cpp C++ Windows Systems
141-
if: ${{ runner.os == 'windows' }}
142-
shell: cmd /C call {0}
143-
run: |
144-
call C:\Users\runneradmin\micromamba-root\condabin\micromamba.bat activate xeus-cpp
145-
cd build\test
146-
.\test_xeus_cpp.exe
132+
make -j ${{ env.ncpus }} check-xeus-cpp
147133
148134
- name: Python tests Unix Systems
149135
if: ${{ runner.os != 'windows' }}
@@ -225,7 +211,7 @@ jobs:
225211
echo "ncpus=$(nproc --all)" >> $GITHUB_ENV
226212
fi
227213
228-
- name: Build xeus-cpp
214+
- name: Build and test xeus-cpp in node, then install
229215
shell: bash -l {0}
230216
run: |
231217
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
@@ -247,9 +233,10 @@ jobs:
247233
-DSYSROOT_PATH=$SYSROOT_PATH \
248234
-DCMAKE_COMPILE_WARNING_AS_ERROR=ON \
249235
..
236+
emmake make -j ${{ env.ncpus }} check-xeus-cpp
250237
emmake make -j ${{ env.ncpus }} install
251238
252-
- name: Test xeus-cpp C++ Emscripten
239+
- name: Test Emscripten xeus-cpp in browser
253240
shell: bash -l {0}
254241
run: |
255242
export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-build
@@ -323,7 +310,6 @@ jobs:
323310
echo "Running test_xeus_cpp in Google Chrome"
324311
python ${{ env.BUILD_PREFIX }}/bin/emrun.py --browser="google-chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html
325312
fi
326-
node test_xeus_cpp.js
327313
timeout-minutes: 4
328314

329315
- name: Jupyter Lite integration

CONTRIBUTING.md

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,26 @@ micromamba create -f environment-dev.yml -y
3535
micromamba activate xeus-cpp
3636
```
3737

38-
You are now in a position to install xeus-cpp into this environment. You can do this by executing
38+
Now you can compile the kernel from the source and run the C++ tests by executing (replace `$CONDA_PREFIX` with a custom installation prefix if need be)
3939

4040
```bash
4141
mkdir build
4242
cd build
43-
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_PREFIX_PATH=$CONDA_PREFIX -D CMAKE_INSTALL_PREFIX=$CONDA_PREFIX -D CMAKE_INSTALL_LIBDIR=lib ..
44-
make install
43+
cmake .. -D CMAKE_PREFIX_PATH=$CONDA_PREFIX -D CMAKE_INSTALL_PREFIX=$CONDA_PREFIX -D CMAKE_INSTALL_LIBDIR=lib
44+
make check-xeus-cpp
4545
```
4646

47-
To check that everything is installed correctly you can run the c++ tests by executing the following
47+
and
4848

4949
```bash
50-
cd ./test
51-
./test_xeus_cpp
50+
cd ../../test
51+
pytest -sv test_xcpp_kernel.py
5252
```
5353

54-
and the python tests by executing
54+
to perform the python tests. After you have checked that the kernel passes all the tests, you can install it by executing
5555

5656
```bash
57-
cd ../../test
58-
pytest -sv test_xcpp_kernel.py
57+
make install
5958
```
6059

6160
## Setting up a development environment (wasm instructions)
@@ -75,14 +74,15 @@ micromamba create -f environment-wasm-build.yml -y
7574
micromamba activate xeus-cpp-wasm-build
7675
```
7776

78-
You are now in a position to build the xeus-cpp kernel. You build it by executing the following
77+
You are now in a position to build the xeus-cpp kernel. You build and test it in node by executing the following
78+
7979
```bash
8080
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
8181
mkdir build
8282
cd build
83-
export BUILD_TOOLS_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-build
83+
export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-build
8484
export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-host
85-
export SYSROOT_PATH=$BUILD_TOOLS_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot
85+
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot
8686

8787
emcmake cmake \
8888
-DCMAKE_BUILD_TYPE=Release \
@@ -91,14 +91,7 @@ emcmake cmake \
9191
-DCMAKE_FIND_ROOT_PATH=$PREFIX \
9292
-DSYSROOT_PATH=$SYSROOT_PATH \
9393
..
94-
emmake make install
95-
```
96-
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
94+
emmake make check-xeus-cpp
10295
```
10396

10497
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
@@ -155,6 +148,12 @@ echo "Running test_xeus_cpp in Google Chrome"
155148
python $BUILD_PREFIX/bin/emrun.py --browser="google-chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html
156149
```
157150

151+
After you have checked that the kernel passes all the tests, you can install it by executing
152+
153+
```bash
154+
emmake make install
155+
```
156+
158157
To build and test Jupyter Lite with this kernel locally you can execute the following
159158
```bash
160159
micromamba create -n xeus-lite-host jupyterlite-core=0.6 jupyter_server jupyterlite-xeus -c conda-forge

README.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,23 @@ micromamba create -f environment-dev.yml
5757
micromamba activate xeus-cpp
5858
micromamba install jupyterlab -c conda-forge
5959
```
60-
Now you can compile the kernel from the source by executing (replace `$CONDA_PREFIX` with a custom installation prefix if need be)
60+
Now you can compile the kernel from the source and run the C++ tests by executing (replace `$CONDA_PREFIX` with a custom installation prefix if need be)
6161
```bash
6262
mkdir build
6363
cd build
6464
cmake .. -D CMAKE_PREFIX_PATH=$CONDA_PREFIX -D CMAKE_INSTALL_PREFIX=$CONDA_PREFIX -D CMAKE_INSTALL_LIBDIR=lib
65-
make install
66-
```
67-
To test the build you execute the following to test the C++ tests
68-
```bash
69-
cd test
70-
./test_xeus_cpp
65+
make check-xeus-cpp
7166
```
7267
and
7368
```bash
7469
cd ../../test
7570
pytest -sv test_xcpp_kernel.py
7671
```
77-
to perform the python tests.
72+
to perform the python tests. After you have checked that the kernel passes all the tests, you can install it by executing
73+
74+
```bash
75+
make install
76+
```
7877

7978
## Installation within a mamba environment (wasm build instructions)
8079

@@ -91,7 +90,7 @@ micromamba create -f environment-wasm-build.yml -y
9190
micromamba activate xeus-cpp-wasm-build
9291
```
9392

94-
You are now in a position to build the xeus-cpp kernel. You build it by executing the following
93+
You are now in a position to build the xeus-cpp kernel. You build and test it in node by executing the following
9594
```bash
9695
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
9796
mkdir build
@@ -107,14 +106,7 @@ emcmake cmake \
107106
-DCMAKE_FIND_ROOT_PATH=$PREFIX \
108107
-DSYSROOT_PATH=$SYSROOT_PATH \
109108
..
110-
emmake make install
111-
```
112-
113-
To test the lite build you can execute the following to run the C++ tests built against emscripten in node
114-
115-
```bash
116-
cd test
117-
node test_xeus_cpp.js
109+
emmake make check-xeus-cpp
118110
```
119111

120112
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
@@ -171,6 +163,12 @@ echo "Running test_xeus_cpp in Google Chrome"
171163
python $BUILD_PREFIX/bin/emrun.py --browser="google-chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html
172164
```
173165

166+
After you have checked that the kernel passes all the tests, you can install it by executing
167+
168+
```bash
169+
emmake make install
170+
```
171+
174172
To build and test Jupyter Lite with this kernel locally you can execute the following
175173
```bash
176174
micromamba create -n xeus-lite-host jupyterlite-core=0.6 jupyter_server jupyterlite-xeus -c conda-forge

docs/source/InstallationAndUsage.rst

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,28 @@ this environment with mamba by executing the following
2525
micromamba activate xeus-cpp
2626
micromamba install jupyterlab -c conda-forge
2727
28-
Now you can compile the kernel from the source by executing (replace `$CONDA_PREFIX`
29-
with a custom installation prefix if need be)
28+
Now you can compile the kernel from the source and run the C++ tests by
29+
executing (replace `$CONDA_PREFIX` with a custom installation prefix if need be)
3030

3131
.. code-block:: bash
3232
33-
mkdir build && cd build
34-
cmake .. -D CMAKE_PREFIX_PATH=$CONDA_PREFIX -D CMAKE_INSTALL_PREFIX=$CONDA_PREFIX
35-
-D CMAKE_INSTALL_LIBDIR=lib
36-
make && make install
33+
mkdir build
34+
cd build
35+
cmake .. -D CMAKE_PREFIX_PATH=$CONDA_PREFIX -D CMAKE_INSTALL_PREFIX=$CONDA_PREFIX -D CMAKE_INSTALL_LIBDIR=lib
36+
make check-xeus-cpp
37+
38+
and
39+
40+
.. code-block:: bash
41+
42+
cd ../../test
43+
pytest -sv test_xcpp_kernel.py
44+
45+
to perform the python tests. After you have checked that the kernel passes all the tests, you can install it by executing
46+
47+
.. code-block:: bash
48+
49+
make install
3750
3851
Installation within a mamba environment (wasm build instructions)
3952
========================
@@ -55,32 +68,25 @@ the following
5568
micromamba create -f environment-wasm-build.yml -y
5669
micromamba activate xeus-cpp-wasm-build
5770
58-
You are now in a position to build the xeus-cpp kernel. You build it by executing the following
71+
You are now in a position to build the xeus-cpp kernel. You build and test it in node by executing the following
5972

6073
.. code-block:: bash
6174
6275
micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32
6376
mkdir build
6477
cd build
65-
export BUILD_TOOLS_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-build
78+
export BUILD_PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-build
6679
export PREFIX=$MAMBA_ROOT_PREFIX/envs/xeus-cpp-wasm-host
67-
export SYSROOT_PATH=$BUILD_TOOLS_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot
68-
emcmake cmake \
69-
-DCMAKE_BUILD_TYPE=Release \
70-
-DCMAKE_INSTALL_PREFIX=$PREFIX \
71-
-DXEUS_CPP_EMSCRIPTEN_WASM_BUILD=ON \
72-
-DCMAKE_FIND_ROOT_PATH=$PREFIX \
73-
-DSYSROOT_PATH=$SYSROOT_PATH \
74-
..
75-
emmake make install
80+
export SYSROOT_PATH=$BUILD_PREFIX/opt/emsdk/upstream/emscripten/cache/sysroot
7681
77-
78-
To test the lite build you can execute the following to run the C++ tests built against emscripten in node
79-
80-
.. code-block:: bash
81-
82-
cd test
83-
node test_xeus_cpp.js
82+
emcmake cmake \
83+
-DCMAKE_BUILD_TYPE=Release \
84+
-DCMAKE_INSTALL_PREFIX=$PREFIX \
85+
-DXEUS_CPP_EMSCRIPTEN_WASM_BUILD=ON \
86+
-DCMAKE_FIND_ROOT_PATH=$PREFIX \
87+
-DSYSROOT_PATH=$SYSROOT_PATH \
88+
..
89+
emmake make check-xeus-cpp
8490
8591
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
8692

@@ -136,6 +142,12 @@ To do this on Ubuntu x86 execute the following
136142
echo "Running test_xeus_cpp in Google Chrome"
137143
python $BUILD_PREFIX/bin/emrun.py --browser="google-chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" test_xeus_cpp.html
138144
145+
After you have checked that the kernel passes all the tests, you can install it by executing
146+
147+
.. code-block:: bash
148+
149+
emmake make install
150+
139151
To build and test Jupyter Lite with this kernel locally you can execute the following
140152

141153
.. code-block:: bash

test/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ if(EMSCRIPTEN)
9696
${CMAKE_CURRENT_BINARY_DIR}/libxeus.so
9797
COMMENT "Copying libxeus.so to the test directory"
9898
)
99+
add_custom_target(check-xeus-cpp
100+
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_CURRENT_BINARY_DIR} node test_xeus_cpp.js
101+
DEPENDS test_xeus_cpp
102+
)
99103
else()
100104
find_package(Threads)
101105

@@ -117,5 +121,5 @@ else()
117121
target_link_libraries(test_xeus_cpp xeus-cpp doctest::doctest ${CMAKE_THREAD_LIBS_INIT})
118122
target_include_directories(test_xeus_cpp PRIVATE ${XEUS_CPP_INCLUDE_DIR})
119123

120-
add_custom_target(xtest COMMAND test_xeus_cpp DEPENDS test_xeus_cpp)
124+
add_custom_target(check-xeus-cpp COMMAND test_xeus_cpp DEPENDS test_xeus_cpp)
121125
endif()

0 commit comments

Comments
 (0)