综合平台编程器项目的远程存储
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

100 líneas
3.2 KiB

  1. [CmdletBinding()]
  2. param(
  3. [ValidateSet('Debug', 'Release')]
  4. [string]$Configuration = 'Debug',
  5. [ValidateSet('Functional', 'Performance', 'All')]
  6. [string]$Suite = 'Functional'
  7. )
  8. Set-StrictMode -Version Latest
  9. $ErrorActionPreference = 'Stop'
  10. $projectRoot = Split-Path -Parent $PSScriptRoot
  11. $qtRoot = 'D:\Qt5.15.2\5.15.2\mingw81_64'
  12. $mingwBin = 'D:\Qt5.15.2\Tools\mingw810_64\bin'
  13. $qmakePath = Join-Path $qtRoot 'bin\qmake.exe'
  14. $makePath = Join-Path $mingwBin 'mingw32-make.exe'
  15. $configurationName = $Configuration.ToLowerInvariant()
  16. $testSourceRoot = Join-Path $projectRoot 'app\tests'
  17. $buildRoot = Join-Path $projectRoot "build\tests\$configurationName"
  18. foreach ($requiredPath in @($qmakePath, $makePath, $testSourceRoot)) {
  19. if (-not (Test-Path -LiteralPath $requiredPath)) {
  20. throw "未找到必要文件:$requiredPath"
  21. }
  22. }
  23. $functionalTargets = @(
  24. 'domain_tests',
  25. 'application_settings_tests',
  26. 'alarm_service_tests',
  27. 'hmi_editor_service_tests',
  28. 'logic_editor_service_tests',
  29. 'offline_simulation_service_tests',
  30. 'project_management_tests',
  31. 'register_monitor_service_tests',
  32. 'runtime_mode_service_tests',
  33. 'runtime_panel_controller_tests',
  34. 'plc_connection_dialog_tests',
  35. 'plc_runtime_tests'
  36. )
  37. $performanceTargets = @('performance_tests')
  38. $targets = switch ($Suite) {
  39. 'Functional' { $functionalTargets }
  40. 'Performance' { $performanceTargets }
  41. 'All' { $functionalTargets + $performanceTargets }
  42. }
  43. $originalPath = $env:Path
  44. $env:Path = "$qtRoot\bin;$mingwBin;$env:Path"
  45. Write-Host "测试类型:$Suite"
  46. try {
  47. foreach ($target in $targets) {
  48. $projectFile = Join-Path $testSourceRoot "$target.pro"
  49. $buildDirectory = Join-Path $buildRoot $target
  50. $executablePath = Join-Path $buildDirectory "$configurationName\$target.exe"
  51. New-Item -ItemType Directory -Path $buildDirectory -Force | Out-Null
  52. Push-Location $buildDirectory
  53. try {
  54. & $qmakePath $projectFile "CONFIG+=$configurationName" "CONFIG-=$(if ($configurationName -eq 'debug') { 'release' } else { 'debug' })"
  55. if ($LASTEXITCODE -ne 0) {
  56. throw "qmake 失败:$target,退出码:$LASTEXITCODE"
  57. }
  58. & $makePath -j2
  59. if ($LASTEXITCODE -ne 0) {
  60. throw "构建失败:$target,退出码:$LASTEXITCODE"
  61. }
  62. if (-not (Test-Path -LiteralPath $executablePath)) {
  63. throw "未生成测试可执行文件:$executablePath"
  64. }
  65. Write-Host "运行 $target"
  66. if ($target -eq 'performance_tests') {
  67. $benchmarkResultPath = Join-Path $buildDirectory 'benchmark.csv'
  68. & $executablePath '-o' "$benchmarkResultPath,csv"
  69. } else {
  70. & $executablePath
  71. }
  72. if ($LASTEXITCODE -ne 0) {
  73. throw "测试失败:$target,退出码:$LASTEXITCODE"
  74. }
  75. if ($target -eq 'performance_tests') {
  76. Write-Host "性能结果:$benchmarkResultPath"
  77. Get-Content -LiteralPath $benchmarkResultPath -Encoding utf8
  78. }
  79. }
  80. finally {
  81. Pop-Location
  82. }
  83. }
  84. }
  85. finally {
  86. $env:Path = $originalPath
  87. }