From 53ffcc9b5c210389053fc7561e485270a8b6f239 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 3 May 2018 23:30:07 +0200 Subject: [PATCH 1/7] Extend run-tests.ps1 by a warning if submodules are not synced I'm contributing to ImageSharp since around a week, and I saw 3 people (myself included) stumbling over failing tests due to the submodule for test data being out of sync. With this commit the run-tests.ps1 test script is extended by the following behaviour: - if something fails during the script run, the submodule status is checked. A warning is printed if - any submodule is not initialized or - any submodule is not synchronized - git could not be called to check the submodule status. --- run-tests.ps1 | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/run-tests.ps1 b/run-tests.ps1 index e13c8fa648..f6279118d4 100644 --- a/run-tests.ps1 +++ b/run-tests.ps1 @@ -15,6 +15,30 @@ function VerifyPath($path, $errorMessage) { } } +function CheckSubmoduleStatus() { + $submoduleStatus = (git submodule status) | Out-String + # if the result string is empty, the command failed to run (we didn't capture the error stream) + if ($submoduleStatus) { + # git has been called successfully, what about the status? + if ($submoduleStatus -contains '-') + { + # submodule has not been initialized! + return 2; + } elseif ($submoduleStatus -contains '+') + { + # submodule is not synced: + return 1; + } else { + # everything fine: + return 0; + } + } else { + # git call failed, so we should warn + return 3; + } +} + + if ( ($targetFramework -eq "netcoreapp2.0") -and ($env:CI -eq "True") -and ($is32Bit -ne "True")) { # We execute CodeCoverage.cmd only for one specific job on CI (netcoreapp2.0 + 64bit ) $testRunnerCmd = ".\tests\CodeCoverage\CodeCoverage.cmd" @@ -64,4 +88,22 @@ Invoke-Expression $testRunnerCmd cd $PSScriptRoot + +if (0 -ne ([int]$LASTEXITCODE)) { + # check submodule status + $submoduleStatus = CheckSubmoduleStatus + if ([int]$submoduleStatus -eq 1) { + # not synced + Write-Host -ForegroundColor Yellow "Check if submodules are up to date. You can use 'git submodule update' to fix this"; + } elseif ($submoduleStatus -eq 2) { + # not initialized + Write-Host -ForegroundColor Yellow "Check if submodules are initialized. You can run 'git submodule init' to initialize them." + } elseif ($submoduleStatus -eq 3) { + # git not found, maybe submodules not synced? + Write-Host -ForegroundColor Yellow "Could not check if submodules are initialized correctly. Maybe git is not installed?" + } else { + #Write-Host "Submodules are up to date"; + } +} + exit $LASTEXITCODE From a7725c0a44fbababbd1bf7c5aacb50e2de9b9989 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 4 May 2018 20:08:52 +0200 Subject: [PATCH 2/7] #557: use spaces, not tabs --- run-tests.ps1 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/run-tests.ps1 b/run-tests.ps1 index f6279118d4..fa3f96ed52 100644 --- a/run-tests.ps1 +++ b/run-tests.ps1 @@ -22,19 +22,19 @@ function CheckSubmoduleStatus() { # git has been called successfully, what about the status? if ($submoduleStatus -contains '-') { - # submodule has not been initialized! - return 2; + # submodule has not been initialized! + return 2; } elseif ($submoduleStatus -contains '+') { # submodule is not synced: - return 1; + return 1; } else { - # everything fine: - return 0; - } + # everything fine: + return 0; + } } else { # git call failed, so we should warn - return 3; + return 3; } } @@ -94,13 +94,13 @@ if (0 -ne ([int]$LASTEXITCODE)) { $submoduleStatus = CheckSubmoduleStatus if ([int]$submoduleStatus -eq 1) { # not synced - Write-Host -ForegroundColor Yellow "Check if submodules are up to date. You can use 'git submodule update' to fix this"; + Write-Host -ForegroundColor Yellow "Check if submodules are up to date. You can use 'git submodule update' to fix this"; } elseif ($submoduleStatus -eq 2) { # not initialized - Write-Host -ForegroundColor Yellow "Check if submodules are initialized. You can run 'git submodule init' to initialize them." + Write-Host -ForegroundColor Yellow "Check if submodules are initialized. You can run 'git submodule init' to initialize them." } elseif ($submoduleStatus -eq 3) { # git not found, maybe submodules not synced? - Write-Host -ForegroundColor Yellow "Could not check if submodules are initialized correctly. Maybe git is not installed?" + Write-Host -ForegroundColor Yellow "Could not check if submodules are initialized correctly. Maybe git is not installed?" } else { #Write-Host "Submodules are up to date"; } From c2149a2c1608a46e029bb4eea456d163584a6e45 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 4 May 2018 20:46:08 +0200 Subject: [PATCH 3/7] #557: fix string comparison and wrong logic 1) -contains is for arrays, not for strings, so we use match (and mask the -) 2) if a module is not initialized the status contains the string ((null)) where usually the commit id is placed (the Hash in parantheses) --- run-tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run-tests.ps1 b/run-tests.ps1 index fa3f96ed52..457f4ef408 100644 --- a/run-tests.ps1 +++ b/run-tests.ps1 @@ -20,11 +20,11 @@ function CheckSubmoduleStatus() { # if the result string is empty, the command failed to run (we didn't capture the error stream) if ($submoduleStatus) { # git has been called successfully, what about the status? - if ($submoduleStatus -contains '-') + if (($submoduleStatus -match "\-") -or ($submoduleStatus -match "\(\(null\)\)")) { # submodule has not been initialized! return 2; - } elseif ($submoduleStatus -contains '+') + } elseif ($submoduleStatus -match "\+") { # submodule is not synced: return 1; From d1bacad43e36cfeaccc6bbc2b52eb4035b16169e Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Sat, 5 May 2018 00:51:45 +0200 Subject: [PATCH 4/7] use 4 spaces in new code (like in the rest of the file) --- run-tests.ps1 | 66 ++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/run-tests.ps1 b/run-tests.ps1 index 457f4ef408..5c61a5fe52 100644 --- a/run-tests.ps1 +++ b/run-tests.ps1 @@ -16,26 +16,28 @@ function VerifyPath($path, $errorMessage) { } function CheckSubmoduleStatus() { - $submoduleStatus = (git submodule status) | Out-String - # if the result string is empty, the command failed to run (we didn't capture the error stream) - if ($submoduleStatus) { - # git has been called successfully, what about the status? - if (($submoduleStatus -match "\-") -or ($submoduleStatus -match "\(\(null\)\)")) - { - # submodule has not been initialized! - return 2; - } elseif ($submoduleStatus -match "\+") - { - # submodule is not synced: - return 1; + $submoduleStatus = (git submodule status) | Out-String + # if the result string is empty, the command failed to run (we didn't capture the error stream) + if ($submoduleStatus) { + # git has been called successfully, what about the status? + if (($submoduleStatus -match "\-") -or ($submoduleStatus -match "\(\(null\)\)")) + { + # submodule has not been initialized! + return 2; + } + elseif ($submoduleStatus -match "\+") + { + # submodule is not synced: + return 1; + } + else { + # everything fine: + return 0; + } } else { - # everything fine: - return 0; + # git call failed, so we should warn + return 3; } - } else { - # git call failed, so we should warn - return 3; - } } @@ -90,20 +92,20 @@ cd $PSScriptRoot if (0 -ne ([int]$LASTEXITCODE)) { - # check submodule status - $submoduleStatus = CheckSubmoduleStatus - if ([int]$submoduleStatus -eq 1) { - # not synced - Write-Host -ForegroundColor Yellow "Check if submodules are up to date. You can use 'git submodule update' to fix this"; - } elseif ($submoduleStatus -eq 2) { - # not initialized - Write-Host -ForegroundColor Yellow "Check if submodules are initialized. You can run 'git submodule init' to initialize them." - } elseif ($submoduleStatus -eq 3) { - # git not found, maybe submodules not synced? - Write-Host -ForegroundColor Yellow "Could not check if submodules are initialized correctly. Maybe git is not installed?" - } else { - #Write-Host "Submodules are up to date"; - } + # check submodule status + $submoduleStatus = CheckSubmoduleStatus + if ([int]$submoduleStatus -eq 1) { + # not synced + Write-Host -ForegroundColor Yellow "Check if submodules are up to date. You can use 'git submodule update' to fix this"; + } elseif ($submoduleStatus -eq 2) { + # not initialized + Write-Host -ForegroundColor Yellow "Check if submodules are initialized. You can run 'git submodule init' to initialize them." + } elseif ($submoduleStatus -eq 3) { + # git not found, maybe submodules not synced? + Write-Host -ForegroundColor Yellow "Could not check if submodules are initialized correctly. Maybe git is not installed?" + } else { + #Write-Host "Submodules are up to date"; + } } exit $LASTEXITCODE From ff33699f364cff683eb41b01e0315c06486ef9bf Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Sat, 5 May 2018 00:58:50 +0200 Subject: [PATCH 5/7] temporary failing test to verify CI behavior --- .../TestUtilities/Tests/TestEnvironmentTests.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs index 9db55281ea..69ad4aa7e4 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs @@ -110,5 +110,11 @@ namespace SixLabors.ImageSharp.Tests IImageDecoder decoder = TestEnvironment.GetReferenceDecoder(fileName); Assert.IsType(expectedDecoderType, decoder); } + + [Fact] + public void TemporaryFailingTest() + { + Assert.True(false); + } } } From ffde7e6286d7919c2fec16ac245380fa6254d82d Mon Sep 17 00:00:00 2001 From: Peter Amrehn Date: Sat, 5 May 2018 12:20:58 +0200 Subject: [PATCH 6/7] fix returning wrong error code. Returned the error code of 'git submodule status' accidently. --- run-tests.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/run-tests.ps1 b/run-tests.ps1 index 5c61a5fe52..d774f7a61a 100644 --- a/run-tests.ps1 +++ b/run-tests.ps1 @@ -90,8 +90,9 @@ Invoke-Expression $testRunnerCmd cd $PSScriptRoot +$exitCodeOfTests = $LASTEXITCODE; -if (0 -ne ([int]$LASTEXITCODE)) { +if (0 -ne ([int]$exitCodeOfTests)) { # check submodule status $submoduleStatus = CheckSubmoduleStatus if ([int]$submoduleStatus -eq 1) { @@ -108,4 +109,4 @@ if (0 -ne ([int]$LASTEXITCODE)) { } } -exit $LASTEXITCODE +exit $exitCodeOfTests From d24889209fda2900c3b4555a9b49cf5cda2c32d1 Mon Sep 17 00:00:00 2001 From: Anton Firsov Date: Mon, 7 May 2018 01:09:21 +0200 Subject: [PATCH 7/7] Undo TemporaryFailingTest --- .../TestUtilities/Tests/TestEnvironmentTests.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs index 69ad4aa7e4..9db55281ea 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs @@ -110,11 +110,5 @@ namespace SixLabors.ImageSharp.Tests IImageDecoder decoder = TestEnvironment.GetReferenceDecoder(fileName); Assert.IsType(expectedDecoderType, decoder); } - - [Fact] - public void TemporaryFailingTest() - { - Assert.True(false); - } } }