$ErrorActionPreference='Stop' $preScript=Join-Path (Split-Path $PSScriptRoot -Parent) 'PreScript.ps1' $root=Join-Path ([IO.Path]::GetTempPath()) ('ndtrack-pre-'+[guid]::NewGuid().ToString('N')) $program=(Get-Process -Id $PID).Path try { & $program -NoProfile -File $preScript -BasePath $root if($LASTEXITCODE -ne 1){throw 'Fehlende Ordner akzeptiert'} if(Test-Path -LiteralPath $root){throw 'PreScript hat Ordner angelegt'} foreach($relative in @('SCRIPT','NDTRACK','RESULTS','SCRIPT/Logs')){ New-Item -Path (Join-Path $root $relative) -ItemType Directory -Force | Out-Null } & $program -NoProfile -File $preScript -BasePath $root if($LASTEXITCODE -ne 1){throw 'Leeres Paket akzeptiert'} # Harmloses Test-Hauptskript dokumentiert nur seinen Start. $fixture='Set-Content -LiteralPath (Join-Path $PSScriptRoot "started.txt") -Value "started"' $main=Join-Path $root 'SCRIPT/NDTrack-Geprueft.ps1' $marker=Join-Path $root 'SCRIPT/started.txt' Set-Content -LiteralPath $main -Value $fixture Set-Content -LiteralPath (Join-Path $root 'NDTRACK/RunNdTrackWindows_Local.cmd') -Value '@echo test' & $program -NoProfile -File $preScript -BasePath $root if($LASTEXITCODE -ne 0 -or -not(Test-Path -LiteralPath $marker)){throw 'Hauptskript nicht gestartet'} Remove-Item -LiteralPath $marker & $program -NoProfile -File $preScript -BasePath $root -Platform Both if($LASTEXITCODE -ne 1 -or (Test-Path -LiteralPath $marker)){throw 'Start trotz fehlender Linux-Datei'} Set-Content -LiteralPath (Join-Path $root 'NDTRACK/RunNdTrackLinuxUnix_Local.sh') -Value '#!/bin/sh' & $program -NoProfile -File $preScript -BasePath $root -Platform Both if($LASTEXITCODE -ne 0 -or -not(Test-Path -LiteralPath $marker)){throw 'Start fuer beide Plattformen fehlgeschlagen'} Remove-Item -LiteralPath $marker Set-Content -LiteralPath $main -Value 'function Broken {' & $program -NoProfile -File $preScript -BasePath $root if($LASTEXITCODE -ne 1 -or (Test-Path -LiteralPath $marker)){throw 'Syntaxfehler akzeptiert'} Write-Host 'PreScript: 6 Szenarien bestanden; fehlende Ordner nicht angelegt; Hauptskript nur bei Erfolg gestartet.' } finally { if(Test-Path -LiteralPath $root){Remove-Item -LiteralPath $root -Recurse -Force} }