brew test

pull/15/head 1.0.1
Miguel Mota 6 years ago
parent 4c88b56dd3
commit 362987c1d8

@ -22,6 +22,9 @@ clean:
test:
go test ./...
cointop/test:
go run main.go -test
snap/clean:
snapcraft clean

@ -3,21 +3,18 @@ class Cointop < Formula
homepage "https://cointop.sh"
url "https://github.com/miguelmota/cointop/archive/1.0.0.tar.gz"
sha256 "8ff6988cd18b35dbf85436add19135a587e03702b43744f563f137bb067f6e04"
revision 1
head "https://github.com/miguelmota/cointop.git"
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
mkdir "#{buildpath}/src/github.com/miguelmota/cointop"
path = buildpath/"src/github.com/miguelmota/cointop"
cd path do
system "git", "clone", "https://github.com/miguelmota/cointop.git", "."
(buildpath/"src/github.com/miguelmota/cointop").install buildpath.children
cd "src/github.com/miguelmota/cointop" do
system "go", "build", "-o", "#{bin}/cointop"
prefix.install_metafiles
end
end
test do
system "true"
system "#{bin}/cointop" "-test"
end
end

@ -1,8 +1,6 @@
package cointop
import (
"flag"
"fmt"
"log"
"os"
"sync"
@ -60,15 +58,11 @@ type Cointop struct {
helpvisible bool
}
// Instance running cointop instance
var Instance *Cointop
// Run runs cointop
func Run() {
var ver bool
flag.BoolVar(&ver, "v", false, "Version")
flag.Parse()
if ver {
fmt.Println("1.0.0")
return
}
var debug bool
if os.Getenv("DEBUG") != "" {
debug = true
@ -95,6 +89,7 @@ func Run() {
searchfieldviewname: "searchfield",
helpviewname: "help",
}
Instance = &ct
err := ct.setupConfig()
if err != nil {
log.Fatal(err)
@ -140,3 +135,10 @@ func (ct *Cointop) quit() error {
func (ct *Cointop) forceQuit() error {
return gocui.ErrQuit
}
// Exit safely exit application
func Exit() {
if Instance != nil {
Instance.g.Close()
}
}

@ -1,9 +1,37 @@
package main
import (
"flag"
"fmt"
"time"
"github.com/miguelmota/cointop/cointop"
)
var version = "1.0.0"
func main() {
var ver bool
flag.BoolVar(&ver, "v", false, "Version")
var test bool
flag.BoolVar(&test, "test", false, "Run test")
flag.Parse()
if ver {
fmt.Println(version)
return
}
if test {
runTest()
return
}
cointop.Run()
}
func runTest() {
go func() {
cointop.Run()
}()
time.Sleep(1 * time.Second)
cointop.Exit()
}

Loading…
Cancel
Save