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
5 changes: 1 addition & 4 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,7 @@ jobs:
run: dotnet build -c Release

- name: Publish AOT
run: dotnet publish TUnit.TestProject/TUnit.TestProject.csproj -c Release --use-current-runtime -p:Aot=true -o TESTPROJECT_AOT --framework net8.0

- name: Publish Single File
run: dotnet publish TUnit.TestProject/TUnit.TestProject.csproj -c Release --use-current-runtime -p:SingleFile=true -o TESTPROJECT_SINGLEFILE --framework net8.0
run: dotnet publish TUnit.TestProject/TUnit.TestProject.csproj -c Release --use-current-runtime -p:Aot=true -o TESTPROJECT_AOT --framework net10.0

- name: Run Pipeline
uses: ./.github/actions/execute-pipeline
Expand Down
1 change: 0 additions & 1 deletion TUnit.Engine.Tests/Enums/TestMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ public enum TestMode
SourceGenerated,
Reflection,
AOT,
SingleFileApplication,
}
5 changes: 2 additions & 3 deletions TUnit.Engine.Tests/ExternalCancellationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,12 @@ private async Task RunTestWithExternalCancellation(string filter, string markerF
.WithWorkingDirectory(testProject.DirectoryName!)
.WithValidation(CommandResultValidation.None),

// Skip AOT and SingleFile modes for external cancellation (only test in CI)
// Skip AOT mode for external cancellation (only test in CI)
TestMode.AOT => null,
TestMode.SingleFileApplication => null,
_ => throw new ArgumentOutOfRangeException(nameof(testMode), testMode, null)
};

// Skip AOT and SingleFile modes
// Skip AOT mode
if (command == null)
{
return;
Expand Down
48 changes: 7 additions & 41 deletions TUnit.Engine.Tests/InvokableTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public static IEnumerable<TestMode> GetTestModes()
if (!EnvironmentVariables.IsNetFramework)
{
yield return TestMode.AOT;
yield return TestMode.SingleFileApplication;
}
}

Expand All @@ -43,7 +42,6 @@ protected Task RunTestsWithFilter(string filter,
TestMode.SourceGenerated => RunWithoutAot(filter, assertions, runOptions, assertionExpression),
TestMode.Reflection => RunWithoutAot(filter, assertions, runOptions.WithArgument("--reflection"), assertionExpression),
TestMode.AOT => RunWithAot(filter, assertions, runOptions, assertionExpression),
TestMode.SingleFileApplication => RunWithSingleFile(filter, assertions, runOptions, assertionExpression),
_ => throw new ArgumentOutOfRangeException(nameof(testMode), testMode, null)
};
}
Expand All @@ -52,15 +50,17 @@ private async Task RunWithoutAot(string filter,
List<Action<TestRun>> assertions, RunOptions runOptions, string assertionExpression)
{
var testProject = Sourcy.DotNet.Projects.TUnit_TestProject;
var projectName = Path.GetFileNameWithoutExtension(testProject.Name);
var binDir = new DirectoryInfo(Path.Combine(testProject.DirectoryName!, "bin", "Release", GetEnvironmentVariable));

var executable = binDir.EnumerateFiles(projectName).FirstOrDefault()
?? binDir.EnumerateFiles(projectName + ".exe").First();

var guid = Guid.NewGuid().ToString("N");
var trxFilename = guid + ".trx";
var command = Cli.Wrap("dotnet")
var command = Cli.Wrap(executable.FullName)
.WithArguments(
[
"run",
"--no-build",
"-f", GetEnvironmentVariable,
"--configuration", "Release",
"--treenode-filter", filter,
"--report-trx", "--report-trx-filename", trxFilename,
"--diagnostic-verbosity", "Debug",
Expand Down Expand Up @@ -110,40 +110,6 @@ private async Task RunWithAot(string filter, List<Action<TestRun>> assertions,
await RunWithFailureLogging(command, runOptions, trxFilename, assertions, assertionExpression);
}

private async Task RunWithSingleFile(string filter,
List<Action<TestRun>> assertions, RunOptions runOptions, string assertionExpression)
{
if (Environment.GetEnvironmentVariable("GITHUB_ACTIONS") != "true")
{
return;
}

var files = FindFolder(x => x.Name == "TESTPROJECT_SINGLEFILE")!
.EnumerateFiles("*", SearchOption.AllDirectories)
.ToArray();

var aotApp = files.FirstOrDefault(x => x.Name == "TUnit.TestProject")
?? files.First(x => x.Name == "TUnit.TestProject.exe");

var guid = Guid.NewGuid().ToString("N");
var trxFilename = guid + ".trx";

var command = Cli.Wrap(aotApp.FullName)
.WithArguments(
[
"--treenode-filter", filter,
"--report-trx", "--report-trx-filename", trxFilename,
"--diagnostic-verbosity", "Debug",
"--diagnostic", "--diagnostic-file-prefix", $"log_{GetType().Name}_SINGLEFILE_",
"--timeout", "5m",
..runOptions.AdditionalArguments
]
)
.WithValidation(CommandResultValidation.None);

await RunWithFailureLogging(command, runOptions, trxFilename, assertions, assertionExpression);
}

protected static FileInfo? FindFile(Func<FileInfo, bool> predicate)
{
return FileSystemHelpers.FindFile(predicate);
Expand Down
Loading