From 608489e61ef7709c56c621ea326ffef20182ae60 Mon Sep 17 00:00:00 2001 From: mcbarton Date: Mon, 21 Jul 2025 22:04:17 +0100 Subject: [PATCH 1/3] Enable safari automated testing --- .github/workflows/deploy-pages.yml | 8 ++++++++ .github/workflows/emscripten.yml | 14 ++++++++++++++ Emscripten-build-instructions.md | 15 ++++++++++++++- docs/Emscripten-build-instructions.rst | 15 ++++++++++++++- scripts/browser_tests_safari.py | 9 +++++++++ unittests/CppInterOp/CMakeLists.txt | 1 + 6 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 scripts/browser_tests_safari.py diff --git a/.github/workflows/deploy-pages.yml b/.github/workflows/deploy-pages.yml index e6f352d29..81c2764c4 100644 --- a/.github/workflows/deploy-pages.yml +++ b/.github/workflows/deploy-pages.yml @@ -168,6 +168,14 @@ jobs: emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html echo "Running DynamicLibraryManagerTests in Google Chrome" emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html + sudo safaridriver --enable + python -m pip install selenium + echo "Running CppInterOpTests in Safari" + emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html & + python browser_tests_safari.py CppInterOpTests.html + echo "Running DynamicLibraryManagerTests in Safari" + emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html & + python browser_tests_safari.py DynamicLibraryManagerTests.html cd ../../ emmake make -j ${{ env.ncpus }} install diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 139aac715..69d323692 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -571,6 +571,14 @@ jobs: emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html echo "Running DynamicLibraryManagerTests in Google Chrome" emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html + sudo safaridriver --enable + python -m pip install selenium + echo "Running CppInterOpTests in Safari" + emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html & + python browser_tests_safari.py CppInterOpTests.html + echo "Running DynamicLibraryManagerTests in Safari" + emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html & + python browser_tests_safari.py DynamicLibraryManagerTests.html else export ARCHITECHURE=$(uname -m) if [[ "$ARCHITECHURE" != "aarch64" ]]; then @@ -706,6 +714,12 @@ jobs: emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html echo "Running DynamicLibraryManagerTests in Google Chrome" emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html + echo "Running CppInterOpTests in Safari" + emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html & + python browser_tests_safari.py CppInterOpTests.html + echo "Running DynamicLibraryManagerTests in Safari" + emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html & + python browser_tests_safari.py DynamicLibraryManagerTests.html else export ARCHITECHURE=$(uname -m) if [[ "$ARCHITECHURE" != "aarch64" ]]; then diff --git a/Emscripten-build-instructions.md b/Emscripten-build-instructions.md index 3d93edd4c..694cdd80f 100644 --- a/Emscripten-build-instructions.md +++ b/Emscripten-build-instructions.md @@ -222,7 +222,7 @@ It is possible to run the Emscripten tests in a headless browser. To do this we cd ./unittests/CppInterOp/ ``` -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 +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 ```bash wget "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US" -O Firefox-latest.dmg @@ -249,6 +249,19 @@ echo "Running DynamicLibraryManagerTests in Google Chrome" emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html ``` +To run tests in Safari you can make use of safaridriver. How to enable this will depend on +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 +python package. This only needs to be enable once, and then you can execute the following to run the tests in Safari + +```bash +echo "Running CppInterOpTests in Safari" +emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html & +python browser_tests_safari.py CppInterOpTests.html +echo "Running DynamicLibraryManagerTests in Safari" +emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html & +python browser_tests_safari.py DynamicLibraryManagerTests.html +``` + To do this on Ubuntu x86 execute the following ```bash diff --git a/docs/Emscripten-build-instructions.rst b/docs/Emscripten-build-instructions.rst index 5ed5032e9..5e4794a44 100644 --- a/docs/Emscripten-build-instructions.rst +++ b/docs/Emscripten-build-instructions.rst @@ -245,7 +245,7 @@ It is possible to run the Emscripten tests in a headless browser. To do this we cd ./unittests/CppInterOp/ -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 +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 .. code:: bash @@ -272,6 +272,19 @@ We will run our tests in a fresh installed browser. Installing the browsers, and echo "Running DynamicLibraryManagerTests in Google Chrome" emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html +To run tests in Safari you can make use of safaridriver. How to enable this will depend on +your MacOS operating system, and is best to consult `safaridriver `_. You will also need to install the Selenium +python package. This only needs to be enable once, and then you can execute the following to run the tests in Safari + +.. code:: bash + + echo "Running CppInterOpTests in Safari" + emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html & + python browser_tests_safari.py CppInterOpTests.html + echo "Running DynamicLibraryManagerTests in Safari" + emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html & + python browser_tests_safari.py DynamicLibraryManagerTests.html + To do this on Ubuntu x86 execute the following .. code:: bash diff --git a/scripts/browser_tests_safari.py b/scripts/browser_tests_safari.py new file mode 100644 index 000000000..4210c22a5 --- /dev/null +++ b/scripts/browser_tests_safari.py @@ -0,0 +1,9 @@ +import sys +import time +from selenium import webdriver + +driver = webdriver.Safari() +driver.get("http://localhost:6931/" + sys.argv[1]) + +time.sleep(60) +driver.quit() diff --git a/unittests/CppInterOp/CMakeLists.txt b/unittests/CppInterOp/CMakeLists.txt index 4b4b43bdd..7fb1d187c 100644 --- a/unittests/CppInterOp/CMakeLists.txt +++ b/unittests/CppInterOp/CMakeLists.txt @@ -1,3 +1,4 @@ +file(COPY ${CMAKE_SOURCE_DIR}/scripts/browser_tests_safari.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) if (EMSCRIPTEN) # So we create a html file, as well as the javascript file set(CMAKE_EXECUTABLE_SUFFIX ".html") From 6b23b41ff8f72b4496770bbc38f8397f6e9b01b0 Mon Sep 17 00:00:00 2001 From: mcbarton Date: Thu, 31 Jul 2025 13:30:59 +0100 Subject: [PATCH 2/3] Use relative path to browser_tests_safari rather than copying to test folder --- .github/workflows/deploy-pages.yml | 4 ++-- .github/workflows/emscripten.yml | 4 ++-- Emscripten-build-instructions.md | 4 ++-- docs/Emscripten-build-instructions.rst | 4 ++-- unittests/CppInterOp/CMakeLists.txt | 1 - 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deploy-pages.yml b/.github/workflows/deploy-pages.yml index 81c2764c4..b5981f7da 100644 --- a/.github/workflows/deploy-pages.yml +++ b/.github/workflows/deploy-pages.yml @@ -172,10 +172,10 @@ jobs: python -m pip install selenium echo "Running CppInterOpTests in Safari" emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html & - python browser_tests_safari.py CppInterOpTests.html + python ../../../scripts/browser_tests_safari.py CppInterOpTests.html echo "Running DynamicLibraryManagerTests in Safari" emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html & - python browser_tests_safari.py DynamicLibraryManagerTests.html + python ../../../scripts/browser_tests_safari.py DynamicLibraryManagerTests.html cd ../../ emmake make -j ${{ env.ncpus }} install diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 69d323692..a1003e990 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -575,10 +575,10 @@ jobs: python -m pip install selenium echo "Running CppInterOpTests in Safari" emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html & - python browser_tests_safari.py CppInterOpTests.html + python ../../../scripts/browser_tests_safari.py CppInterOpTests.html echo "Running DynamicLibraryManagerTests in Safari" emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html & - python browser_tests_safari.py DynamicLibraryManagerTests.html + python ../../../scripts/browser_tests_safari.py DynamicLibraryManagerTests.html else export ARCHITECHURE=$(uname -m) if [[ "$ARCHITECHURE" != "aarch64" ]]; then diff --git a/Emscripten-build-instructions.md b/Emscripten-build-instructions.md index 694cdd80f..673859374 100644 --- a/Emscripten-build-instructions.md +++ b/Emscripten-build-instructions.md @@ -256,10 +256,10 @@ python package. This only needs to be enable once, and then you can execute the ```bash echo "Running CppInterOpTests in Safari" emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html & -python browser_tests_safari.py CppInterOpTests.html +python ../../../scripts/browser_tests_safari.py CppInterOpTests.html echo "Running DynamicLibraryManagerTests in Safari" emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html & -python browser_tests_safari.py DynamicLibraryManagerTests.html +python ../../../scripts/browser_tests_safari.py DynamicLibraryManagerTests.html ``` To do this on Ubuntu x86 execute the following diff --git a/docs/Emscripten-build-instructions.rst b/docs/Emscripten-build-instructions.rst index 5e4794a44..e336a6399 100644 --- a/docs/Emscripten-build-instructions.rst +++ b/docs/Emscripten-build-instructions.rst @@ -280,10 +280,10 @@ python package. This only needs to be enable once, and then you can execute the echo "Running CppInterOpTests in Safari" emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html & - python browser_tests_safari.py CppInterOpTests.html + python ../../../scripts/browser_tests_safari.py CppInterOpTests.html echo "Running DynamicLibraryManagerTests in Safari" emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html & - python browser_tests_safari.py DynamicLibraryManagerTests.html + python ../../../scripts/browser_tests_safari.py DynamicLibraryManagerTests.html To do this on Ubuntu x86 execute the following diff --git a/unittests/CppInterOp/CMakeLists.txt b/unittests/CppInterOp/CMakeLists.txt index 7fb1d187c..4b4b43bdd 100644 --- a/unittests/CppInterOp/CMakeLists.txt +++ b/unittests/CppInterOp/CMakeLists.txt @@ -1,4 +1,3 @@ -file(COPY ${CMAKE_SOURCE_DIR}/scripts/browser_tests_safari.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) if (EMSCRIPTEN) # So we create a html file, as well as the javascript file set(CMAKE_EXECUTABLE_SUFFIX ".html") From 1e839a89d7baca684ba741ac1cf6203aef9ffcdf Mon Sep 17 00:00:00 2001 From: mcbarton Date: Thu, 31 Jul 2025 18:32:56 +0100 Subject: [PATCH 3/3] Update static library Safari tests to use relative path --- .github/workflows/emscripten.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index a1003e990..96dd3a375 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -716,10 +716,10 @@ jobs: emrun --browser="Google Chrome" --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html echo "Running CppInterOpTests in Safari" emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" CppInterOpTests.html & - python browser_tests_safari.py CppInterOpTests.html + python ../../../scripts/browser_tests_safari.py CppInterOpTests.html echo "Running DynamicLibraryManagerTests in Safari" emrun --no_browser --kill_exit --timeout 60 --browser-args="--headless --no-sandbox" DynamicLibraryManagerTests.html & - python browser_tests_safari.py DynamicLibraryManagerTests.html + python ../../../scripts/browser_tests_safari.py DynamicLibraryManagerTests.html else export ARCHITECHURE=$(uname -m) if [[ "$ARCHITECHURE" != "aarch64" ]]; then