From f3f62d362dbc9b84c9e83f12092f04e390756c30 Mon Sep 17 00:00:00 2001 From: Matthew Carney Date: Sat, 3 Feb 2024 20:59:50 +0000 Subject: [PATCH] Fixed build and test scripts Removed x86 tests --- run-tests.ps1 | 14 ++++++------- scripts/build_dotnet_framework.bat | 6 ++---- tests/test-argument-parsing.ps1 | 32 +++++++++++++++--------------- tests/test-lookup-functions.ps1 | 2 +- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/run-tests.ps1 b/run-tests.ps1 index ad97b2da..69318fef 100644 --- a/run-tests.ps1 +++ b/run-tests.ps1 @@ -40,18 +40,18 @@ if ($LASTEXITCODE -ne 0) { ## Check architecture of build Write-Host "============ build architecture check ============" -ForegroundColor Yellow -$powerping_x64_location = (split-path -parent $MyInvocation.MyCommand.Definition).ToString() + "\build\x64\PowerPing.exe" -$powerping_x86_location = (split-path -parent $MyInvocation.MyCommand.Definition).ToString() + "\build\x86\PowerPing.exe" +$powerping_x64_location = (split-path -parent $MyInvocation.MyCommand.Definition).ToString() + "\src\bin\Release\net6.0\PowerPing.exe" +# $powerping_x86_location = (split-path -parent $MyInvocation.MyCommand.Definition).ToString() + "\build\x86\PowerPing.exe" if ([reflection.assemblyname]::GetAssemblyName($powerping_x64_location).ProcessorArchitecture -eq "Amd64") { Write-Host("x64 build is correct architecture") -ForegroundColor Green } else { Write-Warning("x64 build is not correct architecture. Detected: "+ [reflection.assemblyname]::GetAssemblyName($powerping_x64_location).ProcessorArchitecture) } -if ([reflection.assemblyname]::GetAssemblyName($powerping_x86_location).ProcessorArchitecture -eq "X86") { - Write-Host("x86 build is correct architecture") -ForegroundColor Green -} else { - Write-Warning("x86 build is not correct architecture. Detected: "+ [reflection.assemblyname]::GetAssemblyName($powerping_x86_location).ProcessorArchitecture) -} +# if ([reflection.assemblyname]::GetAssemblyName($powerping_x86_location).ProcessorArchitecture -eq "X86") { +# Write-Host("x86 build is correct architecture") -ForegroundColor Green +# } else { +# Write-Warning("x86 build is not correct architecture. Detected: "+ [reflection.assemblyname]::GetAssemblyName($powerping_x86_location).ProcessorArchitecture) +# } ## Run test scripts Write-Host diff --git a/scripts/build_dotnet_framework.bat b/scripts/build_dotnet_framework.bat index 3a72f53e..5b049441 100644 --- a/scripts/build_dotnet_framework.bat +++ b/scripts/build_dotnet_framework.bat @@ -13,14 +13,12 @@ cd "%~dp0" ::set projectPath=%~f1 :: Find appropriate msbuild path using vswhere -for /f "usebackq tokens=*" %%A in (`vswhere -version "[15.0,16.0)" -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe`) do SET msbuild_path=%%A +for /f "usebackq tokens=*" %%A in (`vswhere -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe`) do SET msbuild_path=%%A if "%msbuild_path%"=="" GOTO MSBUILD_NOT_FOUND :: Run build command -call "%msbuild_path%" ..\PowerPing.sln /p:Configuration=Release /p:Platform="x64" /t:rebuild -if errorlevel 1 GOTO BUILD_FAILED -call "%msbuild_path%" ..\PowerPing.sln /p:Configuration=Release /p:Platform="x86" /t:rebuild +call "%msbuild_path%" ..\PowerPing.sln /p:Configuration=Release /p:Platform="Any CPU" /t:rebuild if errorlevel 1 GOTO BUILD_FAILED goto:eof diff --git a/tests/test-argument-parsing.ps1 b/tests/test-argument-parsing.ps1 index 300e439a..eae8a9ae 100644 --- a/tests/test-argument-parsing.ps1 +++ b/tests/test-argument-parsing.ps1 @@ -7,12 +7,12 @@ $script_path = (split-path -parent $MyInvocation.MyCommand.Definition) # TODO: Need a way to test different argument characters # Executable locations -$powerping_x64_location = (split-path -parent $MyInvocation.MyCommand.Definition).ToString() + "\build\x64\PowerPing.exe" -$powerping_x86_location = (split-path -parent $MyInvocation.MyCommand.Definition).ToString() + "\build\x86\PowerPing.exe" +$powerping_x64_location = (split-path -parent $MyInvocation.MyCommand.Definition).ToString() + "\src\bin\Release\net6.0\PowerPing.exe" +# $powerping_x86_location = (split-path -parent $MyInvocation.MyCommand.Definition).ToString() + "\build\x86\PowerPing.exe" # Remove tests directoy from the path $seperator = [IO.Path]::DirectorySeparatorChar -$powerping_x86_location = $powerping_x86_location.replace($seperator + "tests" + $seperator, $seperator) +# $powerping_x86_location = $powerping_x86_location.replace($seperator + "tests" + $seperator, $seperator) $powerping_x64_location = $powerping_x64_location.replace($seperator + "tests" + $seperator, $seperator) # Structure to store test results @@ -33,24 +33,24 @@ function Run-Test($description, $arguments, [int]$returnCode) $stats.TestsPerformed += 1 $Result = Start-Process -FilePath $powerping_x64_location -ArgumentList ($arguments) -PassThru -Wait if($Result.ExitCode -eq $returnCode) { - Write-Host(" ==== Test passed ===== ") -NoNewline -ForegroundColor Green + Write-Host(" ==== Test passed ===== ") -ForegroundColor Green $stats.TestsPassed += 1 } else { - Write-Host(" --- Test Failed --- ") -NoNewline -ForegroundColor Red + Write-Host(" --- Test Failed --- ") -ForegroundColor Red $stats.TestsFailed += 1 } - Write-Host("[x86]") -NoNewline -ForegroundColor Yellow - $stats.TestsPerformed += 1 - $Result = Start-Process -FilePath $powerping_x86_location -ArgumentList ($arguments) -PassThru -Wait - if($Result.ExitCode -eq $returnCode) { - Write-Host(" ==== Test passed =====") -ForegroundColor Green - $stats.TestsPassed += 1 - } else { - Write-Host(" --- Test Failed ---") -ForegroundColor Red - $stats.TestsFailed += 1 - $global:FailedTestDescriptions += $description - } + # Write-Host("[x86]") -NoNewline -ForegroundColor Yellow + # $stats.TestsPerformed += 1 + # $Result = Start-Process -FilePath $powerping_x86_location -ArgumentList ($arguments) -PassThru -Wait + # if($Result.ExitCode -eq $returnCode) { + # Write-Host(" ==== Test passed =====") -ForegroundColor Green + # $stats.TestsPassed += 1 + # } else { + # Write-Host(" --- Test Failed ---") -ForegroundColor Red + # $stats.TestsFailed += 1 + # $global:FailedTestDescriptions += $description + # } } Write-Host diff --git a/tests/test-lookup-functions.ps1 b/tests/test-lookup-functions.ps1 index 96f63efb..b02e107b 100644 --- a/tests/test-lookup-functions.ps1 +++ b/tests/test-lookup-functions.ps1 @@ -6,7 +6,7 @@ $script_path = (split-path -parent $MyInvocation.MyCommand.Definition) # Locate x64 assembly and load into powershell # TODO: Test x86 arch as well? $seperator = [IO.Path]::DirectorySeparatorChar -$powerping_x64_location = (split-path -parent $MyInvocation.MyCommand.Definition).ToString() + "\build\x64\PowerPing.exe" +$powerping_x64_location = (split-path -parent $MyInvocation.MyCommand.Definition).ToString() + "\src\bin\Release\net6.0\PowerPing.exe" $powerping_x64_location = $powerping_x64_location.replace($seperator + "tests" + $seperator, $seperator) [Reflection.Assembly]::LoadFile($powerping_x64_location)