aboutsummaryrefslogtreecommitdiff
path: root/cmd/planr/sub/cli.go
diff options
context:
space:
mode:
authorFlu0r1ne <flur01ne@flu0r1ne.net>2021-08-13 18:15:26 -0500
committerFlu0r1ne <flur01ne@flu0r1ne.net>2021-08-13 18:15:26 -0500
commit4a808e5c97725b0fb4174b6961722a3f4600b9a7 (patch)
tree5049e4ebd351fa17bde8706594383b2a70a42c33 /cmd/planr/sub/cli.go
parent9954b5fa87f74c035739159f4bb831900e5e35be (diff)
downloadplanr-4a808e5c97725b0fb4174b6961722a3f4600b9a7.tar.xz
planr-4a808e5c97725b0fb4174b6961722a3f4600b9a7.zip
Clean up fencing
Diffstat (limited to 'cmd/planr/sub/cli.go')
-rw-r--r--cmd/planr/sub/cli.go53
1 files changed, 27 insertions, 26 deletions
diff --git a/cmd/planr/sub/cli.go b/cmd/planr/sub/cli.go
index 2bcaed9..da888d9 100644
--- a/cmd/planr/sub/cli.go
+++ b/cmd/planr/sub/cli.go
@@ -4,6 +4,7 @@ import (
"github.com/fatih/color"
"golang.flu0r1ne.net/planr"
"fmt"
+ "strings"
)
var (
@@ -43,31 +44,19 @@ func pprintLabeled(label, value string) {
}
const (
- FENCE_WIDTH = 80
+ FENCE_WIDTH = 78
)
func pprintFenced(title, value string) {
wingWidth := FENCE_WIDTH - len(title) - 2
+ wing := strings.Repeat("-", wingWidth / 2)
+ fence := strings.Repeat("-", FENCE_WIDTH)
- for i := 0; i < wingWidth / 2; i++ {
- fmt.Print("-")
- }
-
- fmt.Printf(" %s ", title)
+ fmt.Printf(" %s %s %s\n", wing, title, wing)
- for i := 0; i < wingWidth / 2; i++ {
- fmt.Print("-")
- }
-
- fmt.Println()
-
- fmt.Print(value)
+ fmt.Print(" " + strings.ReplaceAll(value, "\n", "\n "))
- for i := 0; i < FENCE_WIDTH; i++ {
- fmt.Print("-")
- }
-
- fmt.Println()
+ fmt.Println(fence)
}
func tcStatusLine(tc planr.TestCase) {
@@ -95,14 +84,24 @@ func tcPprint(tc planr.TestCase) {
pprintLabeled("description", *tc.Config.Description)
}
- if tc.Result.DebugOutput != "" {
- fmt.Println()
- pprintFenced("compilation output", tc.Result.DebugOutput);
- }
+ res := tc.Result
+
+ if res.Status == planr.COMPILATION_FAILURE {
+
+ if res.DebugOutput != "" {
+ fmt.Println()
+ pprintFenced("compilation output", tc.Result.DebugOutput);
+ } else {
+ fmt.Println("WARN: No debug output provided")
+ }
- if tc.Result.FailureMsg != "" {
- fmt.Println()
- pprintFenced("test output", tc.Result.FailureMsg);
+ } else if res.Status == planr.RUNTIME_FAILURE {
+
+ if tc.Result.FailureMsg != "" {
+ fmt.Println()
+ pprintFenced("test output", tc.Result.FailureMsg);
+ }
+
}
fmt.Println()
@@ -113,7 +112,9 @@ func printResults(passed, tc_total int, earned, points_total float64) {
pprintLabeled("passed", fmt.Sprintf("%d/%d", passed, tc_total));
+ percent := earned / points_total * 100
+
pprintLabeled("score", fmt.Sprintf(
- "%.2f/%.2f ~= %.1f%%", earned, points_total, earned / points_total * 100,
+ "%.2f/%.2f ~= %.1f%%", earned, points_total, percent,
));
}