mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #7688 from heyitsanthony/short-mask
test: fix fmt pass, shorten warnings, clear SA1016
This commit is contained in:
commit
63bb560820
@ -18,6 +18,7 @@ import (
|
||||
"errors"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/coreos/etcd/clientv3"
|
||||
"github.com/coreos/etcd/clientv3/concurrency"
|
||||
@ -73,7 +74,7 @@ func observe(c *clientv3.Client, election string) error {
|
||||
|
||||
donec := make(chan struct{})
|
||||
sigc := make(chan os.Signal, 1)
|
||||
signal.Notify(sigc, os.Interrupt, os.Kill)
|
||||
signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-sigc
|
||||
cancel()
|
||||
@ -107,7 +108,7 @@ func campaign(c *clientv3.Client, election string, prop string) error {
|
||||
|
||||
donec := make(chan struct{})
|
||||
sigc := make(chan os.Signal, 1)
|
||||
signal.Notify(sigc, os.Interrupt, os.Kill)
|
||||
signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-sigc
|
||||
cancel()
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
"errors"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/coreos/etcd/clientv3"
|
||||
"github.com/coreos/etcd/clientv3/concurrency"
|
||||
@ -57,7 +58,7 @@ func lockUntilSignal(c *clientv3.Client, lockname string) error {
|
||||
// unlock in case of ordinary shutdown
|
||||
donec := make(chan struct{})
|
||||
sigc := make(chan os.Signal, 1)
|
||||
signal.Notify(sigc, os.Interrupt, os.Kill)
|
||||
signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-sigc
|
||||
cancel()
|
||||
|
@ -29,7 +29,7 @@ func TestMain(t *testing.T) {
|
||||
}
|
||||
|
||||
notifier := make(chan os.Signal, 1)
|
||||
signal.Notify(notifier, syscall.SIGINT, syscall.SIGTERM, syscall.SIGKILL)
|
||||
signal.Notify(notifier, syscall.SIGINT, syscall.SIGTERM)
|
||||
go main()
|
||||
<-notifier
|
||||
}
|
||||
|
@ -150,7 +150,10 @@ func TestURLsEqual(t *testing.T) {
|
||||
"second.com": "10.0.11.2",
|
||||
}
|
||||
resolveTCPAddr = func(network, addr string) (*net.TCPAddr, error) {
|
||||
host, port, err := net.SplitHostPort(addr)
|
||||
host, port, herr := net.SplitHostPort(addr)
|
||||
if herr != nil {
|
||||
return nil, herr
|
||||
}
|
||||
if _, ok := hostm[host]; !ok {
|
||||
return nil, errors.New("cannot resolve host.")
|
||||
}
|
||||
|
41
test
41
test
@ -250,16 +250,15 @@ function fmt_pass {
|
||||
if which gosimple >/dev/null; then
|
||||
echo "Checking gosimple..."
|
||||
gosimpleResult=`gosimple ${STATIC_ANALYSIS_PATHS} 2>&1 || true`
|
||||
if [ ! -n "${gosimpleResult}" ]; then
|
||||
continue
|
||||
fi
|
||||
# TODO: resolve these after go1.8 migration
|
||||
SIMPLE_CHECK_MASK="S(1024)"
|
||||
if egrep -v "$SIMPLE_CHECK_MASK" "${gosimpleResult}"; then
|
||||
echo -e "gosimple checking ${path} failed:\n${gosimpleResult}"
|
||||
exit 255
|
||||
else
|
||||
echo -e "gosimple warning:\n${gosimpleResult}"
|
||||
if [ -n "${gosimpleResult}" ]; then
|
||||
# TODO: resolve these after go1.8 migration
|
||||
SIMPLE_CHECK_MASK="S(1024)"
|
||||
if echo "${gosimpleResult}" | egrep -v "$SIMPLE_CHECK_MASK"; then
|
||||
echo -e "gosimple checking ${path} failed:\n${gosimpleResult}"
|
||||
exit 255
|
||||
else
|
||||
echo -e "gosimple warning:\n${gosimpleResult}"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Skipping gosimple..."
|
||||
@ -279,17 +278,17 @@ function fmt_pass {
|
||||
if which staticcheck >/dev/null; then
|
||||
echo "Checking staticcheck..."
|
||||
staticcheckResult=`staticcheck ${STATIC_ANALYSIS_PATHS} 2>&1 || true`
|
||||
if [ ! -n "${staticcheckResult}" ]; then
|
||||
continue
|
||||
fi
|
||||
# TODO: resolve these after go1.8 migration
|
||||
# See https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck
|
||||
STATIC_CHECK_MASK="SA(1016|1019|2002)"
|
||||
if egrep -v "$STATIC_CHECK_MASK" "${staticcheckResult}"; then
|
||||
echo -e "staticcheck checking ${path} failed:\n${staticcheckResult}"
|
||||
exit 255
|
||||
else
|
||||
echo -e "staticcheck warning:\n${staticcheckResult}"
|
||||
if [ -n "${staticcheckResult}" ]; then
|
||||
# TODO: resolve these after go1.8 migration
|
||||
# See https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck
|
||||
STATIC_CHECK_MASK="SA(1019|2002)"
|
||||
if echo "${staticcheckResult}" | egrep -v "$STATIC_CHECK_MASK"; then
|
||||
echo -e "staticcheck checking ${path} failed:\n${staticcheckResult}"
|
||||
exit 255
|
||||
else
|
||||
suppressed=`echo "${staticcheckResult}" | sed 's/ /\n/g' | grep "(SA" | sort | uniq -c`
|
||||
echo -e "staticcheck suppressed warnings:\n${suppressed}"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Skipping staticcheck..."
|
||||
|
Loading…
x
Reference in New Issue
Block a user