@@ -49,22 +49,29 @@ private var _appDataDirectoryPath: String? {
49
49
/// On Apple platforms and on Linux, this path is equivalent to
50
50
/// `"~/.swift-testing"`. On Windows, it is equivalent to
51
51
/// `"%HOMEPATH%\AppData\Local\.swift-testing"`.
52
- var swiftTestingDirectoryPath : String {
52
+ /// The value of this property is `nil` if the platform does not support the
53
+ /// concept of a home directory, or if the home directory could not be
54
+ /// determined.
55
+ var swiftTestingDirectoryPath : String ? {
53
56
// The (default) name of the .swift-testing directory.
54
57
let swiftTestingDirectoryName = " .swift-testing "
55
58
56
59
#if os(macOS) || (os(iOS) && targetEnvironment(macCatalyst)) || os(Linux)
57
60
if let homeDirectoryPath = _homeDirectoryPath {
58
61
return appendPathComponent ( swiftTestingDirectoryName, to: homeDirectoryPath)
59
62
}
63
+ return nil
60
64
#elseif os(Windows)
61
65
if let appDataDirectoryPath = _appDataDirectoryPath {
62
66
return appendPathComponent ( swiftTestingDirectoryName, to: appDataDirectoryPath)
63
67
}
68
+ return nil
69
+ #elseif os(WASI)
70
+ return nil
64
71
#else
65
72
#warning("Platform-specific implementation missing: .swift-testing directory location unavailable")
73
+ return nil
66
74
#endif
67
- return " "
68
75
}
69
76
70
77
/// Read tag colors out of the file `"tag-colors.json"` in a given directory.
@@ -83,7 +90,12 @@ var swiftTestingDirectoryPath: String {
83
90
/// assumed to contain a JSON object (a dictionary) where the keys are tags'
84
91
/// string values and the values represent tag colors. For a list of the
85
92
/// supported formats for tag colors in this dictionary, see <doc:AddingTags>.
86
- func loadTagColors( fromFileInDirectoryAtPath swiftTestingDirectoryPath: String = swiftTestingDirectoryPath) throws -> [ Tag : Tag . Color ] {
93
+ func loadTagColors( fromFileInDirectoryAtPath swiftTestingDirectoryPath: String ? = swiftTestingDirectoryPath) throws -> [ Tag : Tag . Color ] {
94
+ guard let swiftTestingDirectoryPath else {
95
+ // If the platform does not support user-specific configuration, skip custom
96
+ // tag colors.
97
+ return [ : ]
98
+ }
87
99
// Find the path to the tag-colors.json file and try to load its contents.
88
100
let tagColorsPath = appendPathComponent ( " tag-colors.json " , to: swiftTestingDirectoryPath)
89
101
let fileHandle = try FileHandle ( forReadingAtPath: tagColorsPath)
0 commit comments