Skip to content

Commit 86c3f6a

Browse files
committed
Add SPM integration test
1 parent 385f435 commit 86c3f6a

File tree

7 files changed

+48
-1
lines changed

7 files changed

+48
-1
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ jobs:
2121
env:
2222
PACKAGE_MANAGER_COMMAND: test -Xswiftc -warnings-as-errors
2323
run: ./run-tests.sh
24+
- name: "Run tests (SPM integration test)"
25+
env:
26+
SPM: run
27+
run: ./run-tests.sh
2428
- name: "Run tests (BUILD_SCHEME: SQLite iOS)"
2529
env:
2630
BUILD_SCHEME: SQLite iOS

Package.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ let package = Package(
4444
#if os(Linux)
4545
package.dependencies = [.package(url: "https://github.com/stephencelis/CSQLite.git", from: "0.0.3")]
4646
package.targets = [
47-
.target(name: "SQLite", exclude: ["Extensions/FTS4.swift", "Extensions/FTS5.swift"]),
47+
.target(
48+
name: "SQLite",
49+
dependencies: [.product(name: "CSQLite", package: "CSQLite")],
50+
exclude: ["Extensions/FTS4.swift", "Extensions/FTS5.swift"]
51+
),
4852
.testTarget(name: "SQLiteTests", dependencies: ["SQLite"], path: "Tests/SQLiteTests", exclude: [
4953
"FTSIntegrationTests.swift",
5054
"FTS4Tests.swift",

Tests/SPM/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
/*.xcodeproj
5+
xcuserdata/
6+
DerivedData/
7+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Tests/SPM/Package.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// swift-tools-version:5.3
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "test",
8+
dependencies: [
9+
.package(path: "../..")
10+
],
11+
targets: [
12+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
13+
// Targets can depend on other targets in this package, and on products in packages this package depends on.
14+
.target(
15+
name: "test",
16+
dependencies: [.product(name: "SQLite", package: "SQLite.swift")]
17+
)
18+
]
19+
)

Tests/SPM/Sources/test/main.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import SQLite
2+
3+
let table = Table("test")
4+
let name = Expression<String>("name")
5+
6+
let db = try Connection("db.sqlite", readonly: true)
7+
8+
for row in try db.prepare(table) {
9+
print(row[name])
10+
}
11+

Tests/SPM/db.sqlite

8 KB
Binary file not shown.

run-tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ elif [ -n "$VALIDATOR_SUBSPEC" ]; then
1414
fi
1515
elif [ -n "$CARTHAGE_PLATFORM" ]; then
1616
cd Tests/Carthage && make test CARTHAGE_PLATFORM="$CARTHAGE_PLATFORM"
17+
elif [ -n "$SPM" ]; then
18+
cd Tests/SPM && swift run
1719
elif [ -n "${PACKAGE_MANAGER_COMMAND}" ]; then
1820
swift ${PACKAGE_MANAGER_COMMAND}
1921
fi

0 commit comments

Comments
 (0)