Skip to content

Commit

Permalink
Adding another test, tweaking some logic
Browse files Browse the repository at this point in the history
  • Loading branch information
belav committed Dec 7, 2024
1 parent bb50680 commit 3d39259
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
11 changes: 4 additions & 7 deletions Src/CSharpier.MsBuild/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 11 additions & 10 deletions Tests/MsBuild/Run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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::"
Expand All @@ -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
}

Expand All @@ -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
Expand Down

0 comments on commit 3d39259

Please sign in to comment.