diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c2e22e3..e0b7051 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,7 +52,9 @@ jobs: run: dotnet tool update -g dotnet-retest --prerelease --add-source . - name: 🧪 test - run: dotnet retest -- ./src/Sample/ --filter "FullyQualifiedName!=Sample.UnitTest1.FailsAlways" + run: | + dotnet retest -- ./src/Sample/ --filter "FullyQualifiedName!=Sample.UnitTest1.FailsAlways" + dotnet retest -- ./src/Sample2/ --filter "FullyQualifiedName!=Sample.UnitTest1.FailsAlways" - name: 🐛 logs uses: actions/upload-artifact@v4 diff --git a/dotnet-retest.sln b/dotnet-retest.sln index 1670ceb..f0ff9be 100644 --- a/dotnet-retest.sln +++ b/dotnet-retest.sln @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-retest", "src\dotnet EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample", "src\Sample\Sample.csproj", "{5A647D73-B3A8-49E8-A8A3-AC3CAD00DF48}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample2", "src\Sample2\Sample2.csproj", "{0F3664F5-4955-4D04-9DBA-FA144E3621F1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {5A647D73-B3A8-49E8-A8A3-AC3CAD00DF48}.Debug|Any CPU.Build.0 = Debug|Any CPU {5A647D73-B3A8-49E8-A8A3-AC3CAD00DF48}.Release|Any CPU.ActiveCfg = Release|Any CPU {5A647D73-B3A8-49E8-A8A3-AC3CAD00DF48}.Release|Any CPU.Build.0 = Release|Any CPU + {0F3664F5-4955-4D04-9DBA-FA144E3621F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0F3664F5-4955-4D04-9DBA-FA144E3621F1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0F3664F5-4955-4D04-9DBA-FA144E3621F1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0F3664F5-4955-4D04-9DBA-FA144E3621F1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Sample/Sample.csproj b/src/Sample/Sample.csproj index f59310b..447fa76 100644 --- a/src/Sample/Sample.csproj +++ b/src/Sample/Sample.csproj @@ -4,9 +4,6 @@ net8.0 enable enable - - false - true diff --git a/src/Sample/UnitTest1.cs b/src/Sample/UnitTest1.cs index d89b93f..a471cbe 100644 --- a/src/Sample/UnitTest1.cs +++ b/src/Sample/UnitTest1.cs @@ -1,3 +1,5 @@ +using System.Security.Cryptography; + namespace Sample; public class UnitTest1 @@ -16,6 +18,23 @@ public void Test1(int value) Assert.True(value > 0); } + [Theory] + [InlineData("this test, shouldn't break")] + [InlineData("successful case")] + public void ParameterEscapingRetries(string value) + { + // get a simple sha from the string to use as filename using the hex value from the sha1 of the value + var file = "failed" + string.Concat(SHA1.HashData(System.Text.Encoding.UTF8.GetBytes(value)).Select(b => b.ToString("x2"))) + ".txt"; + + if (!File.Exists(file)) + { + File.WriteAllText(file, ""); + Assert.Fail("Fails once"); + } + + File.Delete(file); + } + [Fact] public void FailsOnce() { diff --git a/src/Sample2/NUnitTest.cs b/src/Sample2/NUnitTest.cs new file mode 100644 index 0000000..aeb0aa7 --- /dev/null +++ b/src/Sample2/NUnitTest.cs @@ -0,0 +1,26 @@ +using System.Security.Cryptography; +using NUnit.Framework; +using Assert = NUnit.Framework.Assert; + +namespace Sample; + +[TestFixture] +public class NUnitTest +{ + [TestCase("this test, shouldn't break")] + [TestCase("successful case")] + public void ParameterEscapingRetries(string value) + { + // get a simple sha from the string to use as filename using the hex value from the sha1 of the value + var file = "failed" + string.Concat(SHA1.HashData(System.Text.Encoding.UTF8.GetBytes(value)).Select(b => b.ToString("x2"))) + ".txt"; + + if (!File.Exists(file)) + { + File.WriteAllText(file, ""); + Assert.Fail("Fails once"); + } + + File.Delete(file); + } + +} diff --git a/src/Sample2/Sample2.csproj b/src/Sample2/Sample2.csproj new file mode 100644 index 0000000..aacf27e --- /dev/null +++ b/src/Sample2/Sample2.csproj @@ -0,0 +1,16 @@ + + + + net8.0 + enable + enable + + + + + + + + + + diff --git a/src/dotnet-retest/Program.cs b/src/dotnet-retest/Program.cs index 69da94e..394c01a 100644 --- a/src/dotnet-retest/Program.cs +++ b/src/dotnet-retest/Program.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Runtime.InteropServices; +using System.Text; using System.Threading; using System.Threading.Tasks; using Devlooped; @@ -13,6 +15,9 @@ using Spectre.Console.Cli.Help; using Spectre.Console.Rendering; +if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + Console.InputEncoding = Console.OutputEncoding = Encoding.UTF8; + var app = new CommandApp(); // Alias -? to -h for help diff --git a/src/dotnet-retest/Properties/launchSettings.json b/src/dotnet-retest/Properties/launchSettings.json index 9d45612..8790289 100644 --- a/src/dotnet-retest/Properties/launchSettings.json +++ b/src/dotnet-retest/Properties/launchSettings.json @@ -3,7 +3,7 @@ "dotnet-retest": { "commandName": "Project", "commandLineArgs": "-- --filter \"FullyQualifiedName!=Sample.UnitTest1.FailsAlways\"", - "workingDirectory": "..\\Sample" + "workingDirectory": "..\\Sample2" } } } \ No newline at end of file diff --git a/src/dotnet-retest/RetestCommand.cs b/src/dotnet-retest/RetestCommand.cs index 2428580..23e9d4f 100644 --- a/src/dotnet-retest/RetestCommand.cs +++ b/src/dotnet-retest/RetestCommand.cs @@ -259,7 +259,7 @@ Dictionary GetTestResults(string path) async Task RunTestsAsync(string dotnet, List args, IEnumerable failed, IProgress progress) { var finalArgs = args; - var filter = string.Join('|', failed.Select(failed => $"FullyQualifiedName~{failed}")); + var filter = string.Join('|', failed.Select(failed => $"FullyQualifiedName~{failed.Replace("\"", "%22").Replace(",", "%2C").Replace("(", "\\(").Replace(")", "\\)")}")); if (filter.Length > 0) { var parsed = command.Parse(args);