-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cs
More file actions
48 lines (39 loc) · 1.62 KB
/
test.cs
File metadata and controls
48 lines (39 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#region Purpose
// Development CLI for TimeWarp.Terminal repository operations
#endregion
// ═══════════════════════════════════════════════════════════════════════════════
// TEST COMMAND
// ═══════════════════════════════════════════════════════════════════════════════
// Run CI test suite
namespace DevCli;
/// <summary>
/// Run CI test suite
/// </summary>
[NuruRoute("test", Description = "Run CI test suite")]
internal sealed class TestCommand : ICommand<Unit>
{
internal sealed class Handler : ICommandHandler<TestCommand, Unit>
{
private readonly ITerminal Terminal;
public Handler(ITerminal terminal)
{
Terminal = terminal;
}
public async ValueTask<Unit> Handle(TestCommand command, CancellationToken ct)
{
string? repoRoot = Git.FindRoot()
?? throw new InvalidOperationException("Could not find git repository root");
Terminal.WriteLine("Running tests...");
int exitCode = await Shell.Builder("dotnet")
.WithArguments("test", Path.Combine(repoRoot, "timewarp-terminal.slnx"), "--no-build", "-v", "n")
.WithWorkingDirectory(repoRoot)
.RunAsync();
if (exitCode != 0)
{
throw new InvalidOperationException("Tests failed!");
}
Terminal.WriteLine("\n✓ All tests passed");
return Unit.Value;
}
}
}