Skip to content

Commit 420809e

Browse files
committed
Fix build and tests
1 parent 7e0bcf8 commit 420809e

File tree

10 files changed

+52
-9
lines changed

10 files changed

+52
-9
lines changed

Package.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ let package = Package(
5353
),
5454
.testTarget(
5555
name: "ReadiumSharedTests",
56-
dependencies: ["ReadiumShared"],
56+
dependencies: [
57+
"ReadiumShared",
58+
"TestPublications",
59+
],
5760
path: "Tests/SharedTests",
5861
resources: [
5962
.copy("Fixtures"),
@@ -174,5 +177,14 @@ let package = Package(
174177
dependencies: ["ReadiumInternal"],
175178
path: "Tests/InternalTests"
176179
),
180+
181+
// Shared test publications used across multiple test targets.
182+
.target(
183+
name: "TestPublications",
184+
path: "Tests/Publications",
185+
resources: [
186+
.copy("Publications"),
187+
]
188+
),
177189
]
178190
)

Tests/NavigatorTests/UITests/NavigatorTestHost/FixtureList.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class FixtureListViewModel: ObservableObject {
7575
let epubURL = Bundle.main.url(
7676
forResource: components[0],
7777
withExtension: components[1],
78-
subdirectory: "Fixtures"
78+
subdirectory: "Publications"
7979
)
8080
else {
8181
throw FixtureError.notFound(fixture)
@@ -96,8 +96,8 @@ enum FixtureError: LocalizedError {
9696

9797
var errorDescription: String? {
9898
switch self {
99-
case .notFound:
100-
return "Test EPUB fixture not found in bundle"
99+
case let .notFound(fixture):
100+
return "Test fixture \(fixture.filename) not found in bundle"
101101
}
102102
}
103103
}

Tests/NavigatorTests/UITests/NavigatorTestHost/ReaderView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ struct ReaderView: View {
3838
}
3939
}
4040

41-
@MainActor final class ReaderViewModel: ObservableObject, @MainActor Identifiable {
42-
var id: ObjectIdentifier { ObjectIdentifier(self) }
41+
@MainActor final class ReaderViewModel: ObservableObject, Identifiable {
42+
nonisolated var id: ObjectIdentifier { ObjectIdentifier(self) }
4343

4444
let navigator: VisualNavigator & UIViewController
4545

Tests/NavigatorTests/UITests/project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ targets:
1919
deploymentTarget: 15.0
2020
sources:
2121
- path: NavigatorTestHost
22-
- path: ../../Fixtures
22+
- path: ../../Publications/Publications
2323
type: folder
2424
buildPhase: resources
2525
dependencies:
File renamed without changes.
File renamed without changes.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// Copyright 2025 Readium Foundation. All rights reserved.
3+
// Use of this source code is governed by the BSD-style license
4+
// available in the top-level LICENSE file of the project.
5+
//
6+
7+
import Foundation
8+
9+
/// Provides access to shared test publication files.
10+
public enum TestPublications {
11+
/// Returns the resource bundle containing shared test publications.
12+
public static let bundle = Bundle.module
13+
14+
/// Returns a URL for the specified publication file.
15+
///
16+
/// - Parameter filename: The filename with extension (e.g., "childrens-literature.epub").
17+
/// - Returns: A URL pointing to the publication file.
18+
public static func url(for filename: String) -> URL {
19+
let components = filename.split(separator: ".", maxSplits: 1)
20+
let name = String(components[0])
21+
let ext = components.count > 1 ? String(components[1]) : nil
22+
23+
guard let url = bundle.url(forResource: name, withExtension: ext, subdirectory: "Publications") else {
24+
fatalError("Test publication '\(filename)' not found in TestPublications bundle")
25+
}
26+
27+
return url
28+
}
29+
}

Tests/SharedTests/Toolkit/Data/Resource/BufferingResourceTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//
66

77
@testable import ReadiumShared
8+
import TestPublications
89
import XCTest
910

1011
class BufferingResourceTests: XCTestCase {
@@ -99,7 +100,7 @@ class BufferingResourceTests: XCTestCase {
99100
}
100101
}
101102

102-
private let file = Fixtures(path: "Fetcher").url(for: "epub.epub")
103+
private let file = FileURL(url: TestPublications.url(for: "childrens-literature.epub"))!
103104
private lazy var data = try! Data(contentsOf: file.url)
104105
private lazy var resource = FileResource(file: file)
105106

Tests/SharedTests/Toolkit/Data/Resource/TailCachingResourceTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//
66

77
@testable import ReadiumShared
8+
import TestPublications
89
import XCTest
910

1011
class TailCachingResourceTests: XCTestCase {
@@ -50,7 +51,7 @@ class TailCachingResourceTests: XCTestCase {
5051
}
5152
}
5253

53-
private let file = Fixtures(path: "Fetcher").url(for: "epub.epub")
54+
private let file = FileURL(url: TestPublications.url(for: "childrens-literature.epub"))!
5455
private lazy var data = try! Data(contentsOf: file.url)
5556
private lazy var resource = FileResource(file: file)
5657

0 commit comments

Comments
 (0)