[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 }