Skip to content

Commit b1ebaa7

Browse files
committed
Rename String.safe → checked
1 parent a67ebf5 commit b1ebaa7

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

Sources/SafeString.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extension SafeString: CustomStringConvertible {
2222

2323

2424
extension String {
25-
var safe: SafeString {
25+
var checked: SafeString {
2626
get throws { try .init(self) }
2727
}
2828
var unchecked: SafeString { .init(unchecked: self) }

Tests/ShellOutTests/ShellOutTests.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,23 @@ class ShellOutTests: XCTestCase {
3232
}
3333

3434
func testWithoutArguments() throws {
35-
let uptime = try shellOut(to: "uptime".safe)
35+
let uptime = try shellOut(to: "uptime".checked)
3636
XCTAssertTrue(uptime.contains("load average"))
3737
}
3838

3939
func testWithArguments() throws {
40-
let echo = try shellOut(to: "echo".safe, arguments: ["Hello world".quoted])
40+
let echo = try shellOut(to: "echo".checked, arguments: ["Hello world".quoted])
4141
XCTAssertEqual(echo, "Hello world")
4242
}
4343

4444
func testSingleCommandAtPath() throws {
4545
try shellOut(
46-
to: "echo".safe,
46+
to: "echo".checked,
4747
arguments: [#"Hello" > \#(NSTemporaryDirectory())ShellOutTests-SingleCommand.txt"#.quoted]
4848
)
4949

5050
let textFileContent = try shellOut(
51-
to: "cat".safe,
51+
to: "cat".checked,
5252
arguments: ["ShellOutTests-SingleCommand.txt".quoted],
5353
at: NSTemporaryDirectory()
5454
)
@@ -57,26 +57,26 @@ class ShellOutTests: XCTestCase {
5757
}
5858

5959
func testSingleCommandAtPathContainingSpace() throws {
60-
try shellOut(to: "mkdir".safe,
60+
try shellOut(to: "mkdir".checked,
6161
arguments: ["-p".verbatim, "ShellOut Test Folder".quoted],
6262
at: NSTemporaryDirectory())
63-
try shellOut(to: "echo".safe, arguments: ["Hello", ">", "File"].verbatim,
63+
try shellOut(to: "echo".checked, arguments: ["Hello", ">", "File"].verbatim,
6464
at: NSTemporaryDirectory() + "ShellOut Test Folder")
6565

6666
let output = try shellOut(
67-
to: "cat".safe,
67+
to: "cat".checked,
6868
arguments: ["\(NSTemporaryDirectory())ShellOut Test Folder/File".quoted])
6969
XCTAssertEqual(output, "Hello")
7070
}
7171

7272
func testSingleCommandAtPathContainingTilde() throws {
73-
let homeContents = try shellOut(to: "ls".safe, at: "~")
73+
let homeContents = try shellOut(to: "ls".checked, at: "~")
7474
XCTAssertFalse(homeContents.isEmpty)
7575
}
7676

7777
func testThrowingError() {
7878
do {
79-
try shellOut(to: "cd".safe, arguments: ["notADirectory".verbatim])
79+
try shellOut(to: "cd".checked, arguments: ["notADirectory".verbatim])
8080
XCTFail("Expected expression to throw")
8181
} catch let error as ShellOutError {
8282
XCTAssertTrue(error.message.contains("notADirectory"))
@@ -110,7 +110,7 @@ class ShellOutTests: XCTestCase {
110110

111111
func testCapturingOutputWithHandle() throws {
112112
let pipe = Pipe()
113-
let output = try shellOut(to: "echo".safe,
113+
let output = try shellOut(to: "echo".checked,
114114
arguments: ["Hello".verbatim],
115115
outputHandle: pipe.fileHandleForWriting)
116116
let capturedData = pipe.fileHandleForReading.readDataToEndOfFile()
@@ -122,7 +122,7 @@ class ShellOutTests: XCTestCase {
122122
let pipe = Pipe()
123123

124124
do {
125-
try shellOut(to: "cd".safe,
125+
try shellOut(to: "cd".checked,
126126
arguments: ["notADirectory".verbatim],
127127
errorHandle: pipe.fileHandleForWriting)
128128
XCTFail("Expected expression to throw")
@@ -149,10 +149,10 @@ class ShellOutTests: XCTestCase {
149149
func testGitCommands() throws {
150150
// Setup & clear state
151151
let tempFolderPath = NSTemporaryDirectory()
152-
try shellOut(to: "rm".safe,
152+
try shellOut(to: "rm".checked,
153153
arguments: ["-rf", "GitTestOrigin"].verbatim,
154154
at: tempFolderPath)
155-
try shellOut(to: "rm".safe,
155+
try shellOut(to: "rm".checked,
156156
arguments: ["-rf", "GitTestClone"].verbatim,
157157
at: tempFolderPath)
158158

@@ -183,7 +183,7 @@ class ShellOutTests: XCTestCase {
183183
func testSwiftPackageManagerCommands() throws {
184184
// Setup & clear state
185185
let tempFolderPath = NSTemporaryDirectory()
186-
try shellOut(to: "rm".safe,
186+
try shellOut(to: "rm".checked,
187187
arguments: ["-rf", "SwiftPackageManagerTest"].verbatim,
188188
at: tempFolderPath)
189189
try shellOut(to: .createFolder(named: "SwiftPackageManagerTest"), at: tempFolderPath)
@@ -196,22 +196,22 @@ class ShellOutTests: XCTestCase {
196196
// Build the package and verify that there's a .build folder
197197
try shellOut(to: .buildSwiftPackage(), at: packagePath)
198198
XCTAssertTrue(
199-
try shellOut(to: "ls".safe, arguments: ["-a".verbatim], at: packagePath) .contains(".build")
199+
try shellOut(to: "ls".checked, arguments: ["-a".verbatim], at: packagePath) .contains(".build")
200200
)
201201

202202
// Generate an Xcode project
203203
try shellOut(to: .generateSwiftPackageXcodeProject(), at: packagePath)
204204
XCTAssertTrue(
205-
try shellOut(to: "ls".safe, arguments: ["-a".verbatim], at: packagePath)
205+
try shellOut(to: "ls".checked, arguments: ["-a".verbatim], at: packagePath)
206206
.contains("SwiftPackageManagerTest.xcodeproj")
207207
)
208208
}
209209

210210
func testArgumentQuoting() throws {
211-
XCTAssertEqual(try shellOut(to: "echo".safe,
211+
XCTAssertEqual(try shellOut(to: "echo".checked,
212212
arguments: ["foo ; echo bar".quoted]),
213213
"foo ; echo bar")
214-
XCTAssertEqual(try shellOut(to: "echo".safe,
214+
XCTAssertEqual(try shellOut(to: "echo".checked,
215215
arguments: ["foo ; echo bar".verbatim]),
216216
"foo\nbar")
217217
}

0 commit comments

Comments
 (0)