Mercurial > hg
changeset 32293:ca727147ff9f
style: ban [ foo == bar] bashism in tests
author | Augie Fackler <augie@google.com> |
---|---|
date | Mon, 15 May 2017 14:08:02 -0400 |
parents | 0ad0d26ff703 |
children | 905a2eff08a6 |
files | contrib/check-code.py tests/test-contrib-check-code.t |
diffstat | 2 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/check-code.py Sat May 13 16:26:43 2017 -0700 +++ b/contrib/check-code.py Mon May 15 14:08:02 2017 -0400 @@ -116,6 +116,7 @@ (r'printf.*[^\\]\\x', "don't use printf \\x, use Python"), (r'\$\(.*\)', "don't use $(expr), use `expr`"), (r'rm -rf \*', "don't use naked rm -rf, target a directory"), + (r'\[[^\]]+==', '[ foo == bar ] is a bashism, use [ foo = bar ] instead'), (r'(^|\|\s*)grep (-\w\s+)*[^|]*[(|]\w', "use egrep for extended grep syntax"), (r'/bin/', "don't use explicit paths for tools"),
--- a/tests/test-contrib-check-code.t Sat May 13 16:26:43 2017 -0700 +++ b/tests/test-contrib-check-code.t Mon May 15 14:08:02 2017 -0400 @@ -152,6 +152,15 @@ > $ function onwarn {} warning: don't use 'function', use old style [1] + $ cat > error.t <<EOF + > $ [ foo == bar ] + > EOF + $ "$check_code" error.t + error.t:1: + > $ [ foo == bar ] + [ foo == bar ] is a bashism, use [ foo = bar ] instead + [1] + $ rm error.t $ cat > raise-format.py <<EOF > raise SomeException, message > # this next line is okay