Skip to content

Add SPM integration test #1082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 5, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ jobs:
env:
PACKAGE_MANAGER_COMMAND: test -Xswiftc -warnings-as-errors
run: ./run-tests.sh
- name: "Run tests (SPM integration test)"
env:
SPM: run
run: ./run-tests.sh
- name: "Run tests (BUILD_SCHEME: SQLite iOS)"
env:
BUILD_SCHEME: SQLite iOS
Expand Down Expand Up @@ -71,3 +75,7 @@ jobs:
sudo apt-get install -y libsqlite3-dev
- name: Test
run: swift test
- name: "Run tests (SPM integration test)"
env:
SPM: run
run: ./run-tests.sh
6 changes: 5 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ let package = Package(
#if os(Linux)
package.dependencies = [.package(url: "https://github.com/stephencelis/CSQLite.git", from: "0.0.3")]
package.targets = [
.target(name: "SQLite", exclude: ["Extensions/FTS4.swift", "Extensions/FTS5.swift"]),
.target(
name: "SQLite",
dependencies: [.product(name: "CSQLite", package: "CSQLite")],
exclude: ["Extensions/FTS4.swift", "Extensions/FTS5.swift"]
),
.testTarget(name: "SQLiteTests", dependencies: ["SQLite"], path: "Tests/SQLiteTests", exclude: [
"FTSIntegrationTests.swift",
"FTS4Tests.swift",
Expand Down
7 changes: 7 additions & 0 deletions Tests/SPM/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
19 changes: 19 additions & 0 deletions Tests/SPM/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "test",
dependencies: [
.package(path: "../..")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "test",
dependencies: [.product(name: "SQLite", package: "SQLite.swift")]
)
]
)
10 changes: 10 additions & 0 deletions Tests/SPM/Sources/test/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import SQLite

let table = Table("test")
let name = Expression<String>("name")

let db = try Connection("db.sqlite", readonly: true)

for row in try db.prepare(table) {
print(row[name])
}
Binary file added Tests/SPM/db.sqlite
Binary file not shown.
2 changes: 2 additions & 0 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ elif [ -n "$VALIDATOR_SUBSPEC" ]; then
fi
elif [ -n "$CARTHAGE_PLATFORM" ]; then
cd Tests/Carthage && make test CARTHAGE_PLATFORM="$CARTHAGE_PLATFORM"
elif [ -n "$SPM" ]; then
cd Tests/SPM && swift ${SPM}
elif [ -n "${PACKAGE_MANAGER_COMMAND}" ]; then
swift ${PACKAGE_MANAGER_COMMAND}
fi