You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This source file is part of the Swift.org open source project
3
+
4
+
Copyright (c) 2023–2025 Apple Inc. and the Swift project authors
5
+
Licensed under Apache License v2.0 with Runtime Library Exception
6
+
7
+
See https://swift.org/LICENSE.txt for license information
8
+
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
9
+
-->
10
+
11
+
# Environment variables in Swift Testing
12
+
13
+
This document lists the environment variables that Swift Testing currently uses.
14
+
This list is meant for use by developers working on Swift Testing.
15
+
16
+
Those environment variables marked with `*` are defined by components outside
17
+
Swift Testing. In general, environment variables that Swift Testing defines have
18
+
names prefixed with `SWT_`.
19
+
20
+
> [!WARNING]
21
+
> This document is not an API contract. The set of environment variables Swift
22
+
> Testing uses may change at any time.
23
+
24
+
## Console output
25
+
26
+
| Variable Name | Value Type | Notes |
27
+
|-|:-:|-|
28
+
|`COLORTERM`\*|`String`| Used to determine if the current terminal supports 24-bit color. Common across UNIX-like platforms. |
29
+
|`NO_COLOR`[\*](https://no-color.org)|`Any?`| If set to any value, disables color output regardless of terminal capabilities. |
30
+
|`SWT_ENABLE_EXPERIMENTAL_CONSOLE_OUTPUT`|`Bool`| Used to enable or disable experimental console output. |
31
+
|`SWT_SF_SYMBOLS_ENABLED`|`Bool`| Used to explicitly enable or disable SF Symbols support on macOS. |
32
+
|`TERM`[\*](https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap08.html)|`String`| Used to determine if the current terminal supports 4- or 8-bit color. Common across UNIX-like platforms. |
33
+
34
+
## Error handling
35
+
36
+
| Variable Name | Value Type | Notes |
37
+
|-|:-:|-|
38
+
|`SWT_FOUNDATION_ERROR_BACKTRACING_ENABLED`|`Bool`| Used to explicitly enable or disable error backtrace capturing when an instance of `NSError` or `CFError` is created on Apple platforms. |
39
+
|`SWT_SWIFT_ERROR_BACKTRACING_ENABLED`|`Bool`| Used to explicitly enable or disable error backtrace capturing when a Swift error is thrown. |
40
+
41
+
## Event streams
42
+
43
+
| Variable Name | Value Type | Notes |
44
+
|-|:-:|-|
45
+
|`SWT_EXPERIMENTAL_EVENT_STREAM_FIELDS_ENABLED`|`Bool`| Used to explicitly enable or disable experimental fields in the JSON event stream. |
46
+
|`SWT_PRETTY_PRINT_JSON`|`Bool`| Used to enable pretty-printed JSON output to the event stream (for debugging purposes). |
47
+
48
+
## Exit tests
49
+
50
+
| Variable Name | Value Type | Notes |
51
+
|-|:-:|-|
52
+
|`SWT_BACKCHANNEL`|`CInt`/`HANDLE`| A file descriptor (handle on Windows) to which the exit test's events are written. |
53
+
|`SWT_CAPTURED_VALUES`|`CInt`/`HANDLE`| A file descriptor (handle on Windows) containing captured values passed to the exit test. |
54
+
|`SWT_CLOSEFROM`|`CInt`| Used on OpenBSD to emulate `posix_spawn_file_actions_addclosefrom_np()`. |
55
+
|`SWT_EXIT_TEST_ID`|`String` (JSON) | Specifies which exit test to run. |
56
+
|`XCTestBundlePath`\*|`String`| Used on Apple platforms to determine if Xcode is hosting the test run. |
57
+
58
+
## Miscellaneous
59
+
60
+
| Variable Name | Value Type | Notes |
61
+
|-|:-:|-|
62
+
|`CFFIXED_USER_HOME`\*|`String`| Used on Apple platforms to determine the user's home directory. |
63
+
|`HOME`[\*](https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap08.html)|`String`| Used to determine the user's home directory. |
64
+
|`SIMULATOR_RUNTIME_BUILD_VERSION`\*|`String`| Used when running in the iOS (etc.) Simulator to determine the simulator's version. |
65
+
|`SIMULATOR_RUNTIME_VERSION`\*|`String`| Used when running in the iOS (etc.) Simulator to determine the simulator's version. |
66
+
|`SWT_USE_LEGACY_TEST_DISCOVERY`|`Bool`| Used to explicitly enable or disable legacy test discovery. |
0 commit comments