From de597e36742d520d81313f3fce98a548f6064319 Mon Sep 17 00:00:00 2001 From: Sam Khouri Date: Mon, 6 Oct 2025 13:13:40 -0400 Subject: [PATCH] Tests: Run some test serially on Windows The Windows self hosted pipeline occassionally has a test hanging. In order to prevent this from occurring, run some `large` (ie: end-to-end) tests serially on Windows. --- .../SwiftTesting+Traits.swift | 25 +++++++++++++++++++ Tests/CommandsTests/APIDiffTests.swift | 4 ++- Tests/CommandsTests/BuildCommandTests.swift | 1 + Tests/CommandsTests/CoverageTests.swift | 1 + Tests/CommandsTests/PackageCommandTests.swift | 2 +- .../PackageRegistryCommandTests.swift | 1 + .../FunctionalTests/CFamilyTargetTests.swift | 1 + .../DependencyResolutionTests.swift | 1 + Tests/FunctionalTests/MacroTests.swift | 1 + .../ModuleAliasingFixtureTests.swift | 1 + Tests/FunctionalTests/PluginTests.swift | 2 ++ .../FunctionalTests/TestDiscoveryTests.swift | 4 ++- Tests/FunctionalTests/TraitTests.swift | 1 + .../VersionSpecificTests.swift | 1 + 14 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 Sources/_InternalTestSupport/SwiftTesting+Traits.swift diff --git a/Sources/_InternalTestSupport/SwiftTesting+Traits.swift b/Sources/_InternalTestSupport/SwiftTesting+Traits.swift new file mode 100644 index 00000000000..69b91fd83f7 --- /dev/null +++ b/Sources/_InternalTestSupport/SwiftTesting+Traits.swift @@ -0,0 +1,25 @@ +/* + This source file is part of the Swift.org open source project + + Copyright (c) 2025 Apple Inc. and the Swift project authors + Licensed under Apache License v2.0 with Runtime Library Exception + + See http://swift.org/LICENSE.txt for license information + See http://swift.org/CONTRIBUTORS.txt for Swift project authors + */ + +import Testing + +#if os(Windows) + extension Trait where Self == ParallelizationTrait { + public static var serializedIfOnWindows: Self { + .serialized + } + } +#else + extension Trait where Self == ConditionTrait { + public static var serializedIfOnWindows: Self { + .enabled(if: true) + } + } +#endif diff --git a/Tests/CommandsTests/APIDiffTests.swift b/Tests/CommandsTests/APIDiffTests.swift index 570850f60d8..27306499256 100644 --- a/Tests/CommandsTests/APIDiffTests.swift +++ b/Tests/CommandsTests/APIDiffTests.swift @@ -33,7 +33,9 @@ extension Trait where Self == Testing.ConditionTrait { } } -@Suite +@Suite( + .serializedIfOnWindows, +) struct APIDiffTests { @discardableResult private func execute( diff --git a/Tests/CommandsTests/BuildCommandTests.swift b/Tests/CommandsTests/BuildCommandTests.swift index 1ee9ed8c50d..77a2c53516f 100644 --- a/Tests/CommandsTests/BuildCommandTests.swift +++ b/Tests/CommandsTests/BuildCommandTests.swift @@ -119,6 +119,7 @@ fileprivate func build( } @Suite( + .serializedIfOnWindows, .tags( Tag.TestSize.large, Tag.Feature.Command.Build, diff --git a/Tests/CommandsTests/CoverageTests.swift b/Tests/CommandsTests/CoverageTests.swift index 98ba5f6d5e4..958bb90ce5b 100644 --- a/Tests/CommandsTests/CoverageTests.swift +++ b/Tests/CommandsTests/CoverageTests.swift @@ -20,6 +20,7 @@ import struct SPMBuildCore.BuildSystemProvider import Testing @Suite( + .serializedIfOnWindows, .tags( .TestSize.large, .Feature.CodeCoverage, diff --git a/Tests/CommandsTests/PackageCommandTests.swift b/Tests/CommandsTests/PackageCommandTests.swift index 17e48ac8e25..09f68a15eb6 100644 --- a/Tests/CommandsTests/PackageCommandTests.swift +++ b/Tests/CommandsTests/PackageCommandTests.swift @@ -90,7 +90,7 @@ private func executeAddURLDependencyAndAssert( } @Suite( - // .serialized, + .serializedIfOnWindows, .tags( .TestSize.large, .Feature.Command.Package.General, diff --git a/Tests/CommandsTests/PackageRegistryCommandTests.swift b/Tests/CommandsTests/PackageRegistryCommandTests.swift index 4add7133a3f..fa47d13a46f 100644 --- a/Tests/CommandsTests/PackageRegistryCommandTests.swift +++ b/Tests/CommandsTests/PackageRegistryCommandTests.swift @@ -31,6 +31,7 @@ let defaultRegistryBaseURL = URL("https://packages.example.com") let customRegistryBaseURL = URL("https://custom.packages.example.com") @Suite( + .serializedIfOnWindows, .tags( .Feature.Command.PackageRegistry.General, ), diff --git a/Tests/FunctionalTests/CFamilyTargetTests.swift b/Tests/FunctionalTests/CFamilyTargetTests.swift index 0a218b9b2fc..ff4d024be97 100644 --- a/Tests/FunctionalTests/CFamilyTargetTests.swift +++ b/Tests/FunctionalTests/CFamilyTargetTests.swift @@ -40,6 +40,7 @@ fileprivate func expectDirectoryContainsFile( } @Suite( + .serializedIfOnWindows, .tags( .TestSize.large, ), diff --git a/Tests/FunctionalTests/DependencyResolutionTests.swift b/Tests/FunctionalTests/DependencyResolutionTests.swift index 480411dd6fb..aafd553770d 100644 --- a/Tests/FunctionalTests/DependencyResolutionTests.swift +++ b/Tests/FunctionalTests/DependencyResolutionTests.swift @@ -23,6 +23,7 @@ import struct SPMBuildCore.BuildSystemProvider import enum TSCUtility.Git @Suite( + .serializedIfOnWindows, .tags( Tag.TestSize.large, ), diff --git a/Tests/FunctionalTests/MacroTests.swift b/Tests/FunctionalTests/MacroTests.swift index 8f82991c715..1526ca3e40c 100644 --- a/Tests/FunctionalTests/MacroTests.swift +++ b/Tests/FunctionalTests/MacroTests.swift @@ -19,6 +19,7 @@ import PackageModel import Testing @Suite( + .serializedIfOnWindows, .tags( Tag.TestSize.large ), diff --git a/Tests/FunctionalTests/ModuleAliasingFixtureTests.swift b/Tests/FunctionalTests/ModuleAliasingFixtureTests.swift index 44fd2398ebb..db0b9d251e3 100644 --- a/Tests/FunctionalTests/ModuleAliasingFixtureTests.swift +++ b/Tests/FunctionalTests/ModuleAliasingFixtureTests.swift @@ -20,6 +20,7 @@ import Workspace import Testing @Suite( + .serializedIfOnWindows, .tags( Tag.TestSize.large, ), diff --git a/Tests/FunctionalTests/PluginTests.swift b/Tests/FunctionalTests/PluginTests.swift index 57cd562ad50..3352f0ba2f0 100644 --- a/Tests/FunctionalTests/PluginTests.swift +++ b/Tests/FunctionalTests/PluginTests.swift @@ -24,8 +24,10 @@ import Testing import Foundation @Suite( + .serializedIfOnWindows, .tags( .Feature.Command.Package.Plugin, + .TestSize.large, ) ) final class PluginTests { diff --git a/Tests/FunctionalTests/TestDiscoveryTests.swift b/Tests/FunctionalTests/TestDiscoveryTests.swift index b77ce814648..2b77ffb1311 100644 --- a/Tests/FunctionalTests/TestDiscoveryTests.swift +++ b/Tests/FunctionalTests/TestDiscoveryTests.swift @@ -18,7 +18,9 @@ import Testing import struct Foundation.UUID import class Foundation.ProcessInfo -@Suite +@Suite( + .serializedIfOnWindows, +) struct TestDiscoveryTests { static var buildSystems: [BuildSystemProvider.Kind] = [BuildSystemProvider.Kind.native, .swiftbuild] diff --git a/Tests/FunctionalTests/TraitTests.swift b/Tests/FunctionalTests/TraitTests.swift index 80a897ebe8c..7138b7522a8 100644 --- a/Tests/FunctionalTests/TraitTests.swift +++ b/Tests/FunctionalTests/TraitTests.swift @@ -20,6 +20,7 @@ import Testing import _InternalTestSupport @Suite( + .serializedIfOnWindows, .tags( Tag.TestSize.large, Tag.Feature.Traits, diff --git a/Tests/FunctionalTests/VersionSpecificTests.swift b/Tests/FunctionalTests/VersionSpecificTests.swift index 0de9dbfb4e7..341909a5b70 100644 --- a/Tests/FunctionalTests/VersionSpecificTests.swift +++ b/Tests/FunctionalTests/VersionSpecificTests.swift @@ -19,6 +19,7 @@ import struct SPMBuildCore.BuildSystemProvider import enum PackageModel.BuildConfiguration @Suite( + .serializedIfOnWindows, .tags( .TestSize.large, ),