From 41a7ab324fac720c6d8820af58dfa565131db669 Mon Sep 17 00:00:00 2001 From: "Sean E. Russell" Date: Mon, 2 Mar 2020 09:09:17 -0600 Subject: [PATCH] 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. --- cmd/gotop/main.go | 22 ++++++++++++++++++---- config.go | 2 ++ docs/releasing.md | 16 ++++++++-------- 3 files changed, 28 insertions(+), 12 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 +} diff --git a/config.go b/config.go index 272a376..d072dee 100644 --- a/config.go +++ b/config.go @@ -32,6 +32,8 @@ type Config struct { MaxLogSize int64 ExportPort string Extensions []string + + Test bool } func Parse(in io.Reader, conf *Config) error { diff --git a/docs/releasing.md b/docs/releasing.md index 622f561..643bc9f 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -5,12 +5,12 @@ Current steps for a release: 2. Update CHANGELOG.md 3. Tag 4. Push everything -5. ./make.sh -6. Create github release +5. When the github workflows complete, finish the draft release and publish. +6. After the [Homebrew](https://github.com/xxxserxxx/homebrew-gotop) and [AUR](https://github.com/xxxserxxx/gotop-linux] projects are done, check out gotop-linux and run `aurpublish aur` and `aurpublish aur-bin` -### Homebrew -1. Change homebrew-gotop -``` -curl --output - -L https://github.com/xxxserxxx/gotop/releases/download/v3.3.2/gotop_3.3.2_linux_amd64.tgz | sha256sum -curl --output - -L https://github.com/xxxserxxx/gotop/releases/download/v3.3.2/gotop_3.3.2_darwin_amd64.tgz | sha256sum -``` + +Homebrew is automatically updated. The AUR project still needs secret +credentials to aurpublish to the AUR repository, so the final publish step is +still currently manual. + +Oh, what a tangled web.