-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathbuild-test.sh
81 lines (68 loc) · 2.1 KB
/
build-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
#!/bin/bash
ExitCode=0
SCRIPT_DIR="$(dirname $(readlink -f "${BASH_SOURCE}"))"
BUILD_CONFIGURATION=""
Usage() {
echo ""
echo "Discovers and runs tests (unit + functional) defined in the build output/artifacts."
echo ""
echo "Usage:"
echo "---------------------"
echo "build-test.sh"
echo ""
echo "Examples"
echo "---------------------"
echo "# Use defaults"
echo "user@system:~/repo$ chmod +x *.sh"
echo "user@system:~/repo$ ./build.sh"
echo "user@system:~/repo$ ./build-test.sh"
echo ""
echo "# Set specific version and configuration"
echo "user@system:~/repo$ export VCBuildVersion=\"1.16.25\""
echo "user@system:~/repo$ export VCBuildConfiguration=\"Debug\""
echo "user@system:~/repo$ ./build.sh"
echo "user@system:~/repo$ ./build-test.sh"
echo ""
Finish
}
Error() {
ExitCode=1
End
}
End() {
echo "Test Stage Exit Code: $ExitCode"
Finish
}
Finish() {
exit $ExitCode
}
for ((i=1; i<=$#; i++)); do
arg="${!i}"
if [ "$arg" == "/?" ] || [ "$arg" == "-?" ] || [ "$arg" == "--help" ]; then
Usage
fi
done
# The default build configuration is 'Release'.
BUILD_CONFIGURATION="Release"
# The default build configuration (e.g. Release) can be overridden
# by the 'VCBuildConfiguration' environment variable
if [[ -v "VCBuildConfiguration" && -n "$VCBuildConfiguration" ]]; then
BUILD_CONFIGURATION=$VCBuildConfiguration
fi
echo ""
echo "**********************************************************************"
echo "Repo Root : $SCRIPT_DIR"
echo "Configuration : $BUILD_CONFIGURATION"
echo "Tests Directory : $SCRIPT_DIR/out/bin/$BUILD_CONFIGURATION"
echo "**********************************************************************"
echo ""
echo "[Running Tests]"
echo "--------------------------------------------------"
for file in $(find "$(dirname "$0")/src" -type f -name "*Tests.csproj"); do
dotnet test -c $BUILD_CONFIGURATION "$file" --no-restore --no-build --filter "(Category=Unit)" --logger "console;verbosity=normal"
result=$?
if [ $result -ne 0 ]; then
Error
fi
done
End