Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
82640e629d | ||
|
|
f49e5c82c7 | ||
|
|
287afe3783 | ||
|
|
bb449ff412 | ||
|
|
14f03abaad | ||
|
|
ecbb3a60fe | ||
|
|
3af771f543 | ||
|
|
0b68e5c011 | ||
|
|
fec4ed25de | ||
|
|
6e78d9317e | ||
|
|
3035c45808 |
9
.github/workflows/checks.yml
vendored
9
.github/workflows/checks.yml
vendored
@@ -1,14 +1,13 @@
|
||||
name: Checks
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- Sources/**
|
||||
- Tests/**
|
||||
- '**/*.swift'
|
||||
- .github/workflows/checks.yml
|
||||
jobs:
|
||||
macOS:
|
||||
runs-on: macos-latest
|
||||
smoke:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: swift --version
|
||||
|
||||
99
.github/workflows/ci.yml
vendored
99
.github/workflows/ci.yml
vendored
@@ -1,10 +1,18 @@
|
||||
name: CI
|
||||
on: pull_request
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '**/*.swift'
|
||||
- .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
|
||||
@@ -13,71 +21,62 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
matrix:
|
||||
destination:
|
||||
- platform=iOS Simulator,OS=latest,name=iPhone 12
|
||||
- platform=tvOS Simulator,OS=latest,name=Apple TV
|
||||
# - platform=watchOS Simulator,OS=latest,name=Apple Watch Series 5 - 40mm
|
||||
# ^^ coming with Xcode 12.5 which is not yet available on GHA
|
||||
- platform=macOS
|
||||
platform:
|
||||
- iOS
|
||||
- tvOS
|
||||
- macOS
|
||||
- watchOS
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: maxim-lobanov/setup-xcode@v1
|
||||
- uses: mxcl/xcodebuild@v1
|
||||
with:
|
||||
xcode-version: 12.4
|
||||
- run: swift package generate-xcodeproj --enable-code-coverage
|
||||
- uses: sersoft-gmbh/xcodebuild-action@v1
|
||||
with:
|
||||
project: Path.swift.xcodeproj
|
||||
scheme: Path.swift-Package
|
||||
destination: ${{ matrix.destination }}
|
||||
action: test
|
||||
platform: ${{ matrix.platform }}
|
||||
code-coverage: true
|
||||
warnings-as-errors: true
|
||||
- uses: codecov/codecov-action@v1
|
||||
|
||||
linux-swift-4:
|
||||
name: linux (4.2)
|
||||
runs-on: ubuntu-18.04
|
||||
name: linux (${{ matrix.swift }})
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
swift: ['4.2', '5.0']
|
||||
container:
|
||||
image: swift:${{ matrix.swift }}
|
||||
steps:
|
||||
- uses: fwal/setup-swift@v1
|
||||
with:
|
||||
swift-version: 4.2
|
||||
- uses: actions/checkout@v2
|
||||
- run: swift test --parallel
|
||||
- run: useradd -ms /bin/bash mxcl
|
||||
- run: chown -R mxcl .
|
||||
- run: su mxcl -c 'swift test --parallel'
|
||||
|
||||
linux:
|
||||
runs-on: ubuntu-18.04
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
swift:
|
||||
- '5.0'
|
||||
- '5.1'
|
||||
- '5.2'
|
||||
- '5.3'
|
||||
- swift:5.1
|
||||
- swift:5.2
|
||||
- swift:5.3
|
||||
- swift:5.4
|
||||
- swiftlang/swift:nightly-5.5
|
||||
container:
|
||||
image: ${{ matrix.swift }}
|
||||
steps:
|
||||
- uses: fwal/setup-swift@v1
|
||||
with:
|
||||
swift-version: ${{ matrix.swift }}
|
||||
- uses: actions/checkout@v2
|
||||
- run: swift test --parallel --enable-code-coverage
|
||||
- name: Generate Coverage Report
|
||||
- run: useradd -ms /bin/bash mxcl
|
||||
# ^^ we need to be a normal user and not root for the tests to be valid
|
||||
- run: chown -R mxcl .
|
||||
- run: su mxcl -c 'swift test --parallel --enable-code-coverage'
|
||||
- name: Generate `.lcov`
|
||||
run: |
|
||||
sudo apt-get -qq update && sudo apt-get -qq install llvm-10
|
||||
export b=$(swift build --show-bin-path) && llvm-cov-10 \
|
||||
export -format lcov \
|
||||
-instr-profile=$b/codecov/default.profdata \
|
||||
--ignore-filename-regex='\.build/' \
|
||||
$b/Path.swiftPackageTests.xctest \
|
||||
apt-get -qq update && apt-get -qq install curl
|
||||
b=$(swift build --show-bin-path)
|
||||
llvm-cov export \
|
||||
-format lcov \
|
||||
-instr-profile="$b"/codecov/default.profdata \
|
||||
--ignore-filename-regex='\.build|Tests' \
|
||||
"$b"/*.xctest \
|
||||
> info.lcov
|
||||
- uses: codecov/codecov-action@v1
|
||||
with:
|
||||
file: ./info.lcov
|
||||
|
||||
# code coverage fails with 5.4 for some reason
|
||||
linux-swift-5-4:
|
||||
name: linux (5.4)
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: fwal/setup-swift@v1
|
||||
with:
|
||||
swift-version: 5.4
|
||||
- uses: actions/checkout@v2
|
||||
- run: swift test --parallel
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import Foundation
|
||||
|
||||
/// The `extension` that provides static properties that are common directories.
|
||||
extension Path {
|
||||
private enum Foo {
|
||||
//MARK: Common Directories
|
||||
|
||||
/// Returns a `Path` containing `FileManager.default.currentDirectoryPath`.
|
||||
public static var cwd: DynamicPath {
|
||||
static var cwd: DynamicPath {
|
||||
return .init(string: FileManager.default.currentDirectoryPath)
|
||||
}
|
||||
|
||||
/// Returns a `Path` representing the root path.
|
||||
public static var root: DynamicPath {
|
||||
static var root: DynamicPath {
|
||||
return .init(string: "/")
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ extension Path {
|
||||
#endif
|
||||
|
||||
/// Returns a `Path` representing the user’s home directory
|
||||
public static var home: DynamicPath {
|
||||
static var home: DynamicPath {
|
||||
let string: String
|
||||
#if os(macOS)
|
||||
if #available(OSX 10.12, *) {
|
||||
@@ -70,7 +70,7 @@ extension Path {
|
||||
- Note: There is no standard location for documents on Linux, thus we return `~/Documents`.
|
||||
- Note: You should create a subdirectory before creating any files.
|
||||
*/
|
||||
public static var documents: DynamicPath {
|
||||
static var documents: DynamicPath {
|
||||
return path(for: .documentDirectory)
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ extension Path {
|
||||
- Note: On Linux this is `XDG_CACHE_HOME`.
|
||||
- Note: You should create a subdirectory before creating any files.
|
||||
*/
|
||||
public static var caches: DynamicPath {
|
||||
static var caches: DynamicPath {
|
||||
return path(for: .cachesDirectory)
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ extension Path {
|
||||
- Note: On Linux is `XDG_DATA_HOME`.
|
||||
- Note: You should create a subdirectory before creating any files.
|
||||
*/
|
||||
public static var applicationSupport: DynamicPath {
|
||||
static var applicationSupport: DynamicPath {
|
||||
return path(for: .applicationSupportDirectory)
|
||||
}
|
||||
}
|
||||
@@ -108,3 +108,35 @@ func defaultUrl(for searchPath: FileManager.SearchPathDirectory) -> DynamicPath
|
||||
}
|
||||
#endif
|
||||
|
||||
/// The `extension` that provides static properties that are common directories.
|
||||
#if swift(>=5.5)
|
||||
public extension Pathish where Self == Path {
|
||||
static var home: DynamicPath { return Foo.home }
|
||||
static var root: DynamicPath { return Foo.root }
|
||||
static var cwd: DynamicPath { return Foo.cwd }
|
||||
static var documents: DynamicPath { return Foo.documents }
|
||||
static var caches: DynamicPath { return Foo.caches }
|
||||
static var applicationSupport: DynamicPath { return Foo.applicationSupport }
|
||||
static func source(for filePath: String = #filePath) -> (file: DynamicPath, directory: DynamicPath) {
|
||||
return Foo.source(for: filePath)
|
||||
}
|
||||
}
|
||||
#else
|
||||
public extension Path {
|
||||
static var home: DynamicPath { return Foo.home }
|
||||
static var root: DynamicPath { return Foo.root }
|
||||
static var cwd: DynamicPath { return Foo.cwd }
|
||||
static var documents: DynamicPath { return Foo.documents }
|
||||
static var caches: DynamicPath { return Foo.caches }
|
||||
static var applicationSupport: DynamicPath { return Foo.applicationSupport }
|
||||
#if swift(>=5.3)
|
||||
static func source(for filePath: String = #filePath) -> (file: DynamicPath, directory: DynamicPath) {
|
||||
return Foo.source(for: filePath)
|
||||
}
|
||||
#else
|
||||
static func source(for file: String = #file) -> (file: DynamicPath, directory: DynamicPath) {
|
||||
return Foo.source(for: file)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -198,6 +198,6 @@ public extension Array where Element == Path {
|
||||
|
||||
/// Options for `Path.ls(_:)`
|
||||
public enum ListDirectoryOptions {
|
||||
/// Creates intermediary directories; works the same as `mkdir -p`.
|
||||
/// Lists hidden files also
|
||||
case a
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -45,6 +45,7 @@ extension PathTests {
|
||||
("testMktemp", testMktemp),
|
||||
("testMoveInto", testMoveInto),
|
||||
("testMoveTo", testMoveTo),
|
||||
("testNewStuff", testNewStuff),
|
||||
("testNoUndesiredSymlinkResolution", testNoUndesiredSymlinkResolution),
|
||||
("testOptionalInitializer", testOptionalInitializer),
|
||||
("testParent", testParent),
|
||||
|
||||
Reference in New Issue
Block a user