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.

This commit is contained in:
Sean E. Russell 2020-03-02 09:09:17 -06:00
parent b5e451b225
commit 41a7ab324f
3 changed files with 28 additions and 12 deletions

View File

@ -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
}

View File

@ -32,6 +32,8 @@ type Config struct {
MaxLogSize int64
ExportPort string
Extensions []string
Test bool
}
func Parse(in io.Reader, conf *Config) error {

View File

@ -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.