forked from microsoft/vstest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
125 lines (110 loc) · 2.57 KB
/
test.sh
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
120
121
122
123
124
125
#!/usr/bin/env bash
# Copyright (c) Microsoft. All rights reserved.
# Test script for Test Platform.
set -o nounset # Fail on uninitialized variables.
set -e # Fail on non-zero exit code.
# ANSI color codes
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
NOCOLOR='\033[0m'
#
# Parse options
#
CONFIGURATION="Debug"
TARGET_RUNTIME="ubuntu.16.04-x64"
FAIL_FAST=false
VERBOSE=false
PROJECT_NAME_PATTERNS=**Unit*bin*Debug*netcoreapp1.0*UnitTests*dll
while [ $# -gt 0 ]; do
lowerI="$(echo ${1:-} | awk '{print tolower($0)}')"
case $lowerI in
-h | --help)
usage
exit
;;
-c)
CONFIGURATION=$2
;;
-r)
TARGET_RUNTIME=$2
;;
-p)
PROJECT_NAME_PATTERNS=$2
;;
-verbose)
VERBOSE=$2
;;
*)
break
;;
esac
shift
done
#
# Variables
#
TP_ROOT_DIR=$(cd "$(dirname "$0")"; pwd -P)
TP_TOOLS_DIR="$TP_ROOT_DIR/tools"
TP_PACKAGES_DIR="$TP_ROOT_DIR/packages"
TP_OUT_DIR="$TP_ROOT_DIR/artifacts"
#
# Dotnet configuration
#
# Disable first run since we want to control all package sources
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
# Dotnet build doesnt support --packages yet. See https://github.com/dotnet/cli/issues/2712
export NUGET_PACKAGES=$TP_PACKAGES_DIR
DOTNET_CLI_VERSION="latest"
#
# Build configuration
#
TPB_Solution="TestPlatform.sln"
TPB_TargetFrameworkCore="netcoreapp2.0"
TPB_Configuration=$CONFIGURATION
TPB_TargetRuntime=$TARGET_RUNTIME
TPB_Verbose=$VERBOSE
#
# Logging
#
log()
{
printf "${GREEN}... $@${NOCOLOR}\n"
}
verbose()
{
if [ ${TPB_Verbose-false} ]
then
printf "${YELLOW}... $@${NOCOLOR}\n" >&2
fi
}
error()
{
printf "${RED}... $@${NOCOLOR}\n" >&2
}
function usage()
{
log " Usage: ./test.sh [Options]"
log ""
log " -c <CONFIGURATION> Build the specified Configuration (Debug or Release, default: Debug)"
log " -r <TARGET_RUNTIME> Build for the specified runtime moniker (ubuntu.16.04-x64)"
log " -p <PROJECT_NAME_PATTERNS> Pattern to test specific projects"
log " -verbose <VERBOSE> Enable verbose logging (true, false)"
}
#
# Test steps
#
function invoke_test()
{
local dotnet=$(_get_dotnet_path)
local vstest=$TP_OUT_DIR/$TPB_Configuration/$TPB_TargetFrameworkCore/vstest.console.dll
find ./test -path $PROJECT_NAME_PATTERNS | xargs --verbose $dotnet $vstest --parallel
}
#
# Privates
#
_get_dotnet_path()
{
echo "$TP_TOOLS_DIR/dotnet/dotnet"
}
invoke_test