@@ -827,9 +827,9 @@ class PackageDescription4_2LoadingTests: PackageDescriptionLoadingTests {
827
827
828
828
// run this with TSAN/ASAN to detect concurrency issues
829
829
func testConcurrencyWithWarmup( ) throws {
830
- let total = 1000
831
830
try testWithTemporaryDirectory { path in
832
-
831
+ let total = 1000
832
+ let semaphore = DispatchSemaphore ( value: Concurrency . maxOperations)
833
833
let manifestPath = path. appending ( components: " pkg " , " Package.swift " )
834
834
try localFileSystem. writeFileContents ( manifestPath) { stream in
835
835
stream <<< """
@@ -875,6 +875,7 @@ class PackageDescription4_2LoadingTests: PackageDescriptionLoadingTests {
875
875
876
876
let sync = DispatchGroup ( )
877
877
for _ in 0 ..< total {
878
+ semaphore. wait ( )
878
879
sync. enter ( )
879
880
delegate. prepare ( expectParsing: false )
880
881
manifestLoader. load (
@@ -890,7 +891,10 @@ class PackageDescription4_2LoadingTests: PackageDescriptionLoadingTests {
890
891
observabilityScope: observability. topScope,
891
892
on: . global( )
892
893
) { result in
893
- defer { sync. leave ( ) }
894
+ defer {
895
+ semaphore. signal ( )
896
+ sync. leave ( )
897
+ }
894
898
895
899
switch result {
896
900
case . failure( let error) :
@@ -915,16 +919,17 @@ class PackageDescription4_2LoadingTests: PackageDescriptionLoadingTests {
915
919
916
920
// run this with TSAN/ASAN to detect concurrency issues
917
921
func testConcurrencyNoWarmUp( ) throws {
918
- let total = 1000
919
922
try testWithTemporaryDirectory { path in
920
-
923
+ let total = 1000
924
+ let semaphore = DispatchSemaphore ( value: Concurrency . maxOperations)
921
925
let observability = ObservabilitySystem . makeForTesting ( )
922
926
let delegate = ManifestTestDelegate ( )
923
927
let manifestLoader = ManifestLoader ( toolchain: ToolchainConfiguration . default, cacheDir: path, delegate: delegate)
924
928
let identityResolver = DefaultIdentityResolver ( )
925
929
926
930
let sync = DispatchGroup ( )
927
931
for _ in 0 ..< total {
932
+ semaphore. wait ( )
928
933
let random = Int . random ( in: 0 ... total / 4 )
929
934
let manifestPath = path. appending ( components: " pkg- \( random) " , " Package.swift " )
930
935
if !localFileSystem. exists ( manifestPath) {
@@ -958,7 +963,10 @@ class PackageDescription4_2LoadingTests: PackageDescriptionLoadingTests {
958
963
observabilityScope: observability. topScope,
959
964
on: . global( )
960
965
) { result in
961
- defer { sync. leave ( ) }
966
+ defer {
967
+ semaphore. signal ( )
968
+ sync. leave ( )
969
+ }
962
970
963
971
switch result {
964
972
case . failure( let error) :
0 commit comments