Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/gocover/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ a gocover command to run Go unit tests with coverages, updating the README.md wi
| race | run tests with race detector enabled (-race) | boolean | true |
| verbose | run tests with -v | boolean | true |
| tags | comma-separated list of additional build tags (-tags) | string | - |
| run | if set, run only those tests, examples, and fuzz tests matching the regular expression | string | - |
| uncovered-packages | space separated optional list of package patterns to exclude from coverage analysis | string | - |
| green | percentage number for the badge to become green | string | 80 |
| yellow | percentage number for the badge to become yellow | string | 50 |
Expand Down
10 changes: 9 additions & 1 deletion src/gocover/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Go Coverage with Badge",
"id": "gocover",
"version": "1.0.0",
"version": "1.0.1",
"description": "a gocover command to run Go unit tests with coverages, updating the README.md with a coverage badge.",
"keywords": [
"go",
Expand Down Expand Up @@ -44,6 +44,14 @@
"default": "",
"description": "comma-separated list of additional build tags (-tags)"
},
"run": {
"type": "string",
"default": "",
"proposals": [
"^Test"
],
"description": "if set, run only those tests, examples, and fuzz tests matching the regular expression"
},
"uncovered-packages": {
"type": "string",
"default": "",
Expand Down
7 changes: 7 additions & 0 deletions src/gocover/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ HTML=${HTML:-false}
COUNT=${COUNT:-1}
NUM_PROGRAMS=${NUM_PROGRAMS} # ...just a reminder
RACE=${RACE:-true}
#RUN=${RUN}
VERBOSE=${VERBOSE:-true}
GREEN=${GREEN:-80}
YELLOW=${YELLOW:-50}
Expand All @@ -27,11 +28,14 @@ tee "${GOCOVER_PATH}" > /dev/null \
<< EOF
#!/usr/bin/env bash

set -e

ROOT="${ROOT}"
HTML="${HTML}"
COUNT="${COUNT}"
NUM_PROGRAMS="${NUM_PROGRAMS}"
RACE="${RACE}"
RUN="${RUN}"
TAGS="${TAGS}"
VERBOSE="${VERBOSE}"
IGNORE_PKGS=("${IGNORE_PKGS[@]}")
Expand Down Expand Up @@ -88,6 +92,7 @@ trap 'rm -rf -- "\${GOCOVERTMPDIR}"' EXIT
[[ "\${RACE}" = "true" ]] && RACE="-race" || unset RACE
[[ "\${VERBOSE}" = "true" ]] && VERBOSE="-v" || unset VERBOSE
[[ -n "\${TAGS}" ]] && TAGS="-tags=\${TAGS}" || unset TAGS
[[ -n "\${RUN}" ]] && RUN="-run=\${RUN}" || unset RUN

[[ \${#POSARGS[@]} -eq 0 ]] && POSARGS+="./..."

Expand All @@ -97,6 +102,7 @@ if [[ -n "\${ROOT+x}" ]]; then
\${VERBOSE} \
\${RACE} \
-count=\${COUNT} \${NUM_PROGRAMS} \
\${RUN} \
\${TAGS} \
\${COVERPKG} \
\${POSARGS[@]} -args -test.gocoverdir="\${GOCOVERTMPDIR}"
Expand All @@ -105,6 +111,7 @@ go test -cover \
\${VERBOSE} \
\${RACE} \
-count=\${COUNT} \${NUM_PROGRAMS} \
\${RUN} \
\${TAGS} \
\${COVERPKG} \
\${POSARGS[@]} -args -test.gocoverdir="\${GOCOVERTMPDIR}"
Expand Down
2 changes: 2 additions & 0 deletions src/grafanactl/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
### **IMPORTANT NOTE**
- **This Feature is deprecated, and will no longer receive any further updates/support.**

# grafanactl (grafanactl)

Expand Down
37 changes: 37 additions & 0 deletions test/gocover/run-only-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -e

source dev-container-features-test-lib

go mod init example.com/foo

cat >foo.go <<EOF
package foo

func fooed() {
println("Fooed")
}
EOF

cat >foo_test.go <<EOF
package foo

import (
"testing"
)

func TestFoo(t *testing.T) {
fooed()
}

func Example_crash() {
panic("THOU SHALT NOT TEST THIS EXAMPLE")
// Output:
}
EOF

touch README.md

check "run only tests but no examples" bash -c "gocover | tee /dev/tty | grep --color -E 'badge updated to 100.0%'"

reportResults
9 changes: 9 additions & 0 deletions test/gocover/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
}
}
},
"run-only-tests": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/devcontainers/features/go:1": {},
"gocover": {
"run": "^Test"
}
}
},
"html": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
Expand Down
Loading