Skip to content

Commit

Permalink
Run tests in parallel.
Browse files Browse the repository at this point in the history
  • Loading branch information
floitsch committed Aug 22, 2024
1 parent 228458d commit b804698
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
20 changes: 16 additions & 4 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,23 @@ foreach(file ${TESTS})
if("${test_name}" IN_LIST SKIP_TESTS)
continue()
endif()
add_test(
NAME "${test_name}"
COMMAND "${TOIT_EXEC}" "-Xenable-asserts" "${file}" ${BROWSERS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
if ("${file}" MATCHES "webdriver-")
foreach (browser ${BROWSERS})
set(test_name "/tests/${file}-${browser}")
add_test(
NAME "${test_name}"
COMMAND "${TOIT_EXEC}" "-Xenable-asserts" "${file}" "${browser}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
set_tests_properties("${test_name}" PROPERTIES TIMEOUT ${TEST_TIMEOUT})
endforeach()
else()
add_test(
NAME "${test_name}"
COMMAND "${TOIT_EXEC}" "-Xenable-asserts" "${file}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()
set_tests_properties(${test_name} PROPERTIES TIMEOUT ${TEST_TIMEOUT})
endforeach()

Expand Down
16 changes: 15 additions & 1 deletion tests/webdriver.toit
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,26 @@ class WebDriver:
close:
pid := child-process_
if not pid: return
// Delete the session.
// This doesn't shut down the driver, but is good practice.
request := client_.new-request http.DELETE --uri=session-url_
request.send
// Some drivers have a shutdown endpoint. It doesn't hurt to send it
// to all drivers.
client_.get --uri="$session-url_/shutdown"
client_.close
network_.close
child-process_ = null
pipe.wait-for pid
if system.platform == system.PLATFORM-WINDOWS:
// On Windows we only have kill 9.
pipe.kill_ pid 9
else:
pipe.kill_ pid 15
exception := catch --unwind=(: it != DEADLINE-EXCEEDED-ERROR):
with-timeout --ms=3_000:
pipe.wait-for pid
if exception:
pipe.kill_ pid 9

post_ --url/string=session-url_ path/string payload/any -> any:
response := client_.post-json --uri="$url/$path" payload
Expand Down

0 comments on commit b804698

Please sign in to comment.