Skip to content

Commit 719d31e

Browse files
authored
Consolidate test targets (#232)
* Remove unused DownloadError * Inline interruptDownload helper method * Change MARK to TODO * Remove empty overrides for setup and teardown * Consolidate NormalizerTests, PostProcessorTest, and PreTokenizerTests into TokenizerTests target * Remove launch.json and disable automatic generation
1 parent 11d0d0c commit 719d31e

File tree

8 files changed

+6
-43
lines changed

8 files changed

+6
-43
lines changed

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,7 @@
3434
},
3535
"swift.swiftEnvironmentVariables": {
3636
"DEVELOPER_DIR": "/Applications/Xcode.app"
37-
}
37+
},
38+
// Disable automatic generation of launch `launch.json`
39+
"swift.autoGenerateLaunchConfigurations": false
3840
}

Package.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ let package = Package(
3636
.target(name: "Models", dependencies: ["Tokenizers", "Generation", "TensorUtils"]),
3737
.testTarget(name: "TokenizersTests", dependencies: ["Tokenizers", "Models", "Hub"], resources: [.process("Resources"), .process("Vocabs")]),
3838
.testTarget(name: "HubTests", dependencies: ["Hub", .product(name: "Jinja", package: "Jinja")], swiftSettings: swiftSettings),
39-
.testTarget(name: "PreTokenizerTests", dependencies: ["Tokenizers", "Hub"]),
4039
.testTarget(name: "TensorUtilsTests", dependencies: ["TensorUtils", "Models", "Hub"], resources: [.process("Resources")]),
41-
.testTarget(name: "NormalizerTests", dependencies: ["Tokenizers", "Hub"]),
42-
.testTarget(name: "PostProcessorTests", dependencies: ["Tokenizers", "Hub"]),
4340
]
4441
)

Tests/HubTests/DownloaderTests.swift

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,6 @@ import XCTest
1111
@testable import Hub
1212
import XCTest
1313

14-
/// Errors that can occur during the download process
15-
enum DownloadError: LocalizedError {
16-
case invalidDownloadLocation
17-
case unexpectedError
18-
19-
var errorDescription: String? {
20-
switch self {
21-
case .invalidDownloadLocation:
22-
String(localized: "The download location is invalid or inaccessible.", comment: "Error when download destination is invalid")
23-
case .unexpectedError:
24-
String(localized: "An unexpected error occurred during the download process.", comment: "Generic download error message")
25-
}
26-
}
27-
}
28-
29-
private extension Downloader {
30-
func interruptDownload() async {
31-
await session.get()?.invalidateAndCancel()
32-
}
33-
}
34-
3514
final class DownloaderTests: XCTestCase {
3615
var tempDir: URL!
3716

@@ -164,7 +143,8 @@ final class DownloaderTests: XCTestCase {
164143
if threshold != 1.0, progress >= threshold {
165144
// Move to next threshold and interrupt
166145
threshold = threshold == 0.5 ? 0.75 : 1.0
167-
await downloader.interruptDownload()
146+
// Interrupt download
147+
await downloader.session.get()?.invalidateAndCancel()
168148
}
169149
case let .failed(error):
170150
throw error

Tests/HubTests/HubApiTests.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,7 @@ import XCTest
99
@testable import Hub
1010

1111
class HubApiTests: XCTestCase {
12-
override func setUp() {
13-
// Put setup code here. This method is called before the invocation of each test method in the class.
14-
}
15-
16-
override func tearDown() {
17-
// Put teardown code here. This method is called after the invocation of each test method in the class.
18-
}
19-
20-
// MARK: use a specific revision for these tests
12+
// TODO: use a specific revision for these tests
2113

2214
func testFilenameRetrieval() async {
2315
do {

Tests/TokenizersTests/BertTokenizerTests.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@
1111
import XCTest
1212

1313
class BertTokenizerTests: XCTestCase {
14-
override func setUp() {
15-
// Put setup code here. This method is called before the invocation of each test method in the class.
16-
}
17-
18-
override func tearDown() {
19-
// Put teardown code here. This method is called after the invocation of each test method in the class.
20-
}
21-
2214
lazy var bertTokenizer: BertTokenizer = {
2315
let vocab = {
2416
let url = Bundle.module.url(forResource: "bert-vocab", withExtension: "txt")!

0 commit comments

Comments
 (0)