summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorSean E. Russell <ser@ser1.net>2020-03-02 09:09:17 -0600
committerSean E. Russell <ser@ser1.net>2020-03-02 09:58:03 -0600
commit41a7ab324fac720c6d8820af58dfa565131db669 (patch)
tree452fde6187c73283888ef95a0b05ea9f30516a42 /cmd
parentb5e451b22582b16f7334b39ff42050cb4e280ba4 (diff)
resolves #65 Runs tests. Currently, does everything short of initializing the UI, which means it runs the config and plugin code. Currently does not execute any dummy code, such as testing config files etc.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gotop/main.go22
1 files changed, 18 insertions, 4 deletions
diff --git a/cmd/gotop/main.go b/cmd/gotop/main.go
index d243531..9ae093f 100644
--- a/cmd/gotop/main.go
+++ b/cmd/gotop/main.go
@@ -71,6 +71,7 @@ Options:
-i, --interface=NAME Select network interface [default: all]. Several interfaces can be defined using comma separated values. Interfaces can also be ignored using !
-x, --export=PORT Enable metrics for export on the specified port.
-X, --extensions=NAMES Enables the listed extensions. This is a comma-separated list without the .so suffix. The current and config directories will be searched.
+ --test Runs tests and exits with success/failure code
Built-in layouts:
@@ -153,6 +154,9 @@ Colorschemes:
exs, _ := args["--extensions"].(string)
conf.Extensions = strings.Split(exs, ",")
}
+ if val, _ := args["--test"]; val != nil {
+ conf.Test = val.(bool)
+ }
return nil
}
@@ -386,6 +390,15 @@ func main() {
}
defer logfile.Close()
+ lstream := getLayout(conf)
+ ly := layout.ParseLayout(lstream)
+
+ loadExtensions(conf)
+
+ if conf.Test {
+ os.Exit(runTests(conf))
+ }
+
if err := ui.Init(); err != nil {
stderrLogger.Fatalf("failed to initialize termui: %v", err)
}
@@ -397,10 +410,6 @@ func main() {
bar = w.NewStatusBar()
}
- loadExtensions(conf)
-
- lstream := getLayout(conf)
- ly := layout.ParseLayout(lstream)
grid, err := layout.Layout(ly, conf)
if err != nil {
stderrLogger.Fatalf("failed to initialize termui: %v", err)
@@ -497,3 +506,8 @@ func loadExtensions(conf gotop.Config) {
os.Exit(1)
}
}
+
+func runTests(conf gotop.Config) int {
+ fmt.Printf("PASS")
+ return 0
+}