综合平台编程器项目的远程存储
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

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