summaryrefslogtreecommitdiff
path: root/tests/debugger_tests/setup-debuggertests.cmd
blob: 6507f0e8a2d4f7fea9d4674ec2656cda87864a1f (plain)
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
@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=
set __Arch= 
set __CoreclrBinPath=
set __NugetCacheDir=
set __CliPath=

: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)
if /i "%1" == "/coreclrBinDir"      (set __CoreclrBinPath=%2&shift&shift&goto Arg_Loop)
if /i "%1" == "/nugetCacheDir"      (set __NugetCacheDir=%2&shift&shift&goto Arg_Loop)
if /i "%1" == "/cliPath"            (set __CliPath=%2&shift&shift&goto Arg_Loop)


echo Invalid command-line argument: %1
goto Usage

:ArgsDone

if not defined __OutputDir goto Usage
if not defined __Arch goto Usage 

REM Create directories needed
if exist "%__OutputDir%\debuggertests" rmdir /S /Q "%__OutputDir%\debuggertests"
md "%__OutputDir%\debuggertests"
set __InstallDir=%__OutputDir%\debuggertests

REM =========================================================================================
REM ===
REM === download debuggertests package
REM ===
REM =========================================================================================
set DEBUGGERTESTS_URL=https://dotnetbuilddrops.blob.core.windows.net/debugger-container/Windows.DebuggerTests.zip
set LOCAL_ZIP_PATH=%__InstallDir%\debuggertests.zip
if exist "%LOCAL_ZIP_PATH%" del "%LOCAL_ZIP_PATH%"
set DEBUGGERTESTS_INSTALL_LOG="%__ThisScriptPath%debuggerinstall.log"
REM Download the package
echo Download and unzip debuggertests package to %LOCAL_ZIP_PATH%
powershell -NoProfile -ExecutionPolicy unrestricted -Command "$retryCount = 0; $success = $false; do { try { (New-Object Net.WebClient).DownloadFile('%DEBUGGERTESTS_URL%', '%LOCAL_ZIP_PATH%'); $success = $true; } catch { if ($retryCount -ge 6) { throw; } else { $retryCount++; Start-Sleep -Seconds (5 * $retryCount); } } } while ($success -eq $false); Add-Type -Assembly 'System.IO.Compression.FileSystem' -ErrorVariable AddTypeErrors; if ($AddTypeErrors.Count -eq 0) { [System.IO.Compression.ZipFile]::ExtractToDirectory('%LOCAL_ZIP_PATH%', '%__InstallDir%') } else { (New-Object -com shell.application).namespace('%LOCAL_ZIP_PATH%').CopyHere((new-object -com shell.application).namespace('%__InstallDir%').Items(),16) }" >> %DEBUGGERTESTS_INSTALL_LOG%

if errorlevel 1 (
    echo Failed to install debuggertests to %__InstallDir%
    goto Fail
)

REM =========================================================================================
REM ===
REM === Setting up the right config file.
REM ===
REM =========================================================================================
echo Generating config file.

call %__ThisScriptPath%\ConfigFilesGenerators\GenerateConfig.cmd rt %__CoreclrBinPath% nc %__NugetCacheDir% cli %__CliPath%
move Debugger.Tests.Config.txt %__InstallDir%\\Debugger.Tests\dotnet\Debugger.Tests.Config.txt

REM =========================================================================================
REM ===
REM === Scripts generation.
REM ===
REM =========================================================================================
mkdir %__InstallDir%\ScriptGenerator
copy %__ThisScriptPath%\ScriptGenerator\*  %__InstallDir%\ScriptGenerator\
pushd %__InstallDir%\ScriptGenerator
%__CliPath%\dotnet restore
%__CliPath%\dotnet build
popd 

%__CliPath%\dotnet run --project %__InstallDir%\ScriptGenerator %__InstallDir% %__CoreclrBinPath% %__InstallDir%\Dotnet.Tests\dotnet

REM Deleting runtests.cmd to avoid double test-running.
del %__InstallDir%\runtests.cmd

if errorlevel 1 (
    echo Failed to build and run script generation.
    goto Fail
)



exit /b 0

:Fail
exit /b 1

REM =========================================================================================
REM ===
REM === Helper routines
REM ===
REM =========================================================================================

:Usage
echo.
echo install debugger tests
echo.
echo Usage:
echo     %__ThisScriptShort% /coreclrBinDir ^<coreclr bin path^> /outputDir ^<debuggertests install path^> /nugetCacheDir ^<nuget cache dir path^>
echo.
exit /b 1