diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6e20b99..1a72cd0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -132,11 +132,19 @@ jobs: uses: py-actions/py-dependency-install@v3 with: path: "requirements.txt" + - name: Install node + uses: actions/setup-node@v3 + with: + node-version: 20.9.0 + - name: Install browserify + run: npm install -g browserify - name: Setup EMSDK uses: mymindstorm/setup-emsdk@v11 with: version: 3.1.44 - - name: Use local djinni djinni + - name: Install chrome + uses: browser-actions/setup-chrome@latest + - name: Use local djinni on branch for now if: ${{ github.ref != 'refs/heads/master' }} run: export CMAKE_DJINNI_OPT="-DDJINNI_EXECUTABLE=$(pwd)/bin/djinni" - name: Report cmake version @@ -145,7 +153,8 @@ jobs: run: cmake -DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -S . -B build -DDJINNI_WITH_WASM=ON -DDJINNI_EXECUTABLE=$(pwd)/bin/djinni - name: Build release run: cmake --build build --parallel $(nproc) --config Release - + - name: Run headless test + run: pushd build && ctest --output-on-failure build-on-windows-for-cppcli: runs-on: windows-latest diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 4e7d0bb..c5dcaec 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -71,7 +71,6 @@ if(DJINNI_WITH_WASM) ) set(WASM_CC_FLAGS "-s MAIN_MODULE=1 -fexceptions") - message(WARNING ${WASM_CC_FLAGS}) set_target_properties(${DjinniTextsortWasm} PROPERTIES COMPILE_FLAGS ${WASM_CC_FLAGS}) string(JOIN " " EMSCRIPTEN_LINK_OPTIONS @@ -83,7 +82,6 @@ if(DJINNI_WITH_WASM) ) set(WASM_LINK_FLAGS "${EMSCRIPTEN_LINK_OPTIONS} -fexceptions") - message(WARNING ${WASM_LINK_FLAGS}) set_target_properties(${DjinniTextsortWasm} PROPERTIES LINK_FLAGS ${WASM_LINK_FLAGS}) set(CMAKE_EXECUTABLE_SUFFIX ".js") diff --git a/requirements.txt b/requirements.txt index fc947f6..19d6b76 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ cffi==1.14.5 future==0.18.2 pytest==6.2.5 +selenium==4.15.2 diff --git a/test-suite/CMakeLists.txt b/test-suite/CMakeLists.txt index fa918a6..c4480f8 100644 --- a/test-suite/CMakeLists.txt +++ b/test-suite/CMakeLists.txt @@ -240,7 +240,6 @@ if(DJINNI_WITH_WASM) ) set(WASM_CC_FLAGS "-s MAIN_MODULE=1 -fexceptions") - message(WARNING ${WASM_CC_FLAGS}) set_target_properties(${DjinniWasmTest} PROPERTIES COMPILE_FLAGS ${WASM_CC_FLAGS}) string(JOIN " " EMSCRIPTEN_LINK_OPTIONS @@ -252,7 +251,6 @@ if(DJINNI_WITH_WASM) ) set(WASM_LINK_FLAGS "${EMSCRIPTEN_LINK_OPTIONS} -fexceptions") - message(WARNING ${WASM_LINK_FLAGS}) set_target_properties(${DjinniWasmTest} PROPERTIES LINK_FLAGS ${WASM_LINK_FLAGS}) set(CMAKE_EXECUTABLE_SUFFIX ".js") diff --git a/test-suite/handwritten-src/ts/run-tests-selenium.py b/test-suite/handwritten-src/ts/run-tests-selenium.py index f97bb30..76c4643 100755 --- a/test-suite/handwritten-src/ts/run-tests-selenium.py +++ b/test-suite/handwritten-src/ts/run-tests-selenium.py @@ -7,7 +7,7 @@ import sys import threading -port = 8089 +port = "8080" httpd = HTTPServer(("127.0.0.1", int(port)), SimpleHTTPRequestHandler) def run_server(): @@ -19,16 +19,19 @@ def run_server(): service = Service(executable_path=r'/usr/bin/chromedriver') options = webdriver.ChromeOptions() -#options.add_argument('--headless') +options.add_argument('--headless') options.add_argument('--no-sandbox') options.add_argument('--disable-dev-shm-usage') options.add_argument('--disable-gpu') driver = webdriver.Chrome(service=service, options=options) print(f"connecting web driver to http://localhost:{port}/") driver.get(f"http://localhost:{port}/test.html") -#element = driver.find_element(By.NAME, "query") -#assert element.is_enabled() +failed_elements = driver.find_elements(By.XPATH, "//pre[@id='output']/span[contains(text(), 'FAILED')]") +for element in failed_elements: + print(f"{element.text}", file=sys.stderr) driver.quit() -finished_tests = True httpd.shutdown() server_thread.join() +if len(failed_elements) > 0: + exit(1) +exit(0) diff --git a/test-suite/handwritten-src/ts/run.sh b/test-suite/handwritten-src/ts/run.sh index 55cbef1..3d20f6c 100755 --- a/test-suite/handwritten-src/ts/run.sh +++ b/test-suite/handwritten-src/ts/run.sh @@ -1,6 +1,10 @@ #! /usr/bin/env bash +#! /usr/bin/env bash set -eu +# compile TS tsc +# bundle browserify main.js -o bundle.js -sleep 1 && python3 -mwebbrowser http://localhost:8000/test.html & -python3 -m http.server +# then run the selenium tests +sleep 1 && python3 run-tests-selenium.py +