Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
run: dotnet tool update -g dotnet-retest --prerelease --add-source .

- name: 🧪 test
run: dotnet retest -- ./src/Sample/
run: dotnet retest -- ./src/Sample/ --filter "FullyQualifiedName!=Sample.UnitTest1.FailsAlways"

- name: 🐛 logs
uses: actions/upload-artifact@v4
Expand Down
6 changes: 6 additions & 0 deletions src/Sample/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ namespace Sample;

public class UnitTest1
{
[Fact]
public void FailsAlways()
{
throw new InvalidOperationException("Always fails");
}

[Theory]
[InlineData(1)]
[InlineData(2)]
Expand Down
2 changes: 1 addition & 1 deletion src/dotnet-retest/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"dotnet-retest": {
"commandName": "Project",
"commandLineArgs": "",
"commandLineArgs": "-- --filter \"FullyQualifiedName!=Sample.UnitTest1.FailsAlways\"",
"workingDirectory": "..\\Sample"
}
}
Expand Down
19 changes: 16 additions & 3 deletions src/dotnet-retest/RetestCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.CommandLine;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
Expand Down Expand Up @@ -147,7 +148,7 @@ public override async Task<int> ExecuteAsync(CommandContext context, RetestSetti
ctx.Refresh();
}

var exit = await RunTestsAsync(DotnetMuxer.Path.FullName, new List<string>(args), failed, new Progress<string>(line =>
var exit = await RunTestsAsync(DotnetMuxer.Path.FullName, [.. args], failed, new Progress<string>(line =>
{
if (ci)
{
Expand Down Expand Up @@ -247,14 +248,26 @@ Dictionary<string, bool> GetTestResults(string path)
return outcomes;
}

static readonly RootCommand command = new()
{
Options =
{
new Option<string>("--filter")
}
};

async Task<BufferedCommandResult> RunTestsAsync(string dotnet, List<string> args, IEnumerable<string> failed, IProgress<string> progress)
{
var testArgs = string.Join(" ", args);
var finalArgs = args;
var filter = string.Join('|', failed.Select(failed => $"FullyQualifiedName~{failed}"));
if (filter.Length > 0)
{
testArgs = $"--filter \"{filter}\" {testArgs}";
var parsed = command.Parse(args);
if (parsed.GetValue<string>("--filter") is { } existing)
{
finalArgs = [.. parsed.UnmatchedTokens];
filter = $"({existing})&({filter})";
}
finalArgs.InsertRange(0, ["--filter", filter]);
}

Expand Down
4 changes: 2 additions & 2 deletions src/dotnet-retest/dotnet-retest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<PackageReference Include="NuGetizer" Version="1.2.4" />
<PackageReference Include="NuGet.Protocol" Version="6.13.1" />
<PackageReference Include="Spectre.Console.Cli" Version="0.49.1" />
<PackageReference Include="System.CommandLine" Version="2.0.0-rc.1.25451.107" />
<PackageReference Include="ThisAssembly.Git" Version="2.0.12" PrivateAssets="all" />
<PackageReference Include="ThisAssembly.Project" Version="2.0.12" PrivateAssets="all" />
</ItemGroup>
Expand All @@ -47,8 +48,7 @@

<Target Name="RenderHelp" AfterTargets="Build" Condition="$(NoHelp) != 'true' and $(DesignTimeBuild) != 'true'">
<WriteLinesToFile Lines="```shell" Overwrite="true" Encoding="UTF-8" File="help.md" />
<Exec Command="dotnet run --no-build --no-launch-profile -- --help &gt;&gt; help.md" StdOutEncoding="UTF-8"
EnvironmentVariables="NO_COLOR=true" />
<Exec Command="dotnet run --no-build --no-launch-profile -- --help &gt;&gt; help.md" StdOutEncoding="UTF-8" EnvironmentVariables="NO_COLOR=true" />
<WriteLinesToFile Lines="```" Overwrite="false" Encoding="UTF-8" File="help.md" />
</Target>

Expand Down
Loading