Pull down coredistool package on Windows
authorSejong Oh <sejooh@microsoft.com>
Wed, 9 Mar 2016 02:11:57 +0000 (18:11 -0800)
committerSejong OH <sejooh@microsoft.com>
Thu, 10 Mar 2016 23:18:15 +0000 (15:18 -0800)
Commit migrated from https://github.com/dotnet/coreclr/commit/ae020a10676a04c12a0c3aa1265069e37b0296e5

src/coreclr/tests/runtest.cmd
src/coreclr/tests/runtest.sh
src/coreclr/tests/setup-runtime-dependencies.cmd [new file with mode: 0644]
src/coreclr/tests/setup-runtime-dependencies.sh [moved from src/coreclr/tests/setup-gcstress.sh with 90% similarity]

index d564fa1..e0a512b 100644 (file)
@@ -177,6 +177,15 @@ xcopy /s "%__BinDir%" "%CORE_ROOT%"
 
 :SkipCoreRootSetup
 
+:: Pull down dependent packages needed for testing
+setlocal
+if defined __TestEnv call %__TestEnv%
+if defined COMPlus_GCStress set __Result=true
+endlocal & set __IsGCTest=%__Result%
+if "%__IsGCTest%"=="true" (
+    call tests\setup-runtime-dependencies.cmd /outputdir %CORE_ROOT%
+)
+
 set __BuildLogRootName=TestRunResults
 call :msbuild "%__ProjectFilesDir%\runtest.proj" /p:NoBuild=true /clp:showcommandline
 
@@ -186,6 +195,7 @@ if errorlevel 1 (
     exit /b 1
 )
 
+
 REM =========================================================================================
 REM ===
 REM === All tests complete!
index 309ad83..2366da2 100755 (executable)
@@ -758,7 +758,7 @@ load_failing_tests
 
 if [ -n "$COMPlus_GCStress" ]; then
     scriptPath=$(dirname $0)
-    ${scriptPath}/setup-gcstress.sh --outputDir=$coreOverlayDir
+    ${scriptPath}/setup-runtime-dependencies.sh --outputDir=$coreOverlayDir
     if [ $? -ne 0 ] 
     then
         echo 'Failed to download coredistools library'
diff --git a/src/coreclr/tests/setup-runtime-dependencies.cmd b/src/coreclr/tests/setup-runtime-dependencies.cmd
new file mode 100644 (file)
index 0000000..e7d6099
--- /dev/null
@@ -0,0 +1,111 @@
+@if not defined __echo @echo off
+setlocal
+
+set __ThisScriptShort=%0
+set __ThisScriptFull=%~f0
+set __ThisScriptPath=%~dp0
+
+REM =========================================================================================
+REM ===
+REM === Parse arguments
+REM ===
+REM =========================================================================================
+
+set __OutputDir=
+
+:Arg_Loop
+if "%1" == "" goto ArgsDone
+
+if /i "%1" == "/?"    goto Usage
+if /i "%1" == "-?"    goto Usage
+if /i "%1" == "/h"    goto Usage
+if /i "%1" == "-h"    goto Usage
+if /i "%1" == "/help" goto Usage
+if /i "%1" == "-help" goto Usage
+
+if /i "%1" == "/outputdir"        (set __OutputDir=%2&shift&shift&goto Arg_Loop)
+
+echo Invalid command-line argument: %1
+goto Usage
+
+:ArgsDone
+
+if not defined __OutputDir goto Usage
+
+
+REM =========================================================================================
+REM ===
+REM === Check if dotnet CLI and necessary directories exist
+REM ===
+REM =========================================================================================
+
+set __DotNetToolDir=%__ThisScriptPath%..\Tools
+set __DotNetCmd=%__DotNetToolDir%\dotnetcli\bin\dotnet.exe
+set __PackageDir=%__ThisScriptPath%..\Packages
+set __JasonFilePath=%__ThisScriptPath%project.json
+
+REM Check if dotnet CLI exists
+if not exist "%__DotNetToolDir%" (
+    echo Directory containing dotnet CLI does not exist: %__DotNetToolDir%
+    exit /b 1
+)
+if not exist "%__DotNetCmd%" (
+    echo dotnet.exe does not exist: %__DotNetCmd%
+    exit /b 1
+)
+
+REM Create directories needed
+if not exist "%__PackageDir%" md "%__PackageDir%"
+if not exist "%__OutputDir%" md "%__OutputDir%"
+
+
+REM =========================================================================================
+REM ===
+REM === Download packages
+REM ===
+REM =========================================================================================
+
+REM Write dependency information to project.json
+echo { ^
+    "dependencies": { ^
+    "Microsoft.NETCore.CoreDisTools": "1.0.0-prerelease-00001" ^
+    }, ^
+    "frameworks": { "dnxcore50": { } } ^
+    } > "%__JasonFilePath%"
+
+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
+
+REM Get downloaded dll path
+FOR /F "delims=" %%i IN ('dir coredistools.dll /b/s') DO set __LibPath=%%i
+if not exist "%__LibPath%" (
+    echo Failed to locate the downloaded library: %__LibPath%
+    exit /b 1
+)
+
+REM Copy library to output directory
+echo Copy library: %__LibPath% to %__OutputDir%
+copy /y "%__LibPath%" "%__OutputDir%"
+
+REM Delete temporary files
+del "%__JasonFilePath%"
+
+exit /b 0
+
+REM =========================================================================================
+REM ===
+REM === Helper routines
+REM ===
+REM =========================================================================================
+
+:Usage
+echo.
+echo Download coredistool for GC stress testing
+echo.
+echo Usage:
+echo     %__ThisScriptShort% /outputdir ^<coredistools_lib_install_path^>
+echo.
+exit /b 1
similarity index 90%
rename from src/coreclr/tests/setup-gcstress.sh
rename to src/coreclr/tests/setup-runtime-dependencies.sh
index 4d141b5..9bd1003 100755 (executable)
@@ -83,15 +83,12 @@ echo {  \
     \"frameworks\": { \"dnxcore50\": { } } \
     } > $jsonFilePath
 
-# Find runtime id 
-rid=`$dotnetCmd --version | grep 'Runtime Id:' | sed 's/^ *Runtime Id: *//g'`
-
 # Download the package
 echo Downloading CoreDisTools package
-bash -c -x "$dotnetCmd restore $jsonFilePath --source https://dotnet.myget.org/F/dotnet-core/ --packages $packageDir --runtime $rid"
+bash -c -x "$dotnetCmd restore $jsonFilePath --source https://dotnet.myget.org/F/dotnet-core/ --packages $packageDir"
 
 # Get library path
-libPath=`find $packageDir | grep $rid | grep -m 1 libcoredistools`
+libPath=`find $packageDir | grep -m 1 libcoredistools`
 if [ ! -e $libPath ]; then
     echo 'Failed to locate the downloaded library'
     exit 1