Merge pull request #73 from mxcl/fixes/55
typealias PathStruct and add Swift 5.5 niceness
This commit is contained in:
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -6,11 +6,13 @@ on:
|
|||||||
- .github/workflows/ci.yml
|
- .github/workflows/ci.yml
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '3 3 * * 5' # 3:03 AM, every Friday
|
- cron: '3 3 * * 5' # 3:03 AM, every Friday
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.head_ref || 'push' }}
|
||||||
|
cancel-in-progress: true
|
||||||
jobs:
|
jobs:
|
||||||
smoke:
|
smoke:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: technote-space/auto-cancel-redundant-job@v1
|
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- run: swift test --generate-linuxmain
|
- run: swift test --generate-linuxmain
|
||||||
- run: git diff --exit-code
|
- run: git diff --exit-code
|
||||||
|
|||||||
@@ -108,3 +108,13 @@ func defaultUrl(for searchPath: FileManager.SearchPathDirectory) -> DynamicPath
|
|||||||
}
|
}
|
||||||
#endif
|
#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
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import func Glibc.realpath
|
|||||||
let _realpath = Glibc.realpath
|
let _realpath = Glibc.realpath
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
public typealias PathStruct = Path
|
||||||
|
|
||||||
/**
|
/**
|
||||||
A `Path` represents an absolute path on a filesystem.
|
A `Path` represents an absolute path on a filesystem.
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,20 @@ import func XCTest.XCTAssertEqual
|
|||||||
import Foundation
|
import Foundation
|
||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
|
extension PathStruct {
|
||||||
|
var foo: Int { fatalError()}
|
||||||
|
}
|
||||||
|
|
||||||
class PathTests: XCTestCase {
|
class PathTests: XCTestCase {
|
||||||
|
func testNewStuff() {
|
||||||
|
#if swift(>=5.5)
|
||||||
|
func foo<P: Pathish>(_ path: P) {}
|
||||||
|
|
||||||
|
foo(.home)
|
||||||
|
foo(.root)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
func testConcatenation() {
|
func testConcatenation() {
|
||||||
XCTAssertEqual((Path.root/"bar").string, "/bar")
|
XCTAssertEqual((Path.root/"bar").string, "/bar")
|
||||||
XCTAssertEqual(Path.cwd.string, FileManager.default.currentDirectoryPath)
|
XCTAssertEqual(Path.cwd.string, FileManager.default.currentDirectoryPath)
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ extension PathTests {
|
|||||||
("testMktemp", testMktemp),
|
("testMktemp", testMktemp),
|
||||||
("testMoveInto", testMoveInto),
|
("testMoveInto", testMoveInto),
|
||||||
("testMoveTo", testMoveTo),
|
("testMoveTo", testMoveTo),
|
||||||
|
("testNewStuff", testNewStuff),
|
||||||
("testNoUndesiredSymlinkResolution", testNoUndesiredSymlinkResolution),
|
("testNoUndesiredSymlinkResolution", testNoUndesiredSymlinkResolution),
|
||||||
("testOptionalInitializer", testOptionalInitializer),
|
("testOptionalInitializer", testOptionalInitializer),
|
||||||
("testParent", testParent),
|
("testParent", testParent),
|
||||||
|
|||||||
Reference in New Issue
Block a user