Skip to content

Commit ffd8269

Browse files
committed
[cmake] Make unittests build with swift-testing using CMake.
1 parent 0ab5d32 commit ffd8269

File tree

7 files changed

+51
-2
lines changed

7 files changed

+51
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.DS_Store
22
/.build
33
/build
4+
/b
45
/Packages
56
xcuserdata/
67
DerivedData/

CMakeLists.txt

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
88
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
99
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
1010

11-
option(SWIFT_WEBDRIVER_BUILD_WINAPPDRIVER "Build WinAppDriver functionality." TRUE)
11+
option(SWIFT_WEBDRIVER_BUILD_WINAPPDRIVER "Build WinAppDriver functionality." YES)
1212

13-
add_subdirectory(Sources/WebDriver)
13+
include(CTest)
14+
if(BUILD_TESTING)
15+
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-enable-testing>)
16+
endif()
1417

18+
add_subdirectory(Vendor)
19+
add_subdirectory(Sources/WebDriver)
1520
if(SWIFT_WEBDRIVER_BUILD_WINAPPDRIVER)
1621
add_subdirectory(Sources/WinAppDriver)
1722
endif()
23+
if(BUILD_TESTING)
24+
add_subdirectory(Tests)
25+
endif()

Testing/Temporary/CTestCostData.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
---

Testing/Temporary/LastTest.log

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Start testing: Apr 29 10:52 Pacific Daylight Time
2+
----------------------------------------------------------
3+
End testing: Apr 29 10:52 Pacific Daylight Time

Tests/CMakeLists.txt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
add_library(TestsCommon
2+
Common/PNGUtilities.swift)
3+
4+
SwiftTesting_GenerateDerivedSources()
5+
add_executable(SwiftWebdriverPackageTests
6+
UnitTests/APITests.swift
7+
UnitTests/MockWebDriver.swift
8+
${swiftwebdriver_SwiftTesting_Sources})
9+
set_target_properties(SwiftWebdriverPackageTests PROPERTIES
10+
SUFFIX .swift-testing)
11+
target_link_libraries(SwiftWebdriverPackageTests PRIVATE
12+
WebDriver
13+
Testing
14+
TestsCommon)
15+
16+
add_test(NAME SwiftWebdriverPackageTests
17+
COMMAND SwiftWebdriverPackageTests)

Vendor/CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
include(FetchContent)
2+
3+
# Ignore warnings from dependencies' source code.
4+
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-suppress-warnings>)
5+
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-suppress-remarks>)
6+
7+
if(BUILD_TESTING)
8+
include(SwiftTesting.cmake)
9+
endif()

Vendor/SwiftTesting.cmake

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FetchContent_Declare(SwiftTesting
2+
# GIT_REPOSITORY https://github.com/apple/swift-testing.git
3+
# GIT_TAG e07ef28413b5be951fa5672b290bc10fa2e3cd65)
4+
GIT_REPOSITORY https://github.com/thebrowsercompany/swift-testing.git
5+
GIT_TAG cef620855b4ed1c8e43a43372ee9d517b2cd71bd)
6+
FetchContent_GetProperties(SwiftTesting)
7+
if(NOT SwiftTesting_POPULATED)
8+
message(STATUS "syncing SwiftTesting")
9+
FetchContent_MakeAvailable(SwiftTesting)
10+
endif()

0 commit comments

Comments
 (0)