dynamically assign drive letter to WORKSPACE env var

fix underfined env var check

check for defined JRUBYSRCDIR env var

check for errorlevel after launching rake tasks

cosmetics

call rake

keep original path

cosmetic

cosmetic
This commit is contained in:
Colin Surprenant 2017-09-26 18:32:09 -04:00
parent eaa8b5feb7
commit d64049f2b5

View file

@ -1,35 +1,86 @@
@echo off
setlocal enabledelayedexpansion
setlocal
REM Since we are using the system jruby, we need to make sure our jvm process
REM uses at least 1g of memory, If we don't do this we can get OOM issues when
REM installing gems. See https://github.com/elastic/logstash/issues/5179
SET JRUBY_OPTS="-J-Xmx1g"
SET SELECTEDTESTSUITE=%1
SET /p JRUBYVERSION=<.ruby-version
IF NOT EXIST %JRUBYSRCDIR% (
echo "Variable JRUBYSRCDIR must be declared with a valid directory. Aborting.."
if "%WORKSPACE%" == "" (
echo Error: environment variable WORKSPACE must be defined. Aborting..
exit /B 1
)
SET JRUBYPATH=%JRUBYSRCDIR%\%JRUBYVERSION%
:: see if %WORKSPACE% is alread mapped to a drive
for /f "tokens=1* delims==> " %%G IN ('subst') do (
set sdrive=%%G
:: removing extra space
set sdrive=!sdrive:~0,2!
set spath=%%H
IF NOT EXIST %JRUBYPATH% (
echo "Could not find JRuby in %JRUBYPATH%. Aborting.."
if /I "!spath!" == "%WORKSPACE%" (
set use_drive=!sdrive!
goto :found_drive
)
)
:: no existing mapping
:: try to assign "%WORKSPACE%" to the first drive letter which works
for %%i in (A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z) do (
set "drive=%%i:"
subst !drive! "%WORKSPACE%" >nul
if not errorlevel 1 (
set use_drive=!drive!
goto :found_drive
)
)
echo Error: unable to subst drive to path %WORKSPACE%. Aborting...
exit /B 1
:found_drive
echo Using drive !use_drive! for %WORKSPACE%
:: change current directory to that drive
!use_drive!
:: Since we are using the system jruby, we need to make sure our jvm process
:: uses at least 1g of memory, If we don't do this we can get OOM issues when
:: installing gems. See https://github.com/elastic/logstash/issues/5179
set JRUBY_OPTS="-J-Xmx1g"
set SELECTEDTESTSUITE=%1
set /p JRUBYVERSION=<.ruby-version
if "%JRUBYSRCDIR%" == "" (
echo Error: environment variable JRUBYSRCDIR must be defined. Aborting..
exit /B 1
)
SET RAKEPATH=%JRUBYPATH%\bin\rake
IF "%SELECTEDTESTSUITE%"=="core-fail-fast" (
echo "Running core-fail-fast tests"
%RAKEPATH% test:install-core
%RAKEPATH% test:core-fail-fast
) ELSE (
echo "Running core tests"
%RAKEPATH% test:install-core
%RAKEPATH% test:core
if not exist %JRUBYSRCDIR% (
echo Error: variable JRUBYSRCDIR must be declared with a valid directory. Aborting..
exit /B 1
)
set JRUBYPATH=%JRUBYSRCDIR%\%JRUBYVERSION%
if not exist %JRUBYPATH% (
echo Error: could not find JRuby in %JRUBYPATH%. Aborting..
exit /B 1
)
set RAKEPATH=%JRUBYPATH%\bin\rake
echo Installing core plugins..
call %RAKEPATH% test:install-core
if errorlevel 1 (
echo Error: failed to install core plugins. Aborting..
exit /B 1
)
if "%SELECTEDTESTSUITE%" == "core-fail-fast" (
echo Running core-fail-fast tests..
call %RAKEPATH% test:core-fail-fast
) else (
echo Running core tests..
call %RAKEPATH% test:core
)
if errorlevel 1 (
echo Error: failed to run core tests. Aborting..
exit /B 1
)