Use #if !canImport(Combine) per test case (as done by @marcprux) and throw an XCTSkip for these test cases. This gives a better impression how many tests are skipped on Linux/non-Darwin platforms.

This commit is contained in:
Tim De Jong authored and Gwendal Roué committed 2025-10-12 18:03:57 +02:00
1 parent a212bf9e89
commit 389c3e0d4a
1 file changed
+44 -2
+44 -2
View File
@@ -9,8 +9,10 @@ class DatabaseMigratorTests : GRDBTestCase {
try migrator.migrate(writer)
}
#if canImport(Combine)
func testEmptyMigratorSync() throws {
#if !canImport(Combine)
throw XCTSkip("Combine not supported on this platform")
#else
func test(writer: some DatabaseWriter) throws {
let migrator = DatabaseMigrator()
try migrator.migrate(writer)
@@ -19,9 +21,13 @@ class DatabaseMigratorTests : GRDBTestCase {
try Test(test).run { try DatabaseQueue() }
try Test(test).runAtTemporaryDatabasePath { try DatabaseQueue(path: $0) }
try Test(test).runAtTemporaryDatabasePath { try DatabasePool(path: $0) }
#endif
}
func testEmptyMigratorAsync() throws {
#if !canImport(Combine)
throw XCTSkip("Combine not supported on this platform")
#else
func test(writer: some DatabaseWriter) throws {
let expectation = self.expectation(description: "")
let migrator = DatabaseMigrator()
@@ -39,9 +45,13 @@ class DatabaseMigratorTests : GRDBTestCase {
try Test(test).run { try DatabaseQueue() }
try Test(test).runAtTemporaryDatabasePath { try DatabaseQueue(path: $0) }
try Test(test).runAtTemporaryDatabasePath { try DatabasePool(path: $0) }
#endif
}
func testEmptyMigratorPublisher() throws {
#if !canImport(Combine)
throw XCTSkip("Combine not supported on this platform")
#else
func test(writer: some DatabaseWriter) throws {
let migrator = DatabaseMigrator()
let publisher = migrator.migratePublisher(writer)
@@ -52,9 +62,13 @@ class DatabaseMigratorTests : GRDBTestCase {
try Test(test).run { try DatabaseQueue() }
try Test(test).runAtTemporaryDatabasePath { try DatabaseQueue(path: $0) }
try Test(test).runAtTemporaryDatabasePath { try DatabasePool(path: $0) }
#endif
}
func testNonEmptyMigratorSync() throws {
#if !canImport(Combine)
throw XCTSkip("Combine not supported on this platform")
#else
func test(writer: some DatabaseWriter) throws {
var migrator = DatabaseMigrator()
migrator.registerMigration("createPersons") { db in
@@ -96,9 +110,13 @@ class DatabaseMigratorTests : GRDBTestCase {
try Test(test).run { try DatabaseQueue() }
try Test(test).runAtTemporaryDatabasePath { try DatabaseQueue(path: $0) }
try Test(test).runAtTemporaryDatabasePath { try DatabasePool(path: $0) }
#endif
}
func testNonEmptyMigratorAsync() throws {
#if !canImport(Combine)
throw XCTSkip("Combine not supported on this platform")
#else
func test(writer: some DatabaseWriter) throws {
var migrator = DatabaseMigrator()
migrator.registerMigration("createPersons") { db in
@@ -147,9 +165,13 @@ class DatabaseMigratorTests : GRDBTestCase {
try Test(test).run { try DatabaseQueue() }
try Test(test).runAtTemporaryDatabasePath { try DatabaseQueue(path: $0) }
try Test(test).runAtTemporaryDatabasePath { try DatabasePool(path: $0) }
#endif
}
func testNonEmptyMigratorPublisher() throws {
#if !canImport(Combine)
throw XCTSkip("Combine not supported on this platform")
#else
func test(writer: some DatabaseWriter) throws {
var migrator = DatabaseMigrator()
migrator.registerMigration("createPersons") { db in
@@ -199,9 +221,13 @@ class DatabaseMigratorTests : GRDBTestCase {
try Test(test).run { try DatabaseQueue() }
try Test(test).runAtTemporaryDatabasePath { try DatabaseQueue(path: $0) }
try Test(test).runAtTemporaryDatabasePath { try DatabasePool(path: $0) }
#endif
}
func testEmptyMigratorPublisherIsAsynchronous() throws {
#if !canImport(Combine)
throw XCTSkip("Combine not supported on this platform")
#else
func test(writer: some DatabaseWriter) throws {
let migrator = DatabaseMigrator()
let expectation = self.expectation(description: "")
@@ -221,9 +247,13 @@ class DatabaseMigratorTests : GRDBTestCase {
try Test(test).run { try DatabaseQueue() }
try Test(test).runAtTemporaryDatabasePath { try DatabaseQueue(path: $0) }
try Test(test).runAtTemporaryDatabasePath { try DatabasePool(path: $0) }
#endif
}
func testNonEmptyMigratorPublisherIsAsynchronous() throws {
#if !canImport(Combine)
throw XCTSkip("Combine not supported on this platform")
#else
func test(writer: some DatabaseWriter) throws {
var migrator = DatabaseMigrator()
migrator.registerMigration("first", migrate: { _ in })
@@ -244,9 +274,13 @@ class DatabaseMigratorTests : GRDBTestCase {
try Test(test).run { try DatabaseQueue() }
try Test(test).runAtTemporaryDatabasePath { try DatabaseQueue(path: $0) }
try Test(test).runAtTemporaryDatabasePath { try DatabasePool(path: $0) }
#endif
}
func testMigratorPublisherDefaultScheduler() throws {
#if !canImport(Combine)
throw XCTSkip("Combine not supported on this platform")
#else
func test<Writer: DatabaseWriter>(writer: Writer) {
var migrator = DatabaseMigrator()
migrator.registerMigration("first", migrate: { _ in })
@@ -269,9 +303,13 @@ class DatabaseMigratorTests : GRDBTestCase {
try Test(test).run { try DatabaseQueue() }
try Test(test).runAtTemporaryDatabasePath { try DatabaseQueue(path: $0) }
try Test(test).runAtTemporaryDatabasePath { try DatabasePool(path: $0) }
#endif
}
func testMigratorPublisherCustomScheduler() throws {
#if !canImport(Combine)
throw XCTSkip("Combine not supported on this platform")
#else
func test<Writer: DatabaseWriter>(writer: Writer) {
var migrator = DatabaseMigrator()
migrator.registerMigration("first", migrate: { _ in })
@@ -295,9 +333,13 @@ class DatabaseMigratorTests : GRDBTestCase {
try Test(test).run { try DatabaseQueue() }
try Test(test).runAtTemporaryDatabasePath { try DatabaseQueue(path: $0) }
try Test(test).runAtTemporaryDatabasePath { try DatabasePool(path: $0) }
#endif
}
func testMigrateUpTo() throws {
#if !canImport(Combine)
throw XCTSkip("Combine not supported on this platform")
#else
func test(writer: some DatabaseWriter) throws {
var migrator = DatabaseMigrator()
migrator.registerMigration("a") { db in
@@ -346,9 +388,9 @@ class DatabaseMigratorTests : GRDBTestCase {
try Test(test).run { try DatabaseQueue() }
try Test(test).runAtTemporaryDatabasePath { try DatabaseQueue(path: $0) }
try Test(test).runAtTemporaryDatabasePath { try DatabasePool(path: $0) }
#endif
}
#endif
func testMigrationFailureTriggersRollback() throws {
var migrator = DatabaseMigrator()
migrator.registerMigration("createPersons") { db in