综合平台编程器项目的远程存储
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

98 wiersze
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. 'alarm_service_tests',
  26. 'hmi_editor_service_tests',
  27. 'logic_editor_service_tests',
  28. 'offline_simulation_service_tests',
  29. 'project_management_tests',
  30. 'register_monitor_service_tests',
  31. 'runtime_mode_service_tests',
  32. 'runtime_panel_controller_tests',
  33. 'plc_runtime_tests'
  34. )
  35. $performanceTargets = @('performance_tests')
  36. $targets = switch ($Suite) {
  37. 'Functional' { $functionalTargets }
  38. 'Performance' { $performanceTargets }
  39. 'All' { $functionalTargets + $performanceTargets }
  40. }
  41. $originalPath = $env:Path
  42. $env:Path = "$qtRoot\bin;$mingwBin;$env:Path"
  43. Write-Host "测试类型:$Suite"
  44. try {
  45. foreach ($target in $targets) {
  46. $projectFile = Join-Path $testSourceRoot "$target.pro"
  47. $buildDirectory = Join-Path $buildRoot $target
  48. $executablePath = Join-Path $buildDirectory "$configurationName\$target.exe"
  49. New-Item -ItemType Directory -Path $buildDirectory -Force | Out-Null
  50. Push-Location $buildDirectory
  51. try {
  52. & $qmakePath $projectFile "CONFIG+=$configurationName" "CONFIG-=$(if ($configurationName -eq 'debug') { 'release' } else { 'debug' })"
  53. if ($LASTEXITCODE -ne 0) {
  54. throw "qmake 失败:$target,退出码:$LASTEXITCODE"
  55. }
  56. & $makePath -j2
  57. if ($LASTEXITCODE -ne 0) {
  58. throw "构建失败:$target,退出码:$LASTEXITCODE"
  59. }
  60. if (-not (Test-Path -LiteralPath $executablePath)) {
  61. throw "未生成测试可执行文件:$executablePath"
  62. }
  63. Write-Host "运行 $target"
  64. if ($target -eq 'performance_tests') {
  65. $benchmarkResultPath = Join-Path $buildDirectory 'benchmark.csv'
  66. & $executablePath '-o' "$benchmarkResultPath,csv"
  67. } else {
  68. & $executablePath
  69. }
  70. if ($LASTEXITCODE -ne 0) {
  71. throw "测试失败:$target,退出码:$LASTEXITCODE"
  72. }
  73. if ($target -eq 'performance_tests') {
  74. Write-Host "性能结果:$benchmarkResultPath"
  75. Get-Content -LiteralPath $benchmarkResultPath -Encoding utf8
  76. }
  77. }
  78. finally {
  79. Pop-Location
  80. }
  81. }
  82. }
  83. finally {
  84. $env:Path = $originalPath
  85. }