Skip to content

Commit c7dace2

Browse files
fix: add support for Xcode 13 (#80)
* Fix compilation issue on Xcode 13 * Fix ambiguous use of `expect` issue
1 parent 2eb235a commit c7dace2

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

Sources/PathKit.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,9 @@ extension Path {
588588
extension Path {
589589
public static func glob(_ pattern: String) -> [Path] {
590590
var gt = glob_t()
591-
let cPattern = strdup(pattern)
591+
guard let cPattern = strdup(pattern) else {
592+
fatalError("strdup returned null: Likely out of memory")
593+
}
592594
defer {
593595
globfree(&gt)
594596
free(cPattern)
@@ -619,8 +621,10 @@ extension Path {
619621
}
620622

621623
public func match(_ pattern: String) -> Bool {
622-
let cPattern = strdup(pattern)
623-
let cPath = strdup(path)
624+
guard let cPattern = strdup(pattern),
625+
let cPath = strdup(path) else {
626+
fatalError("strdup returned null: Likely out of memory")
627+
}
624628
defer {
625629
free(cPattern)
626630
free(cPath)

Tests/PathKitTests/PathKitSpec.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,12 @@ describe("PathKit") {
290290
let current = Path.current
291291
let error = ThrowError()
292292

293-
try expect {
293+
try expect({
294294
try Path("/usr/bin").chdir {
295295
try expect(Path.current) == Path("/usr/bin")
296296
throw error
297297
}
298-
}.toThrow(error)
298+
}).toThrow(error)
299299

300300
try expect(Path.current) == current
301301
}
@@ -324,9 +324,9 @@ describe("PathKit") {
324324
$0.it("errors when you read from a non-existing file as NSData") {
325325
let path = Path("/tmp/pathkit-testing")
326326

327-
try expect {
327+
try expect({
328328
try path.read() as Data
329-
}.toThrow()
329+
}).toThrow()
330330
}
331331

332332
$0.it("can read a String from a file") {
@@ -339,9 +339,9 @@ describe("PathKit") {
339339
$0.it("errors when you read from a non-existing file as a String") {
340340
let path = Path("/tmp/pathkit-testing")
341341

342-
try expect {
342+
try expect({
343343
try path.read() as String
344-
}.toThrow()
344+
}).toThrow()
345345
}
346346
}
347347

@@ -364,9 +364,9 @@ describe("PathKit") {
364364
let path = Path("/")
365365
let data = "Hi".data(using: String.Encoding.utf8, allowLossyConversion: true)
366366

367-
try expect {
367+
try expect({
368368
try path.write(data!)
369-
}.toThrow()
369+
}).toThrow()
370370
#endif
371371
}
372372

@@ -384,9 +384,9 @@ describe("PathKit") {
384384
#else
385385
let path = Path("/")
386386

387-
try expect {
387+
try expect({
388388
try path.write("hi")
389-
}.toThrow()
389+
}).toThrow()
390390
#endif
391391
}
392392
}

0 commit comments

Comments
 (0)