Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@
},
"swift.swiftEnvironmentVariables": {
"DEVELOPER_DIR": "/Applications/Xcode.app"
}
},
// Disable automatic generation of launch `launch.json`
"swift.autoGenerateLaunchConfigurations": false
}
3 changes: 0 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ let package = Package(
.target(name: "Models", dependencies: ["Tokenizers", "Generation", "TensorUtils"]),
.testTarget(name: "TokenizersTests", dependencies: ["Tokenizers", "Models", "Hub"], resources: [.process("Resources"), .process("Vocabs")]),
.testTarget(name: "HubTests", dependencies: ["Hub", .product(name: "Jinja", package: "Jinja")], swiftSettings: swiftSettings),
.testTarget(name: "PreTokenizerTests", dependencies: ["Tokenizers", "Hub"]),
.testTarget(name: "TensorUtilsTests", dependencies: ["TensorUtils", "Models", "Hub"], resources: [.process("Resources")]),
.testTarget(name: "NormalizerTests", dependencies: ["Tokenizers", "Hub"]),
.testTarget(name: "PostProcessorTests", dependencies: ["Tokenizers", "Hub"]),
]
)
24 changes: 2 additions & 22 deletions Tests/HubTests/DownloaderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,6 @@ import XCTest
@testable import Hub
import XCTest

/// Errors that can occur during the download process
enum DownloadError: LocalizedError {
case invalidDownloadLocation
case unexpectedError

var errorDescription: String? {
switch self {
case .invalidDownloadLocation:
String(localized: "The download location is invalid or inaccessible.", comment: "Error when download destination is invalid")
case .unexpectedError:
String(localized: "An unexpected error occurred during the download process.", comment: "Generic download error message")
}
}
}

private extension Downloader {
func interruptDownload() async {
await session.get()?.invalidateAndCancel()
}
}

final class DownloaderTests: XCTestCase {
var tempDir: URL!

Expand Down Expand Up @@ -164,7 +143,8 @@ final class DownloaderTests: XCTestCase {
if threshold != 1.0, progress >= threshold {
// Move to next threshold and interrupt
threshold = threshold == 0.5 ? 0.75 : 1.0
await downloader.interruptDownload()
// Interrupt download
await downloader.session.get()?.invalidateAndCancel()
}
case let .failed(error):
throw error
Expand Down
10 changes: 1 addition & 9 deletions Tests/HubTests/HubApiTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,7 @@ import XCTest
@testable import Hub

class HubApiTests: XCTestCase {
override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

// MARK: use a specific revision for these tests
// TODO: use a specific revision for these tests

func testFilenameRetrieval() async {
do {
Expand Down
8 changes: 0 additions & 8 deletions Tests/TokenizersTests/BertTokenizerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
import XCTest

class BertTokenizerTests: XCTestCase {
override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

lazy var bertTokenizer: BertTokenizer = {
let vocab = {
let url = Bundle.module.url(forResource: "bert-vocab", withExtension: "txt")!
Expand Down