stryker-mutator / stryker-net

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

Command "dotnet stryker" throws error "System.InvalidOperationException" #2108

Closed zoyo23 closed 1 year ago

zoyo23 commented 2 years ago

Describe the bug When i run Dotnet stryker, all the steps run, but the HTML report throws an error: "System.InvalidOperationException".

My Stryker-config.json: { "stryker-config": { "solution": "../../FizzBuzz.sln", "reporters": [ "progress", "html", "json" ], "verbosity": "info", "additional-timeout": 15000, "project": "Demo.FizzBuzz.csproj", "thresholds": { "high": 90, "low": 70, "break": 0 }, "concurrency": 4, "mutation-level": "Standard", "ignore-mutations": [ "block", "linq", "string" ], "ignore-methods": [ "ToString", "BeginCorrelationIdScope", "LogInformation", "LogError", "Append", "FirstOrDefault", "First" ], "disable-bail": false, "baseline": { "provider": "Dashboard" } } }

Logs The output:

Your json report has been generated at: [16:59:04 INF] Time Elapsed 00:00:43.6247923 Unhandled exception. System.InvalidOperationException: Could not find color or style '-'. at Spectre.Console.StyleParser.Parse(String text) in //src/Spectre.Console/StyleParser.cs:line 10 at Spectre.Console.MarkupParser.Parse(String text, Style style) in //src/Spectre.Console/Internal/Text/Markup/MarkupParser.cs:line 22 at Spectre.Console.AnsiConsoleExtensions.Markup(IAnsiConsole console, String value) in //src/Spectre.Console/Extensions/AnsiConsoleExtensions.Markup.cs:line 77 at Spectre.Console.AnsiConsoleExtensions.MarkupLine(IAnsiConsole console, String value) in //src/Spectre.Console/Extensions/AnsiConsoleExtensions.Markup.cs:line 117 at Stryker.Core.Reporters.Json.JsonReporter.OnAllMutantsTested(IReadOnlyProjectComponent reportComponent) in //src/Stryker.Core/Stryker.Core/Reporters/Json/JsonReporter.cs:line 39 at Stryker.Core.Reporters.BroadcastReporter.OnAllMutantsTested(IReadOnlyProjectComponent reportComponent) in //src/Stryker.Core/Stryker.Core/Reporters/BroadcastReporter.cs:line 63 at Stryker.Core.StrykerRunner.RunMutationTest(IStrykerInputs inputs, ILoggerFactory loggerFactory, IProjectOrchestrator projectOrchestrator) in //src/Stryker.Core/Stryker.Core/StrykerRunner.cs:line 111 at Stryker.CLI.StrykerCli.RunStryker(IStrykerInputs inputs) in //src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs:line 93 at Stryker.CLI.StrykerCli.<>cDisplayClass10_0.b_0() in //src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs:line 68 at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>cDisplayClass143_0.b_0(CancellationToken ) at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken) at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args) at Stryker.CLI.StrykerCli.Run(String[] args) in //src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs:line 74 at Stryker.CLI.Program.Main(String[] args) in //src/Stryker.CLI/Stryker.CLI/Program.cs:line 14

Notebook Dell Inspiron 15:

Additional context Tried:

image

richardwerkman commented 2 years ago

I suspect you must have the character [ in your filepath. When I try it locally I see your error:

image

So the easy fix would be to remove the character from the filepath. But I'll see if we can escape those characters as they are valid file paths and we can't handle them appariently.

richardwerkman commented 2 years ago

Explaination: we use a package Spectre.Console to give color to our console messages using the format [red]myredtext[/]. If you have a [ in your filepath it will try to parse the text after it as a color and not find it.

richardwerkman commented 2 years ago

I have retraced this to be a bug in Spectre.Console. https://github.com/spectreconsole/spectre.console/issues/903

dupdob commented 2 years ago

closing this issue as the workaround has been merged and released. @zoyo23 : feel free to reopen this issue if you still encounter exceptions with V2.11

rouke-broersma commented 2 years ago

Sorry @dupdob I should have updated the PR and issue when we merged this. The escaping is implemented but does not actually solve the problem because the escaping in Spectre.Console contains a bug that makes it not work 😅

rouke-broersma commented 2 years ago

Will be fixed with https://github.com/spectreconsole/spectre.console/pull/911 (after a release with this fix pr)

dupdob commented 2 years ago

Sorry, should I have checked the PR first 😵‍💫 .

Lutti1988 commented 2 years ago

Hello,

we also have the same issue with a space in the file path. So for example "C:/Workspace/My project/" has the same exception: System.InvalidOperationException: Could not find color or style 'project' at Spectre.Console.StyleParser.Parse(String text) in //src/Spectre.Console/StyleParser.cs:line 10 at Spectre.Console.MarkupParser.Parse(String text, Style style) in //src/Spectre.Console/Internal/Text/Markup/MarkupParser.cs:line 22

Greetings

rouke-broersma commented 2 years ago

This will be fixed when a new version of spectre.console is released. In the mean time you can remove spaces from your file path or manually navigate to the report.

rouke-broersma commented 2 years ago

This should be fixed by #2172