Skip to content

Commit

Permalink
Add --strict_error flag to conformance tool (#25)
Browse files Browse the repository at this point in the history
Defaulting it to off. This should be turned on for any implementations
that can type-check before running the program, so currently only
cel-go/protovalidate-go. This will allow others (like cc, python, java,
etc) to enable --strict mode.
  • Loading branch information
Alfus authored Jun 9, 2023
1 parent 94061fd commit 38af593
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ message ResultOptions {

// If the violation message must be an exact match.
bool strict_message = 5;
// If the distinciton between runtime and compile time errors must be exact.
bool strict_error = 6;
}

message ResultSet {
Expand Down
134 changes: 73 additions & 61 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/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type config struct {
verbose bool
strict bool
strictMessage bool
strictError bool
proto bool
json bool
print bool
Expand All @@ -57,6 +58,7 @@ func parseFlags() config {
flag.BoolVarP(&cfg.verbose, "verbose", "v", cfg.verbose, "verbose output")
flag.BoolVar(&cfg.strict, "strict", cfg.strict, "strict mode")
flag.BoolVar(&cfg.strictMessage, "strict_message", cfg.strictMessage, "require that violation messages match the expected message exactly")
flag.BoolVar(&cfg.strictError, "strict_error", cfg.strictError, "require that compile-time errors are distinguished from runtime errors")
flag.BoolVar(&cfg.json, "json", cfg.json, "return results as JSON to stdout")
flag.BoolVar(&cfg.proto, "proto", cfg.proto, "return results as binary serialized proto to stdout")
flag.BoolVar(&cfg.dump, "dump", cfg.dump, "output the expected results, without a command")
Expand Down
2 changes: 1 addition & 1 deletion tools/protovalidate-conformance/internal/results/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (c compilationErrorResult) IsSuccessWith(other Result, options *harness.Res
case compilationErrorResult:
return true
case runtimeErrorResult:
return !options.Strict
return !options.StrictError
default:
return false
}
Expand Down
1 change: 1 addition & 0 deletions tools/protovalidate-conformance/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func main() {
Verbose: cfg.verbose,
Strict: cfg.strict,
StrictMessage: cfg.strictMessage,
StrictError: cfg.strictError,
}
resultSet := &results.Set{
Options: options,
Expand Down

0 comments on commit 38af593

Please sign in to comment.