diff --git a/src/client/sparkcmd/Cmd/ScriptClientCommand.cs b/src/client/sparkcmd/Cmd/ScriptClientCommand.cs index 5f00cf392..57cf26389 100644 --- a/src/client/sparkcmd/Cmd/ScriptClientCommand.cs +++ b/src/client/sparkcmd/Cmd/ScriptClientCommand.cs @@ -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(); diff --git a/src/client/sparkcmd/Cmd/ServiceTail.cs b/src/client/sparkcmd/Cmd/ServiceTail.cs index 926bc5a6c..d7c47c6d8 100644 --- a/src/client/sparkcmd/Cmd/ServiceTail.cs +++ b/src/client/sparkcmd/Cmd/ServiceTail.cs @@ -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; } diff --git a/src/client/sparkcmd/Cmd/TestCommand.cs b/src/client/sparkcmd/Cmd/TestCommand.cs index 89dbf7498..b5b919f0a 100644 --- a/src/client/sparkcmd/Cmd/TestCommand.cs +++ b/src/client/sparkcmd/Cmd/TestCommand.cs @@ -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 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 _enumerator = new Lazy(() => new TestEnumerator("spark_test")); static TestEnumerator Enumerator => _enumerator.Value; - static int run_tests(IEnumerable tests) { + static int run_tests(TestCommandOptions o, IEnumerable 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) { diff --git a/src/client/sparkcmd/Program.cs b/src/client/sparkcmd/Program.cs index 14b3df9bb..3f73e04c2 100644 --- a/src/client/sparkcmd/Program.cs +++ b/src/client/sparkcmd/Program.cs @@ -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(args) - .MapResult( + return Parser.Default + .ParseArguments(args) + .MapResult( Configcheck.Run, ScriptClientCommand.Run, TailService.Run, ServiceTest.Run, SettingsManagerCommand.Run, + TestCommand.Run, errors => 1); } } diff --git a/src/client/sparkcmd/sparkcmd.csproj b/src/client/sparkcmd/sparkcmd.csproj index 1a8c7f607..75fd218c8 100644 --- a/src/client/sparkcmd/sparkcmd.csproj +++ b/src/client/sparkcmd/sparkcmd.csproj @@ -23,6 +23,7 @@ +