diff --git a/Tests/ShellOutTests/ShellOutTests.swift b/Tests/ShellOutTests/ShellOutTests.swift index 6aa8107..6e68845 100644 --- a/Tests/ShellOutTests/ShellOutTests.swift +++ b/Tests/ShellOutTests/ShellOutTests.swift @@ -267,6 +267,20 @@ final class ShellOutTests: XCTestCase { v0.1.0 """) } + + func test_environment_isolation() async throws { + setenv("TOKEN", "secret", 1) + defer { unsetenv("TOKEN") } + + await XCTAssertEqualAsync( + try await shellOut(to: "bash", arguments: ["-c", "echo $TOKEN"], + environment: ProcessInfo.processInfo.environment).stdout, "secret" + ) + await XCTAssertEqualAsync( + try await shellOut(to: "bash", arguments: ["-c", "echo $TOKEN"], + environment: [:]).stdout, "" + ) + } } extension ShellOutTests {