From 20bbd0b1cc81e6c5a7c32a3f8e61358a8f51c43e Mon Sep 17 00:00:00 2001 From: wenovus Date: Mon, 27 Sep 2021 11:18:03 -0700 Subject: [PATCH] Improve error message for goyang-ygot and failed validator executions (on test.sh). --- cmd_gen/main.go | 4 ++-- cmd_gen/main_test.go | 4 ++-- post_results/main.go | 9 +++++++-- post_results/main_test.go | 6 ++++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/cmd_gen/main.go b/cmd_gen/main.go index cf56334..ee506e2 100644 --- a/cmd_gen/main.go +++ b/cmd_gen/main.go @@ -226,9 +226,9 @@ function run-dir() { status=0 $cmd "${options[@]}" "${script_options[@]}" "$@" &> ${prefix}pass || status=1 cd "$outdir" - go get &> ${prefix}pass || status=1 + go get &>> ${prefix}pass || status=1 if [[ $status -eq "0" ]]; then - go build &> ${prefix}pass || status=1 + go build &>> ${prefix}pass || status=1 fi if [[ $status -eq "1" ]]; then mv ${prefix}pass ${prefix}fail diff --git a/cmd_gen/main_test.go b/cmd_gen/main_test.go index c50a289..2a30917 100644 --- a/cmd_gen/main_test.go +++ b/cmd_gen/main_test.go @@ -196,9 +196,9 @@ function run-dir() { status=0 $cmd "${options[@]}" "${script_options[@]}" "$@" &> ${prefix}pass || status=1 cd "$outdir" - go get &> ${prefix}pass || status=1 + go get &>> ${prefix}pass || status=1 if [[ $status -eq "0" ]]; then - go build &> ${prefix}pass || status=1 + go build &>> ${prefix}pass || status=1 fi if [[ $status -eq "1" ]]; then mv ${prefix}pass ${prefix}fail diff --git a/post_results/main.go b/post_results/main.go index 5673b05..c05cff3 100644 --- a/post_results/main.go +++ b/post_results/main.go @@ -97,6 +97,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("
  • "+format+"
  • \n", a...) @@ -471,11 +475,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 = sprintSummaryHTML("cmd", "bash command", "
    %s
    ", bashCommand) } + // Also display the error string. modelHTML.WriteString(sprintSummaryHTML(status, modelName, bashCommandSummary+outString)) } } @@ -520,7 +525,7 @@ func getResult(validatorId, resultsDir string, condensed bool) (string, bool, er } // 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": diff --git a/post_results/main_test.go b/post_results/main_test.go index 5a1adb8..9849fce 100644 --- a/post_results/main_test.go +++ b/post_results/main_test.go @@ -250,7 +250,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", @@ -441,7 +443,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",