mirror of
https://github.com/walles/moar.git
synced 2024-11-30 02:34:13 +03:00
Pass one integration test
This commit is contained in:
parent
680045fbc1
commit
0029c2de0f
2
go.mod
2
go.mod
@ -2,4 +2,4 @@ module github.com/walles/moar
|
||||
|
||||
go 1.12
|
||||
|
||||
require rsc.io/quote v1.5.2
|
||||
require golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5
|
||||
|
12
go.sum
12
go.sum
@ -1,6 +1,10 @@
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5 h1:58fnuSXlxZmFdJyvtTFVmVhcMLU6v5fEb/ok4wyqtNU=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
rsc.io/quote v1.5.2 h1:w5fcysjrx7yqtD/aO+QwRjYZOKnaM9Uh2b40tElTs3Y=
|
||||
rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0=
|
||||
rsc.io/sampler v1.3.0 h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=
|
||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
|
@ -4,14 +4,14 @@
|
||||
|
||||
set -e -o pipefail
|
||||
|
||||
echo Test redirecting a file by name into file by redirecting stdout...
|
||||
RESULT="$(mktemp)"
|
||||
./moar moar.go > "$RESULT"
|
||||
diff -u moar.go "$RESULT"
|
||||
rm "$RESULT"
|
||||
|
||||
echo Test reading from redirected stdin, writing to redirected stdout...
|
||||
RESULT="$(mktemp)"
|
||||
./moar < moar.go > "$RESULT"
|
||||
diff -u moar.go "$RESULT"
|
||||
rm "$RESULT"
|
||||
|
||||
echo Test redirecting a file by name into file by redirecting stdout...
|
||||
RESULT="$(mktemp)"
|
||||
./moar moar.go > "$RESULT"
|
||||
diff -u moar.go "$RESULT"
|
||||
rm "$RESULT"
|
||||
|
16
moar.go
16
moar.go
@ -1,10 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"rsc.io/quote"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(quote.Hello())
|
||||
// If stdin is a non-TTY and stdout is a non-TTY, just pump
|
||||
stdinIsRedirected := !terminal.IsTerminal(int(os.Stdin.Fd()))
|
||||
stdoutIsRedirected := !terminal.IsTerminal(int(os.Stdout.Fd()))
|
||||
if stdinIsRedirected && stdoutIsRedirected {
|
||||
io.Copy(os.Stdout, os.Stdin)
|
||||
}
|
||||
|
||||
// FIXME: If first arg is a file name and stdout is a non-TTY, pump file onto stdout
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user