tmp_runtests2.ps1 1.8 KB

12345678910111213141516171819202122232425262728293031
  1. $root = 'd:/GOPATH/src/TsDB2'
  2. $demos = @(
  3. 'hash_index_test','hash_probe','hash_verify','hash_widekey_test','lock_table_test',
  4. 'orm_full','stress_extreme_config','stress_small_config','stress_test','txn_test','wal_rowlevel_test'
  5. )
  6. $summary = Join-Path $root 'tmp_test_summary2.txt'
  7. Set-Content -Path $summary -Value 'START2' -Encoding UTF8
  8. foreach ($d in $demos) {
  9. $dir = Join-Path $root ('demo/' + $d)
  10. Add-Content -Path $summary -Value ('===== ' + $d + ' =====') -Encoding UTF8
  11. if (-not (Test-Path $dir)) { Add-Content -Path $summary -Value 'DIR MISSING' -Encoding UTF8; continue }
  12. Push-Location $dir
  13. foreach ($f in @('_t.exe','_out.log','_err.log')) { if (Test-Path $f) { Remove-Item $f -Force } }
  14. $b = & go build -o '_t.exe' . 2>&1
  15. if ($LASTEXITCODE -ne 0) {
  16. Add-Content -Path $summary -Value 'BUILD FAILED' -Encoding UTF8
  17. Add-Content -Path $summary -Value (($b | Select-Object -Last 15) -join ' | ') -Encoding UTF8
  18. Pop-Location
  19. continue
  20. }
  21. $p = Start-Process -FilePath (Join-Path $dir '_t.exe') -RedirectStandardOutput (Join-Path $dir '_out.log') -RedirectStandardError (Join-Path $dir '_err.log') -PassThru -WindowStyle Hidden
  22. $exited = $p.WaitForExit(240000)
  23. if (-not $exited) { try { $p.Kill() } catch {}; Add-Content -Path $summary -Value 'TIMEOUT(240s)' -Encoding UTF8 }
  24. else { Add-Content -Path $summary -Value 'finished' -Encoding UTF8 }
  25. $o = Get-Content (Join-Path $dir '_out.log') -Encoding UTF8 -ErrorAction SilentlyContinue
  26. $e = Get-Content (Join-Path $dir '_err.log') -Encoding UTF8 -ErrorAction SilentlyContinue
  27. Add-Content -Path $summary -Value ('STDOUT_TAIL: ' + (($o | Select-Object -Last 12) -join ' | ')) -Encoding UTF8
  28. Add-Content -Path $summary -Value ('STDERR_TAIL: ' + (($e | Select-Object -Last 12) -join ' | ')) -Encoding UTF8
  29. Pop-Location
  30. }
  31. Add-Content -Path $summary -Value 'ALL DONE2' -Encoding UTF8