Skip to content

Commit f38f79c

Browse files
authored
Maintain environment variable containing test bundle path when spawning an exit test subprocess (#1640)
This modifies the logic for constructing the set of environment variables applied to an Exit Test subprocess so that it does not filter out a useful environment variable specified by Xcode (`XCTestBundlePath`) and maintains it whenever it is present in the parent process's environment. Resolves rdar://172950962 ### Motivation: This environment variable can be useful to allow integrated tools to more reliably locate and load the test bundle if it resides an unconventional location. Currently, many environment variables related to XCTest are filtered out to avoid the possibility of an exit test subprocess incorrectly behaving as a "normal" test runner and entering into an infinite loop, but this variable doesn't pose that risk. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 66c32ae commit f38f79c

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Sources/Testing/ExitTests/ExitTest.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -878,9 +878,10 @@ extension ExitTest {
878878
// platform-specific changes.
879879
var childEnvironment = Environment.get()
880880
#if SWT_TARGET_OS_APPLE
881-
// We need to remove Xcode's environment variables from the child
882-
// environment to avoid accidentally accidentally recursing.
883-
for key in childEnvironment.keys where key.starts(with: "XCTest") {
881+
// We need to remove the XCTest-related environment variables set by Xcode,
882+
// except those known to be safe and relevant, from the child environment
883+
// to avoid accidentally recursing.
884+
for key in childEnvironment.keys where key.starts(with: "XCTest") && key != "XCTestBundlePath" {
884885
childEnvironment.removeValue(forKey: key)
885886
}
886887
#endif

0 commit comments

Comments
 (0)