diff --git a/.travis.yml b/.travis.yml index 564728a..d846b4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,10 +3,9 @@ go_import_path: github.com/kardianos/service sudo: required go: - - 1.6.x - - 1.7.x - 1.8.x - 1.9.x + - "1.10" - master before_install: diff --git a/service_su_test.go b/service_su_test.go index 031a6fb..74eca3d 100644 --- a/service_su_test.go +++ b/service_su_test.go @@ -8,6 +8,7 @@ package service_test import ( + "flag" "fmt" "io/ioutil" "log" @@ -23,17 +24,18 @@ import ( const runAsServiceArg = "RunThisAsService" func TestMain(m *testing.M) { - if len(os.Args) == 2 { + reportDir := flag.String("su.reportDir", "", "") + runAsService := flag.Bool("su.runAsService", false, "") + flag.Parse() + if !*runAsService { os.Exit(m.Run()) - } else if len(os.Args) == 4 && os.Args[2] == runAsServiceArg { - reportDir := os.Args[3] - writeReport(reportDir, "call") - runService() - writeReport(reportDir, "finished") - os.Exit(0) } - - log.Fatalf("Invalid arguments: %v", os.Args) + if len(*reportDir) == 0 { + log.Fatal("missing su.reportDir argument") + } + writeReport(*reportDir, "call") + runService() + writeReport(*reportDir, "finished") } func TestInstallRunRestartStopRemove(t *testing.T) { @@ -168,7 +170,7 @@ func mustNewRunAsService( ) service.Service { sc := &service.Config{ Name: "go_service_test", - Arguments: []string{"-test.v=true", runAsServiceArg, reportDir}, + Arguments: []string{"-test.v=true", "-su.runAsService", "-su.reportDir", reportDir}, } s, err := service.New(p, sc) if err != nil {