build: add server-rs test scripts
This commit is contained in:
49
server-rs/scripts/test.ps1
Normal file
49
server-rs/scripts/test.ps1
Normal file
@@ -0,0 +1,49 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Alias("h")]
|
||||
[switch]$Help,
|
||||
[string]$Package = ""
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Write-Usage {
|
||||
@(
|
||||
'Usage:'
|
||||
' ./server-rs/scripts/test.ps1'
|
||||
' ./server-rs/scripts/test.ps1 -Package api-server'
|
||||
''
|
||||
'Notes:'
|
||||
' 1. Run cargo test for the server-rs workspace by default'
|
||||
' 2. Use -Package to target one workspace package only'
|
||||
) -join [Environment]::NewLine
|
||||
}
|
||||
|
||||
if ($Help) {
|
||||
Write-Usage
|
||||
exit 0
|
||||
}
|
||||
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$serverRsDir = Split-Path -Parent $scriptDir
|
||||
$manifestPath = Join-Path $serverRsDir "Cargo.toml"
|
||||
|
||||
if (-not (Test-Path $manifestPath)) {
|
||||
throw "Missing server-rs/Cargo.toml, cannot start test script."
|
||||
}
|
||||
|
||||
Write-Host "[server-rs:test] working dir: $serverRsDir"
|
||||
|
||||
Push-Location $serverRsDir
|
||||
try {
|
||||
if ([string]::IsNullOrWhiteSpace($Package)) {
|
||||
cargo test --manifest-path $manifestPath
|
||||
}
|
||||
else {
|
||||
Write-Host "[server-rs:test] target package: $Package"
|
||||
cargo test -p $Package --manifest-path $manifestPath
|
||||
}
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
Reference in New Issue
Block a user