11using System ;
2- using System . Collections . Concurrent ;
32using System . Collections . Generic ;
43using System . Diagnostics ;
54using System . IO ;
@@ -395,10 +394,9 @@ public async Task DiffPipeline_ParallelClean_AllFilesGeneratePatches()
395394 // Also add some new files in target (no old version)
396395 File . WriteAllBytes ( Path . Combine ( tgt , "new_features.dll" ) , [ 1 , 2 , 3 , 4 , 5 ] ) ;
397396
398- var completedFiles = new ConcurrentBag < string > ( ) ;
399397 var progress = new SyncProgress < DiffProgress > ( ) ;
400398 var pipeline = new DiffPipelineBuilder ( )
401- . WithParallelism ( Environment . ProcessorCount )
399+ . WithParallelism ( Math . Min ( Environment . ProcessorCount , 4 ) )
402400 . Build ( ) ;
403401
404402 // Act
@@ -407,7 +405,8 @@ public async Task DiffPipeline_ParallelClean_AllFilesGeneratePatches()
407405 _output . WriteLine ( $ "Parallel Clean (30 files): { sw . ElapsedMilliseconds } ms") ;
408406
409407 // Assert
410- Assert . True ( progress . LastValue . IsComplete ) ;
408+ Assert . True ( progress . LastValue . Total > 0 , "Progress Total should be > 0" ) ;
409+ Assert . Equal ( progress . LastValue . Total , progress . LastValue . Completed ) ;
411410 _output . WriteLine ( $ "Progress: { progress . LastValue . Completed } /{ progress . LastValue . Total } ") ;
412411
413412 // Each modified file should have a .patch
@@ -807,17 +806,18 @@ public async Task MultiFile_HighParallelism_AllFilesProcessed()
807806 File . WriteAllBytes ( Path . Combine ( app , $ "h_{ i : D3} .dll") , oldContent ) ;
808807 }
809808
809+ var parallelism = Math . Min ( Environment . ProcessorCount , 4 ) ;
810810 var pipeline = new DiffPipelineBuilder ( )
811- . WithParallelism ( Environment . ProcessorCount )
811+ . WithParallelism ( parallelism )
812812 . Build ( ) ;
813813
814814 var sw = Stopwatch . StartNew ( ) ;
815815 await pipeline . CleanAsync ( src , tgt , patchDir ) ;
816- _output . WriteLine ( $ "Clean { fileCount } files (x{ Environment . ProcessorCount } ): { sw . ElapsedMilliseconds } ms") ;
816+ _output . WriteLine ( $ "Clean { fileCount } files (x{ parallelism } ): { sw . ElapsedMilliseconds } ms") ;
817817
818818 sw . Restart ( ) ;
819819 await pipeline . DirtyAsync ( app , patchDir ) ;
820- _output . WriteLine ( $ "Dirty { fileCount } files (x{ Environment . ProcessorCount } ): { sw . ElapsedMilliseconds } ms") ;
820+ _output . WriteLine ( $ "Dirty { fileCount } files (x{ parallelism } ): { sw . ElapsedMilliseconds } ms") ;
821821
822822 for ( var i = 0 ; i < fileCount ; i ++ )
823823 {
0 commit comments