Skip to content

Commit

Permalink
make it so test runner returns a status code
Browse files Browse the repository at this point in the history
  • Loading branch information
vddCore committed Apr 5, 2024
1 parent 4cccff1 commit 221d4bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VirtualMachine/Tests/Ceres.LanguageTests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
vm.Start();

var testRunner = new TestRunner("tests", vm);
await testRunner.RunTests();
return await testRunner.RunTests();
13 changes: 12 additions & 1 deletion VirtualMachine/Tests/Ceres.LanguageTests/TestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ private void CompileTests()
TextOut.WriteLine();
}

public async Task RunTests()
public async Task<int> RunTests()
{
var failuresOccurred = false;

foreach (var testRoot in TestRoots)
{
var passed = 0;
Expand Down Expand Up @@ -180,6 +182,8 @@ public async Task RunTests()
? "were"
: "was";

failuresOccurred |= failed > 0;

TextOut.WriteLine($"{passed} tests passed, {failed} failed, {ignored} {verb} ignored.");
using (var process = Process.GetCurrentProcess())
{
Expand All @@ -189,6 +193,13 @@ public async Task RunTests()
}

ReportAnyTestFailures();

if (failuresOccurred)
{
return 1;
}

return 0;
}

private async Task<bool?> RunTestChunk(Chunk chunk, string path)
Expand Down

0 comments on commit 221d4bd

Please sign in to comment.