From 389c3e0d4a255eaec3b152cff4ed851bfcdc4f67 Mon Sep 17 00:00:00 2001 From: Tim De Jong Date: Fri, 3 Oct 2025 09:30:54 +0200 Subject: [PATCH] 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. --- Tests/GRDBTests/DatabaseMigratorTests.swift | 46 ++++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/Tests/GRDBTests/DatabaseMigratorTests.swift b/Tests/GRDBTests/DatabaseMigratorTests.swift index 73d873020..1b053e258 100644 --- a/Tests/GRDBTests/DatabaseMigratorTests.swift +++ b/Tests/GRDBTests/DatabaseMigratorTests.swift @@ -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: 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: 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