Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/FoundationEssentials/ProcessInfo/ProcessInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ final class _ProcessInfo: Sendable {
_ = GetUserNameExW(NameDisplay, nil, &ulLength)

return withUnsafeTemporaryAllocation(of: WCHAR.self, capacity: Int(ulLength)) { wszBuffer in
guard GetUserNameExW(NameDisplay, wszBuffer.baseAddress!, &ulLength) == 0 else {
guard GetUserNameExW(NameDisplay, wszBuffer.baseAddress!, &ulLength) != 0 else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we have a unit test that validates that the user name is not empty but it only runs on macOS. Should we also run it on Windows to validate this behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

return ""
}
return String(decoding: wszBuffer.prefix(Int(ulLength)), as: UTF16.self)
Expand Down
2 changes: 1 addition & 1 deletion Tests/FoundationEssentialsTests/ProcessInfoTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private struct ProcessInfoTests {
"ProcessInfo thinks we are on System 70")
}

#if os(macOS)
#if canImport(Darwin) || os(Windows)
@Test func userName() {
#expect(!ProcessInfo.processInfo.userName.isEmpty)
}
Expand Down