From 3d39259ef1c297b4f8326905493d7b2693fd2867 Mon Sep 17 00:00:00 2001 From: Bela VanderVoort Date: Sat, 7 Dec 2024 12:41:34 -0600 Subject: [PATCH] Adding another test, tweaking some logic --- Src/CSharpier.MsBuild/README.md | 11 ++++------- Tests/MsBuild/Run.ps1 | 21 +++++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Src/CSharpier.MsBuild/README.md b/Src/CSharpier.MsBuild/README.md index 2226efa94..25e9d392f 100644 --- a/Src/CSharpier.MsBuild/README.md +++ b/Src/CSharpier.MsBuild/README.md @@ -5,15 +5,12 @@ One way to test the changes in the build/* files - Ensure you revert those files and make the same changes to the files here. Some automated tests exist -- the validate PR GH action runs these, mostly around framework versions +- the validate PR GH action runs these - cd ./Tests/MsBuild -- ./Run.ps1 +- ./Run.ps1 - some of these don't seem to work well locally Other things that would be really really nice to automate -- exits properly in release when no files formatted - https://github.com/belav/csharpier/issues/1357 -- same as above if thing set - formats files in debug - formats files if told to in release -- a few scenarios in here I think, compilation errors etc - https://github.com/belav/csharpier/issues/1131 +- checks files if told to in debug +- log levels \ No newline at end of file diff --git a/Tests/MsBuild/Run.ps1 b/Tests/MsBuild/Run.ps1 index 5a80983d1..9c04d17f7 100644 --- a/Tests/MsBuild/Run.ps1 +++ b/Tests/MsBuild/Run.ps1 @@ -16,7 +16,7 @@ if (Test-Path $basePath) { New-Item $basePath -ItemType Directory | Out-Null -$failureMessage = "" +$failureMessages = @() foreach ($scenario in $scenarios) { # these fail on windows in GH and because they use dockerfiles for the scenarios we don't need to run them twice anyway @@ -67,7 +67,7 @@ RUN dotnet build -c Release docker build . -f $dockerFile if ($LASTEXITCODE -ne 0) { - $failureMessage += "::error::The scenario $($scenario.name) failed to build. See the logs above for details`n" + $failureMessages += "The scenario $($scenario.name) failed to build. See the logs above for details" } Write-Host "::endgroup::" @@ -76,19 +76,20 @@ RUN dotnet build -c Release Write-Host "::group::UnformattedFileCausesError" $output = [TestHelper]::RunTestCase("UnformattedFileCausesError", $true) -# TODO do we need to test output? Write-Host "::endgroup::" Write-Host "::group::FileThatCantCompileCausesOneError" $output = [TestHelper]::RunTestCase("FileThatCantCompileCausesOneError", $true) -# TODO what do we need to look for in the output? -Write-Host "::endgroup::" - -# TODO any other scenarior to test? +if (-not($output.Contains("1 Error(s)"))) { + $failureMessages += "The TestCase FileThatCantCompileCausesOneError did not contain the text '1 Error(s)1" +} +Write-Host "::endgroup::" -if ($failureMessage -ne "") { - Write-Host $failureMessage +if ($failureMessages.Length -ne 0) { + foreach ($message in $failureMessages) { + Write-Host "::error::$message`n" + } exit 1 } @@ -103,7 +104,7 @@ class TestHelper { } if ($LASTEXITCODE -ne $expectedExitCode) { - $failureMessage += "::error::The TestCase $testCase did not return an exit code of $expectedExitCode`n" + $failureMessages += "The TestCase $testCase did not return an exit code of $expectedExitCode" } return $output