2
0

jenkins.testone.cmd 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. ::-------------------------------------------------------------------------------------------------------
  2. :: Copyright (C) Microsoft. All rights reserved.
  3. :: Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. ::-------------------------------------------------------------------------------------------------------
  5. :: ============================================================================
  6. ::
  7. :: jenkins.testone.cmd
  8. ::
  9. :: Runs tests for Jenkins continuous integration. This script is called from
  10. :: the Jenkins CI build and it runs all tests for x86 and x64, debug and test
  11. :: build configs.
  12. ::
  13. :: Do not use this script to run all tests on your dev box.
  14. :: - It will delete all your existing test logs
  15. :: - It does not run the various flavors of the tests in parallel (though
  16. :: this is not currently possible anyway because rl stages logs in a
  17. :: common directory)
  18. :: - It does nothing to provide useful output when there are failures, e.g.
  19. :: they can be buried under thousands of lines of output from further
  20. :: tests run.
  21. :: - It cannot be cancelled without risk of polluting your command prompt
  22. :: environment with environment variables that will make further calls to
  23. :: runtests.cmd behave unexpectedly.
  24. ::
  25. :: ============================================================================
  26. @echo off
  27. setlocal
  28. set _RootDir=%~dp0..
  29. set _HadFailures=0
  30. set _error=0
  31. :: ============================================================================
  32. :: Main script
  33. :: ============================================================================
  34. :main
  35. if not "%JENKINS_BUILD%" == "True" (
  36. echo This script should be run under a Jenkins Build environment
  37. exit /b 2
  38. )
  39. pushd %_RootDir%\test
  40. set _TestDir=%CD%
  41. call jenkins.parsetestargs.cmd %*
  42. set _LogDir=%_TestDir%\logs\%_TestArch%_%_TestType%
  43. set _TestArgs=%_TestArch%%_TestType%
  44. set _BinDir=%_RootDir%\Build\VcBuild%_SpecialBuild%\bin
  45. call :doSilent rd /s/q %_LogDir%
  46. call :runTests %_TestArgs%
  47. if "%_ReducedTestRun%" == "1" (
  48. echo -- jenkins.testone.cmd ^>^> Reduced test run: skipping native tests.
  49. ) else (
  50. call :runNativeTests %_TestArgs%
  51. )
  52. call :summarizeLogs
  53. echo.
  54. echo -- jenkins.testone.cmd ^>^> Failure code: %_HadFailures%
  55. if "%_HadFailures%" NEQ "0" (
  56. if "%_HadFailures%" == "3" (
  57. echo -- jenkins.testone.cmd ^>^> Unit tests failed! 1>&2
  58. ) else if "%_HadFailures%" == "4" (
  59. echo -- jenkins.testone.cmd ^>^> Native tests failed! 1>&2
  60. ) else (
  61. echo -- jenkins.testone.cmd ^>^> Unknown failure! 1>&2
  62. )
  63. ) else (
  64. echo -- jenkins.testone.cmd ^>^> Tests passed!
  65. )
  66. popd
  67. exit /b %_HadFailures%
  68. goto :eof
  69. :: ============================================================================
  70. :: Run one test suite against one build config and record if there were errors
  71. :: ============================================================================
  72. :runTests
  73. call :do %_TestDir%\runtests.cmd -%1 -quiet -cleanupall -nottags exclude_jenkins %_ExtraTestArgs% -binDir %_BinDir%
  74. if "%_error%" NEQ "0" (
  75. echo -- jenkins.testone.cmd ^>^> runtests.cmd failed
  76. set _HadFailures=3
  77. )
  78. goto :eof
  79. :: ============================================================================
  80. :: Run jsrt test suite against one build config and record if there were errors
  81. :: ============================================================================
  82. :runNativeTests
  83. echo -- jenkins.testone.cmd ^>^> Running native tests... this can take some time
  84. if not exist %_LogDir%\ mkdir %_LogDir%
  85. set _LogFile=%_LogDir%\nativetests.log
  86. call :do %_TestDir%\runnativetests.cmd -%1 -binDir %_BinDir% > %_LogFile% 2>&1
  87. echo -- jenkins.testone.cmd ^>^> Running native tests... DONE!
  88. if "%_error%" NEQ "0" (
  89. echo -- jenkins.testone.cmd ^>^> runnativetests.cmd failed; printing %_LogFile%
  90. powershell "if (Test-Path %_LogFile%) { Get-Content %_LogFile% }"
  91. set _HadFailures=4
  92. )
  93. goto :eof
  94. :: ============================================================================
  95. :: Summarize the logs into a listing of only the failures
  96. :: ============================================================================
  97. :summarizeLogs
  98. pushd %_LogDir%
  99. findstr /sp failed rl.results.log > summary.log
  100. findstr /sip failed nativetests.log >> summary.log
  101. rem Echo to stderr so that VSO includes the output in the build summary
  102. echo -- jenkins.testone.cmd ^>^> Printing summary...
  103. type summary.log 1>&2
  104. popd
  105. :: ============================================================================
  106. :: Echo a command line before executing it
  107. :: ============================================================================
  108. :do
  109. echo -- jenkins.testone.cmd ^>^> :do %*
  110. cmd /s /c "%*"
  111. set _error=%ERRORLEVEL%
  112. goto :eof
  113. :: ============================================================================
  114. :: Echo a command line before executing it and redirect the command's output
  115. :: to nul
  116. :: ============================================================================
  117. :doSilent
  118. echo -- jenkins.testone.cmd ^>^> :doSilent %* ^> nul 2^>^&1
  119. cmd /s /c "%* > nul 2>&1"
  120. set _error=%ERRORLEVEL%
  121. goto :eof