Skip to content

Commit

Permalink
Merge pull request #8513 from petermattis/pmattis/forbidden-imports-log
Browse files Browse the repository at this point in the history
build: use a tmp file for forbidden.log
  • Loading branch information
petermattis authored Aug 14, 2016
2 parents b44ebfb + 129832b commit 00354c9
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions build/check-style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,31 @@ TestTabsInShellScripts() {

TestForbiddenImports() {
echo "checking for forbidden imports"
local log=$(mktemp -t test-forbidden-imports.XXXXXX)
trap "rm -f ${log}" EXIT

go list -f '{{ $ip := .ImportPath }}{{ range .Imports}}{{ $ip }}: {{ println . }}{{end}}{{ range .TestImports}}{{ $ip }}: {{ println . }}{{end}}{{ range .XTestImports}}{{ $ip }}: {{ println . }}{{end}}' "$PKG" | \
grep -E ' (github.com/golang/protobuf/proto|github.com/satori/go\.uuid|log|path|context)$' | \
grep -vE 'cockroach/(base|security|util/(log|randutil|stop)): log$' | \
grep -vE 'cockroach/(server/serverpb|ts/tspb): github.com/golang/protobuf/proto$' | \
grep -vF 'util/uuid: github.com/satori/go.uuid' | tee forbidden.log; \
if grep -E ' path$' forbidden.log > /dev/null; then \
grep -vF 'util/uuid: github.com/satori/go.uuid' | tee ${log}; \
if grep -E ' path$' ${log} > /dev/null; then \
echo; echo "Please use 'path/filepath' instead of 'path'."; echo; \
fi; \
if grep -E ' log$' forbidden.log > /dev/null; then \
if grep -E ' log$' ${log} > /dev/null; then \
echo; echo "Please use 'util/log' instead of 'log'."; echo; \
fi; \
if grep -E ' github.com/golang/protobuf/proto$' forbidden.log > /dev/null; then \
if grep -E ' github.com/golang/protobuf/proto$' ${log} > /dev/null; then \
echo; echo "Please use 'gogo/protobuf/proto' instead of 'golang/protobuf/proto'."; echo; \
fi; \
if grep -E ' github.com/satori/go\.uuid$' forbidden.log > /dev/null; then \
if grep -E ' github.com/satori/go\.uuid$' ${log} > /dev/null; then \
echo; echo "Please use 'util/uuid' instead of 'satori/go.uuid'."; echo; \
fi; \
if grep -E ' context$' forbidden.log > /dev/null; then \
if grep -E ' context$' ${log} > /dev/null; then \
echo; echo "Please use 'golang.org/x/net/context' instead of 'context'."; echo; \
fi; \
test ! -s forbidden.log
test ! -s ${log}
ret=$?
rm -f forbidden.log
return $ret
}

Expand Down Expand Up @@ -172,7 +174,7 @@ tests=$(declare -F|cut -d' ' -f3|grep '^Test'|grep "${TESTS-.}")
export -f runcheck
export -f $tests
if hash parallel 2>/dev/null; then
parallel runcheck {} ::: $tests || exit_status=$?
parallel -j4 runcheck {} ::: $tests || exit_status=$?
else
for i in $tests; do
check_status=0
Expand Down

0 comments on commit 00354c9

Please sign in to comment.