@@ -342,7 +342,7 @@ public void TestInstrument_ExcludedFilesHelper(string[] excludeFilterHelper, Val
342342 }
343343 }
344344
345- [ Fact ( Skip = "Temporary disabled because flaky on CI, we cannot use coverlet.core.dll/pdb as test lib" ) ]
345+ [ Fact ]
346346 public void SkipEmbeddedPpdbWithoutLocalSource ( )
347347 {
348348 string xunitDll = Directory . GetFiles ( Directory . GetCurrentDirectory ( ) , "xunit.*.dll" ) . First ( ) ;
@@ -354,32 +354,57 @@ public void SkipEmbeddedPpdbWithoutLocalSource()
354354 loggerMock . Verify ( l => l . LogVerbose ( It . IsAny < string > ( ) ) ) ;
355355
356356 // Default case
357- string coverletCoreDll = Directory . GetFiles ( Directory . GetCurrentDirectory ( ) , "coverlet.core .dll" ) . First ( ) ;
358- instrumenter = new Instrumenter ( coverletCoreDll , "_coverlet_core_instrumented " , Array . Empty < string > ( ) , Array . Empty < string > ( ) , Array . Empty < string > ( ) , Array . Empty < string > ( ) , false , loggerMock . Object , _instrumentationHelper , new FileSystem ( ) ) ;
359- Assert . True ( _instrumentationHelper . HasPdb ( coverletCoreDll , out embedded ) ) ;
357+ string sample = Directory . GetFiles ( Directory . GetCurrentDirectory ( ) , "coverlet.tests.projectsample.empty .dll" ) . First ( ) ;
358+ instrumenter = new Instrumenter ( sample , "_coverlet_tests_projectsample_empty " , Array . Empty < string > ( ) , Array . Empty < string > ( ) , Array . Empty < string > ( ) , Array . Empty < string > ( ) , false , loggerMock . Object , _instrumentationHelper , new FileSystem ( ) ) ;
359+ Assert . True ( _instrumentationHelper . HasPdb ( sample , out embedded ) ) ;
360360 Assert . False ( embedded ) ;
361361 Assert . True ( instrumenter . CanInstrument ( ) ) ;
362362 loggerMock . VerifyNoOtherCalls ( ) ;
363363 }
364364
365- [ Fact ( Skip = "Temporary disabled because flaky on CI, we cannot use coverlet.core.dll/pdb as test lib" ) ]
365+ [ Fact ]
366366 public void SkipPpdbWithoutLocalSource ( )
367367 {
368- Mock < FileSystem > partialMockFileSystem = new Mock < FileSystem > ( ) ;
369- partialMockFileSystem . CallBase = true ;
370- partialMockFileSystem . Setup ( fs => fs . Exists ( It . IsAny < string > ( ) ) ) . Returns ( ( string path ) =>
371- {
372- return Path . GetExtension ( path ) != ".cs" ;
373- } ) ;
374- InstrumentationHelper instrumentationHelper = new InstrumentationHelper ( new ProcessExitHandler ( ) , new RetryHelper ( ) , partialMockFileSystem . Object ) ;
368+ string dllFileName = "75d9f96508d74def860a568f426ea4a4.dll" ;
369+ string pdbFileName = "75d9f96508d74def860a568f426ea4a4.pdb" ;
375370
376- string coverletLib = Directory . GetFiles ( Directory . GetCurrentDirectory ( ) , "coverlet.core.dll" ) . First ( ) ;
377- var loggerMock = new Mock < ILogger > ( ) ;
378- Instrumenter instrumenter = new Instrumenter ( coverletLib , "_corelib_instrumented" , Array . Empty < string > ( ) , Array . Empty < string > ( ) , Array . Empty < string > ( ) , Array . Empty < string > ( ) , false , loggerMock . Object , instrumentationHelper , partialMockFileSystem . Object ) ;
379- Assert . True ( _instrumentationHelper . HasPdb ( coverletLib , out bool embedded ) ) ;
380- Assert . False ( embedded ) ;
381- Assert . False ( instrumenter . CanInstrument ( ) ) ;
382- loggerMock . Verify ( l => l . LogVerbose ( It . IsAny < string > ( ) ) ) ;
371+ // We test only on win because sample dll/pdb were build on it
372+ if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
373+ {
374+ Mock < FileSystem > partialMockFileSystem = new Mock < FileSystem > ( ) ;
375+ partialMockFileSystem . CallBase = true ;
376+ partialMockFileSystem . Setup ( fs => fs . NewFileStream ( It . IsAny < string > ( ) , It . IsAny < FileMode > ( ) ) ) . Returns ( ( string path , FileMode mode ) =>
377+ {
378+ if ( Path . GetFileName ( path ) == pdbFileName )
379+ {
380+ return new FileStream ( Path . Combine ( Path . Combine ( Directory . GetCurrentDirectory ( ) , "TestAssets" ) , pdbFileName ) , mode ) ;
381+ }
382+ else
383+ {
384+ return new FileStream ( path , mode ) ;
385+ }
386+ } ) ;
387+ partialMockFileSystem . Setup ( fs => fs . Exists ( It . IsAny < string > ( ) ) ) . Returns ( ( string path ) =>
388+ {
389+ if ( Path . GetFileName ( path ) == pdbFileName )
390+ {
391+ return File . Exists ( Path . Combine ( Path . Combine ( Directory . GetCurrentDirectory ( ) , "TestAssets" ) , pdbFileName ) ) ;
392+ }
393+ else
394+ {
395+ return File . Exists ( path ) ;
396+ }
397+ } ) ;
398+
399+ InstrumentationHelper instrumentationHelper = new InstrumentationHelper ( new ProcessExitHandler ( ) , new RetryHelper ( ) , partialMockFileSystem . Object ) ;
400+ string sample = Directory . GetFiles ( Path . Combine ( Directory . GetCurrentDirectory ( ) , "TestAssets" ) , dllFileName ) . First ( ) ;
401+ var loggerMock = new Mock < ILogger > ( ) ;
402+ Instrumenter instrumenter = new Instrumenter ( sample , "_75d9f96508d74def860a568f426ea4a4_instrumented" , Array . Empty < string > ( ) , Array . Empty < string > ( ) , Array . Empty < string > ( ) , Array . Empty < string > ( ) , false , loggerMock . Object , instrumentationHelper , partialMockFileSystem . Object ) ;
403+ Assert . True ( instrumentationHelper . HasPdb ( sample , out bool embedded ) ) ;
404+ Assert . False ( embedded ) ;
405+ Assert . False ( instrumenter . CanInstrument ( ) ) ;
406+ loggerMock . Verify ( l => l . LogVerbose ( It . IsAny < string > ( ) ) ) ;
407+ }
383408 }
384409
385410 [ Fact ]
0 commit comments