Skip to content

Commit

Permalink
Fixed build and test scripts
Browse files Browse the repository at this point in the history
Removed x86 tests
  • Loading branch information
Killeroo committed Feb 3, 2024
1 parent 9e61ada commit f3f62d3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 28 deletions.
14 changes: 7 additions & 7 deletions run-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions scripts/build_dotnet_framework.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
32 changes: 16 additions & 16 deletions tests/test-argument-parsing.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test-lookup-functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit f3f62d3

Please sign in to comment.