Skip to content

Commit

Permalink
Merge pull request #62 from openconfig/improve-error-msg
Browse files Browse the repository at this point in the history
Improve error message for goyang-ygot and failed validator executions (on test.sh).
  • Loading branch information
wenovus authored Aug 4, 2023
2 parents ff3c08b + aa1ed2f commit 0d9f3d1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
8 changes: 4 additions & 4 deletions cmd_gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function run-dir() {
status=0
$cmd "${options[@]}" "${script_options[@]}" "$@" &> ${prefix}pass || status=1
if [[ $status -eq "0" ]]; then
python "${output_file}" &> ${prefix}pass || status=1
python "${output_file}" &>> ${prefix}pass || status=1
fi
if [[ $status -eq "1" ]]; then
mv ${prefix}pass ${prefix}fail
Expand Down Expand Up @@ -236,9 +236,9 @@ function run-dir() {
$cmd "${options[@]}" "${script_options[@]}" "$@" &> ${prefix}pass || status=1
cd "$outdir"
if [[ $status -eq "0" ]]; then
go mod init &> ${prefix}pass || status=1
go mod tidy &> ${prefix}pass || status=1
go build &> ${prefix}pass || status=1
go mod init &>> ${prefix}pass || status=1
go mod tidy &>> ${prefix}pass || status=1
go build &>> ${prefix}pass || status=1
fi
if [[ $status -eq "1" ]]; then
mv ${prefix}pass ${prefix}fail
Expand Down
8 changes: 4 additions & 4 deletions cmd_gen/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function run-dir() {
status=0
$cmd "${options[@]}" "${script_options[@]}" "$@" &> ${prefix}pass || status=1
if [[ $status -eq "0" ]]; then
python "${output_file}" &> ${prefix}pass || status=1
python "${output_file}" &>> ${prefix}pass || status=1
fi
if [[ $status -eq "1" ]]; then
mv ${prefix}pass ${prefix}fail
Expand Down Expand Up @@ -206,9 +206,9 @@ function run-dir() {
$cmd "${options[@]}" "${script_options[@]}" "$@" &> ${prefix}pass || status=1
cd "$outdir"
if [[ $status -eq "0" ]]; then
go mod init &> ${prefix}pass || status=1
go mod tidy &> ${prefix}pass || status=1
go build &> ${prefix}pass || status=1
go mod init &>> ${prefix}pass || status=1
go mod tidy &>> ${prefix}pass || status=1
go build &>> ${prefix}pass || status=1
fi
if [[ $status -eq "1" ]]; then
mv ${prefix}pass ${prefix}fail
Expand Down
9 changes: 7 additions & 2 deletions post_results/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ func init() {
flag.StringVar(&version, "version", "", "(optional) specific version of the validator tool.")
}

func blockQuote(s string) string {
return "```\n" + s + "\n```"
}

// sprintLineHTML prints a single list item to be put under a top-level summary item.
func sprintLineHTML(format string, a ...interface{}) string {
return fmt.Sprintf(" <li>"+format+"</li>\n", a...)
Expand Down Expand Up @@ -440,11 +444,12 @@ func parseModelResultsHTML(validatorId, validatorResultDir string, condensed boo
}

if !condensed || !modelPass {
// Display bash command that produced the validator result.
// Display bash command that produced the validator result if it exists.
var bashCommandSummary string
if bashCommand != "" && bashCommandModelDirName == modelDirName && bashCommandModelName == modelName {
bashCommandSummary = fmt.Sprintf("%s&nbsp; %s\n<pre>%s</pre>\n", commonci.Emoji("cmd"), "bash command", bashCommand)
}
// Also display the error string.
modelHTML.WriteString(sprintSummaryHTML(status, modelName, bashCommandSummary+outString))
}
}
Expand Down Expand Up @@ -496,7 +501,7 @@ func getResult(validatorId, resultsDir string, condensed bool) (string, bool, ve
}
// For per-model validators, an execution failure suggests a CI infra failure.
if validator.IsPerModel {
outString = "Validator script failed -- infra bug?\n" + outString
outString = fmt.Sprintf("Validator script failed -- infra bug?\n%s", blockQuote(outString))
}
pass = false
case validator.IsPerModel && validatorId == "misc-checks":
Expand Down
6 changes: 4 additions & 2 deletions post_results/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@ Passed.
inValidatorId: "oc-pyang",
wantPass: false,
wantOut: `Validator script failed -- infra bug?
Test failed with no stderr output.`,
` + "```" + `
Test failed with no stderr output.
` + "```",
wantCondensedOutSame: true,
}, {
name: "basic non-pyang pass",
Expand Down Expand Up @@ -510,7 +512,7 @@ Failed.
inValidatorResultDir: "testdata/oc-pyang-script-fail",
inValidatorId: "oc-pyang",
wantPass: false,
wantOut: "Validator script failed -- infra bug?\nI failed\n",
wantOut: "Validator script failed -- infra bug?\n```\nI failed\n\n```",
wantCondensedOutSame: true,
}, {
name: "openconfig-version, revision version, and .spec.yml checks all pass",
Expand Down

0 comments on commit 0d9f3d1

Please sign in to comment.