Skip to content

Commit

Permalink
Merge pull request #73 from mxcl/fixes/55
Browse files Browse the repository at this point in the history
typealias PathStruct and add Swift 5.5 niceness
  • Loading branch information
mxcl authored Jun 16, 2021
2 parents ecbb3a6 + 14f03ab commit bb449ff
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ on:
- .github/workflows/ci.yml
schedule:
- cron: '3 3 * * 5' # 3:03 AM, every Friday
concurrency:
group: ${{ github.head_ref || 'push' }}
cancel-in-progress: true
jobs:
smoke:
runs-on: macos-latest
steps:
- uses: technote-space/auto-cancel-redundant-job@v1
- uses: actions/checkout@v2
- run: swift test --generate-linuxmain
- run: git diff --exit-code
Expand Down
10 changes: 10 additions & 0 deletions Sources/Path+CommonDirectories.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,13 @@ func defaultUrl(for searchPath: FileManager.SearchPathDirectory) -> DynamicPath
}
#endif

#if swift(>=5.5)
extension Pathish where Self == Path {
static var home: DynamicPath { Path.home }
static var root: DynamicPath { Path.root }
static var cwd: DynamicPath { Path.cwd }
static var documents: DynamicPath { Path.documents }
static var caches: DynamicPath { Path.caches }
static var applicationSupport: DynamicPath { Path.applicationSupport }
}
#endif
2 changes: 2 additions & 0 deletions Sources/Path.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import func Glibc.realpath
let _realpath = Glibc.realpath
#endif

public typealias PathStruct = Path

/**
A `Path` represents an absolute path on a filesystem.
Expand Down
13 changes: 13 additions & 0 deletions Tests/PathTests/PathTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@ import func XCTest.XCTAssertEqual
import Foundation
import XCTest

extension PathStruct {
var foo: Int { fatalError()}
}

class PathTests: XCTestCase {
func testNewStuff() {
#if swift(>=5.5)
func foo<P: Pathish>(_ path: P) {}

foo(.home)
foo(.root)
#endif
}

func testConcatenation() {
XCTAssertEqual((Path.root/"bar").string, "/bar")
XCTAssertEqual(Path.cwd.string, FileManager.default.currentDirectoryPath)
Expand Down
1 change: 1 addition & 0 deletions Tests/PathTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ extension PathTests {
("testMktemp", testMktemp),
("testMoveInto", testMoveInto),
("testMoveTo", testMoveTo),
("testNewStuff", testNewStuff),
("testNoUndesiredSymlinkResolution", testNoUndesiredSymlinkResolution),
("testOptionalInitializer", testOptionalInitializer),
("testParent", testParent),
Expand Down

0 comments on commit bb449ff

Please sign in to comment.