Compare commits

..

7 Commits
0.4.1 ... 0.4.2

Author SHA1 Message Date
Max Howell
aac81b85a4 Merge pull request #8 from mxcl/better-deploy
Better deploy
2019-01-20 18:53:11 -05:00
Max Howell
3644124a36 Fix testing on tvOS/iOS 2019-01-20 18:44:24 -05:00
Max Howell
ca4ac3ec8f Fix stage types in .travis.yml 2019-01-20 17:33:56 -05:00
Max Howell
920f007660 Fix Linux testEnumerationSkippingHiddenFiles() 2019-01-20 17:32:39 -05:00
Max Howell
751b855a26 Pretest that fails if Linux tests aren't current 2019-01-20 17:25:46 -05:00
Max Howell
c0e5023632 Better deployment of Jazzy and Pods 2019-01-20 17:13:03 -05:00
Max Howell
e0c62108e8 Update Linux tests 2019-01-20 16:30:02 -05:00
7 changed files with 77 additions and 48 deletions

View File

@@ -2,6 +2,7 @@
if: type != push OR branch = master OR branch =~ /^\d+\.\d+(\.\d+)?(-\S*)?$/ if: type != push OR branch = master OR branch =~ /^\d+\.\d+(\.\d+)?(-\S*)?$/
stages: stages:
- name: pretest
- name: test - name: test
- name: deploy - name: deploy
if: branch =~ ^\d+\.\d+\.\d+$ if: branch =~ ^\d+\.\d+\.\d+$
@@ -34,7 +35,6 @@ jobs:
-destination 'platform=watchOS Simulator,OS=latest,name=Apple Watch Series 4 - 40mm' \ -destination 'platform=watchOS Simulator,OS=latest,name=Apple Watch Series 4 - 40mm' \
build | xcpretty build | xcpretty
- env: SWIFT_VERSION=4.2.1 - env: SWIFT_VERSION=4.2.1
os: linux os: linux
name: Linux name: Linux
@@ -43,30 +43,34 @@ jobs:
sudo: false sudo: false
install: eval "$(curl -sL https://swiftenv.fuller.li/install.sh)" install: eval "$(curl -sL https://swiftenv.fuller.li/install.sh)"
script: swift test script: swift test
- stage: pretest
name: Check if Linux tests are up-to-date
install: swift test --generate-linuxmain
script: git diff --exit-code
- <<: *xcodebuild - stage: deploy
stage: deploy
name: Jazzy name: Jazzy
before_install: | before_install: |
cat << EOF > .jazzy.yml cat << EOF > .jazzy.yaml
module: Path
module_version: $TRAVIS_TAG
custom_categories: custom_categories:
- name: Path - name: Path
children: children:
- Path - Path
- /(_:_:) - /(_:_:)
xcodebuild_arguments:
- UseModernBuildSystem=NO
output: output
github_url: https://github.com/mxcl/Path.swift
EOF EOF
touch Contents.md install: |
install: gem install jazzy gem install jazzy
swift package generate-xcodeproj
script: | script: |
jazzy \ jazzy
--no-hide-documentation-coverage \ rm -rf output/docsets
--theme fullwidth \
--output output \
--readme Contents.md \
--root-url https://mxcl.github.io/Path.swift/ \
--github_url https://github.com/mxcl/Path.swift \
--module Path \
--module-version $TRAVIS_TAG
deploy: deploy:
provider: pages provider: pages
skip-cleanup: true skip-cleanup: true
@@ -75,7 +79,25 @@ jobs:
on: on:
tags: true tags: true
- stage: deploy - name: CocoaPods
name: CocoaPods before_install: |
cat << EOF > Path.swift.podspec
Pod::Spec.new do |s|
s.name = 'Path.swift'
s.version = '$TRAVIS_TAG'
s.summary = 'Delightful, robust file-pathing functions'
s.homepage = 'https://github.com/mxcl/Path.swift'
s.license = { :type => 'Unlicense', :file => 'LICENSE.md' }
s.author = { 'mxcl' => 'mxcl@me.com' }
s.source = { :git => 'https://github.com/mxcl/Path.swift.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/mxcl'
s.osx.deployment_target = '10.10'
s.ios.deployment_target = '8.0'
s.tvos.deployment_target = '10.0'
s.watchos.deployment_target = '3.0'
s.source_files = 'Sources/*'
s.swift_version = "4.2"
end
EOF
install: gem install cocoapods --pre install: gem install cocoapods --pre
script: pod trunk push --allow-warnings script: pod trunk push --allow-warnings

View File

@@ -1,19 +0,0 @@
Pod::Spec.new do |s|
s.name = 'Path.swift'
s.version = '0.4.1'
s.summary = 'Delightful, robust file-pathing functions'
s.homepage = 'https://github.com/mxcl/Path.swift'
s.license = { :type => 'Unlicense', :file => 'LICENSE.md' }
s.author = { 'mxcl' => 'mxcl@me.com' }
s.source = { :git => 'https://github.com/mxcl/Path.swift.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/mxcl'
s.osx.deployment_target = '10.10'
s.ios.deployment_target = '8.0'
s.tvos.deployment_target = '10.0'
s.watchos.deployment_target = '3.0'
s.source_files = 'Sources/*'
s.swift_version = "4.2"
end

View File

@@ -208,4 +208,4 @@ https://codebasesaga.com/canopy/
[badge-platforms]: https://img.shields.io/badge/platforms-macOS%20%7C%20Linux%20%7C%20iOS%20%7C%20tvOS%20%7C%20watchOS-lightgrey.svg [badge-platforms]: https://img.shields.io/badge/platforms-macOS%20%7C%20Linux%20%7C%20iOS%20%7C%20tvOS%20%7C%20watchOS-lightgrey.svg
[badge-languages]: https://img.shields.io/badge/swift-4.2-orange.svg [badge-languages]: https://img.shields.io/badge/swift-4.2-orange.svg
[online API documentation]: https://mxcl.github.io/Path.swift/ [online API documentation]: https://mxcl.github.io/Path.swift/Structs/Path.html

View File

@@ -1,13 +1,19 @@
import Foundation import Foundation
public extension Path { public extension Path {
/// Same as the `ls` command is shallow /**
/// - Parameter skipHiddenFiles: Same as the `ls -a` if false. Otherwise returns only the non hidden files. Default is false. Same as the `ls -a` command is shallow
func ls(skipHiddenFiles: Bool = false) throws -> [Entry] { - Parameter includeHiddenFiles: If `true`, hidden files are included in the results. Defaults to `true`.
let options: FileManager.DirectoryEnumerationOptions = skipHiddenFiles ? [.skipsHiddenFiles] : [] - Important: `includeHiddenFiles` does not work on Linux
let paths = try FileManager.default.contentsOfDirectory(at: url, */
includingPropertiesForKeys: nil, func ls(includeHiddenFiles: Bool = true) throws -> [Entry] {
options: options) var opts = FileManager.DirectoryEnumerationOptions()
#if !os(Linux)
if !includeHiddenFiles {
opts.insert(.skipsHiddenFiles)
}
#endif
let paths = try FileManager.default.contentsOfDirectory(at: url, includingPropertiesForKeys: nil, options: opts)
func convert(url: URL) -> Entry? { func convert(url: URL) -> Entry? {
guard let path = Path(url.path) else { return nil } guard let path = Path(url.path) else { return nil }
return Entry(kind: path.isDirectory ? .directory : .file, path: path) return Entry(kind: path.isDirectory ? .directory : .file, path: path)

View File

@@ -31,8 +31,9 @@ class PathTests: XCTestCase {
XCTAssertEqual(paths, ["a", "b", "c", ".d"]) XCTAssertEqual(paths, ["a", "b", "c", ".d"])
} }
func testEnumerationSkippingHiddenFiles() throws { func testEnumerationSkippingHiddenFiles() throws {
#if !os(Linux)
let tmpdir_ = try TemporaryDirectory() let tmpdir_ = try TemporaryDirectory()
let tmpdir = tmpdir_.path let tmpdir = tmpdir_.path
try tmpdir.join("a").mkdir().join("c").touch() try tmpdir.join("a").mkdir().join("c").touch()
@@ -42,7 +43,7 @@ class PathTests: XCTestCase {
var paths = Set<String>() var paths = Set<String>()
var dirs = 0 var dirs = 0
for entry in try tmpdir.ls(skipHiddenFiles: true) { for entry in try tmpdir.ls(includeHiddenFiles: false) {
if entry.kind == .directory { if entry.kind == .directory {
dirs += 1 dirs += 1
} }
@@ -50,7 +51,7 @@ class PathTests: XCTestCase {
} }
XCTAssertEqual(dirs, 1) XCTAssertEqual(dirs, 1)
XCTAssertEqual(paths, ["a", "b", "c"]) XCTAssertEqual(paths, ["a", "b", "c"])
#endif
} }
func testRelativeTo() { func testRelativeTo() {

View File

@@ -52,3 +52,20 @@ extension Path {
return try body(tmp.path) return try body(tmp.path)
} }
} }
#if !os(macOS) && !os(Linux)
import XCTest
// SwiftPM generates code that is improperly escaped thus we require this to
// compile on iOS & tvOS.
public typealias XCTestCaseEntry = (testCaseClass: XCTestCase.Type, allTests: [(String, (XCTestCase) throws -> Void)])
public func testCase<T: XCTestCase>(_ allTests: [(String, (T) -> () throws -> Void)]) -> XCTestCaseEntry {
fatalError()
}
public func testCase<T: XCTestCase>(_ allTests: [(String, (T) -> () -> Void)]) -> XCTestCaseEntry {
fatalError()
}
#endif

View File

@@ -6,8 +6,10 @@ extension PathTests {
("testCodable", testCodable), ("testCodable", testCodable),
("testConcatenation", testConcatenation), ("testConcatenation", testConcatenation),
("testEnumeration", testEnumeration), ("testEnumeration", testEnumeration),
("testEnumerationSkippingHiddenFiles", testEnumerationSkippingHiddenFiles),
("testExists", testExists), ("testExists", testExists),
("testIsDirectory", testIsDirectory), ("testIsDirectory", testIsDirectory),
("testJoin", testJoin),
("testMkpathIfExists", testMkpathIfExists), ("testMkpathIfExists", testMkpathIfExists),
("testMktemp", testMktemp), ("testMktemp", testMktemp),
("testRelativePathCodable", testRelativePathCodable), ("testRelativePathCodable", testRelativePathCodable),
@@ -15,7 +17,7 @@ extension PathTests {
] ]
} }
#if os(Linux) #if !os(macOS)
public func __allTests() -> [XCTestCaseEntry] { public func __allTests() -> [XCTestCaseEntry] {
return [ return [
testCase(PathTests.__allTests), testCase(PathTests.__allTests),