Skip to content

FIx an overrelease in StdlibUnittest's getSystemVersionPlistProperty #25135

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

Merged
Merged
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
1 change: 0 additions & 1 deletion stdlib/private/StdlibUnittest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ add_swift_target_library(swiftStdlibUnittest ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES}
StringConvertible.swift
TestHelpers.swift
TypeIndexed.swift
GetOSVersion.mm

SWIFT_MODULE_DEPENDS SwiftPrivate SwiftPrivateThreadExtras SwiftPrivateLibcExtras
SWIFT_MODULE_DEPENDS_IOS Darwin Foundation
Expand Down
38 changes: 0 additions & 38 deletions stdlib/private/StdlibUnittest/GetOSVersion.mm

This file was deleted.

8 changes: 2 additions & 6 deletions stdlib/private/StdlibUnittest/StdlibUnittest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import SwiftPrivateThreadExtras
import SwiftPrivateLibcExtras

#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
import Foundation
import Darwin
#elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku)
import Glibc
Expand Down Expand Up @@ -1712,13 +1713,8 @@ public final class TestSuite {
}

#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
@_silgen_name("getSystemVersionPlistProperty")
func _getSystemVersionPlistPropertyImpl(
_ propertyName: UnsafePointer<CChar>) -> UnsafePointer<CChar>?

func _getSystemVersionPlistProperty(_ propertyName: String) -> String? {
let cs = _getSystemVersionPlistPropertyImpl(propertyName)
return cs.map(String.init(cString:))
return NSDictionary(contentsOfFile: "/System/Library/CoreServices/SystemVersion.plist")?[propertyName] as? String
}
#endif

Expand Down
14 changes: 14 additions & 0 deletions test/stdlib/StdlibUnittestOverrelease.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: %target-run-simple-swift
// REQUIRES: executable_test
// REQUIRES: foundation

import Foundation
import StdlibUnittest

var Suite = TestSuite("Overrelease")

Suite.test("doesntfail").xfail(.never).code { }

autoreleasepool {
runAllTests()
}