Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] Support for unknown platforms names #87

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
11 changes: 4 additions & 7 deletions Sources/SymbolKit/SymbolGraph/Platform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,10 @@ extension SymbolGraph {
switch os {
case "macosx", "macos":
return SymbolGraph.Symbol.Availability.Domain.macOS
case "ios" where environment == "macabi":
return SymbolGraph.Symbol.Availability.Domain.macCatalyst
case "ios":
if environment == "macabi" {
return SymbolGraph.Symbol.Availability.Domain.macCatalyst

} else {
return SymbolGraph.Symbol.Availability.Domain.iOS
}
return SymbolGraph.Symbol.Availability.Domain.iOS
case "watchos":
return SymbolGraph.Symbol.Availability.Domain.watchOS
case "tvos":
Expand All @@ -65,7 +62,7 @@ extension SymbolGraph {
case "linux":
return SymbolGraph.Symbol.Availability.Domain.linux
default:
return "Unsupported OS: \(os)"
return os
}
}

Expand Down
18 changes: 14 additions & 4 deletions Tests/SymbolKitTests/SymbolGraph/PlatformTests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
This source file is part of the Swift.org open source project

Copyright (c) 2021 Apple Inc. and the Swift project authors
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception

See https://swift.org/LICENSE.txt for license information
Expand Down Expand Up @@ -35,15 +35,15 @@ class PlatformTests: XCTestCase {
}
}

func testInvalidOperatingSystemName() {
func testUnknownOperatingSystemName() {
let platform = SymbolGraph.Platform(
architecture: nil,
vendor: nil,
operatingSystem: SymbolGraph.OperatingSystem(name: "invalidos"),
operatingSystem: SymbolGraph.OperatingSystem(name: "unknown"),
environment: nil
)

XCTAssertEqual(platform.name, "Unsupported OS: invalidos")
XCTAssertEqual(platform.name, "unknown")
}

func testMacCatalystName() {
Expand All @@ -56,4 +56,14 @@ class PlatformTests: XCTestCase {

XCTAssertEqual(platform.name, "macCatalyst", "'ios' should return macCatalyst when set with 'macabi'.")
}

func testiOSName() {
let platform = SymbolGraph.Platform(
architecture: nil,
vendor: nil,
operatingSystem: SymbolGraph.OperatingSystem(name: "ios")
)

XCTAssertEqual(platform.name, "iOS", "'ios' should return iOS when set with no `macabi` environment.")
}
}