diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..a43997c --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,19 @@ +{ + "name": "swift 5.8", + "image": "swift:5.8", + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + "extensions": [ + "sswg.swift-lang" + ], + "settings": { + "lldb.library": "/usr/lib/liblldb.so", + "terminal.integrated.env.linux": { + "LOCALSTACK_ENDPOINT": "http://localstack:4566" + } + } + } + }, + "forwardPorts": [8080] +} \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7aa7759 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,48 @@ +name: CI + +on: + workflow_dispatch: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + macOS: + # https://github.com/actions/runner-images + runs-on: macos-13 + strategy: + matrix: + xcode: ['15.0', '14.3.1'] + steps: + - uses: actions/checkout@v3 + - run: git config --global user.email "me@example.com" + - run: git config --global user.name "Name" + - name: Get swift version + run: env DEVELOPER_DIR="/Applications/Xcode_${{ matrix.xcode }}.app" swift --version + - name: Test + run: env DEVELOPER_DIR="/Applications/Xcode_${{ matrix.xcode }}.app" swift test + - name: Build release + run: env DEVELOPER_DIR="/Applications/Xcode_${{ matrix.xcode }}.app" swift build -c release + + Linux: + # https://github.com/actions/runner-images + runs-on: ubuntu-latest + strategy: + matrix: + image: [ + 'swift:5.8', + 'swiftlang/swift@sha256:f212429011a4c3592ffaa660fd78b5bc149e9df7920da02dfc0e7a761582fa10' # swiftlang/swift:nightly-5.9-focal 2023-08-16 + ] + container: + image: ${{ matrix.image }} + steps: + - uses: actions/checkout@v3 + - run: git config --global user.email "me@example.com" + - run: git config --global user.name "Name" + - name: Get swift version + run: swift --version + - name: Test + run: swift test + - name: Build release + run: swift build -c release diff --git a/.swift-version b/.swift-version deleted file mode 100644 index bf77d54..0000000 --- a/.swift-version +++ /dev/null @@ -1 +0,0 @@ -4.2 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 06f52f3..0000000 --- a/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -os: linux -language: generic -sudo: required -dist: trusty -install: - - eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)" -script: - - swift test diff --git a/Sources/ShellOut.swift b/Sources/ShellOut.swift index c2b957c..39b2119 100644 --- a/Sources/ShellOut.swift +++ b/Sources/ShellOut.swift @@ -316,12 +316,6 @@ public extension ShellOutCommand { .init(command: "swift".unchecked, arguments: ["package", "update"].verbatim) } - /// Generate an Xcode project for a Swift package - static func generateSwiftPackageXcodeProject() -> ShellOutCommand { - .init(command: "swift".unchecked, - arguments: ["package", "generate-xcodeproj"].verbatim) - } - /// Build a Swift package using a given configuration (see SwiftBuildConfiguration for options) static func buildSwiftPackage(withConfiguration configuration: SwiftBuildConfiguration = .debug) -> ShellOutCommand { .init(command: "swift".unchecked, @@ -424,7 +418,6 @@ private extension Process { let errorPipe = Pipe() standardError = errorPipe - #if !os(Linux) outputPipe.fileHandleForReading.readabilityHandler = { handler in let data = handler.availableData outputQueue.async { @@ -440,7 +433,6 @@ private extension Process { errorHandle?.write(data) } } - #endif #if os(Linux) try run() @@ -448,13 +440,6 @@ private extension Process { launch() #endif - #if os(Linux) - outputQueue.sync { - outputData = outputPipe.fileHandleForReading.readDataToEndOfFile() - errorData = errorPipe.fileHandleForReading.readDataToEndOfFile() - } - #endif - waitUntilExit() if let handle = outputHandle, !handle.isStandard { @@ -465,10 +450,8 @@ private extension Process { handle.closeFile() } - #if !os(Linux) outputPipe.fileHandleForReading.readabilityHandler = nil errorPipe.fileHandleForReading.readabilityHandler = nil - #endif // Block until all writes have occurred to outputData and errorData, // and then read the data back out. diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift deleted file mode 100644 index b8a6c6c..0000000 --- a/Tests/LinuxMain.swift +++ /dev/null @@ -1,6 +0,0 @@ -import XCTest -@testable import ShellOutTests - -XCTMain([ - testCase(ShellOutTests.allTests), -]) diff --git a/Tests/ShellOutTests/ShellOutTests+Linux.swift b/Tests/ShellOutTests/ShellOutTests+Linux.swift deleted file mode 100644 index 508ad34..0000000 --- a/Tests/ShellOutTests/ShellOutTests+Linux.swift +++ /dev/null @@ -1,24 +0,0 @@ -/** - * ShellOut - * Copyright (c) John Sundell 2017 - * Licensed under the MIT license. See LICENSE file. - */ - -import XCTest -@testable import ShellOut - -#if os(Linux) -extension ShellOutTests { - static var allTests = [ - ("testWithoutArguments", testWithoutArguments), - ("testWithArguments", testWithArguments), - ("testWithInlineArguments", testWithInlineArguments), - ("testSingleCommandAtPath", testSingleCommandAtPath), - ("testSeriesOfCommands", testSeriesOfCommands), - ("testSeriesOfCommandsAtPath", testSeriesOfCommandsAtPath), - ("testThrowingError", testThrowingError), - ("testGitCommands", testGitCommands), - ("testSwiftPackageManagerCommands", testSwiftPackageManagerCommands) - ] -} -#endif diff --git a/Tests/ShellOutTests/ShellOutTests.swift b/Tests/ShellOutTests/ShellOutTests.swift index c3886da..7c86d58 100644 --- a/Tests/ShellOutTests/ShellOutTests.swift +++ b/Tests/ShellOutTests/ShellOutTests.swift @@ -42,15 +42,16 @@ class ShellOutTests: XCTestCase { } func testSingleCommandAtPath() throws { + let tempDir = NSTemporaryDirectory() try shellOut( to: "echo".checked, - arguments: [#"Hello" > \#(NSTemporaryDirectory())ShellOutTests-SingleCommand.txt"#.quoted] + arguments: ["Hello", ">".verbatim, "\(tempDir)ShellOutTests-SingleCommand.txt".quoted] ) let textFileContent = try shellOut( to: "cat".checked, arguments: ["ShellOutTests-SingleCommand.txt".quoted], - at: NSTemporaryDirectory() + at: tempDir ) XCTAssertEqual(textFileContent, "Hello") @@ -70,7 +71,7 @@ class ShellOutTests: XCTestCase { } func testSingleCommandAtPathContainingTilde() throws { - let homeContents = try shellOut(to: "ls".checked, at: "~") + let homeContents = try shellOut(to: "ls".checked, arguments: ["-a"], at: "~") XCTAssertFalse(homeContents.isEmpty) } @@ -180,33 +181,6 @@ class ShellOutTests: XCTestCase { XCTAssertEqual(try shellOut(to: .readFile(at: filePath)), "Hello again") } - func testSwiftPackageManagerCommands() throws { - // Setup & clear state - let tempFolderPath = NSTemporaryDirectory() - try shellOut(to: "rm".checked, - arguments: ["-rf", "SwiftPackageManagerTest"].verbatim, - at: tempFolderPath) - try shellOut(to: .createFolder(named: "SwiftPackageManagerTest"), at: tempFolderPath) - - // Create a Swift package and verify that it has a Package.swift file - let packagePath = tempFolderPath + "/SwiftPackageManagerTest" - try shellOut(to: .createSwiftPackage(), at: packagePath) - XCTAssertFalse(try shellOut(to: .readFile(at: packagePath + "/Package.swift")).isEmpty) - - // Build the package and verify that there's a .build folder - try shellOut(to: .buildSwiftPackage(), at: packagePath) - XCTAssertTrue( - try shellOut(to: "ls".checked, arguments: ["-a".verbatim], at: packagePath) .contains(".build") - ) - - // Generate an Xcode project - try shellOut(to: .generateSwiftPackageXcodeProject(), at: packagePath) - XCTAssertTrue( - try shellOut(to: "ls".checked, arguments: ["-a".verbatim], at: packagePath) - .contains("SwiftPackageManagerTest.xcodeproj") - ) - } - func testArgumentQuoting() throws { XCTAssertEqual(try shellOut(to: "echo".checked, arguments: ["foo ; echo bar".quoted]),