This repository has been archived by the owner on Jan 16, 2023. It is now read-only.
forked from JSkimming/Castle.Core.AsyncInterceptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
coverage.sh
executable file
·61 lines (48 loc) · 1.75 KB
/
coverage.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
#!/bin/sh -eu
# function to display commands
exe() { echo; echo "\$ $*" ; "$@" ; }
# Parameters
framework="${1-net6.0}"
config="${2-Debug}"
include="[Castle.Core.AsyncInterceptor]*"
exclude="\"[Castle.Core.AsyncInterceptor]*.NoCoverage.*,[*.Tests]*\""
# Cannot use a bash solution in alpine builds https://stackoverflow.com/a/246128
#rootDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
rootDir=$(pwd)
testResults="test/TestResults"
output="$rootDir/$testResults/output"
tools="$rootDir/$testResults/tools"
testProj1="$rootDir/test/Castle.Core.AsyncInterceptor.Tests/Castle.Core.AsyncInterceptor.Tests.csproj"
# Restore the packages
exe dotnet restore "$rootDir"
# Build the test projects
exe dotnet build --no-restore -f "$framework" -c "$config" "$testProj1"
# Execute the tests
exe dotnet test --no-restore --no-build -f "$framework" -c "$config" \
"$testProj1" \
--results-directory "$output/" \
--logger "\"trx;LogFileName=$(basename "$testProj1" .csproj).trx\"" \
--logger "\"Console;noprogress=true\"" \
-p:CollectCoverage=true \
-p:Include="$include" \
-p:Exclude="$exclude" \
-p:CoverletOutput="$output/" \
-p:CoverletOutputFormat="\"json,opencover,cobertura,lcov\""
# Install trx2junit if not already installed
if [ ! -f "$tools/trx2junit" ]
then
exe dotnet tool install trx2junit --tool-path "$tools"
fi
# Install ReportGenerator if not already installed
if [ ! -f "$tools/reportgenerator" ]
then
exe dotnet tool install dotnet-reportgenerator-globaltool --tool-path "$tools"
fi
# Convert the MSTest trx files to junit xml
exe "$tools/trx2junit" "$output"/*.trx
# Generate the reports
exe "$tools/reportgenerator" \
"-verbosity:Info" \
"-reports:$output/coverage.$framework.opencover.xml" \
"-targetdir:$output/Report" \
"-reporttypes:Html"