Repository navigation
report test2json: report key=value subtest names as parameters - #46
Open
DzmitryHumianiuk wants to merge 2 commits into
Open
DzmitryHumianiuk wants to merge 2 commits into
DzmitryHumianiuk wants to merge 2 commits into
Conversation
A subtest named after the table test convention 'key=value' gets the pair as a test item parameter. Several pairs in one name are separated by '/' or ',', and a subtest also gets the parameters of the subtests it is nested in. Only names that consist of such pairs count: keys are letters, digits, '.' and '-' (no '_', which is what the testing package makes of a space, so 'fails_when_n=1' is a sentence), values are non-empty and have no '='. The '#1' suffix of a repeated name is not part of the value. The test case ID, unique ID and code reference stay the full test name. Part of #26. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of #26 (slice C6). Stacked on C5 → C4 → C3 → C2 → #29. The change itself only touches
startTest.Go has no parameterized tests, but table tests and benchmarks name their cases
key=value. This PR reports thosepairs as ReportPortal test item
parameters. Identity is not touched:testCaseId,uniqueIdandcodeRefstaythe full test name.
Changes
internal/commands/report_parameters.go:subtestParameters(name)derives parameters from a subtest's namerelative to its parent:
n=1n=1n=1#01n=1(the suffix Go adds to a repeated name is dropped)size=64/align=8size=64,align=8tls=true,http2=falsetls=true,http2=falselist=a,b,c,path=a/blist="a,b,c",path="a/b"(the rest is not a pair, so it is part of the value)expr=a=b,k=,=v,url=http://x/y?q=1fails_when_n=1,max_size=10plain,SetZero/string/size=16Key rule: a letter followed by letters, digits,
.or-. No_: the testing package turns spaces intounderscores, so
t.Run("fails when n=1")arrives asfails_when_n=1, and that must not become the parameterfails_when_n. The price is thatmax_size=10gives no parameter.Value rule: non-empty and without
=.A subtest also gets the parameters of the subtests it is nested in (
cache=ram→pages=16→plainall carrycache=ram), because the test case ran with all of them. Top-level tests never have parameters.Fixture
internal/commands/testdata/params/params.jsonl(realgo test -json, go1.27.4), unit tests, an e2etest, README and skill.
Behaviour change
Items of subtests named
key=valuegetparameters. Nothing else changes; items without such names are sent asbefore (
parametersis omitted).Verification
go build ./... && go vet ./... && go test -race ./...: ok. Lint: 0 issues (also--build-tags e2e ./e2e/...).TestSubtestParameters(24 names) andTestReportLaunch_SubtestParameters(the real stream: parametersand unchanged
testCaseIdof all 16 tests).go test -tags e2e -count=1 -v -run SubtestParameters ./e2e/...→PASS TestReportTest2JSON_SubtestParameters (5.03s): the server returns the parameters on the items(
n=1#01→n=1;pages=16andplain→cache=ram,pages=16; none forexpr=a=b), andtestCaseIdis thefull name. The server returns parameters in a different order than sent, so the test compares them as sets.
Investigation log
scratchpad/wave/survey_params.shgreps the*_test.gofiles of the Godistribution (go1.27.4,
$(go env GOROOT)/src) forRun("…=…")andRun(fmt.Sprintf("…=…")); output inscratchpad/wave/live/c6-survey.log: 433 literal and 71 formatted names with=./:n=%d,size=64,Key=int64/Elem=int64,tableSize=%d/elems=%d/load=%0.3f,cache=ram/pages=%d.sameSubject=%t,sameKey=%t,DisableKeepAlive=%v,RequestClose=%v.Decision: accept it, but only when every comma-separated piece is a pair.
-(work-dur,tickers-per-P); none with_.SetZero/%s/size=%d,gc=yes/ptrs=%v/%s). As nestedt.Runcalls each level is judgedon its own; as one name with slashes they give nothing.
scratchpad/wave/mkparams.sh→ real stream. A repeatedn=1becomes
n=1#01;name=two wordsbecomesname=two_words; a name with/stays one test(
TestParams/tableSize=8/elems=4has noTestParams/tableSize=8parent)._. The unit testwith_n=1_inside/plainthen produced theparameter
with_n, which showed the sentence problem; hence the key rule above.parentOf), not by splittingthe full test name at
/:url=http://x/ysplit at/would give the wrong pairurl=http:.testCaseIdis set explicitly by the reporter (reporter.go,startTest), so the server does not derive itfrom the parameters; confirmed by the e2e assertion.
Open questions
_(max_size=10) are not recognised. Allowing them needs another way to tell a pair from asentence.
plainundercache=ram/pages=16has none.Not verified
go test -bench -json): their names end in-GOMAXPROCS(size=64-8), which would end up in thevalue.
report test2jsondoes not handle benchmark events today.🤖 Generated with Claude Code