Skip to content

Commit

Permalink
Also run demo app as headless on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mutagene committed Nov 26, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 07ed123 commit e945626
Showing 6 changed files with 57 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -155,6 +155,8 @@ jobs:
run: cmake --build build --parallel $(nproc) --config Release
- name: Run headless test
run: pushd build && ctest --output-on-failure
- name: Run integration test on sample app
run: pushd build/examples && ./run.sh && python3 run-tests-selenium.py

build-on-windows-for-cppcli:
runs-on: windows-latest
Binary file modified bin/djinni
Binary file not shown.
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ add_djinni_target(DjinniTextSort
WASM_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/wasm"
TS_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/ts"
TS_MODULE "example"
TS_SUPPORT_FILES_OUT "${CMAKE_CURRENT_BINARY_DIR}/ts-support-lib"
YAML_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/yaml"
YAML_PREFIX "test_"

53 changes: 53 additions & 0 deletions examples/ts/run-tests-selenium.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#! /usr/bin/env python3

from http.server import HTTPServer, SimpleHTTPRequestHandler
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
import sys
import time
import threading

port = "8050"
httpd = HTTPServer(("127.0.0.1", int(port)), SimpleHTTPRequestHandler)

def run_server():
print("Serving HTTP on localhost port " + port + " (http://localhost:" + port + "/) ...")
httpd.serve_forever()

server_thread = threading.Thread(target=run_server)
server_thread.start()

service = Service(executable_path=r'/usr/bin/chromedriver')
options = webdriver.ChromeOptions()
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}/demo.html")
asc_button = driver.find_element(By.ID, "btnAsc")
desc_button = driver.find_element(By.ID, "btnDesc")

asc_button.click()
print("Wait for Asc button press")
time.sleep(0.5)
value = driver.find_element(By.ID, "txt").get_attribute("value")
is_ascending_ok = value == "item1\nitem2\nitem3\nitem4\nitem5"
print(f"text area on Sort Asc pressed:\n{value}")
desc_button.click()
print("Wait for Desc button press")
time.sleep(0.5)
value = driver.find_element(By.ID, "txt").get_attribute("value")
print(f"text area on Sort Desc pressed:\n{value}")
is_descending_ok = value == "item5\nitem4\nitem3\nitem2\nitem1"

driver.quit()
httpd.shutdown()
server_thread.join()
if is_ascending_ok and is_descending_ok:
exit(0)
print(f"is_ascending_ok = {is_ascending_ok}")
print(f"is_descending_ok = {is_descending_ok}")
exit(1)
2 changes: 0 additions & 2 deletions examples/ts/run.sh
Original file line number Diff line number Diff line change
@@ -2,5 +2,3 @@
set -eu
tsc
browserify demo.js -o bundle.js
sleep 1 && python3 -mwebbrowser http://localhost:8000/demo.html &
python3 -m http.server
2 changes: 1 addition & 1 deletion test-suite/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ add_djinni_target(DjinniAllTests
WASM_NAMESPACE "testsuite"
TS_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/ts"
TS_MODULE "test"
TS_SUPPORT_FILES_OUT "${CMAKE_CURRENT_BINARY_DIR}/ts-support-lib"
YAML_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/yaml"
YAML_PREFIX "test_"

@@ -80,7 +81,6 @@ add_djinni_target(DjinniWCharTests
WASM_NAMESPACE "testsuite"
TS_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/ts"
TS_MODULE "test_wchar"
TS_SUPPORT_FILES_OUT "${CMAKE_CURRENT_BINARY_DIR}/ts-support-lib"
YAML_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/yaml"
YAML_PREFIX "test_"

0 comments on commit e945626

Please sign in to comment.