Skip to content

Commit 9e66712

Browse files
committed
Add skip reason and link
1 parent 91b97ed commit 9e66712

File tree

7 files changed

+21
-13
lines changed

7 files changed

+21
-13
lines changed

internal/testrunner/reporters/formats/human.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ func reportHumanFormat(results []testrunner.TestResult) (string, error) {
3636
result = fmt.Sprintf("ERROR: %s", r.ErrorMsg)
3737
} else if r.FailureMsg != "" {
3838
result = fmt.Sprintf("FAIL: %s", r.FailureMsg)
39-
} else if r.Skipped {
40-
result = "SKIPPED"
39+
} else if r.Skipped != nil {
40+
result = r.Skipped.String()
4141
} else {
4242
result = "PASS"
4343
}

internal/testrunner/reporters/formats/xunit.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func reportXUnitFormat(results []testrunner.TestResult) (string, error) {
8585
numErrors++
8686
}
8787

88-
if r.Skipped {
88+
if r.Skipped != nil {
8989
numSkipped++
9090
}
9191

@@ -102,8 +102,8 @@ func reportXUnitFormat(results []testrunner.TestResult) (string, error) {
102102
Failure: failure,
103103
}
104104

105-
if r.Skipped {
106-
c.Skipped = &skipped{""} // TODO: include reason?
105+
if r.Skipped != nil {
106+
c.Skipped = &skipped{r.Skipped.String()}
107107
}
108108

109109
numTests++

internal/testrunner/runners/asset/runner.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (r *runner) run() ([]testrunner.TestResult, error) {
8181
logger.Warnf("skipping %s test for %s: %s (details: %s)",
8282
TestType, r.testFolder.Package,
8383
testConfig.Skip.Reason, testConfig.Skip.Link.String())
84-
return result.WithSkip()
84+
return result.WithSkip(testConfig.Skip)
8585
}
8686

8787
pkgManifest, err := packages.ReadPackageManifest(filepath.Join(r.packageRootPath, packages.PackageManifestFile))

internal/testrunner/runners/pipeline/runner.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (r *runner) run() ([]testrunner.TestResult, error) {
112112
TestType, r.options.TestFolder.Package, r.options.TestFolder.DataStream,
113113
tc.config.Skip.Reason, tc.config.Skip.Link.String())
114114

115-
tr.Skipped = true
115+
tr.Skipped = tc.config.Skip
116116
results = append(results, tr)
117117
continue
118118
}

internal/testrunner/runners/system/runner.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (r *runner) run() (results []testrunner.TestResult, err error) {
146146
TestType, r.options.TestFolder.Package, r.options.TestFolder.DataStream,
147147
testConfig.Skip.Reason, testConfig.Skip.Link.String())
148148
result := r.newResult(testConfig.Name())
149-
partial, err = result.WithSkip()
149+
partial, err = result.WithSkip(testConfig.Skip)
150150
}
151151

152152
results = append(results, partial...)

internal/testrunner/test_config.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@
44

55
package testrunner
66

7-
import "net/url"
7+
import (
8+
"fmt"
9+
"net/url"
10+
)
811

912
// SkipConfig allows a test to be marked as skipped
1013
type SkipConfig struct {
1114
Reason string `config:"reason"`
1215
Link url.URL `config:"url"`
1316
}
17+
18+
func (s SkipConfig) String() string {
19+
return fmt.Sprintf("%s [%s]", s.Reason, s.Link.String())
20+
}

internal/testrunner/testrunner.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ type TestResult struct {
8181
// to an unexpected runtime error in the test execution.
8282
ErrorMsg string
8383

84-
// Flag to indicate that test was skipped.
85-
Skipped bool
84+
// If the test was skipped, the reason it was skipped and a link for more
85+
// details.
86+
Skipped *SkipConfig
8687
}
8788

8889
// ResultComposer wraps a TestResult and provides convenience methods for
@@ -115,8 +116,8 @@ func (rc *ResultComposer) WithSuccess() ([]TestResult, error) {
115116
}
116117

117118
// WithSkip marks the test result wrapped by ResultComposer as skipped.
118-
func (rc *ResultComposer) WithSkip() ([]TestResult, error) {
119-
rc.TestResult.Skipped = true
119+
func (rc *ResultComposer) WithSkip(s *SkipConfig) ([]TestResult, error) {
120+
rc.TestResult.Skipped = s
120121
return rc.WithError(nil)
121122
}
122123

0 commit comments

Comments
 (0)