Skip to content

Commit e945626

Browse files
committed
Also run demo app as headless on CI
1 parent 07ed123 commit e945626

File tree

6 files changed

+57
-3
lines changed

6 files changed

+57
-3
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ jobs:
155155
run: cmake --build build --parallel $(nproc) --config Release
156156
- name: Run headless test
157157
run: pushd build && ctest --output-on-failure
158+
- name: Run integration test on sample app
159+
run: pushd build/examples && ./run.sh && python3 run-tests-selenium.py
158160

159161
build-on-windows-for-cppcli:
160162
runs-on: windows-latest

bin/djinni

2.17 KB
Binary file not shown.

examples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ add_djinni_target(DjinniTextSort
3636
WASM_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/wasm"
3737
TS_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/ts"
3838
TS_MODULE "example"
39+
TS_SUPPORT_FILES_OUT "${CMAKE_CURRENT_BINARY_DIR}/ts-support-lib"
3940
YAML_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/yaml"
4041
YAML_PREFIX "test_"
4142

examples/ts/run-tests-selenium.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#! /usr/bin/env python3
2+
3+
from http.server import HTTPServer, SimpleHTTPRequestHandler
4+
from selenium import webdriver
5+
from selenium.webdriver.common.by import By
6+
from selenium.webdriver.chrome.service import Service
7+
import sys
8+
import time
9+
import threading
10+
11+
port = "8050"
12+
httpd = HTTPServer(("127.0.0.1", int(port)), SimpleHTTPRequestHandler)
13+
14+
def run_server():
15+
print("Serving HTTP on localhost port " + port + " (http://localhost:" + port + "/) ...")
16+
httpd.serve_forever()
17+
18+
server_thread = threading.Thread(target=run_server)
19+
server_thread.start()
20+
21+
service = Service(executable_path=r'/usr/bin/chromedriver')
22+
options = webdriver.ChromeOptions()
23+
options.add_argument('--headless')
24+
options.add_argument('--no-sandbox')
25+
options.add_argument('--disable-dev-shm-usage')
26+
options.add_argument('--disable-gpu')
27+
driver = webdriver.Chrome(service=service, options=options)
28+
print(f"connecting web driver to http://localhost:{port}/")
29+
driver.get(f"http://localhost:{port}/demo.html")
30+
asc_button = driver.find_element(By.ID, "btnAsc")
31+
desc_button = driver.find_element(By.ID, "btnDesc")
32+
33+
asc_button.click()
34+
print("Wait for Asc button press")
35+
time.sleep(0.5)
36+
value = driver.find_element(By.ID, "txt").get_attribute("value")
37+
is_ascending_ok = value == "item1\nitem2\nitem3\nitem4\nitem5"
38+
print(f"text area on Sort Asc pressed:\n{value}")
39+
desc_button.click()
40+
print("Wait for Desc button press")
41+
time.sleep(0.5)
42+
value = driver.find_element(By.ID, "txt").get_attribute("value")
43+
print(f"text area on Sort Desc pressed:\n{value}")
44+
is_descending_ok = value == "item5\nitem4\nitem3\nitem2\nitem1"
45+
46+
driver.quit()
47+
httpd.shutdown()
48+
server_thread.join()
49+
if is_ascending_ok and is_descending_ok:
50+
exit(0)
51+
print(f"is_ascending_ok = {is_ascending_ok}")
52+
print(f"is_descending_ok = {is_descending_ok}")
53+
exit(1)

examples/ts/run.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,3 @@
22
set -eu
33
tsc
44
browserify demo.js -o bundle.js
5-
sleep 1 && python3 -mwebbrowser http://localhost:8000/demo.html &
6-
python3 -m http.server

test-suite/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ add_djinni_target(DjinniAllTests
3737
WASM_NAMESPACE "testsuite"
3838
TS_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/ts"
3939
TS_MODULE "test"
40+
TS_SUPPORT_FILES_OUT "${CMAKE_CURRENT_BINARY_DIR}/ts-support-lib"
4041
YAML_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/yaml"
4142
YAML_PREFIX "test_"
4243

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

0 commit comments

Comments
 (0)