diff options
author | Sejong Oh <sejooh@microsoft.com> | 2016-03-15 13:56:41 -0700 |
---|---|---|
committer | Sejong OH <sejooh@microsoft.com> | 2016-03-16 16:58:30 -0700 |
commit | 62e0f5c054524a14ab35f93d78e6ee820c4e03aa (patch) | |
tree | 3aa558327eecc08babe418de49c499bbf1adc6e3 /tests | |
parent | c37aae496c6d83ddd49c96e0eeb9cc1bce2bff76 (diff) | |
download | coreclr-62e0f5c054524a14ab35f93d78e6ee820c4e03aa.tar.gz coreclr-62e0f5c054524a14ab35f93d78e6ee820c4e03aa.tar.bz2 coreclr-62e0f5c054524a14ab35f93d78e6ee820c4e03aa.zip |
Fix setup-runtime-dependencies.cmd
Diffstat (limited to 'tests')
-rwxr-xr-x[-rw-r--r--] | tests/setup-runtime-dependencies.cmd | 37 | ||||
-rwxr-xr-x | tests/setup-runtime-dependencies.sh | 61 |
2 files changed, 78 insertions, 20 deletions
diff --git a/tests/setup-runtime-dependencies.cmd b/tests/setup-runtime-dependencies.cmd index e7d6099b8d..6c7f6d10b1 100644..100755 --- a/tests/setup-runtime-dependencies.cmd +++ b/tests/setup-runtime-dependencies.cmd @@ -42,22 +42,30 @@ REM ============================================================================ set __DotNetToolDir=%__ThisScriptPath%..\Tools set __DotNetCmd=%__DotNetToolDir%\dotnetcli\bin\dotnet.exe set __PackageDir=%__ThisScriptPath%..\Packages -set __JasonFilePath=%__ThisScriptPath%project.json +set __TmpDir=%Temp%\coreclr_gcstress_%RANDOM% -REM Check if dotnet CLI exists +REM Check if donet cli exists if not exist "%__DotNetToolDir%" ( echo Directory containing dotnet CLI does not exist: %__DotNetToolDir% - exit /b 1 + goto Fail ) if not exist "%__DotNetCmd%" ( echo dotnet.exe does not exist: %__DotNetCmd% - exit /b 1 + goto Fail ) REM Create directories needed if not exist "%__PackageDir%" md "%__PackageDir%" if not exist "%__OutputDir%" md "%__OutputDir%" +REM Check and create a temp directory +if exist "%__TmpDir%" ( + rmdir /S /Q %__TmpDir% +) +mkdir %__TmpDir% + +REM Project.json path +set __JasonFilePath=%__TmpDir%\project.json REM ========================================================================================= REM === @@ -75,15 +83,16 @@ echo { ^ REM Download the package echo Downloading CoreDisTools package -echo on -call "%__DotNetCmd%" restore "%__JasonFilePath%" --source https://dotnet.myget.org/F/dotnet-core/ --packages "%__PackageDir%" -@echo off +set DOTNETCMD="%__DotNetCmd%" restore "%__JasonFilePath%" --source https://dotnet.myget.org/F/dotnet-core/ --packages "%__PackageDir%" +echo %DOTNETCMD% +call %DOTNETCMD% +if errorlevel 1 goto Fail REM Get downloaded dll path -FOR /F "delims=" %%i IN ('dir coredistools.dll /b/s') DO set __LibPath=%%i +FOR /F "delims=" %%i IN ('dir %__PackageDir%\coredistools.dll /b/s') DO set __LibPath=%%i if not exist "%__LibPath%" ( echo Failed to locate the downloaded library: %__LibPath% - exit /b 1 + goto Fail ) REM Copy library to output directory @@ -91,10 +100,18 @@ echo Copy library: %__LibPath% to %__OutputDir% copy /y "%__LibPath%" "%__OutputDir%" REM Delete temporary files -del "%__JasonFilePath%" +if exist "%__TmpDir%" ( + rmdir /S /Q "%__TmpDir%" +) exit /b 0 +:Fail +if exist "%__TmpDir%" ( + rmdir /S /Q "%__TmpDir%" +) +exit /b 1 + REM ========================================================================================= REM === REM === Helper routines diff --git a/tests/setup-runtime-dependencies.sh b/tests/setup-runtime-dependencies.sh index 9bd1003e54..17fbb16334 100755 --- a/tests/setup-runtime-dependencies.sh +++ b/tests/setup-runtime-dependencies.sh @@ -1,4 +1,9 @@ #!/usr/bin/env bash +set -x +# +# Constants +# +readonly EXIT_CODE_SUCCESS=0 # # This script should be located in coreclr/tests. @@ -17,6 +22,31 @@ function print_usage { echo '' } +# temorary directory +tmpDirPath= + +function exit_with_error { + local errorCode=$1 + local errorMsg=$2 + + if [ ! -z "$2" ]; then + echo $2 + fi + + if [ -e $tmpDirPath ]; then + rm -rf $tmpDirPath + fi + + exit $errorCode +} + +function handle_ctrl_c { + exit_with_error 1 'Aborted by Ctrl+C' + } + +# Register the Ctrl-C handler +trap handle_ctrl_c INT + # Argument variables libInstallDir= @@ -45,7 +75,13 @@ done if [ -z "$libInstallDir" ]; then echo "--libInstallDir is required." print_usage - exit $EXIT_CODE_EXCEPTION + exit_with_error 1 +fi + +# create temp directory +tmpDirPath=`mktemp -d` +if [ ! -e $tmpDirPath ]; then + exit_with_error 1 "Cannot create a temporary directory" fi # This script must be located in coreclr/tests. @@ -53,16 +89,14 @@ scriptDir=$(cd "$(dirname "$0")"; pwd -P) dotnetToolsDir=$scriptDir/../Tools dotnetCmd=${dotnetToolsDir}/dotnetcli/bin/dotnet packageDir=${scriptDir}/../packages -jsonFilePath=${scriptDir}/project.json +jsonFilePath=${tmpDirPath}/project.json # Check tool directory if [ ! -e $dotnetToolsDir ]; then - echo 'Directory containing dotnet commandline does not exist:' $dotnetToolsDir - exit 1 + exit_with_error 1 'Directory containing dotnet commandline does not exist:'$dotnetToolsDir fi if [ ! -e $dotnetCmd ]; then - echo 'donet commandline does not exist:' $dotnetCmd - exit 1 + exit_with_error 1 'donet commandline does not exist:'$dotnetCmd fi # make package directory @@ -86,21 +120,28 @@ echo { \ # Download the package echo Downloading CoreDisTools package bash -c -x "$dotnetCmd restore $jsonFilePath --source https://dotnet.myget.org/F/dotnet-core/ --packages $packageDir" +if [ $? -ne 0 ] +then + exit_with_error 1 "Failed to restore the package" +fi # Get library path libPath=`find $packageDir | grep -m 1 libcoredistools` if [ ! -e $libPath ]; then - echo 'Failed to locate the downloaded library' - exit 1 + exit_with_error 1 'Failed to locate the downloaded library' fi # Copy library to output directory echo 'Copy library:' $libPath '-->' $libInstallDir/ cp -f $libPath $libInstallDir +if [ $? -ne 0 ] +then + exit_with_error 1 "Failed to copy the library" +fi # Delete temporary files -rm -rf $jsonFilePath +rm -rf $tmpDirPath # Return success -exit 0 +exit $EXIT_CODE_SUCCESS |