1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
|
@echo off
rem ##########################################################################
rem # Copyright 2002-2009 LAMP/EPFL
rem #
rem # This is free software; see the distribution for copying conditions.
rem # There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
rem # PARTICULAR PURPOSE.
rem ##########################################################################
rem We adopt the following conventions:
rem - System/user environment variables start with a letter
rem - Local batch variables start with an underscore ('_')
echo ######################################################################
echo ## DEPRECATION WARNING ##
echo ######################################################################
echo ## The 'scalatest' runner script has been deprecated. Please use ##
echo ## 'partest' instead. ##
echo ######################################################################
echo.
if "%OS%"=="Windows_NT" (
@setlocal
call :set_home
) else (
set _SCALA_HOME=%SCALA_HOME%
if "%_SCALA_HOME%"=="" goto err_home
)
rem We use the value of the JAVACMD environment variable if defined
set _JAVACMD=%JAVACMD%
if "%_JAVACMD%"=="" set _JAVACMD=java
set _BIN=dists\latest\bin
set _NORUN=
set _TYPE=auto
set _SHOWLOG=
set _SHOWDIFF=
set _FAILED=
set _ARGS=
:loop
rem Argument %1 may contain quotes so we use parentheses here
if (%1)==() goto exec
if (%1)==(--auto) set _TYPE=auto& goto next
if (%1)==(--run) set _TYPE=run& goto next
if (%1)==(--jvm) set _TYPE=jvm& goto next
if (%1)==(--pos) set _TYPE=pos& goto next
if (%1)==(--neg) set _TYPE=neg& goto next
if (%1)==(--msil) set _TYPE=msil& goto next
if (%1)==(--quick) set _BIN=build\quick\bin& goto next
if (%1)==(--no-run) set _NORUN=1& goto next
if (%1)==(--show-log) set _SHOWLOG=1& goto next
if (%1)==(--show-diff) set _SHOWDIFF=1& goto next
if (%1)==(--failed) set _FAILED=1& goto next
if (%1)==(--help) call :prt_help & goto :eof
if (%1)==(-h) call :prt_help & goto :eof
if (%1)==(-?) call :prt_help & goto :eof
if (%1)==(--version) call :prt_version & goto :eof
if (%1)==(-v) call :prt_version & goto :eof
call :chk_option %1
if errorlevel 0 goto err_opt
set _ARGS=%_ARGS% %1
:next
shift
goto loop
:exec
if exist "%_SCALA_HOME%\meta\universe" (
set _BINDIR=%_SCALA_HOME%\bin
set _SRCDIR=%_SCALA_HOME%\misc\scala-test\files
set _DIFFDIR=%_SCALA_HOME%\bin\diff
) else (
set _BINDIR=%_SCALA_HOME%\%_BIN%
set _SRCDIR=%_SCALA_HOME%\test\files
set _DIFFDIR=%_SCALA_HOME%\test\diff
)
set _SCALA=%_BINDIR%\scala
set _SCALAC=%_BINDIR%\scalac
set _SCALAP=%_BINDIR%\scalap
set _DIFF=%_DIFFDIR%\diff.exe --text --strip-trailing-cr
if not exist "%_BINDIR%" goto err_bin
set _OBJDIR=
set _TMPDIR=%TEMP%
if not "%_OBJDIR%"=="" (
if not exist "%_OBJDIR%" mkdir "%_OBJDIR%"
)
if not "%_TMPDIR%"=="" (
if not exist "%_TMPDIR%" mkdir "%_TMPDIR%"
)
call :prt_dir "Source directory is :" "%_SRCDIR%"
call :prt_dir "Scala binaries are in:" "%_BINDIR%"
call :set_version
call :prt_dir "Scala version is :" "%_NSC_VERSION%"
call :prt_dir "Java runtime is :" "%_JVM_VERSION%"
set _FILES_POS=
set _FILES_RUN=
set _FILES_JVM=
set _FILES_NEG=
set _FILES_MSIL=
if %_TYPE%==pos (
set _FILES_POS=%_SRCDIR%\pos
) else if %_TYPE%==run (
set _FILES_RUN=%_SRCDIR%\run
) else if %_TYPE%==jvm (
set _FILES_JVM=%_SRCDIR%\jvm
set _FILES_RUN=%_SRCDIR%\run
) else if %_TYPE%==neg (
set _FILES_NEG=%_SRCDIR%\neg
) else if %_TYPE%==msil (
set _FILES_MSIL=%_SRCDIR%\msil
) else if %_TYPE%==auto (
set _FILES_POS=%_SRCDIR%\pos
set _FILES_NEG=%_SRCDIR%\neg
set _FILES_JVM=%_SRCDIR%\jvm
set _FILES_RUN=%_SRCDIR%\run
) else (
goto err_test
)
:start
call :chk_all
goto end
rem ##########################################################################
rem # subroutines
rem # NB. goto/call commands use only the first 8 characters of a label
:prt_dir
echo %~1 %~2
goto :eof
:prt_header
echo.
echo %~1
goto :eof
:prt_help
echo Usage: scalatest [OPTION]...
echo.
echo --auto use filenames to select the test to run
echo --run next files test the interpreter and all backends
echo --jvm next files test the JVM backend
echo --pos next files test a compilation success
echo --neg next files test a compilation failure
echo --msil next files test the .NET
echo --quick use the 'quick' build instead of the distribution
echo --no-run run no test, use results of last run
echo --show-log show output of failed tests
echo --show-diff show differences between actual and expected output
echo --failed test only files that failed last time
echo --help, -h, -? display this help and exit
echo --version, -v output version information and exit
goto :eof
:prt_version
echo Scala test suite 0.9.3 -- (c) 2002-2009 LAMP/EPFL
goto :eof
:prt_status
set _MSG=testing: [...]\%~1\%2
if not "%_STATUS%"=="0" goto failed
set /a _CNT_SUCCESS=_CNT_SUCCESS+1
echo %_MSG% [OK]
goto :eof
:failed
set /a _CNT_FAILURE=_CNT_FAILURE+1
echo %_MSG% [FAILED]
if not "%_SHOWLOG%"=="" type %_LOGFILE%
goto :eof
rem Variable "%~dps0" works on WinXP SP2 or newer
rem (see http://support.microsoft.com/?kbid=833431)
rem set _SCALA_HOME=%~dps0..
:set_home
set _BINDIR=
for %%i in (%~sf0) do set _BINDIR=%_BINDIR%%%~dpsi
set _SCALA_HOME=%_BINDIR%..
goto :eof
:set_version
set _TMPFILE=%_TMPDIR%\.version
call %_SCALAC% -version 2> %_TMPFILE%
for /f "tokens=*" %%f in (%_TMPFILE%) do @set _VERSION=%%f
set _NSC_VERSION=%_VERSION%
%_JAVACMD% -version 2> %_TMPFILE%
for /f "skip=2 tokens=*" %%f in (%_TMPFILE%) do @set _VERSION=%%f
set _JVM_VERSION=%_VERSION%
goto :eof
:chk_option
echo %~1 | findstr /r /c:"-.*" 1>NUL
goto :eof
rem Tests a compilation success.
:test_pos
rmdir /s/q %_DSTBASE%.obj 2>NUL
mkdir %_DSTBASE%.obj
call %_SCALAC% -d %_DSTBASE%.obj %1 1>NUL 2>NUL
if errorlevel 1 goto status_pos
set _STATUS=0
goto next_pos
:status_pos
set _STATUS=1
:next_pos
rmdir /s/q %_DSTBASE%.obj
goto :eof
rem Tests a compilation failure.
:test_neg
rmdir /s/q %_DSTBASE%.obj 2>NUL
mkdir %_DSTBASE%.obj
call %_SCALAC% -d %_DSTBASE%.obj %1 1>NUL 2>NUL
if errorlevel 1 goto status_neg
set _STATUS=1
goto next_neg
:status_neg
set _STATUS=0
:next_neg
rmdir /s/q %_DSTBASE%.obj
goto :eof
rem Tests the JVM backend.
:test_jvm
rmdir /s/q %_DSTBASE%.obj 2>NUL
mkdir %_DSTBASE%.obj
call %_SCALAC% -d %_DSTBASE%.obj %1 2>NUL
if errorlevel 1 goto status_jvm
call %_SCALA% -cp %_DSTBASE%.obj Test "jvm" 1>%_LOGFILE% 2>NUL
if errorlevel 1 goto status_jvm
set _STATUS=0
goto next_jvm
:status_jvm
set _STATUS=1
:next_jvm
rmdir /s/q %_DSTBASE%.obj
goto :eof
:chk_test
if "%_OBJDIR%"=="" (
set _DSTDIR=%_SRCDIR%
) else (
set _DSTDIR=%_OBJDIR%
)
set _DSTBASE=%_DSTDIR%\%~n1-%_KIND%
set _LOGFILE=%_DSTBASE%.log
set _CHKFILE=%~dpn1.check
if not '%_HEADER%'=='' call :prt_header %_HEADER% & set _HEADER=
if "%_KIND%"=="jvm" call :test_jvm %1 & goto status
if "%_KIND%"=="pos" call :test_pos %1 & goto status
if "%_KIND%"=="neg" call :test_neg %1 & goto status
goto :eof
:status
if exist %_LOGFILE% %_DIFF% %_LOGFILE% %_CHKFILE% 2>NUL
call :prt_status %_KIND% %~nx1
del /s/q %_LOGFILE% 2>NUL 1>NUL
goto :eof
:chk_file
set _CNT_SUCCESS=0
set _CNT_FAILURE=0
for %%f in (%1\*.scala) do call :chk_test %%f
set /a _CNT_TOTAL=_CNT_SUCCESS+_CNT_FAILURE
if "%_CNT_FAILURE%"=="0" goto success
echo %_CNT_FAILURE% of %_CNT_TOTAL% tests failed
goto :eof
:success
echo All of %_CNT_TOTAL% tests were successful
goto :eof
:chk_kind
set _HEADER=%1
shift
set _KIND=%1
shift
:loop_kind
if "%1"=="" goto done
call :chk_file %1
shift
goto loop_kind
:done
goto :eof
rem Checks everything.
:chk_all
call :chk_kind "Testing JVM backend" jvm %_FILES_RUN% %_FILES_JVM%
call :chk_kind "Testing compiler (on files whose compilation should succeed)" pos %_FILES_POS%
call :chk_kind "Testing compiler (on files whose compilation should fail)" neg %_FILES_NEG%
call :chk_kind "Testing .NET backend" msil %_FILES_MSIL%
goto :eof
rem ##########################################################################
rem # errors
:err_bin
echo ERROR: missing command "%_SCALAC%; run "ant build".
goto end
:err_home
echo ERROR: Windows NT or newer is required to run this batch command.
goto end
:err_test
echo ERROR: Illegal test type %_TYPE%.
goto end
:err_opt
echo ERROR: Unknown option %1
goto end
:end
if "%OS%"=="Windows_NT" @endlocal
|