2
0

runnativetests.cmd 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. :: runnativetests.cmd
  8. ::
  9. :: ============================================================================
  10. @echo off
  11. setlocal
  12. goto :main
  13. :: ============================================================================
  14. :: Print usage
  15. :: ============================================================================
  16. :printUsage
  17. echo runnativetests.cmd -x86^|-x64 -debug^|-test
  18. echo.
  19. echo Required switches:
  20. echo.
  21. echo Specify architecture of jsrt binaries (required):
  22. echo.
  23. echo -x86 Build arch of binaries is x86
  24. echo -x64 Build arch of binaries is x64
  25. echo.
  26. echo Specify type of jsrt binaries (required):
  27. echo.
  28. echo -debug Build type of binaries is debug
  29. echo -test Build type of binaries is test
  30. echo.
  31. echo Shorthand combinations can be used, e.g. -x64debug
  32. echo.
  33. goto :eof
  34. :: ============================================================================
  35. :: Print how to get help
  36. :: ============================================================================
  37. :printGetHelp
  38. echo For help use runnativetests.cmd -?
  39. goto :eof
  40. :: ============================================================================
  41. :: Main script
  42. :: ============================================================================
  43. :main
  44. call :initVars
  45. call :parseArgs %*
  46. if not "%fShowUsage%" == "" (
  47. call :printUsage
  48. goto :eof
  49. )
  50. call :validateArgs
  51. if not "%fShowGetHelp%" == "" (
  52. call :printGetHelp
  53. goto :eof
  54. )
  55. call :configureVars
  56. call :copyScriptsAndBinaries
  57. call :runtest
  58. call :cleanup
  59. exit /b %_HadFailures%
  60. :: ============================================================================
  61. :: Parse the user arguments into environment variables
  62. :: ============================================================================
  63. :parseArgs
  64. :NextArgument
  65. if "%1" == "-?" set fShowUsage=1& goto :ArgOk
  66. if "%1" == "/?" set fShowUsage=1& goto :ArgOk
  67. if /i "%1" == "-x86" set _BuildArch=x86& goto :ArgOk
  68. if /i "%1" == "-x64" set _BuildArch=x64& goto :ArgOk
  69. if /i "%1" == "-debug" set _BuildType=debug& goto :ArgOk
  70. if /i "%1" == "-test" set _BuildType=test& goto :ArgOk
  71. if /i "%1" == "-x86debug" set _BuildArch=x86&set _BuildType=debug& goto :ArgOk
  72. if /i "%1" == "-x64debug" set _BuildArch=x64&set _BuildType=debug& goto :ArgOk
  73. if /i "%1" == "-x86test" set _BuildArch=x86&set _BuildType=test& goto :ArgOk
  74. if /i "%1" == "-x64test" set _BuildArch=x64&set _BuildType=test& goto :ArgOk
  75. if /i "%1" == "-binDir" set _BinDirBase=%~f2& goto :ArgOkShift2
  76. if not "%1" == "" echo -- runnativetests.cmd ^>^> Unknown argument: %1 & set fShowGetHelp=1
  77. goto :eof
  78. :ArgOkShift2
  79. shift
  80. :ArgOk
  81. shift
  82. goto :NextArgument
  83. :: ============================================================================
  84. :: Initialize batch script variables to defaults
  85. :: ============================================================================
  86. :initVars
  87. set _HadFailures=0
  88. set _RootDir=%~dp0..
  89. set _BinDirBase=%_RootDir%\Build\VcBuild\Bin
  90. set _BinDir=
  91. set _TestTempDir=
  92. set _BuildArch=
  93. set _BuildType=
  94. goto :eof
  95. :: ============================================================================
  96. :: Validate that required arguments were specified
  97. :: ============================================================================
  98. :validateArgs
  99. if "%_BuildArch%" == "" (
  100. echo Error missing required build architecture or build type switch
  101. set fShowGetHelp=1
  102. goto :eof
  103. )
  104. if "%_BuildType%" == "" (
  105. echo Error missing required build architecture or build type switch
  106. set fShowGetHelp=1
  107. )
  108. goto :eof
  109. :: ============================================================================
  110. :: Configure the script variables and environment based on parsed arguments
  111. :: ============================================================================
  112. :configureVars
  113. set _BinDir=%_BinDirBase%\%_BuildArch%_%_BuildType%\
  114. rem Use %_BinDir% as the root for %_TestTempDir% to ensure that running jsrt
  115. rem native tests from multiple repos simultaneously do not clobber each other.
  116. rem This means we need to delete the temp directory afterwards to clean up.
  117. set _TestTempDir=%_BinDir%\jsrttest\
  118. if not exist %_TestTempDir% mkdir %_TestTempDir%
  119. echo -- runnativetests.cmd ^>^> #### BinDir: %_BinDir%
  120. echo -- runnativetests.cmd ^>^> #### TestTempDir: %_TestTempDir%
  121. goto :eof
  122. :: ============================================================================
  123. :: Copying javascript files from source location to temp test location and test
  124. :: binaries from binary location to test temp location.
  125. :: ============================================================================
  126. :copyScriptsAndBinaries
  127. echo -- runnativetests.cmd ^>^> copying scripts from '%_RootDir%\bin\nativetests\Scripts' to '%_TestTempDir%'
  128. copy /y %_RootDir%\bin\nativetests\Scripts\*.js %_TestTempDir%
  129. copy /y %_BinDir%ChakraCore.dll %_TestTempDir%
  130. copy /y %_BinDir%nativetests.exe %_TestTempDir%
  131. goto :eof
  132. :: ============================================================================
  133. :: Running tests using nativetests.exe
  134. :: ============================================================================
  135. :runtest
  136. pushd %_TestTempDir%
  137. call :do nativetests.exe
  138. if ERRORLEVEL 1 set _HadFailures=1
  139. popd
  140. goto :eof
  141. :: ============================================================================
  142. :: Clean up left over files
  143. :: ============================================================================
  144. :cleanUp
  145. call :do rd /s/q %_TestTempDir%
  146. goto :eof
  147. :: ============================================================================
  148. :: Echo a command line before executing it
  149. :: ============================================================================
  150. :do
  151. echo ^>^> %*
  152. cmd /s /c "%*"
  153. goto :eof
  154. :: ============================================================================
  155. :: Echo a command line before executing it and redirect the command's output
  156. :: to nul
  157. :: ============================================================================
  158. :doSilent
  159. echo ^>^> %* ^> nul 2^>^&1
  160. cmd /s /c "%* > nul 2>&1"
  161. goto :eof