2
0

jenkins.testone.cmd 6.2 KB

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