From 3337257fe24b67871406217e98862d34647dd725 Mon Sep 17 00:00:00 2001
From: Flu0r1ne <flur01ne@flu0r1ne.net>
Date: Fri, 13 Aug 2021 16:31:04 -0500
Subject: Add colorized output and build traces

---
 cmd/planr/sub/cli.go      | 89 +++++++++++++++++++++++++++++++++++++++++++++++
 cmd/planr/sub/evaluate.go | 40 +++++++--------------
 2 files changed, 102 insertions(+), 27 deletions(-)
 create mode 100644 cmd/planr/sub/cli.go

(limited to 'cmd/planr/sub')

diff --git a/cmd/planr/sub/cli.go b/cmd/planr/sub/cli.go
new file mode 100644
index 0000000..42d1c81
--- /dev/null
+++ b/cmd/planr/sub/cli.go
@@ -0,0 +1,89 @@
+package sub
+
+import (
+	"github.com/fatih/color"
+	"golang.flu0r1ne.net/planr"
+        "fmt"
+)
+
+var (
+  col_pass = color.New(color.FgGreen)
+  col_fail = color.New(color.FgRed)
+  col_title = color.New(color.FgHiWhite)
+  col_label = color.New(color.FgCyan)
+);
+
+func tcTitle(tc planr.TestCase) string {
+  title := tc.Cname
+
+  if tc.Config.Title != nil {
+    title = *tc.Config.Title
+  }
+
+  return title
+}
+
+func tcStatus(tc planr.TestCase) string {
+    status := "SILENT"
+
+    if tc.Result != nil {
+      if tc.Result.Status == planr.PASSING {
+        status = "PASS"
+      } else {
+        status = "FAIL"
+      }
+    }
+
+    return status
+}
+
+func pprintLabeled(label, value string) {
+  col_label.Printf("  %s: ", label)
+  fmt.Println(value)
+}
+
+func tcStatusLine(tc planr.TestCase) {
+  title  := tcTitle(tc)
+  status := tcStatus(tc)
+
+  if status == "PASS" {
+    col_pass.Printf("[%s] ", status);
+  } else {
+    col_fail.Printf("[%s] ", status);
+  }
+
+  col_title.Println(title);  
+}
+
+func tcPprint(tc planr.TestCase) {
+  tcStatusLine(tc)
+
+  if tc.Config.Points != nil {
+    points := fmt.Sprintf("%.1f", *tc.Config.Points)
+    pprintLabeled("points", points)
+  }
+
+  if tc.Config.Description != nil {
+    pprintLabeled("description", *tc.Config.Description)
+  }
+
+  if tc.Result.DebugOutput != "" {
+    pprintLabeled("debug output", tc.Result.DebugOutput)
+  }
+
+  if tc.Result.FailureMsg != "" {
+    pprintLabeled("failure", tc.Result.FailureMsg);
+  }
+
+  fmt.Println()
+}
+
+func printResults(passed, tc_total int, earned, points_total float64) {
+  col_title.Println("Final Results:")
+  
+  pprintLabeled("passed", fmt.Sprintf("%d/%d", passed, tc_total));
+
+  pprintLabeled("score", fmt.Sprintf(
+    "%.2f/%.2f ~= %.1f%%", earned, points_total, earned / points_total * 100,
+  ));
+}
diff --git a/cmd/planr/sub/evaluate.go b/cmd/planr/sub/evaluate.go
index 1174b3f..8ce4d81 100644
--- a/cmd/planr/sub/evaluate.go
+++ b/cmd/planr/sub/evaluate.go
@@ -1,7 +1,6 @@
 package sub
 
 import (
-  "fmt"
   "golang.flu0r1ne.net/planr"
 )
 
@@ -10,43 +9,30 @@ func Evaluate(params []string) {
 
   tcs := Runner().Evaluate(rd)
 
-  fmt.Printf("\n\nREPORT:\n=======\n\n")
-
   earned := 0.0
   total  := 0.0
+  passed := 0
   for _, tc := range tcs {
     cfg := tc.Config
-  
-    name := tc.Cname
-    if cfg.Title != nil {
-      name = *cfg.Title
-    }
 
-    var points float64 =  0.0
     if cfg.Points != nil {
-      points = float64(*cfg.Points)
-    }
+      points := float64(*cfg.Points)
+
+      total += points
 
-    status := "SILENT"
-    if tc.Result != nil {
-      if tc.Result.Pass {
-        status = "PASS"
+      if tc.Result.Status == planr.PASSING {
         earned += points
-      } else {
-        status = "FAIL"
+        passed++
       }
     }
 
-    total += points
-
-    fmt.Printf("[%s] %s (%f)\n", status, name, points)
-
-    if cfg.Description != nil {
-      fmt.Printf("> %s\n", *cfg.Description)
-    }
-
-    fmt.Println()
+    tcPprint(tc)
   }
 
-  fmt.Printf("Score: %f (%f%%)\n", earned, (earned / total) * 100)
+  printResults(
+    passed,
+    len(tcs),
+    earned,
+    total,
+  );
 }
-- 
cgit v1.2.3


From 9954b5fa87f74c035739159f4bb831900e5e35be Mon Sep 17 00:00:00 2001
From: Flu0r1ne <flur01ne@flu0r1ne.net>
Date: Fri, 13 Aug 2021 17:03:57 -0500
Subject: Fenced test & compilation output

---
 cmd/planr/sub/cli.go | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

(limited to 'cmd/planr/sub')

diff --git a/cmd/planr/sub/cli.go b/cmd/planr/sub/cli.go
index 42d1c81..2bcaed9 100644
--- a/cmd/planr/sub/cli.go
+++ b/cmd/planr/sub/cli.go
@@ -42,6 +42,34 @@ func pprintLabeled(label, value string) {
   fmt.Println(value)
 }
 
+const (
+  FENCE_WIDTH = 80
+)
+
+func pprintFenced(title, value string) {
+  wingWidth := FENCE_WIDTH - len(title) - 2
+
+  for i := 0; i < wingWidth / 2; i++ {
+    fmt.Print("-")
+  }
+
+  fmt.Printf(" %s ", title)
+  
+  for i := 0; i < wingWidth / 2; i++ {
+    fmt.Print("-")
+  }
+
+  fmt.Println()
+
+  fmt.Print(value)
+
+  for i := 0; i < FENCE_WIDTH; i++ {
+    fmt.Print("-") 
+  }
+  
+  fmt.Println()
+}
+
 func tcStatusLine(tc planr.TestCase) {
   title  := tcTitle(tc)
   status := tcStatus(tc)
@@ -68,11 +96,13 @@ func tcPprint(tc planr.TestCase) {
   }
 
   if tc.Result.DebugOutput != "" {
-    pprintLabeled("debug output", tc.Result.DebugOutput)
+    fmt.Println()
+    pprintFenced("compilation output", tc.Result.DebugOutput);
   }
 
   if tc.Result.FailureMsg != "" {
-    pprintLabeled("failure", tc.Result.FailureMsg);
+    fmt.Println()
+    pprintFenced("test output", tc.Result.FailureMsg);
   }
 
   fmt.Println()
-- 
cgit v1.2.3


From 4a808e5c97725b0fb4174b6961722a3f4600b9a7 Mon Sep 17 00:00:00 2001
From: Flu0r1ne <flur01ne@flu0r1ne.net>
Date: Fri, 13 Aug 2021 18:15:26 -0500
Subject: Clean up fencing

---
 cmd/planr/sub/cli.go | 53 ++++++++++++++++++++++++++--------------------------
 1 file changed, 27 insertions(+), 26 deletions(-)

(limited to 'cmd/planr/sub')

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,
   ));
 }
-- 
cgit v1.2.3


From 5d33040ab80b5cce7883b2e5965aa17db2e6515a Mon Sep 17 00:00:00 2001
From: Flu0r1ne <flur01ne@flu0r1ne.net>
Date: Fri, 13 Aug 2021 18:25:17 -0500
Subject: Opt to show CLI output over JSON output

---
 cmd/planr/sub/cli.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'cmd/planr/sub')

diff --git a/cmd/planr/sub/cli.go b/cmd/planr/sub/cli.go
index da888d9..dff9089 100644
--- a/cmd/planr/sub/cli.go
+++ b/cmd/planr/sub/cli.go
@@ -97,9 +97,9 @@ func tcPprint(tc planr.TestCase) {
 
   } else if res.Status == planr.RUNTIME_FAILURE {
 
-    if tc.Result.FailureMsg != "" {
+    if tc.Result.TestOutput != "" {
       fmt.Println()
-      pprintFenced("test output", tc.Result.FailureMsg);
+      pprintFenced("test output", tc.Result.TestOutput);
     }
     
   }
-- 
cgit v1.2.3


From 24548e87decbdfea38bbf692cecad6d4eefc3ec0 Mon Sep 17 00:00:00 2001
From: Flu0r1ne <flur01ne@flu0r1ne.net>
Date: Sun, 22 Aug 2021 23:27:53 -0500
Subject: Refactoring & Enhanced logging

---
 cmd/planr/sub/cli.go | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'cmd/planr/sub')

diff --git a/cmd/planr/sub/cli.go b/cmd/planr/sub/cli.go
index dff9089..0e6a942 100644
--- a/cmd/planr/sub/cli.go
+++ b/cmd/planr/sub/cli.go
@@ -75,6 +75,8 @@ func tcStatusLine(tc planr.TestCase) {
 func tcPprint(tc planr.TestCase) {
   tcStatusLine(tc)
 
+  pprintLabeled("id", tc.Cname)
+
   if tc.Config.Points != nil {
     points := fmt.Sprintf("%.1f", *tc.Config.Points)
     pprintLabeled("points", points)
-- 
cgit v1.2.3