i like ts one

This commit is contained in:
lda
2025-11-02 01:13:02 +07:00 Unverified
parent 40cb8faa59
commit e2d33a0db6
+40 -24
View File
@@ -4,42 +4,58 @@
param( param(
[string]$Package = "lda-ipjs", [string]$Package = "lda-ipjs",
[string]$TestName = "", [string]$TestName = "",
[ValidateSet("debug", "release")]
[string]$BuildProfile = "debug", [string]$BuildProfile = "debug",
[string]$password, [string]$password,
[switch]$Quiet [switch]$Verbose,
[string]$RemoteTestPath = "/root/.bin/test",
[string]$RemoteHost = "[email protected]"
) )
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
# Build tests # Build tests and capture output
Write-Host "Building tests for $Package..." -ForegroundColor Cyan Write-Host "Building tests for $Package..." -ForegroundColor Cyan
cargo test --no-run -p $Package --target armv7-unknown-linux-musleabihf $(if ($BuildProfile -eq "release") { "-r" })
# Find the test binary # Stream cargo output anc convert to text
$testBinary = Get-ChildItem -Path "target\armv7-unknown-linux-musleabihf\$BuildProfile\deps\test-*" -File | $cargoOutput = cargo test --no-run -p $Package --target armv7-unknown-linux-musleabihf $(if ($BuildProfile -eq "release") { "-r" }) 2>&1 |
Where-Object { $_.Name -match '^test-[a-f0-9]+$' } | ForEach-Object {
Sort-Object LastWriteTime -Descending | $line = if ($_ -is [System.Management.Automation.ErrorRecord]) { $_.ToString() } else { $_ }
Select-Object -First 1 if ($Verbose) {
Write-Host $line
}
$line # Pass through to capture
}
if (-not $testBinary) { # Parse test binary paths from cargo output
Write-Error "Test binary not found!" $testBinaries = $cargoOutput |
Select-String -Pattern "Executable.*\((.+)\)" |
ForEach-Object { $_.Matches.Groups[1].Value } |
Get-Item
if ($testBinaries.Count -eq 0) {
Write-Error "No test binaries found!"
Write-Host "Cargo output:" -ForegroundColor Yellow
$cargoOutput | ForEach-Object { Write-Host $_ }
exit 1 exit 1
} }
Write-Host "Found test binary: $($testBinary.Name)" -ForegroundColor Green Write-Host "Found $($testBinaries.Count) test $($testBinaries.Count -eq 1 ? "binary" : "binaries")" -ForegroundColor Green
# Copy to target # Run each test binary
Write-Host "Copying to target..." -ForegroundColor Cyan foreach ($testBinary in $testBinaries) {
pscp.exe -l root -batch -scp -pw $password $testBinary.FullName root@192.168.100.1:/tmp/test Write-Host "`nTesting: $($testBinary.Name)" -ForegroundColor Cyan
# Run on target # Copy to target
Write-Host "Running tests on target..." -ForegroundColor Cyan pscp.exe -batch -scp -pw $password $testBinary.FullName ${RemoteHost}:$RemoteTestPath | Out-Null
$testArgs = "$(if (!$Quiet) {" --nocapture --show-output"})"
if ($TestName) { # Run on target
$testArgs = "$TestName$testArgs" $testArgs = "$(if ($Verbose) {"--nocapture --show-output"})"
if ($TestName) {
$testArgs = "$TestName $testArgs"
}
plink -batch -ssh $RemoteHost -pw $password "chmod +x $RemoteTestPath && $RemoteTestPath $testArgs"
} }
plink -batch -ssh root@192.168.100.1 -pw $password "chmod +x /tmp/test && /tmp/test $testArgs" Write-Host "`nDone!" -ForegroundColor Green
Write-Host "Done!" -ForegroundColor Green