From c8f00df17023562e173fda0b9bdb13d3575a39ce Mon Sep 17 00:00:00 2001 From: Ian O'Neill Date: Mon, 21 Jun 2021 15:52:59 +0100 Subject: [PATCH] Fix code-format and test invocation through PowerShell Fixes the `Invoke-CodeFormat` and `Invoke-OpenConsoleTests` functions in `OpenConsole.psm1` so that they can be run directly from PowerShell. Addresses the issues found when creating #10447. `Invoke-CodeFormat` did not work when invoked directly from PowerShell due to a relative path being passed into the .NET function `[IO.File]::WriteAllLines()`. The working directory for .NET objects does not change when you change directory in PowerShell, so the paths were being treated as relative to the initial working directory of the shell - which was not the terminal git repo. `Invoke-OpenConsoleTests` had 3 issues: 1. The path to `TestHostApp` was wrong. 2. It would attempt to run the "in host app" tests both in the host app and not in the host app. 3. The test configuration in `tests.xml` wasn't in sync with the `runABC.cmd` files, so the remoting and control unit tests didn't run. ## Validation Steps Performed 1. Ran `Invoke-CodeFormat` and `runformat.cmd` from multiple directories and didn't see errors. 2. Ran `Invoke-OpenConsoleTests` and didn't see errors. --- tools/OpenConsole.psm1 | 16 +++++++++------- tools/tests.xml | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tools/OpenConsole.psm1 b/tools/OpenConsole.psm1 index bb746507f..b1a8de52e 100644 --- a/tools/OpenConsole.psm1 +++ b/tools/OpenConsole.psm1 @@ -193,7 +193,7 @@ function Invoke-OpenConsoleTests() return } $OpenConsolePlatform = $Platform - $TestHostAppPath = "$root\$OpenConsolePlatform\$Configuration\TestHostApp" + $TestHostAppPath = "$root\bin\$OpenConsolePlatform\$Configuration\TestHostApp" if ($Platform -eq 'x86') { $OpenConsolePlatform = 'Win32' @@ -240,8 +240,10 @@ function Invoke-OpenConsoleTests() { & $TaefExePath "$TestHostAppPath\$($t.binary)" $TaefArgs } - - & $TaefExePath "$BinDir\$($t.binary)" $TaefArgs + else + { + & $TaefExePath "$BinDir\$($t.binary)" $TaefArgs + } } elseif ($t.type -eq "ft") { @@ -393,10 +395,10 @@ function Invoke-XamlFormat() { dotnet tool run xstyler -- -c "$root\XamlStyler.json" -f "$xamlsForStyler" # Strip BOMs from all the .xaml files - $xamls = (git ls-files "$root/**/*.xaml") - foreach ($file in $xamls ) { - $content = Get-Content $file - [IO.File]::WriteAllLines("$file", $content) + $xamls = (git ls-files --full-name "$root/**/*.xaml") + foreach ($file in $xamls) { + $content = Get-Content "$root/$file" + [IO.File]::WriteAllLines("$root/$file", $content) } } diff --git a/tools/tests.xml b/tools/tests.xml index 19507741d..fd6444662 100644 --- a/tools/tests.xml +++ b/tools/tests.xml @@ -6,8 +6,8 @@ - - + +