Skip to content

Commit

Permalink
[cmake] Make unittests build with swift-testing using CMake.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffdav committed Apr 29, 2024
1 parent 0ab5d32 commit 70f179a
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
/.build
/build
/b
/Packages
xcuserdata/
DerivedData/
Expand Down
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)

option(SWIFT_WEBDRIVER_BUILD_WINAPPDRIVER "Build WinAppDriver functionality." TRUE)
option(SWIFT_WEBDRIVER_BUILD_WINAPPDRIVER "Build WinAppDriver functionality." YES)

add_subdirectory(Sources/WebDriver)
include(CTest)
if(BUILD_TESTING)
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-enable-testing>)
endif()

add_subdirectory(Vendor)
add_subdirectory(Sources/WebDriver)
if(SWIFT_WEBDRIVER_BUILD_WINAPPDRIVER)
add_subdirectory(Sources/WinAppDriver)
endif()
if(BUILD_TESTING)
add_subdirectory(Tests)
endif()
1 change: 1 addition & 0 deletions Testing/Temporary/CTestCostData.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
3 changes: 3 additions & 0 deletions Testing/Temporary/LastTest.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Start testing: Apr 29 10:52 Pacific Daylight Time
----------------------------------------------------------
End testing: Apr 29 10:52 Pacific Daylight Time
17 changes: 17 additions & 0 deletions Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
add_library(TestsCommon
Common/PNGUtilities.swift)

SwiftTesting_GenerateDerivedSources()
add_executable(SwiftWebdriverPackageTests
UnitTests/APITests.swift
UnitTests/MockWebDriver.swift
${swiftwebdriver_SwiftTesting_Sources})
set_target_properties(SwiftWebdriverPackageTests PROPERTIES
SUFFIX .swift-testing)
target_link_libraries(SwiftWebdriverPackageTests PRIVATE
WebDriver
Testing
TestsCommon)

add_test(NAME SwiftWebdriverPackageTests
COMMAND SwiftWebdriverPackageTests)
9 changes: 9 additions & 0 deletions Vendor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include(FetchContent)

# Ignore warnings from dependencies' source code.
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-suppress-warnings>)
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-suppress-remarks>)

if(BUILD_TESTING)
include(SwiftTesting.cmake)
endif()
10 changes: 10 additions & 0 deletions Vendor/SwiftTesting.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FetchContent_Declare(SwiftTesting
# GIT_REPOSITORY https://github.com/apple/swift-testing.git
# GIT_TAG e07ef28413b5be951fa5672b290bc10fa2e3cd65)
GIT_REPOSITORY https://github.com/thebrowsercompany/swift-testing.git
GIT_TAG 7512437778c16acf88bf2b4377b19c84864d327c)
FetchContent_GetProperties(SwiftTesting)
if(NOT SwiftTesting_POPULATED)
message(STATUS "syncing SwiftTesting")
FetchContent_MakeAvailable(SwiftTesting)
endif()

0 comments on commit 70f179a

Please sign in to comment.