summaryrefslogtreecommitdiff
path: root/tests/debugger_tests/ConfigFilesGenerators/GenerateConfig.sh
blob: 38834ed6a511f6ff4e08d77fe5d61dad3d43d84b (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
#!/bin/bash

function print_usage {
    echo ''
    echo 'Usage:'
    echo '[rt=<runtime_path>] [nc=<nuget_cache_path>] [cli=<cli_path>] where:'
    echo '  <runtime_path>: path to the runtime that you want to use for testing.'
    echo '  <nuget_cache_path>: path to the nuget cache.'
    echo '  <cli_path>: path to the cli tool.'
    echo ''
    echo ''
}

# Argument variables
__RuntimeRoot='$(TestRoot)\Runtimes\Coreclr1'
__NugetCacheDir='$(WorkingDir)\packages'
__CliPath=
__ConfigFileName='Debugger.Tests.Config.txt'
__TemplateFileName='ConfigTemplate.txt'

for i in "$@"
do
    case $i in
        -h|--help)
            print_usage
            exit $EXIT_CODE_SUCCESS
            ;;
        rt=*)
            __RuntimeRoot=${i#*=}
            ;;
        nc=*)
            __NugetCacheDir=${i#*=}
            ;;
        cli=*)
            __CliPath=${i#*=}
            ;;
        *)
            echo "Unknown switch: $i"
            print_usage
            exit $EXIT_CODE_SUCCESS
            ;;
    esac
done

if ! -e "$__TemplateFileName"
then
    echo '$__TemplateFileName does not exist'
    exit 1
fi

if -e "$__ConfigFileName"
then
    rm "$__ConfigFileName"
fi

cp "$__TemplateFileName" "$__ConfigFileName"

sed -i \
    's/##Insert_Runtime_Root##/$__RuntimeRoot/g;' \
    's/##Insert_Nuget_Cache_Root##/$__NugetCacheDir/g'\
    's/##Cli_Path##/$__CliPath/g'\
    's/corerun.exe/corerun/g'\
    "$__ConfigFileName"

exit 0