From f83bd74aea31ae6d867bbcc3e6ea27f1676a2f7d Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Thu, 7 May 2026 16:15:02 -0700 Subject: [PATCH] Move FormatterFixtures into a nested package --- .gitignore | 1 + Package.swift | 15 +----- .../Debugger/FormatterFixtures/Package.swift | 53 +++++++++++++++++++ .../Sources}/RigidArray_Fixture.swift | 0 Utils/Debugger/test_formatters.py | 5 +- Xcode/Collections.xcodeproj/project.pbxproj | 50 +++++++++++++++++ 6 files changed, 109 insertions(+), 15 deletions(-) create mode 100644 Utils/Debugger/FormatterFixtures/Package.swift rename {Sources/FormatterFixtures => Utils/Debugger/FormatterFixtures/Sources}/RigidArray_Fixture.swift (100%) mode change 100644 => 100755 Utils/Debugger/test_formatters.py diff --git a/.gitignore b/.gitignore index cb33e5fe..4042772f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,6 @@ xcuserdata/ .*.sw? /Benchmarks/.swiftpm /Benchmarks/.build +/Utils/Debugger/FormatterFixtures/.build .docc-build __pycache__ diff --git a/Package.swift b/Package.swift index 16b9a9c6..67038187 100644 --- a/Package.swift +++ b/Package.swift @@ -367,19 +367,8 @@ let _products: [Product] = targets.compactMap { t in } let _targets: [Target] = targets.map { $0.toTarget() } -let _formatterTargets: [Target] = [ - .executableTarget( - name: "FormatterFixtures", - dependencies: ["BasicContainers"], - swiftSettings: _settings), -] -let _formatterProducts: [Product] = _formatterTargets.map { t in - .executable(name: t.name, targets: [t.name]) -} - let package = Package( name: "swift-collections", - products: _products + _formatterProducts, + products: _products, traits: _traits, - targets: _targets + _formatterTargets -) + targets: _targets) diff --git a/Utils/Debugger/FormatterFixtures/Package.swift b/Utils/Debugger/FormatterFixtures/Package.swift new file mode 100644 index 00000000..b00a08ed --- /dev/null +++ b/Utils/Debugger/FormatterFixtures/Package.swift @@ -0,0 +1,53 @@ +// swift-tools-version:6.3 +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift Collections open source project +// +// Copyright (c) 2026 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 +// +// SPDX-License-Identifier: Apache-2.0 WITH Swift-exception +// +//===----------------------------------------------------------------------===// + +import PackageDescription + +let availabilityMacros: KeyValuePairs = [ + "SwiftStdlib 5.0": "macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2", + "SwiftStdlib 5.1": "macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0", + "SwiftStdlib 5.6": "macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4", + "SwiftStdlib 5.8": "macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4", + "SwiftStdlib 5.9": "macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0", + "SwiftStdlib 5.10": "macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4, visionOS 1.1", + "SwiftStdlib 6.0": "macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0", + "SwiftStdlib 6.1": "macOS 15.4, iOS 18.4, watchOS 11.4, tvOS 18.4, visionOS 2.4", + "SwiftStdlib 6.2": "macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0", + "SwiftStdlib 6.3": "macOS 26.4, iOS 26.4, watchOS 26.4, tvOS 26.4, visionOS 26.4", +] + +let _settings: [SwiftSetting] = + availabilityMacros.map { name, value in + .enableExperimentalFeature("AvailabilityMacro=\(name): \(value)") + } + +let package = Package( + name: "swift-collections.Benchmarks", + platforms: [.macOS(.v26), .iOS(.v26), .watchOS(.v26), .tvOS(.v26), .visionOS(.v26)], + products: [ + .executable(name: "FormatterFixtures", targets: ["FormatterFixtures"]), + ], + dependencies: [ + .package(name: "swift-collections", path: "../../.."), + ], + targets: [ + .executableTarget( + name: "FormatterFixtures", + dependencies: [ + .product(name: "BasicContainers", package: "swift-collections"), + ], + path: "Sources", + swiftSettings: _settings), + ] +) diff --git a/Sources/FormatterFixtures/RigidArray_Fixture.swift b/Utils/Debugger/FormatterFixtures/Sources/RigidArray_Fixture.swift similarity index 100% rename from Sources/FormatterFixtures/RigidArray_Fixture.swift rename to Utils/Debugger/FormatterFixtures/Sources/RigidArray_Fixture.swift diff --git a/Utils/Debugger/test_formatters.py b/Utils/Debugger/test_formatters.py old mode 100644 new mode 100755 index fb1f9c5b..e4f0e44a --- a/Utils/Debugger/test_formatters.py +++ b/Utils/Debugger/test_formatters.py @@ -66,8 +66,9 @@ class TestRigidArrayFormatter(unittest.TestCase): """Build the test fixture with SwiftPM and return the binary path.""" target = "FormatterFixtures" repo_root = _run(("git", "rev-parse", "--show-toplevel")) - _xcode_run(("swift", "build", "--product", target), cwd=repo_root) - bin_dir = _xcode_run(("swift", "build", "--show-bin-path"), cwd=repo_root) + fixture_root = os.path.join(repo_root, "Utils", "Debugger", "FormatterFixtures") + _xcode_run(("swift", "build", "--product", target), cwd=fixture_root) + bin_dir = _xcode_run(("swift", "build", "--show-bin-path"), cwd=fixture_root) return os.path.join(bin_dir, target) @classmethod diff --git a/Xcode/Collections.xcodeproj/project.pbxproj b/Xcode/Collections.xcodeproj/project.pbxproj index a8daa42f..569faf6e 100644 --- a/Xcode/Collections.xcodeproj/project.pbxproj +++ b/Xcode/Collections.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 7D24E3ED2FAD4C37005A55EB /* RigidArray+Formatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D24E3EC2FAD4C37005A55EB /* RigidArray+Formatter.swift */; }; 7D2A77262F27F1D1005780C7 /* Span+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D2A77252F27F1D1005780C7 /* Span+Extras.swift */; }; 7D2A77382F27F1E4005780C7 /* BorrowingSequence+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D2A772D2F27F1E4005780C7 /* BorrowingSequence+Utilities.swift */; }; 7D2A77392F27F1E4005780C7 /* UniqueBox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D2A77332F27F1E4005780C7 /* UniqueBox.swift */; }; @@ -601,6 +602,14 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 7D24E3EC2FAD4C37005A55EB /* RigidArray+Formatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RigidArray+Formatter.swift"; sourceTree = ""; }; + 7D24E9862FAD53E1005A55EB /* RigidArray_Fixture.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RigidArray_Fixture.swift; sourceTree = ""; }; + 7D24E9882FAD53E1005A55EB /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = ""; }; + 7D24E98A2FAD53E1005A55EB /* RigidArray.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = RigidArray.py; sourceTree = ""; }; + 7D24E98C2FAD53E1005A55EB /* formatter_bytecode.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = formatter_bytecode.py; sourceTree = ""; }; + 7D24E98D2FAD53E1005A55EB /* generate_formatters.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = generate_formatters.sh; sourceTree = ""; }; + 7D24E98E2FAD53E1005A55EB /* HEADER.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HEADER.swift; sourceTree = ""; }; + 7D24E98F2FAD53E1005A55EB /* test_formatters.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = test_formatters.py; sourceTree = ""; }; 7D2A77252F27F1D1005780C7 /* Span+Extras.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Span+Extras.swift"; sourceTree = ""; }; 7D2A77272F27F1E4005780C7 /* OutputSpan+Extras.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OutputSpan+Extras.swift"; sourceTree = ""; }; 7D2A77282F27F1E4005780C7 /* TemporaryAllocation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemporaryAllocation.swift; sourceTree = ""; }; @@ -1245,6 +1254,44 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 7D24E9872FAD53E1005A55EB /* Sources */ = { + isa = PBXGroup; + children = ( + 7D24E9862FAD53E1005A55EB /* RigidArray_Fixture.swift */, + ); + path = Sources; + sourceTree = ""; + }; + 7D24E9892FAD53E1005A55EB /* FormatterFixtures */ = { + isa = PBXGroup; + children = ( + 7D24E9872FAD53E1005A55EB /* Sources */, + 7D24E9882FAD53E1005A55EB /* Package.swift */, + ); + path = FormatterFixtures; + sourceTree = ""; + }; + 7D24E98B2FAD53E1005A55EB /* Formatters */ = { + isa = PBXGroup; + children = ( + 7D24E98A2FAD53E1005A55EB /* RigidArray.py */, + ); + path = Formatters; + sourceTree = ""; + }; + 7D24E9902FAD53E1005A55EB /* Debugger */ = { + isa = PBXGroup; + children = ( + 7D24E9892FAD53E1005A55EB /* FormatterFixtures */, + 7D24E98B2FAD53E1005A55EB /* Formatters */, + 7D24E98C2FAD53E1005A55EB /* formatter_bytecode.py */, + 7D24E98D2FAD53E1005A55EB /* generate_formatters.sh */, + 7D24E98E2FAD53E1005A55EB /* HEADER.swift */, + 7D24E98F2FAD53E1005A55EB /* test_formatters.py */, + ); + path = Debugger; + sourceTree = ""; + }; 7D2A77292F27F1E4005780C7 /* Extensions */ = { isa = PBXGroup; children = ( @@ -1506,6 +1553,7 @@ 7DA23F5B2F32C68B00E4C03A /* RigidArray+Descriptions.swift */, 7DA23F572F32C65900E4C03A /* RigidArray+Equatable.swift */, 7DA23F382F329A2300E4C03A /* RigidArray+Experimental.swift */, + 7D24E3EC2FAD4C37005A55EB /* RigidArray+Formatter.swift */, 7DA23F592F32C67D00E4C03A /* RigidArray+Hashable.swift */, 7DA23F392F329A2300E4C03A /* RigidArray+Initializers.swift */, 7DA23F3A2F329A2300E4C03A /* RigidArray+Insertions.swift */, @@ -2138,6 +2186,7 @@ 7DE921AC29CA78B2004483EB /* Utils */ = { isa = PBXGroup; children = ( + 7D24E9902FAD53E1005A55EB /* Debugger */, 7D5A64D329CCEE9A00CB2595 /* README.md */, 7DE921B629CA78B2004483EB /* generate-docs.sh */, 7DE921AD29CA78B2004483EB /* run-benchmarks.sh */, @@ -2851,6 +2900,7 @@ 7DA23F4F2F329A2300E4C03A /* RigidArray+Initializers.swift in Sources */, 7DA23F502F329A2300E4C03A /* RigidArray+Insertions.swift in Sources */, 7DA23F512F329A2300E4C03A /* UniqueArray+Append.swift in Sources */, + 7D24E3ED2FAD4C37005A55EB /* RigidArray+Formatter.swift in Sources */, 7DA23F522F329A2300E4C03A /* UniqueArray+Experimental.swift in Sources */, 7DA23F532F329A2300E4C03A /* UniqueArray+Insertions.swift in Sources */, 7DA23F542F329A2300E4C03A /* RigidArray.swift in Sources */,