-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathcoverage.sh
executable file
·82 lines (69 loc) · 2.49 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# To collect code coverage, you will need the following environment setup:
#
# - A "GODOT" environment variable pointing to the Godot executable
# - ReportGenerator installed
#
# dotnet tool install -g dotnet-reportgenerator-globaltool
#
# - A version of coverlet > 3.2.0.
#
# As of Jan 2023, this is not yet released.
#
# The included `nuget.config` file will allow you to install a nightly
# version of coverlet from the coverlet nightly nuget feed.
#
# dotnet tool install --global coverlet.console --prerelease.
#
# You can build coverlet yourself, but you will need to edit the path to
# coverlet below to point to your local build of the coverlet dll.
#
# If you need help with coverage, feel free to join the Chickensoft Discord.
# https://chickensoft.games
dotnet build --no-restore
coverlet \
"./.godot/mono/temp/bin/Debug" --verbosity detailed \
--target $GODOT \
--targetargs "--run-tests --coverage --quit-on-finish" \
--format "opencover" \
--output "./coverage/coverage.xml" \
--exclude-by-file "**/test/**/*.cs" \
--exclude-by-file "**/*Microsoft.NET.Test.Sdk.Program.cs" \
--exclude-by-file "**/Godot.SourceGenerators/**/*.cs" \
--exclude-by-file "**/Chickensoft.*/**/*.cs" \
--exclude-by-file "**/*.g.cs" \
--exclude-assemblies-without-sources "missingall" \
--skipautoprops
# Projects included via <ProjectReference> will be collected in code coverage.
# If you want to exclude them, replace the string below with the names of
# the assemblies to ignore. e.g.,
# ASSEMBLIES_TO_REMOVE="-AssemblyToRemove1;-AssemblyToRemove2"
ASSEMBLIES_TO_REMOVE=""
reportgenerator \
-reports:"./coverage/coverage.xml" \
-targetdir:"./coverage/report" \
"-assemblyfilters:$ASSEMBLIES_TO_REMOVE" \
"-classfilters:-GodotPlugins.Game.Main;-GameDemo.Main;-Chickensoft.AutoInject*;-Chickensoft.PowerUps*" \
-reporttypes:"Html;Badges" || exit 0
# Copy badges into their own folder. The badges folder should be included in
# source control so that the README.md in the root can reference the badges.
mkdir -p ./badges
mv ./coverage/report/badge_branchcoverage.svg ./badges/branch_coverage.svg
mv ./coverage/report/badge_linecoverage.svg ./badges/line_coverage.svg
# Determine OS, open coverage accordingly.
case "$(uname -s)" in
Darwin)
echo 'Mac OS X'
open coverage/report/index.htm
;;
Linux)
echo 'Linux'
;;
CYGWIN*|MINGW32*|MSYS*|MINGW*)
echo 'MS Windows'
start coverage/report/index.htm
;;
*)
echo 'Other OS'
;;
esac