Test iOS, tvOS & watchOS

This commit is contained in:
Max Howell
2019-01-18 13:37:28 -05:00
committed by GitHub
parent 9553968d66
commit f99e7b5ae7
3 changed files with 57 additions and 10 deletions

View File

@@ -1,14 +1,38 @@
# only run for: merge commits, releases and pull-requests
if: type != push OR branch = master OR branch =~ /^\d+\.\d+(\.\d+)?(-\S*)?$/
os: osx
language: swift
osx_image: xcode10.1
xcode_project: Path.swift.xcodeproj
xcode_scheme: Path.swift-Package
jobs:
include:
- os: osx
language: swift
osx_image: xcode10.1
script: swift test
- script: swift test
name: macOS
- &xcodebuild
before_install: swift package generate-xcodeproj
xcode_destination: platform=iOS Simulator,OS=latest,name=iPhone XS
name: iOS
- <<: *xcodebuild
xcode_destination: platform=tvOS Simulator,OS=latest,name=Apple TV
name: tvOS
- <<: *xcodebuild
name: watchOS
script: |
set -o pipefail
xcodebuild \
-project Path.swift.xcodeproj \
-scheme Path.swift-Package \
-destination 'platform=watchOS Simulator,OS=latest,name=Apple Watch Series 4 - 40mm' \
build | xcpretty
- env: SWIFT_VERSION=4.2.1
os: linux
name: Linux
language: generic
dist: trusty
sudo: false

View File

@@ -147,5 +147,5 @@ package.append(.package(url: "https://github.com/mxcl/Path.swift", from: "0.0.0"
https://codebasesaga.com/canopy/
[badge-platforms]: https://img.shields.io/badge/platforms-macOS%20%7C%20Linux-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

View File

@@ -4,9 +4,32 @@ public class TemporaryDirectory {
public let url: URL
public var path: Path { return Path(string: url.path) }
public init() throws {
/**
Creates a new temporary directory.
The directory is recursively deleted when this object deallocates.
If you need a temporary directory on a specific volume use the `appropriateFor`
parameter.
- Important: If you are moving a file, ensure to use the `appropriateFor`
parameter, since it is volume aware and moving the file across volumes will take
exponentially longer!
- Important: The `appropriateFor` parameter does not work on Linux.
- Parameter appropriateFor: The temporary directory will be located on this
volume.
*/
public init(appropriateFor: URL? = nil) throws {
#if !os(Linux)
url = try FileManager.default.url(for: .itemReplacementDirectory, in: .userDomainMask, appropriateFor: URL(fileURLWithPath: "/"), create: true)
let appropriate: URL
if let appropriateFor = appropriateFor {
appropriate = appropriateFor
} else if #available(OSX 10.12, iOS 10, tvOS 10, watchOS 3, *) {
appropriate = FileManager.default.temporaryDirectory
} else {
appropriate = URL(fileURLWithPath: NSTemporaryDirectory())
}
url = try FileManager.default.url(for: .itemReplacementDirectory, in: .userDomainMask, appropriateFor: appropriate, create: true)
#else
let envs = ProcessInfo.processInfo.environment
let env = envs["TMPDIR"] ?? envs["TEMP"] ?? envs["TMP"] ?? "/tmp"