综合平台编程器项目的远程存储
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

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