aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--golings/cmd/root.go8
-rw-r--r--golings/cmd/verify.go10
-rw-r--r--golings/exercises/exercises_suite_test.go3
3 files changed, 17 insertions, 4 deletions
diff --git a/golings/cmd/root.go b/golings/cmd/root.go
index 9f40c16..4d0880a 100644
--- a/golings/cmd/root.go
+++ b/golings/cmd/root.go
@@ -1,6 +1,9 @@
package cmd
import (
+ "fmt"
+ "os"
+
"github.com/spf13/cobra"
)
@@ -20,5 +23,8 @@ func NewRootCmd(version string) *cobra.Command {
}
func Execute(version string) {
- NewRootCmd(version).Execute()
+ if err := NewRootCmd(version).Execute(); err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
}
diff --git a/golings/cmd/verify.go b/golings/cmd/verify.go
index 0d6017c..6e1e341 100644
--- a/golings/cmd/verify.go
+++ b/golings/cmd/verify.go
@@ -35,12 +35,18 @@ var cmdVerify = &cobra.Command{
BarEnd: "]",
}),
)
- bar.RenderBlank()
+ if err := bar.RenderBlank(); err != nil {
+ color.Red(err.Error())
+ os.Exit(1)
+ }
for _, e := range exs {
bar.Describe(fmt.Sprintf("Running %s", e.Name))
result, _ := exercises.Run(e.Name, "info.toml")
- bar.Add(1)
+ if err := bar.Add(1); err != nil {
+ color.Red(err.Error())
+ os.Exit(1)
+ }
if result.Err != "" {
fmt.Print("\n\n")
color.Cyan("Failed to compile the exercise %s\n\n", e.Path)
diff --git a/golings/exercises/exercises_suite_test.go b/golings/exercises/exercises_suite_test.go
index 1d94056..8ab45db 100644
--- a/golings/exercises/exercises_suite_test.go
+++ b/golings/exercises/exercises_suite_test.go
@@ -19,7 +19,8 @@ var _ = Describe("Exercises", func() {
When("'I AM NOT DONE' comment is still there", func() {
It("has the Pending state", func() {
file, err := os.CreateTemp("/tmp", "exercise*.go")
- file.Write([]byte(`// exercise1.go
+ Expect(err).NotTo(HaveOccurred())
+ _, err = file.Write([]byte(`// exercise1.go
// I AM NOT DONE
package main