stryker-mutator / stryker-net

Mutation testing for .NET core and .NET framework!
https://stryker-mutator.io
Apache License 2.0
1.77k stars 184 forks source link

Mutations not building for .netcore3.0 targeted apps (in some circumstances) #804

Closed threefjefff closed 4 years ago

threefjefff commented 4 years ago

Describe the bug Mutations fail to build in CI pipeline, but seem to be built and executed correctly when run locally against the project

Logs


[14:24:20 WRN] Argument --files-to-exclude is deprecated: Use '--mutate' instead.
[14:24:56 INF] The project /home/vsts/work/1/s/Src/Pricing.Api/Pricing.Api.csproj will be mutated
[14:24:57 WRN] Project analyzer result not successful
[14:24:57 INF] Started initial build using dotnet build
[14:25:21 INF] Initial build successful
[14:25:31 INF] Using testrunner VsTest
[14:25:31 INF] Total number of tests found: 39
[14:25:31 INF] Initial testrun started
[14:25:33 INF] Using 14018 ms as testrun timeout
[14:25:38 WRN] Stryker.NET encountered an compile error in Stryker.Core.InjectedHelpers.MutantControl.cs with message: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) (Source code: System)
[14:25:38 WRN] Safe Mode! Stryker will try to continue by rolling back all mutations in method. This should not happen, please report this as an issue on github with the previous error message.
[14:25:38 FTL] Stryker.NET could not compile the project after mutation. This is probably an error for Stryker.NET and not your project. Please report this issue on github with the previous error message.
[14:25:38 ERR] An error occurred during the mutation test run 
System.ApplicationException: Internal error due to compile error.
   at Stryker.Core.Compiling.RollbackProcess.RemoveMutantIfStatements(SyntaxTree originalTree, ICollection`1 diagnosticInfo, Boolean devMode)
   at Stryker.Core.Compiling.RollbackProcess.Start(CSharpCompilation compiler, ImmutableArray`1 diagnostics, Boolean devMode)
   at Stryker.Core.Compiling.CompilingProcess.TryCompilation(MemoryStream ms, CSharpCompilation compilation, EmitResult previousEmitResult, Boolean devMode, Int32 retryCount)
   at Stryker.Core.Compiling.CompilingProcess.Compile(IEnumerable`1 syntaxTrees, MemoryStream ms, Boolean devMode)
   at Stryker.Core.MutationTest.MutationTestProcess.Mutate()
   at Stryker.Core.StrykerRunner.RunMutationTest(StrykerOptions options, IEnumerable`1 initialLogMessages)
[14:25:38 INF] Time Elapsed 00:01:18.3925756
##[error]Bash exited with code '1'.

Expected behavior Mutations created and tested against.

Desktop (please complete the following information):

rouke-broersma commented 4 years ago

Do you have both dotnet core 2.1 and dotnet core 3.0 available on the build agent? Could you share the pipeline with us?

threefjefff commented 4 years ago

Do you have both dotnet core 2.1 and dotnet core 3.0 available on the build agent?

Yeah, it has a host of different sdks available:

dotnet --list-sdks
2.1.300 [/usr/share/dotnet/sdk]
2.1.301 [/usr/share/dotnet/sdk]
2.1.302 [/usr/share/dotnet/sdk]
2.1.401 [/usr/share/dotnet/sdk]
2.1.402 [/usr/share/dotnet/sdk]
2.1.403 [/usr/share/dotnet/sdk]
2.1.500 [/usr/share/dotnet/sdk]
2.1.502 [/usr/share/dotnet/sdk]
2.1.503 [/usr/share/dotnet/sdk]
2.1.504 [/usr/share/dotnet/sdk]
2.1.505 [/usr/share/dotnet/sdk]
2.1.506 [/usr/share/dotnet/sdk]
2.1.507 [/usr/share/dotnet/sdk]
2.1.508 [/usr/share/dotnet/sdk]
2.1.509 [/usr/share/dotnet/sdk]
2.1.602 [/usr/share/dotnet/sdk]
2.1.603 [/usr/share/dotnet/sdk]
2.1.604 [/usr/share/dotnet/sdk]
2.1.605 [/usr/share/dotnet/sdk]
2.1.606 [/usr/share/dotnet/sdk]
2.1.700 [/usr/share/dotnet/sdk]
2.1.701 [/usr/share/dotnet/sdk]
2.1.801 [/usr/share/dotnet/sdk]
2.1.802 [/usr/share/dotnet/sdk]
2.2.100 [/usr/share/dotnet/sdk]
2.2.101 [/usr/share/dotnet/sdk]
2.2.102 [/usr/share/dotnet/sdk]
2.2.103 [/usr/share/dotnet/sdk]
2.2.104 [/usr/share/dotnet/sdk]
2.2.105 [/usr/share/dotnet/sdk]
2.2.106 [/usr/share/dotnet/sdk]
2.2.107 [/usr/share/dotnet/sdk]
2.2.108 [/usr/share/dotnet/sdk]
2.2.109 [/usr/share/dotnet/sdk]
2.2.202 [/usr/share/dotnet/sdk]
2.2.203 [/usr/share/dotnet/sdk]
2.2.204 [/usr/share/dotnet/sdk]
2.2.205 [/usr/share/dotnet/sdk]
2.2.206 [/usr/share/dotnet/sdk]
2.2.300 [/usr/share/dotnet/sdk]
2.2.301 [/usr/share/dotnet/sdk]
2.2.401 [/usr/share/dotnet/sdk]
2.2.402 [/usr/share/dotnet/sdk]
3.0.100 [/usr/share/dotnet/sdk]

Could you share the pipeline with us?

I can share the Stryker section of it, sure.


    - job: Stryker_API
        displayName: Run Stryker Command
        dependsOn: [BuildUnittestSonar]
        steps:
          - template: steps/nuget-feed-auth.yaml@templates
            parameters:
              Nuget_Config: ${{ variables.Nuget_Config_Location }}
          - task: DotNetCoreCLI@2
            displayName: 'Install Stryker'
            continueOnError: true
            inputs:
              command: custom
              custom: tool
              vstsFeed: ${{ variables.Artifact_Shared_Package_Feed }}
              arguments: 'install dotnet-stryker --version 0.13.0 --tool-path $(Agent.BuildDirectory)/tools'
          - script: |
                cd ${{ variables.Unit_Test_Folder }}/${{ variables.Api_Project }}.UnitTests/
                $(Agent.BuildDirectory)/tools/dotnet-stryker```
rouke-broersma commented 4 years ago

Am I missing something or are none of the sdk's in that list dotnet core 3.0.x? 🤔

threefjefff commented 4 years ago

Fat fingered the copy D: , Updated the post.

rouke-broersma commented 4 years ago

Could you do a run with logging to file turned on (-f flag) and send us the logs? You can cross out any sensitive information. I am most interested in this dependencies Stryker was able to resolve, they should include dotnet core frameworks at the least and that information gets logged in the log file.

threefjefff commented 4 years ago

Here's the zip of the folder:

stryker-logs.zip

rouke-broersma commented 4 years ago

@threefjefff Sorry for not getting back to you. I've looked into the issue and can't really find any reason this would happen. I also can't really debug it because it seems related to your project and build environment. We did just introduce a new feature which should make stryker work on dotnet core 3.0 systems without a need for dotnet core 2.1 to be available. When that is released as part of 0.16.0 perhaps it solves your problem as well.

rouke-broersma commented 4 years ago

If this problem still persists, please let us know