Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run integration and unit tests separately
- Loading branch information
Showing
5 changed files
with
113 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"flag" | ||
"fmt" | ||
"io" | ||
"os" | ||
"os/exec" | ||
"os/signal" | ||
"syscall" | ||
) | ||
|
||
func main() { | ||
var ( | ||
pre = flag.String("prefix", "", "A string to prefix stdout/stderr with.") | ||
) | ||
flag.Parse() | ||
args := flag.Args() | ||
cmd := exec.Command(args[0], args[1:]...) | ||
cmd.Stdout = prefix(os.Stdout, *pre) | ||
cmd.Stderr = prefix(os.Stderr, *pre) | ||
cmd.Stdin = os.Stdin | ||
|
||
err := cmd.Start() | ||
must(err) | ||
|
||
ch := make(chan os.Signal) | ||
signal.Notify(ch) | ||
go func() { | ||
for sig := range ch { | ||
cmd.Process.Signal(sig) | ||
} | ||
}() | ||
|
||
err = cmd.Wait() | ||
if exiterr, ok := err.(*exec.ExitError); ok { | ||
if status, ok := exiterr.ProcessState.Sys().(syscall.WaitStatus); ok { | ||
os.Exit(status.ExitStatus()) | ||
} | ||
} | ||
must(err) | ||
} | ||
|
||
func must(err error) { | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "err: %v\n", err) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
// prefixWriter wraps an io.Writer to append a prefix to each line written. | ||
type prefixWriter struct { | ||
prefix []byte | ||
|
||
// The underlying io.Writer where prefixed lines will be written. | ||
w io.Writer | ||
|
||
// Buffer to hold the last line, which doesn't have a newline yet. | ||
b []byte | ||
} | ||
|
||
func prefix(w io.Writer, prefix string) io.Writer { | ||
if w == nil { | ||
return w | ||
} | ||
return &prefixWriter{ | ||
prefix: []byte(prefix), | ||
w: w, | ||
} | ||
} | ||
|
||
func (w *prefixWriter) Write(b []byte) (int, error) { | ||
p := b | ||
for { | ||
i := bytes.IndexRune(p, '\n') | ||
|
||
if i >= 0 { | ||
w.b = append(w.b, p[:i+1]...) | ||
p = p[i+1:] | ||
_, err := w.w.Write(append(w.prefix, w.b...)) | ||
w.b = nil | ||
if err != nil { | ||
return len(b), err | ||
} | ||
continue | ||
} | ||
|
||
w.b = append(w.b, p...) | ||
break | ||
} | ||
return len(b), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
deps() { | ||
echo bundled | ||
echo 110-compile/all | ||
echo 111-compile/all | ||
echo 200-frontend/all | ||
echo 300-docker/all | ||
} | ||
|
||
case $1 in | ||
deps) deps ;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#!/bin/bash | ||
|
||
target=$1 | ||
|
||
deps() { | ||
find .. -type f -iname '*.go' | ||
} | ||
|