From be5f54326e5b5c1d5b25087093ed737ffab41f68 Mon Sep 17 00:00:00 2001 From: Eric Harding Date: Wed, 18 Sep 2019 15:16:28 -0400 Subject: [PATCH 1/2] sparkcmd test should always respect test type (unit/system) --- .../spark_core/TestRunner/InProcessTestRunner.cs | 6 +++--- src/client/spark_core/TestRunner/TestEnumerator.cs | 9 +++++---- src/client/sparkcmd/Cmd/TestCommand.cs | 12 +++++++++--- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/client/spark_core/TestRunner/InProcessTestRunner.cs b/src/client/spark_core/TestRunner/InProcessTestRunner.cs index 871f06b58..4b786d1f5 100644 --- a/src/client/spark_core/TestRunner/InProcessTestRunner.cs +++ b/src/client/spark_core/TestRunner/InProcessTestRunner.cs @@ -10,9 +10,9 @@ using System.Diagnostics; namespace bts.test { public static class InProcessTestRunner { - public static void run_test_synchronously(string v, TestEnumerator enumerator, Action report) { - foreach (var t in enumerator.find(v)) { - run_test_synchronously(t, report); + public static void run_test_synchronously(string v, TestType type, TestEnumerator enumerator, Action report) { + foreach (var t in enumerator.find(v,type)) { + run_test_synchronously(t, report); } } public static void run_test_synchronously(TestMethod test, Action report) { diff --git a/src/client/spark_core/TestRunner/TestEnumerator.cs b/src/client/spark_core/TestRunner/TestEnumerator.cs index e18c9b838..0fbaf3087 100644 --- a/src/client/spark_core/TestRunner/TestEnumerator.cs +++ b/src/client/spark_core/TestRunner/TestEnumerator.cs @@ -36,18 +36,19 @@ namespace bts.test { } - public IEnumerable find(string name) { + public IEnumerable find(string name, TestType type) { foreach (var g in TestGroups) { foreach (var t in g.methods) { - if (g.name == name || t.name == name || t.full_name == name) { + if (g.test_type == type && + (g.name == name || t.name == name || t.full_name == name)) { yield return t; } } } } - public IEnumerable match(IEnumerable names) { - return names.SelectMany(find).Distinct(); + public IEnumerable match(TestType type, IEnumerable names) { + return names.SelectMany(name => find(name,type)).Distinct(); } } diff --git a/src/client/sparkcmd/Cmd/TestCommand.cs b/src/client/sparkcmd/Cmd/TestCommand.cs index 9b071eb7a..aff93988d 100644 --- a/src/client/sparkcmd/Cmd/TestCommand.cs +++ b/src/client/sparkcmd/Cmd/TestCommand.cs @@ -48,7 +48,7 @@ namespace sparkcmd { } else Configuration.initialize(); - Console.WriteLine(JsonConvert.SerializeObject(o)); + ConsoleEx.WriteLine(JsonConvert.SerializeObject(o), ConsoleColor.DarkGray); if (o.list) { list_tests((o.type)); @@ -58,13 +58,19 @@ namespace sparkcmd { if (o.timeout == 0 && o.tests.Count() == 1 && !o.self_contained) { //System.Threading.Thread.Sleep(5000); using (var trr = new TestResultReceiver(true)) { - InProcessTestRunner.run_test_synchronously(o.tests.First(), Enumerator, trr.get_reporter()); + InProcessTestRunner.run_test_synchronously(o.tests.First(), o.type, Enumerator, trr.get_reporter()); trr.print_summary(); + if (trr.ResultCount == 0) { + ConsoleEx.Write("No ", ConsoleColor.Red); + ConsoleEx.Write(o.type.ToString(), ConsoleColor.Yellow); + ConsoleEx.WriteLine($" tests matched filter '{o.tests.First()}'", ConsoleColor.Red); + return -1; + } return trr.ErrorCount; } } else if (o.tests.Count() > 0) { - return run_tests(o, Enumerator.match(o.tests)); + return run_tests(o, Enumerator.match(o.type, o.tests)); } else { return run_tests(o, Enumerator.get_of_type(o.type)); From 71915de4b0e0a9c1a4d839f78657d245be575509 Mon Sep 17 00:00:00 2001 From: Eric Harding Date: Wed, 18 Sep 2019 15:47:53 -0400 Subject: [PATCH 2/2] sparkcmd CaseInsensitiveEnumValues --- src/client/sparkcmd/Program.cs | 6 +++++- src/client/sparkcmd/sparkcmd.csproj | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/client/sparkcmd/Program.cs b/src/client/sparkcmd/Program.cs index 8999b8bcc..96b1d2dc8 100644 --- a/src/client/sparkcmd/Program.cs +++ b/src/client/sparkcmd/Program.cs @@ -29,8 +29,12 @@ namespace sparkcmd { // initialized from c++ instead of c# BTSNativeMethods.provide_command_line(args, args.Length); + var parser = new Parser(ps => { + ps.CaseInsensitiveEnumValues = true; + }); + // note: this can be made to infer the options type list from the list of delegates - return Parser.Default + return parser .ParseArguments< ConfigcheckOptions, ScriptClientOptions, diff --git a/src/client/sparkcmd/sparkcmd.csproj b/src/client/sparkcmd/sparkcmd.csproj index 52d9db007..b05a9d2d3 100644 --- a/src/client/sparkcmd/sparkcmd.csproj +++ b/src/client/sparkcmd/sparkcmd.csproj @@ -22,7 +22,7 @@ - +