综合平台编程器项目的远程存储
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

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