Skip to content

Commit 8e609b6

Browse files
Merge pull request #11 from SwiftPackageIndex/environment-handling
Add test_environment_isolation
2 parents e862e88 + 7d5bd45 commit 8e609b6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Tests/ShellOutTests/ShellOutTests.swift

+14
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,20 @@ final class ShellOutTests: XCTestCase {
267267
v0.1.0
268268
""")
269269
}
270+
271+
func test_environment_isolation() async throws {
272+
setenv("TOKEN", "secret", 1)
273+
defer { unsetenv("TOKEN") }
274+
275+
await XCTAssertEqualAsync(
276+
try await shellOut(to: "bash", arguments: ["-c", "echo $TOKEN"],
277+
environment: ProcessInfo.processInfo.environment).stdout, "secret"
278+
)
279+
await XCTAssertEqualAsync(
280+
try await shellOut(to: "bash", arguments: ["-c", "echo $TOKEN"],
281+
environment: [:]).stdout, ""
282+
)
283+
}
270284
}
271285

272286
extension ShellOutTests {

0 commit comments

Comments
 (0)