From 806eb6357669f68ddef808958724f28362f5bedc Mon Sep 17 00:00:00 2001 From: Vivian Thiebaut Date: Tue, 15 Nov 2022 15:29:31 -0500 Subject: [PATCH] Enable all tests --- .../AzDOBuildTools/AzDOBuildTools.psm1 | 124 +++++++++--------- contrib/win32/openssh/OpenSSHTestHelper.psm1 | 6 +- .../pesterTests/PlatformAbstractLayer.psm1 | 2 +- 3 files changed, 65 insertions(+), 67 deletions(-) diff --git a/contrib/win32/openssh/AzDOBuildTools/AzDOBuildTools.psm1 b/contrib/win32/openssh/AzDOBuildTools/AzDOBuildTools.psm1 index 85402bc80..9293a3475 100644 --- a/contrib/win32/openssh/AzDOBuildTools/AzDOBuildTools.psm1 +++ b/contrib/win32/openssh/AzDOBuildTools/AzDOBuildTools.psm1 @@ -200,20 +200,20 @@ function Invoke-OpenSSHTests # ... # FixHostFilePermissions.ps1 # ... - # Write-Verbose -Verbose -Message "Running Unit Tests..." - # Write-Verbose -Verbose -Message "Unit test directory is: ${OpenSSHBinPath}" + Write-Verbose -Verbose -Message "Running Unit Tests..." + Write-Verbose -Verbose -Message "Unit test directory is: ${OpenSSHBinPath}" - # $unitTestFailed = Invoke-OpenSSHUnitTest -UnitTestDirectory $OpenSSHBinPath + $unitTestFailed = Invoke-OpenSSHUnitTest -UnitTestDirectory $OpenSSHBinPath - # if($unitTestFailed) - # { - # Write-BuildMessage "At least one of the unit tests failed!" -Category Error - # $AllTestsPassed = $false - # } - # else - # { - # Write-BuildMessage -Message "All Unit tests passed!" -Category Information - # } + if($unitTestFailed) + { + Write-BuildMessage "At least one of the unit tests failed!" -Category Error + $AllTestsPassed = $false + } + else + { + Write-BuildMessage -Message "All Unit tests passed!" -Category Information + } # Run all E2E tests. Write-Verbose -Verbose -Message "Running E2E Tests..." @@ -239,62 +239,62 @@ function Invoke-OpenSSHTests } } - # # Bash tests. - # Write-Verbose -Verbose -Message "Running Bash Tests..." + # Bash tests. + Write-Verbose -Verbose -Message "Running Bash Tests..." - # # Ensure CygWin is installed, and install from Chocolatey if needed. - # $cygwinInstalled = $true - # $cygwinInstallLocation = "$env:SystemDrive/cygwin" - # if (! (Test-Path -Path "$cygwinInstallLocation/bin/sh.exe")) - # { - # Write-Verbose -Verbose -Message "CygWin not found" - # Install-CygWin -InstallLocation $cygwinInstallLocation + # Ensure CygWin is installed, and install from Chocolatey if needed. + $cygwinInstalled = $true + $cygwinInstallLocation = "$env:SystemDrive/cygwin" + if (! (Test-Path -Path "$cygwinInstallLocation/bin/sh.exe")) + { + Write-Verbose -Verbose -Message "CygWin not found" + Install-CygWin -InstallLocation $cygwinInstallLocation - # # Hack to fix up mangled CygWin directory, if needed. - # $expectedCygWinPath = "$env:SystemDrive/cygwin/bin/sh.exe" - # if (! (Test-Path -Path $expectedCygWinPath)) - # { - # Write-Verbose -Verbose -Message "CygWin did not install correctly, missing expected path: ${expectedCygWinPath}" + # Hack to fix up mangled CygWin directory, if needed. + $expectedCygWinPath = "$env:SystemDrive/cygwin/bin/sh.exe" + if (! (Test-Path -Path $expectedCygWinPath)) + { + Write-Verbose -Verbose -Message "CygWin did not install correctly, missing expected path: ${expectedCygWinPath}" - # $cygWinDirs = Get-Item -Path "$env:SystemDrive/cygwin*" - # if ($cygWinDirs.Count -gt 1) - # { - # Write-Verbose -Verbose -Message "CygWin install failed with mangled folder locations: ${cygWinDirs}" - # Write-Verbose -Verbose -Message 'TODO: Add hack to fix up CygWin folder.' - # } + $cygWinDirs = Get-Item -Path "$env:SystemDrive/cygwin*" + if ($cygWinDirs.Count -gt 1) + { + Write-Verbose -Verbose -Message "CygWin install failed with mangled folder locations: ${cygWinDirs}" + Write-Verbose -Verbose -Message 'TODO: Add hack to fix up CygWin folder.' + } - # Write-BuildMessage -Message "All bash tests failed because CygWin install failed" -Category Error - # $AllTestsPassed = $false - # $cygwinInstalled = $false - # } - # } + Write-BuildMessage -Message "All bash tests failed because CygWin install failed" -Category Error + $AllTestsPassed = $false + $cygwinInstalled = $false + } + } - # # Run UNIX bash tests. - # if ($cygwinInstalled) - # { - # Write-Verbose -Verbose -Message "Starting Bash Tests..." - # Invoke-OpenSSHBashTests - # if (-not $Global:bash_tests_summary) - # { - # $errorMessage = "Failed to start OpenSSH bash tests" - # Write-BuildMessage -Message $errorMessage -Category Error - # $AllTestsPassed = $false - # } - # else - # { - # if ($Global:bash_tests_summary["TotalBashTestsFailed"] -ne 0) - # { - # $total_bash_failed_tests = $Global:bash_tests_summary["TotalBashTestsFailed"] - # $total_bash_tests = $Global:bash_tests_summary["TotalBashTests"] - # $errorMessage = "At least one of the bash tests failed. [$total_bash_failed_tests of $total_bash_tests]" - # Write-BuildMessage -Message $errorMessage -Category Error - # $AllTestsPassed = $false - # } + # Run UNIX bash tests. + if ($cygwinInstalled) + { + Write-Verbose -Verbose -Message "Starting Bash Tests..." + Invoke-OpenSSHBashTests + if (-not $Global:bash_tests_summary) + { + $errorMessage = "Failed to start OpenSSH bash tests" + Write-BuildMessage -Message $errorMessage -Category Error + $AllTestsPassed = $false + } + else + { + if ($Global:bash_tests_summary["TotalBashTestsFailed"] -ne 0) + { + $total_bash_failed_tests = $Global:bash_tests_summary["TotalBashTestsFailed"] + $total_bash_tests = $Global:bash_tests_summary["TotalBashTests"] + $errorMessage = "At least one of the bash tests failed. [$total_bash_failed_tests of $total_bash_tests]" + Write-BuildMessage -Message $errorMessage -Category Error + $AllTestsPassed = $false + } - # $OpenSSHTestInfo["BashTestSummaryFile"] = $Global:bash_tests_summary["BashTestSummaryFile"] - # $OpenSSHTestInfo["BashTestLogFile"] = $Global:bash_tests_summary["BashTestLogFile"] - # } - # } + $OpenSSHTestInfo["BashTestSummaryFile"] = $Global:bash_tests_summary["BashTestSummaryFile"] + $OpenSSHTestInfo["BashTestLogFile"] = $Global:bash_tests_summary["BashTestLogFile"] + } + } # OpenSSH Uninstall Tests Invoke-OpenSSHUninstallTest diff --git a/contrib/win32/openssh/OpenSSHTestHelper.psm1 b/contrib/win32/openssh/OpenSSHTestHelper.psm1 index 61a845e48..2d5b2118d 100644 --- a/contrib/win32/openssh/OpenSSHTestHelper.psm1 +++ b/contrib/win32/openssh/OpenSSHTestHelper.psm1 @@ -689,10 +689,8 @@ function Invoke-OpenSSHE2ETest # Discover all CI tests and run them. Push-Location $Script:E2ETestDirectory Write-Log -Message "Running OpenSSH E2E tests..." - # $testFolders = @(Get-ChildItem *.tests.ps1 -Recurse | ForEach-Object{ Split-Path $_.FullName} | Sort-Object -Unique) - # Invoke-Pester $testFolders -OutputFormat NUnitXml -OutputFile $Script:E2ETestResultsFile -Tag $pri -PassThru - Invoke-Pester .\SSH.tests.ps1 -OutputFormat NUnitXml -OutputFile $Script:E2ETestResultsFile -Tag $pri -PassThru - Invoke-Pester .\ShellHost.tests.ps1 -OutputFormat NUnitXml -OutputFile $Script:E2ETestResultsFile -Tag $pri -PassThru + $testFolders = @(Get-ChildItem *.tests.ps1 -Recurse | ForEach-Object{ Split-Path $_.FullName} | Sort-Object -Unique) + Invoke-Pester $testFolders -OutputFormat NUnitXml -OutputFile $Script:E2ETestResultsFile -Tag $pri -PassThru Pop-Location } diff --git a/regress/pesterTests/PlatformAbstractLayer.psm1 b/regress/pesterTests/PlatformAbstractLayer.psm1 index 5ea304d70..9d59bfa15 100644 --- a/regress/pesterTests/PlatformAbstractLayer.psm1 +++ b/regress/pesterTests/PlatformAbstractLayer.psm1 @@ -19,7 +19,7 @@ Enum PlatformType { function Set-Platform { # Use the .NET Core APIs to determine the current platform; if a runtime # exception is thrown, we are on FullCLR, not .NET Core. - if($IsOSX) { + if($IsMacOS) { [PlatformType]::OSX } elseif($IsLinux) { [PlatformType]::Linux