Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
os: [ ubuntu-latest, windows-latest, macos-latest ]
# The versions should contain (at least) the lowest requirement
# and a version that is more up to date.
toit-version: [ v2.0.0-alpha.150, latest ]
toit-version: [ v2.0.0-alpha.170, latest ]
include:
- toit-version: v2.0.0-alpha.150
- toit-version: v2.0.0-alpha.170
version-name: old
- toit-version: latest
version-name: new
Expand Down
2 changes: 1 addition & 1 deletion examples/package.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ packages:
toit-cert-roots:
url: github.com/toitware/toit-cert-roots
name: certificate-roots
version: 1.9.0
version: 1.10.0
hash: 1445c4a6cae47689674ae02c5f1dc03660f1df8c
2 changes: 1 addition & 1 deletion examples/package.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
certificate_roots:
url: github.com/toitware/toit-cert-roots
version: ^1.9.0
version: ^1.10.0
http:
path: ..
1 change: 1 addition & 0 deletions package.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sdk: ^2.0.0-alpha.170
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: http
description: An HTTP server and client.
environment:
sdk: ^2.0.0-alpha.150
sdk: ^2.0.0-alpha.170
12 changes: 5 additions & 7 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
file(GLOB TESTS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*-test.toit")
file(GLOB HTTPBIN_TESTS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*-test-httpbin.toit")

set(TOIT_EXEC "toit.run${CMAKE_EXECUTABLE_SUFFIX}" CACHE FILEPATH "The executable used to run the tests")
set(TPKG_EXEC "toit.pkg${CMAKE_EXECUTABLE_SUFFIX}" CACHE FILEPATH "The executable used to install the packages")
set(TOIT_EXEC "toit${CMAKE_EXECUTABLE_SUFFIX}" CACHE FILEPATH "The executable used to run the tests")
set(TEST_TIMEOUT 180 CACHE STRING "The maximal amount of time each test is allowed to run")
set(ENABLE_HTTPBIN_TESTS ON CACHE BOOL "Whether to run tests that depend on httpbin.org docker")
set(USE_HTTPBIN_DOCKER OFF CACHE BOOL "Whether to use the httpbin.org docker container")
Expand All @@ -19,10 +18,9 @@ if (${ENABLE_HTTPBIN_TESTS})
endif()
endif()

message("TPKG: ${TPKG_EXEC}")
add_custom_target(
"install-pkgs"
COMMAND "${TPKG_EXEC}" install
COMMAND "${TOIT_EXEC}" pkg install
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)

Expand Down Expand Up @@ -63,7 +61,7 @@ foreach(file ${TESTS})
set(test_name "/tests/${file}-${browser}")
add_test(
NAME "${test_name}"
COMMAND "${TOIT_EXEC}" "-Xenable-asserts" "${file}" "${browser}"
COMMAND "${TOIT_EXEC}" run --enable-asserts "${file}" -- "${browser}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
set_tests_properties("${test_name}" PROPERTIES TIMEOUT ${TEST_TIMEOUT})
Expand All @@ -72,7 +70,7 @@ foreach(file ${TESTS})
else()
add_test(
NAME "${test_name}"
COMMAND "${TOIT_EXEC}" "-Xenable-asserts" "${file}"
COMMAND "${TOIT_EXEC}" run --enable-asserts "${file}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()
Expand All @@ -87,7 +85,7 @@ if (${ENABLE_HTTPBIN_TESTS})
endif()
add_test(
NAME "${test_name}"
COMMAND "${TOIT_EXEC}" "-Xenable-asserts" "${file}" "${HTTPBIN_URL}"
COMMAND "${TOIT_EXEC}" run --enable-asserts "${file}" -- "${HTTPBIN_URL}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
set_tests_properties(${test_name} PROPERTIES TIMEOUT ${TEST_TIMEOUT})
Expand Down
8 changes: 4 additions & 4 deletions tests/package.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sdk: ^2.0.0-alpha.150
sdk: ^2.0.0-alpha.170
prefixes:
certificate_roots: toit-cert-roots
fs: pkg-fs
Expand All @@ -17,10 +17,10 @@ packages:
pkg-host:
url: github.com/toitlang/pkg-host
name: host
version: 1.15.3
hash: 62393e8522b77eafbafe60b9817935266117daf6
version: 1.16.2
hash: ae83f761db80166a20bb38498edd009916b72563
toit-cert-roots:
url: github.com/toitware/toit-cert-roots
name: certificate-roots
version: 1.9.0
version: 1.10.0
hash: 1445c4a6cae47689674ae02c5f1dc03660f1df8c
4 changes: 2 additions & 2 deletions tests/package.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
dependencies:
certificate_roots:
url: github.com/toitware/toit-cert-roots
version: ^1.9.0
version: ^1.10.0
fs:
url: github.com/toitlang/pkg-fs
version: ^2.3.1
host:
url: github.com/toitlang/pkg-host
version: ^1.15.3
version: ^1.16.2
http:
path: ..
17 changes: 7 additions & 10 deletions tests/webdriver.toit
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ DRIVERS_ ::= {

class WebDriver:
driver-app_/string
child-process_/any := null
child-process_/pipe.Process? := null
session-url_/string? := null
network_/net.Interface? := null
client_/http.Client? := null
Expand All @@ -40,14 +40,10 @@ class WebDriver:
"$program-dir/third-party/ephemeral-port-reserve/ephemeral_port_reserve.py"
port = port.trim
command := ["$driver-app_$extension", "--port=$port"]
fork-data := pipe.fork
true // use_path
pipe.PIPE-INHERITED // stdin.
pipe.PIPE-INHERITED // stdout
pipe.PIPE-INHERITED // stderr
child-process_ = pipe.fork
--use-path
command.first
command
child-process_ = fork-data[3]
network_ = net.open
client_ = http.Client network_

Expand Down Expand Up @@ -106,8 +102,8 @@ class WebDriver:
print "Started"

close:
pid := child-process_
if not pid: return
if not child-process_: return
pid := child-process_.pid
// Delete the session.
// This doesn't shut down the driver, but is good practice.
request := client_.new-request http.DELETE --uri=session-url_
Expand All @@ -117,6 +113,7 @@ class WebDriver:
client_.get --uri="$session-url_/shutdown"
client_.close
network_.close
child-process := child-process_
child-process_ = null
if system.platform == system.PLATFORM-WINDOWS:
// On Windows we only have kill 9.
Expand All @@ -125,7 +122,7 @@ class WebDriver:
pipe.kill_ pid 15
exception := catch --unwind=(: it != DEADLINE-EXCEEDED-ERROR):
with-timeout --ms=3_000:
pipe.wait-for pid
child-process.wait
if exception:
pipe.kill_ pid 9

Expand Down