Update unit/system tests command line parser

This commit is contained in:
Eric Harding committed 2019-04-24 10:12:08 -04:00
1 parent 8793c6c527
commit 9cc4b5aa87
5 files changed
+17 -21

No files matched your search

@@ -23,10 +23,6 @@ namespace sparkcmd {
}
public class ScriptClientCommand {
bool _server = false;
string _host;
string _logfile;
public static int Run(ScriptClientOptions o) {
if (o.server) {
ScriptClient.runserver();
+1
View File
@@ -8,6 +8,7 @@ using System.Text;
using System.Threading.Tasks;
namespace bts {
[Verb("tail", HelpText="'console dsqa'")]
class TailServiceOptions {
[Option('m', "method", Required=true, HelpText = "'[ServiceName].[Method]' to call")]
public string method { get;set; }
+11 -14
View File
@@ -8,28 +8,23 @@ using System.Threading.Tasks;
using mbts.config;
using System.Linq;
using CommandLine;
using Newtonsoft.Json;
namespace sparkcmd {
[Verb("test", HelpText="Run Tests")]
public class TestCommandOptions {
[Option('t', "timeout", HelpText="Timeout unit tets", Default=0)]
[Option('t', "timeout", HelpText="Timeout unit tets", Default=0u)]
public uint timeout { get; set; }
[Option('l', "list", HelpText="List tests")]
public bool list { get; set; }
[Option('i', "insular", HelpText="Tests run sparkd and use their own config (if specified)")]
public bool self_contained { get; set; }
// [Option("unit", HelpText="Run unit tests")]
// public bool unit { get; set; }
// [Option("system", HelpText="Run system tests")]
// public bool system { get; set; }
// [Option("shell", HelpText="Run shell tests")]
// public bool shell { get; set; }
[Option("type", HelpText ="Run all tests of type [Unit|System|Shell]")]
public TestType type { get; set; }
[Value(0, MetaName="TestType")]
public string type { get; set; }
[Value(1, MetaName="Tests", HelpText="Test list")]
public IEnumerable<string> tests { get; set; }
@@ -46,8 +41,10 @@ namespace sparkcmd {
}
public static int Run(TestCommandOptions o) {
Console.WriteLine(JsonConvert.SerializeObject(o));
if (o.list) {
list_tests(test_type(o.type));
list_tests((o.type));
return 0;
}
@@ -60,20 +57,20 @@ namespace sparkcmd {
}
}
else if (o.tests.Count() > 0) {
return run_tests(Enumerator.match(tests));
return run_tests(o, Enumerator.match(o.tests));
}
else {
return run_tests(Enumerator.get_of_type(test_type));
return run_tests(o, Enumerator.get_of_type(o.type));
}
}
static Lazy<TestEnumerator> _enumerator = new Lazy<TestEnumerator>(() => new TestEnumerator("spark_test"));
static TestEnumerator Enumerator => _enumerator.Value;
static int run_tests(IEnumerable<TestMethod> tests) {
static int run_tests(TestCommandOptions o, IEnumerable<TestMethod> tests) {
var runner = new TestRunner();
// waits for all child processes to exit or time out
return runner.run_tests(tests, _timeout, self_contained);
return runner.run_tests(tests, o.timeout, o.self_contained);
}
static void list_tests(TestType test_type) {
+4 -3
View File
@@ -24,14 +24,15 @@ namespace sparkcmd {
// }
static int Main(string[] args) {
// note: this can be made to infer the options type list from the list of delegates
return CommandLine.Parser.Default
.ParseArguments<ConfigcheckOptions,ScriptClientOptions,TailServiceOptions,ServiceTestOptions,SettingsManagerOptions >(args)
.MapResult<ConfigcheckOptions,ScriptClientOptions,TailServiceOptions,ServiceTestOptions,SettingsManagerOptions,int>(
return Parser.Default
.ParseArguments<ConfigcheckOptions,ScriptClientOptions,TailServiceOptions,ServiceTestOptions,SettingsManagerOptions,TestCommandOptions >(args)
.MapResult<ConfigcheckOptions,ScriptClientOptions,TailServiceOptions,ServiceTestOptions,SettingsManagerOptions,TestCommandOptions,int>(
Configcheck.Run,
ScriptClientCommand.Run,
TailService.Run,
ServiceTest.Run,
SettingsManagerCommand.Run,
TestCommand.Run,
errors => 1);
}
}
+1
View File
@@ -23,6 +23,7 @@
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.4.3" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>
</Project>