Buckets:
localhost1978/localhost / LOCALHOST1978 /Modules /SSK_Foundation /Tests /SSK_FoundationTests /LoreIgnoreTests.swift
| import XCTest | |
| @testable import SSK_Foundation | |
| final class LoreIgnoreTests: XCTestCase { | |
| var tempDirectoryURL: URL! | |
| override func setUp() async throws { | |
| let tempDir = FileManager.default.temporaryDirectory | |
| tempDirectoryURL = tempDir.appendingPathComponent("LoreIgnoreTests_\(UUID().uuidString)") | |
| try FileManager.default.createDirectory(at: tempDirectoryURL, withIntermediateDirectories: true) | |
| } | |
| override func tearDown() async throws { | |
| if FileManager.default.fileExists(atPath: tempDirectoryURL.path) { | |
| try FileManager.default.removeItem(at: tempDirectoryURL) | |
| } | |
| } | |
| func testLoreIgnoreRuleMatching() { | |
| guard let rule = LoreIgnoreRule(line: ".build/") else { | |
| XCTFail("Failed to create rule") | |
| return | |
| } | |
| XCTAssertTrue(rule.isDirectoryOnly) | |
| XCTAssertTrue(rule.matches(relativePath: ".build", isDirectory: true)) | |
| XCTAssertTrue(rule.matches(relativePath: "Modules/SSK_Foundation/.build/debug/foo", isDirectory: false)) | |
| } | |
| func testWildcardExtensionMatching() { | |
| guard let rule = LoreIgnoreRule(line: "*.zip") else { | |
| XCTFail("Failed to create rule") | |
| return | |
| } | |
| XCTAssertTrue(rule.matches(relativePath: "archive.zip", isDirectory: false)) | |
| XCTAssertTrue(rule.matches(relativePath: "sub/folder/data.zip", isDirectory: false)) | |
| XCTAssertFalse(rule.matches(relativePath: "archive.swift", isDirectory: false)) | |
| } | |
| func testNegatedRuleMatching() { | |
| let loreIgnoreContent = """ | |
| src/legacy_intake/ | |
| !src/legacy_intake/Thesis/ | |
| """ | |
| let ignoreFileURL = tempDirectoryURL.appendingPathComponent(".loreignore") | |
| try? loreIgnoreContent.write(to: ignoreFileURL, atomically: true, encoding: .utf8) | |
| let loreIgnore = LoreIgnore(rootURL: tempDirectoryURL) | |
| let ignoredSubPath = tempDirectoryURL.appendingPathComponent("src/legacy_intake/photos/img.png") | |
| let unignoredSubPath = tempDirectoryURL.appendingPathComponent("src/legacy_intake/Thesis/AskMikeeHost/main.py") | |
| XCTAssertTrue(loreIgnore.isIgnored(url: ignoredSubPath, isDirectory: false)) | |
| XCTAssertFalse(loreIgnore.isIgnored(url: unignoredSubPath, isDirectory: false)) | |
| } | |
| func testLoreIgnoreFilter() { | |
| let loreIgnoreContent = """ | |
| .DS_Store | |
| .build/ | |
| *.log | |
| """ | |
| let ignoreFileURL = tempDirectoryURL.appendingPathComponent(".loreignore") | |
| try? loreIgnoreContent.write(to: ignoreFileURL, atomically: true, encoding: .utf8) | |
| let loreIgnore = LoreIgnore(rootURL: tempDirectoryURL) | |
| let validFile = tempDirectoryURL.appendingPathComponent("Sources/Main.swift") | |
| let dsStore = tempDirectoryURL.appendingPathComponent("Sources/.DS_Store") | |
| let buildFile = tempDirectoryURL.appendingPathComponent(".build/foo.o") | |
| let logFile = tempDirectoryURL.appendingPathComponent("output.log") | |
| let urls = [validFile, dsStore, buildFile, logFile] | |
| let filtered = loreIgnore.filter(urls) | |
| XCTAssertEqual(filtered.count, 1) | |
| XCTAssertEqual(filtered.first, validFile) | |
| } | |
| } | |
Xet Storage Details
- Size:
- 3.33 kB
- Xet hash:
- 4e2e147e8f53330342b7ebee35b0c3c2f2238249e27e1369230c01fe1fe4bbed
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.