-
Notifications
You must be signed in to change notification settings - Fork 40
Add ability to pass arbitrary arguments to go test
#26
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,9 @@ | |
package main | ||
|
||
import ( | ||
"flag" | ||
"log" | ||
"os" | ||
"strconv" | ||
|
||
"github.com/nathany/looper/gat" | ||
) | ||
|
@@ -43,15 +44,14 @@ out: | |
} | ||
|
||
func main() { | ||
var tags string | ||
var debug bool | ||
flag.StringVar(&tags, "tags", "", "a list of build tags for testing.") | ||
flag.BoolVar(&debug, "debug", false, "adds additional logging") | ||
flag.Parse() | ||
// Get debug status from env var, if error ignore and debug is off | ||
debug, _ := strconv.ParseBool(os.Getenv("LOOPER_DEBUG")) | ||
|
||
runner := gat.Run{Tags: tags} | ||
// Pass all args to go test, except the name of the looper command | ||
gtargs := os.Args[1:len(os.Args)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is "gt"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I have already fixed
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. args sounds good. thanks |
||
runner := gat.Run{Args: gtargs} | ||
|
||
Header() | ||
Header(gtargs) | ||
if debug { | ||
DebugEnabled() | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,17 @@ import ( | |
"github.com/koyachi/go-term-ansicolor/ansicolor" | ||
) | ||
|
||
func Header() { | ||
fmt.Println(ansicolor.Cyan("Looper 0.3.2 is watching your files")) | ||
func Header(gtargs []string) { | ||
fmt.Println(ansicolor.Cyan("Looper 0.3.4 is watching your files")) | ||
|
||
if len(gtargs) > 0 { | ||
fmt.Printf(ansicolor.Green("Passing %d addition argument(s) to go test:\n"), len(gtargs)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure about this. It seems pretty verbose (multiple lines). Also, don't we already show the full command when it actually executes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It can be removed. It was mostly a leftover from the first commit that still had differing Now that they are all being passed to go test I see no reason to keep this output, which would also revert the method signature to be the same as it was before I tinkered with it. |
||
for _, arg := range gtargs { | ||
fmt.Printf(ansicolor.Green(" %s\n"), arg) | ||
} | ||
fmt.Println(ansicolor.Green(" <files>")) | ||
} | ||
|
||
fmt.Println("Type " + ansicolor.Magenta("help") + " for help.\n") | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious. Any specific reason to use
{}
as a placeholder?