From 73c93585bed260ca6b8572e6d8ad7f73983a9bb1 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 e13c8fa64..f6279118d 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 42835e2ba816b590510ca307bf991737b941da59 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 f6279118d..fa3f96ed5 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 6086b7a89b78920904995c4fed4931f0c9f18d33 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 fa3f96ed5..457f4ef40 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 e9460ce0ce8d5b3e06d602f0266195919ec5cdbd 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 457f4ef40..5c61a5fe5 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 29582d7a3765d94f980d6028c28831959a9b8aa7 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 9db55281e..69ad4aa7e 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 4c7553bf29b9440f81dd1cf12caadb81141842cd 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 5c61a5fe5..d774f7a61 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 0df1d7ced6cebc52afebc116b7cce745d48a9a6d 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 69ad4aa7e..9db55281e 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); - } } }