diff --git a/Python/InedoExtension/InedoExtension.csproj b/Python/InedoExtension/InedoExtension.csproj index 77eee8d..2f6e3a8 100644 --- a/Python/InedoExtension/InedoExtension.csproj +++ b/Python/InedoExtension/InedoExtension.csproj @@ -1,6 +1,6 @@  - net452;net5.0 + net6.0 Library Inedo.Extensions.Python Python @@ -8,8 +8,8 @@ latest - - + + diff --git a/Python/InedoExtension/Operations/CapturePackageInfoOperation.cs b/Python/InedoExtension/Operations/CapturePackageInfoOperation.cs index 60ccaae..4adaae7 100644 --- a/Python/InedoExtension/Operations/CapturePackageInfoOperation.cs +++ b/Python/InedoExtension/Operations/CapturePackageInfoOperation.cs @@ -27,7 +27,8 @@ public override async Task ExecuteAsync(IOperationExecutionContext context) WorkingDirectory = context.WorkingDirectory }; - startInfo.Arguments += AH.ConcatNE(" ", this.AdditionalArguments); + if (!string.IsNullOrWhiteSpace(this.AdditionalArguments)) + startInfo.Arguments += this.AdditionalArguments; await this.WrapInVirtualEnv(context, startInfo); diff --git a/Python/InedoExtension/Operations/InstallPackagesOperation.cs b/Python/InedoExtension/Operations/InstallPackagesOperation.cs index 358b197..e9eef36 100644 --- a/Python/InedoExtension/Operations/InstallPackagesOperation.cs +++ b/Python/InedoExtension/Operations/InstallPackagesOperation.cs @@ -35,7 +35,8 @@ public override async Task ExecuteAsync(IOperationExecutionContext context) startInfo.Arguments += " -r requirements.txt"; } - startInfo.Arguments += AH.ConcatNE(" ", this.AdditionalArguments); + if (!string.IsNullOrWhiteSpace(this.AdditionalArguments)) + startInfo.Arguments += this.AdditionalArguments; await this.WrapInVirtualEnv(context, startInfo); await this.ExecuteCommandLineAsync(context, startInfo); diff --git a/Python/InedoExtension/Operations/PyUnitOperation.cs b/Python/InedoExtension/Operations/PyUnitOperation.cs index 5c3289c..f62fdb9 100644 --- a/Python/InedoExtension/Operations/PyUnitOperation.cs +++ b/Python/InedoExtension/Operations/PyUnitOperation.cs @@ -86,9 +86,9 @@ string getTestLog(IGrouping test) var skipReason = test.FirstOrDefault(e => e.Type == EventType.Skip)?.Message; var exceptions = test.Select(e => e.Err).Where(e => e != null).ToArray(); - return "Test: " + test.Key.ID + AH.ConcatNE("\n", test.Key.Desc) + - "\n\nResult: " + AH.CoalesceString(result, "Unknown") + AH.ConcatNE(" (", skipReason, ")") + - AH.ConcatNE("\n\nOutput:\n", stdout) + AH.ConcatNE("\n\nError:\n", stderr) + + return "Test: " + test.Key.ID + ConcatNE("\n", test.Key.Desc) + + "\n\nResult: " + AH.CoalesceString(result, "Unknown") + ConcatNE(" (", skipReason, ")") + + ConcatNE("\n\nOutput:\n", stdout) + ConcatNE("\n\nError:\n", stderr) + (exceptions.Any() ? "\n\nExceptions:\n\n" + string.Join("\n\n", exceptions) : string.Empty) + "\n"; } @@ -104,6 +104,14 @@ TimeSpan getDuration(IGrouping test) var end = (test.FirstOrDefault(e => e.Type == EventType.StopCase) ?? test.Last()).Time; return TimeSpan.FromSeconds(end - start); } + + static string ConcatNE(string a, string b, string c = "") + { + if (!string.IsNullOrEmpty(b)) + return a + b + c; + else + return string.Empty; + } } private async Task RunTestsAsync(IOperationExecutionContext context) @@ -150,7 +158,7 @@ protected override void LogProcessOutput(string text) { if (text.StartsWith("__BuildMasterPythonTestRunner__")) { - this.Events.Add(JsonConvert.DeserializeObject(text.Substring("__BuildMasterPythonTestRunner__".Length))); + this.Events.Add(JsonConvert.DeserializeObject(text["__BuildMasterPythonTestRunner__".Length..])); return; }