Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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]
}
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion .swift-version

This file was deleted.

8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

17 changes: 0 additions & 17 deletions Sources/ShellOut.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand All @@ -440,21 +433,13 @@ private extension Process {
errorHandle?.write(data)
}
}
#endif

#if os(Linux)
try run()
#else
launch()
#endif

#if os(Linux)
outputQueue.sync {
outputData = outputPipe.fileHandleForReading.readDataToEndOfFile()
errorData = errorPipe.fileHandleForReading.readDataToEndOfFile()
}
#endif

waitUntilExit()

if let handle = outputHandle, !handle.isStandard {
Expand All @@ -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.
Expand Down
6 changes: 0 additions & 6 deletions Tests/LinuxMain.swift

This file was deleted.

24 changes: 0 additions & 24 deletions Tests/ShellOutTests/ShellOutTests+Linux.swift

This file was deleted.

34 changes: 4 additions & 30 deletions Tests/ShellOutTests/ShellOutTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
}

Expand Down Expand Up @@ -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]),
Expand Down