mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
Swift 6 test targets
This commit is contained in:
1 parent
064eb9dea2
commit
fe59d44499
5 files changed
+302
-2
No files matched your search
+26
-2
@@ -1,4 +1,4 @@
|
||||
// swift-tools-version:6.1
|
||||
// swift-tools-version:6.2
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import Foundation
|
||||
@@ -80,6 +80,9 @@ let package = Package(
|
||||
"Swift6Migration",
|
||||
"generatePerformanceReport.rb",
|
||||
"parsePerformanceTests.rb",
|
||||
"Swift6ApprochableConcurrencyGRDBTests",
|
||||
"Swift6DefaultGRDBTests",
|
||||
"Swift6MainActorIsolationGRDBTests",
|
||||
],
|
||||
resources: [
|
||||
.copy("GRDBTests/Betty.jpeg"),
|
||||
@@ -92,7 +95,28 @@ let package = Package(
|
||||
.swiftLanguageMode(.v5),
|
||||
.enableUpcomingFeature("InferSendableFromCaptures"),
|
||||
.enableUpcomingFeature("GlobalActorIsolatedTypesUsability"),
|
||||
])
|
||||
]),
|
||||
.testTarget(
|
||||
name: "Swift6ApprochableConcurrencyGRDBTests",
|
||||
dependencies: ["GRDB"],
|
||||
swiftSettings: [
|
||||
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances")
|
||||
]
|
||||
),
|
||||
.testTarget(
|
||||
name: "Swift6DefaultGRDBTests",
|
||||
dependencies: ["GRDB"]
|
||||
),
|
||||
.testTarget(
|
||||
name: "Swift6MainActorIsolationGRDBTests",
|
||||
dependencies: ["GRDB"],
|
||||
swiftSettings: [
|
||||
.defaultIsolation(MainActor.self),
|
||||
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances")
|
||||
]
|
||||
),
|
||||
],
|
||||
swiftLanguageModes: [.v6]
|
||||
)
|
||||
@@ -0,0 +1,105 @@
|
||||
// swift-tools-version:6.1
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import Foundation
|
||||
import PackageDescription
|
||||
|
||||
let darwinPlatforms: [Platform] = [
|
||||
.iOS,
|
||||
.macOS,
|
||||
.macCatalyst,
|
||||
.tvOS,
|
||||
.visionOS,
|
||||
.watchOS,
|
||||
]
|
||||
var swiftSettings: [SwiftSetting] = [
|
||||
.define("SQLITE_ENABLE_FTS5"),
|
||||
.define("SQLITE_ENABLE_SNAPSHOT"),
|
||||
]
|
||||
var cSettings: [CSetting] = []
|
||||
var dependencies: [PackageDescription.Package.Dependency] = []
|
||||
|
||||
// Don't rely on those environment variables. They are ONLY testing conveniences:
|
||||
// $ SQLITE_ENABLE_PREUPDATE_HOOK=1 make test_SPM
|
||||
if ProcessInfo.processInfo.environment["SQLITE_ENABLE_PREUPDATE_HOOK"] == "1" {
|
||||
swiftSettings.append(.define("SQLITE_ENABLE_PREUPDATE_HOOK"))
|
||||
cSettings.append(.define("GRDB_SQLITE_ENABLE_PREUPDATE_HOOK"))
|
||||
}
|
||||
|
||||
// The SPI_BUILDER environment variable enables documentation building
|
||||
// on <https://swiftpackageindex.com/groue/GRDB.swift>. See
|
||||
// <https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/2122>
|
||||
// for more information.
|
||||
//
|
||||
// SPI_BUILDER also enables the `make docs-localhost` command.
|
||||
if ProcessInfo.processInfo.environment["SPI_BUILDER"] == "1" {
|
||||
dependencies.append(.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"))
|
||||
}
|
||||
|
||||
let package = Package(
|
||||
name: "GRDB",
|
||||
defaultLocalization: "en", // for tests
|
||||
platforms: [
|
||||
.iOS(.v13),
|
||||
.macOS(.v10_15),
|
||||
.tvOS(.v13),
|
||||
.watchOS(.v7),
|
||||
],
|
||||
products: [
|
||||
.library(name: "GRDBSQLite", targets: ["GRDBSQLite"]),
|
||||
.library(name: "GRDB", targets: ["GRDB"]),
|
||||
.library(name: "GRDB-dynamic", type: .dynamic, targets: ["GRDB"]),
|
||||
],
|
||||
dependencies: dependencies,
|
||||
targets: [
|
||||
.systemLibrary(
|
||||
name: "GRDBSQLite",
|
||||
providers: [.apt(["libsqlite3-dev"])]),
|
||||
.target(
|
||||
name: "GRDB",
|
||||
dependencies: [
|
||||
.target(name: "GRDBSQLite"),
|
||||
],
|
||||
path: "GRDB",
|
||||
resources: [.copy("PrivacyInfo.xcprivacy")],
|
||||
cSettings: cSettings,
|
||||
swiftSettings: swiftSettings),
|
||||
.testTarget(
|
||||
name: "GRDBTests",
|
||||
dependencies: ["GRDB"],
|
||||
path: "Tests",
|
||||
exclude: [
|
||||
"CocoaPods",
|
||||
"Crash",
|
||||
"CustomSQLite",
|
||||
"GRDBManualInstall",
|
||||
"GRDBTests/getThreadsCount.c",
|
||||
"Info.plist",
|
||||
"Performance",
|
||||
"SPM",
|
||||
"Swift6Migration",
|
||||
"generatePerformanceReport.rb",
|
||||
"parsePerformanceTests.rb",
|
||||
"Swift6ApprochableConcurrencyGRDBTests",
|
||||
"Swift6DefaultGRDBTests",
|
||||
"Swift6MainActorIsolationGRDBTests",
|
||||
],
|
||||
resources: [
|
||||
.copy("GRDBTests/Betty.jpeg"),
|
||||
.copy("GRDBTests/InflectionsTests.json"),
|
||||
.copy("GRDBTests/Issue1383.sqlite"),
|
||||
],
|
||||
cSettings: cSettings,
|
||||
swiftSettings: swiftSettings + [
|
||||
// Tests still use the Swift 5 language mode.
|
||||
.swiftLanguageMode(.v5),
|
||||
.enableUpcomingFeature("InferSendableFromCaptures"),
|
||||
.enableUpcomingFeature("GlobalActorIsolatedTypesUsability"),
|
||||
]),
|
||||
.testTarget(
|
||||
name: "Swift6DefaultGRDBTests",
|
||||
dependencies: ["GRDB"]
|
||||
),
|
||||
],
|
||||
swiftLanguageModes: [.v6]
|
||||
)
|
||||
@@ -0,0 +1,57 @@
|
||||
import GRDB
|
||||
import Testing
|
||||
|
||||
private class NonSendable {
|
||||
var value: Int
|
||||
|
||||
init(value: Int) {
|
||||
self.value = value
|
||||
}
|
||||
}
|
||||
|
||||
@Suite struct NonSendableTests {
|
||||
@Test func non_sendable_type_sent_to_databaseReader_read() async throws {
|
||||
let dbQueue = try DatabaseQueue()
|
||||
let nonSendable = NonSendable(value: 0)
|
||||
let value = try await dbQueue.read { _ in
|
||||
nonSendable.value
|
||||
}
|
||||
#expect(value == 0)
|
||||
}
|
||||
|
||||
@Test func non_sendable_type_sent_to_databaseReader_unsafeRead() async throws {
|
||||
let dbQueue = try DatabaseQueue()
|
||||
let nonSendable = NonSendable(value: 0)
|
||||
let value = try await dbQueue.unsafeRead { _ in
|
||||
nonSendable.value
|
||||
}
|
||||
#expect(value == 0)
|
||||
}
|
||||
|
||||
@Test func non_sendable_type_sent_to_databaseWriter_barrierWriteWithoutTransaction() async throws {
|
||||
let dbQueue = try DatabaseQueue()
|
||||
let nonSendable = NonSendable(value: 0)
|
||||
let value = try await dbQueue.barrierWriteWithoutTransaction { _ in
|
||||
nonSendable.value
|
||||
}
|
||||
#expect(value == 0)
|
||||
}
|
||||
|
||||
@Test func non_sendable_type_sent_to_databaseWriter_write() async throws {
|
||||
let dbQueue = try DatabaseQueue()
|
||||
let nonSendable = NonSendable(value: 0)
|
||||
let value = try await dbQueue.write { _ in
|
||||
nonSendable.value
|
||||
}
|
||||
#expect(value == 0)
|
||||
}
|
||||
|
||||
@Test func non_sendable_type_sent_to_databaseWriter_writeWithoutTransaction() async throws {
|
||||
let dbQueue = try DatabaseQueue()
|
||||
let nonSendable = NonSendable(value: 0)
|
||||
let value = try await dbQueue.writeWithoutTransaction { _ in
|
||||
nonSendable.value
|
||||
}
|
||||
#expect(value == 0)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import GRDB
|
||||
import Testing
|
||||
|
||||
private class NonSendable {
|
||||
var value: Int
|
||||
|
||||
init(value: Int) {
|
||||
self.value = value
|
||||
}
|
||||
}
|
||||
|
||||
@Suite struct NonSendableTests {
|
||||
@Test func non_sendable_type_sent_to_databaseReader_read() async throws {
|
||||
let dbQueue = try DatabaseQueue()
|
||||
let nonSendable = NonSendable(value: 0)
|
||||
let value = try await dbQueue.read { _ in
|
||||
nonSendable.value
|
||||
}
|
||||
#expect(value == 0)
|
||||
}
|
||||
|
||||
@Test func non_sendable_type_sent_to_databaseReader_unsafeRead() async throws {
|
||||
let dbQueue = try DatabaseQueue()
|
||||
let nonSendable = NonSendable(value: 0)
|
||||
let value = try await dbQueue.unsafeRead { _ in
|
||||
nonSendable.value
|
||||
}
|
||||
#expect(value == 0)
|
||||
}
|
||||
|
||||
@Test func non_sendable_type_sent_to_databaseWriter_barrierWriteWithoutTransaction() async throws {
|
||||
let dbQueue = try DatabaseQueue()
|
||||
let nonSendable = NonSendable(value: 0)
|
||||
let value = try await dbQueue.barrierWriteWithoutTransaction { _ in
|
||||
nonSendable.value
|
||||
}
|
||||
#expect(value == 0)
|
||||
}
|
||||
|
||||
@Test func non_sendable_type_sent_to_databaseWriter_write() async throws {
|
||||
let dbQueue = try DatabaseQueue()
|
||||
let nonSendable = NonSendable(value: 0)
|
||||
let value = try await dbQueue.write { _ in
|
||||
nonSendable.value
|
||||
}
|
||||
#expect(value == 0)
|
||||
}
|
||||
|
||||
@Test func non_sendable_type_sent_to_databaseWriter_writeWithoutTransaction() async throws {
|
||||
let dbQueue = try DatabaseQueue()
|
||||
let nonSendable = NonSendable(value: 0)
|
||||
let value = try await dbQueue.writeWithoutTransaction { _ in
|
||||
nonSendable.value
|
||||
}
|
||||
#expect(value == 0)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import GRDB
|
||||
import Testing
|
||||
|
||||
nonisolated private class NonSendable {
|
||||
var value: Int
|
||||
|
||||
init(value: Int) {
|
||||
self.value = value
|
||||
}
|
||||
}
|
||||
|
||||
@Suite struct NonSendableTests {
|
||||
@Test func non_sendable_type_sent_to_databaseReader_read() async throws {
|
||||
let dbQueue = try DatabaseQueue()
|
||||
let nonSendable = NonSendable(value: 0)
|
||||
let value = try await dbQueue.read { _ in
|
||||
nonSendable.value
|
||||
}
|
||||
#expect(value == 0)
|
||||
}
|
||||
|
||||
@Test func non_sendable_type_sent_to_databaseReader_unsafeRead() async throws {
|
||||
let dbQueue = try DatabaseQueue()
|
||||
let nonSendable = NonSendable(value: 0)
|
||||
let value = try await dbQueue.unsafeRead { _ in
|
||||
nonSendable.value
|
||||
}
|
||||
#expect(value == 0)
|
||||
}
|
||||
|
||||
@Test func non_sendable_type_sent_to_databaseWriter_barrierWriteWithoutTransaction() async throws {
|
||||
let dbQueue = try DatabaseQueue()
|
||||
let nonSendable = NonSendable(value: 0)
|
||||
let value = try await dbQueue.barrierWriteWithoutTransaction { _ in
|
||||
nonSendable.value
|
||||
}
|
||||
#expect(value == 0)
|
||||
}
|
||||
|
||||
@Test func non_sendable_type_sent_to_databaseWriter_write() async throws {
|
||||
let dbQueue = try DatabaseQueue()
|
||||
let nonSendable = NonSendable(value: 0)
|
||||
let value = try await dbQueue.write { _ in
|
||||
nonSendable.value
|
||||
}
|
||||
#expect(value == 0)
|
||||
}
|
||||
|
||||
@Test func non_sendable_type_sent_to_databaseWriter_writeWithoutTransaction() async throws {
|
||||
let dbQueue = try DatabaseQueue()
|
||||
let nonSendable = NonSendable(value: 0)
|
||||
let value = try await dbQueue.writeWithoutTransaction { _ in
|
||||
nonSendable.value
|
||||
}
|
||||
#expect(value == 0)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user