Skip to content

Commit dc09558

Browse files
committed
Basic tests for PostBuild
1 parent e2ca7ac commit dc09558

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

Tests/CommandLineTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using RT.Json;
2+
using RT.PostBuild;
23
using RT.Serialization;
34
using Xunit;
45

@@ -126,4 +127,22 @@ public static void TestMore()
126127
JsonValue.Parse(@"{""Boolean"":false,""Subcommand"":{""SharedString"":null,""Id"":""this"","":type"":""Test2SubcommandDelete""}}")
127128
== ClassifyJson.Serialize(CommandLineParser.Parse<Test2Cmd>(["del", "this"])));
128129
}
130+
131+
[Fact]
132+
public static void TestPostBuild()
133+
{
134+
var reporter = new Reporter();
135+
CommandLineParser.PostBuildStep<CommandLineWithOption>(reporter);
136+
CommandLineParser.PostBuildStep<CommandLineWithArray>(reporter);
137+
CommandLineParser.PostBuildStep<Test1Cmd>(reporter);
138+
CommandLineParser.PostBuildStep<Test2Cmd>(reporter);
139+
}
140+
141+
class Reporter : IPostBuildReporter
142+
{
143+
public void Error(string message, params string[] tokens) => throw new Exception(message);
144+
public void Error(string message, string filename, int lineNumber, int? columnNumber = null) => throw new Exception(message);
145+
public void Warning(string message, params string[] tokens) { }
146+
public void Warning(string message, string filename, int lineNumber, int? columnNumber = null) { }
147+
}
129148
}

Tests/Test1.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class Test1Cmd : ICommandLineValidatable
1212
[IsPositional, IsMandatory]
1313
public Test1SubcommandBase Subcommand;
1414

15+
[Ignore]
1516
public static int ValidateCalled = 0;
1617

1718
public ConsoleColoredString Validate()

Tests/Test2.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Test2Cmd
66
{
77
[Option("-b")]
88
public bool Boolean;
9-
9+
[IsPositional]
1010
public Test2Subcommand Subcommand;
1111
}
1212

0 commit comments

Comments
 (0)