Skip to content

Commit

Permalink
Output the input test case on failure (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfus authored May 31, 2023
1 parent f0ee190 commit 8a44b59
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ syntax = "proto3";
package buf.validate.conformance.harness;

import "buf/validate/conformance/harness/harness.proto";
import "google/protobuf/any.proto";

message ResultSet {
int32 successes = 1;
Expand All @@ -41,4 +42,5 @@ message CaseResult {
bool success = 2;
TestResult wanted = 3;
TestResult got = 4;
google.protobuf.Any input = 5;
}
139 changes: 77 additions & 62 deletions tools/internal/gen/buf/validate/conformance/harness/results.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions tools/protovalidate-conformance/internal/results/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ func (suite *SuiteResults) printCase(w io.Writer, testCase *harness.CaseResult)
if testCase.Success {
return
}
_, _ = fmt.Fprintf(w, "%sinput: %v\n",
resultPadding, testCase.Input)
_, _ = fmt.Fprintf(w, "%s want: %v\n",
resultPadding, FromProto(testCase.Wanted))
_, _ = fmt.Fprintf(w, "%s got: %v\n",
Expand Down
5 changes: 5 additions & 0 deletions tools/protovalidate-conformance/internal/suites/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,16 @@ func (s Suite) ProcessResults(
"missing results on response")
}

anyInput, err := anypb.New(testCase.Message)
if err != nil {
return err
}
out.AddCase(&harness2.CaseResult{
Name: caseName,
Success: testCase.Expected.IsSuccessWith(actual, strict),
Wanted: testCase.Expected.ToProto(),
Got: actual.ToProto(),
Input: anyInput,
}, verbose)
return nil
})
Expand Down

0 comments on commit 8a44b59

Please sign in to comment.