2
0

ci.testone.cmd 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. :: testone.cmd
  9. ::
  10. :: Runs tests for continuous integration. This script is called from
  11. :: the 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. REM check that we have enough parameters
  30. if "%1"=="" (
  31. goto :usage
  32. )
  33. if "%2"=="" (
  34. goto :usage
  35. )
  36. if "%_ENTRY_SCRIPT_NAME%"=="" (
  37. set _ENTRY_SCRIPT_NAME=%0
  38. )
  39. set _RootDir=%~dp0..
  40. set _HadFailures=0
  41. set _error=0
  42. :: ============================================================================
  43. :: Main script
  44. :: ============================================================================
  45. :main
  46. pushd %_RootDir%\test
  47. set _TestDir=%CD%
  48. call ci.parsetestargs.cmd %*
  49. set _LogDir=%_TestDir%\logs\%_TestArch%_%_TestType%
  50. set _TestArgs=%_TestArch%%_TestType%
  51. set _BinDir=%_RootDir%\Build\VcBuild%_SpecialBuild%\bin
  52. call :doSilent rd /s/q %_LogDir%
  53. call :verifyBytcode
  54. if "%_HadFailures%" == "0" (
  55. call :runTests %_TestArgs%
  56. if "%_ReducedTestRun%" == "1" (
  57. echo -- ci.testone.cmd ^>^> Reduced test run: skipping native tests.
  58. ) else (
  59. call :runNativeTests %_TestArgs%
  60. )
  61. )
  62. echo.
  63. echo -- ci.testone.cmd ^>^> Failure code: %_HadFailures%
  64. if "%_HadFailures%" NEQ "0" (
  65. if "%_HadFailures%" == "2" (
  66. echo -- ci.testone.cmd ^>^> Bytecode test failed, bytecode needs to be updated! 1>&2
  67. ) else if "%_HadFailures%" == "3" (
  68. echo -- ci.testone.cmd ^>^> Unit tests failed! 1>&2
  69. ) else if "%_HadFailures%" == "4" (
  70. echo -- ci.testone.cmd ^>^> Native tests failed! 1>&2
  71. call :summarizeLogs
  72. ) else (
  73. echo -- ci.testone.cmd ^>^> Unknown failure! 1>&2
  74. )
  75. ) else (
  76. echo -- ci.testone.cmd ^>^> Tests passed!
  77. )
  78. popd
  79. exit /b %_HadFailures%
  80. goto :eof
  81. :: ============================================================================
  82. :: Verify that generated bytecode if up to date for one config report if not
  83. :: ============================================================================
  84. :verifyBytcode
  85. set bytecode_type=--jit
  86. if "%_SpecialBuild%" == ".NoJIT" (
  87. set bytecode_type=--noJit
  88. )
  89. call :do python %_RootDir%\tools\regenByteCode.py --verify %bytecode_type% --%_TestArch% --binary=%_BinDir%\%_TestArch%_%_TestType%\ch.exe
  90. if "%_error%" NEQ "0" (
  91. echo -- ci.testone.cmd ^>^> verifying bytecode failed
  92. set _HadFailures=2
  93. )
  94. goto :eof
  95. :: ============================================================================
  96. :: Run one test suite against one build config and record if there were errors
  97. :: ============================================================================
  98. :runTests
  99. if "%_SpecialBuild%" == ".NoJIT" (
  100. set OverideVariant=--variants=disable_jit
  101. )
  102. call :do python %_TestDir%\runtests.py --%_TestArch% --%_TestType% %OverideVariant% %_ExtraTestArgs% --binary=%_BinDir%\%_TestArch%_%_TestType%\ch.exe
  103. if "%_error%" NEQ "0" (
  104. echo -- ci.testone.cmd ^>^> runtests.py failed
  105. set _HadFailures=3
  106. )
  107. goto :eof
  108. :: ============================================================================
  109. :: Run jsrt test suite against one build config and record if there were errors
  110. :: ============================================================================
  111. :runNativeTests
  112. echo -- ci.testone.cmd ^>^> Running native tests... this can take some time
  113. if not exist %_LogDir%\ mkdir %_LogDir%
  114. set _LogFile=%_LogDir%\nativetests.log
  115. call :do %_TestDir%\runnativetests.cmd -%1 -binDir %_BinDir% -d yes > %_LogFile% 2>&1
  116. echo -- ci.testone.cmd ^>^> Running native tests... DONE!
  117. if "%_error%" NEQ "0" (
  118. echo -- ci.testone.cmd ^>^> runnativetests.cmd failed; printing %_LogFile%
  119. powershell "if (Test-Path %_LogFile%) { Get-Content %_LogFile% }"
  120. set _HadFailures=4
  121. )
  122. goto :eof
  123. :: ============================================================================
  124. :: Summarize the logs into a listing of only the failures
  125. :: ============================================================================
  126. :summarizeLogs
  127. pushd %_LogDir%
  128. findstr /sip failed nativetests.log >> summary.log
  129. rem Echo to stderr so that VSO includes the output in the build summary
  130. type summary.log 1>&2
  131. popd
  132. :: ============================================================================
  133. :: Echo a command line before executing it
  134. :: ============================================================================
  135. :do
  136. echo -- ci.testone.cmd ^>^> :do %*
  137. cmd /s /c "%*"
  138. set _error=%ERRORLEVEL%
  139. goto :eof
  140. :: ============================================================================
  141. :: Echo a command line before executing it and redirect the command's output
  142. :: to nul
  143. :: ============================================================================
  144. :doSilent
  145. echo -- ci.testone.cmd ^>^> :doSilent %* ^> nul 2^>^&1
  146. cmd /s /c "%* > nul 2>&1"
  147. set _error=%ERRORLEVEL%
  148. goto :eof
  149. :: ============================================================================
  150. :: Not enough params
  151. :: ============================================================================
  152. :usage
  153. echo Not enough parameters. Please specify architecture and type.
  154. echo Examples:
  155. echo.
  156. echo %_ENTRY_SCRIPT_NAME% x86 debug
  157. echo %_ENTRY_SCRIPT_NAME% x86 test
  158. echo.
  159. echo %_ENTRY_SCRIPT_NAME% x64 debug
  160. echo %_ENTRY_SCRIPT_NAME% x64 test
  161. goto :end