summaryrefslogtreecommitdiff
path: root/cmd/planr
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/planr')
-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,
));
}