Files
Genarrative/server-rs/scripts/test.ps1
kdletters cbc27bad4a
Some checks failed
CI / verify (push) Has been cancelled
init with react+axum+spacetimedb
2026-04-26 18:06:23 +08:00

51 lines
1.1 KiB
PowerShell

[CmdletBinding()]
param(
[Alias("h")]
[switch]$Help,
[Alias("Package")]
[string]$Crate = ""
)
$ErrorActionPreference = "Stop"
function Write-Usage {
@(
'Usage:'
' ./server-rs/scripts/test.ps1'
' ./server-rs/scripts/test.ps1 -Crate api-server'
''
'Notes:'
' 1. Run cargo test for the server-rs workspace by default'
' 2. Use -Crate to target one workspace crate 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($Crate)) {
cargo test --manifest-path $manifestPath
}
else {
Write-Host "[server-rs:test] target crate: $Crate"
cargo test -p $Crate --manifest-path $manifestPath
}
}
finally {
Pop-Location
}