Skip to content
Snippets Groups Projects
Commit 572c22c8 authored by Matt Mackall's avatar Matt Mackall
Browse files

tests: fix check-code detection of anchored expressions, fix echo -n usage

parent 628a4a9e
No related branches found
No related tags found
No related merge requests found
......@@ -45,7 +45,7 @@
[
(r'(pushd|popd)', "don't use 'pushd' or 'popd', use 'cd'"),
(r'\W\$?\(\([^\)\n]*\)\)', "don't use (()) or $(()), use 'expr'"),
(r'^function', "don't use 'function', use old style"),
(r'(^|\n)function', "don't use 'function', use old style"),
(r'grep.*-q', "don't use 'grep -q', redirect to /dev/null"),
(r'echo.*\\n', "don't use 'echo \\n', use printf"),
(r'echo -n', "don't use 'echo -n', use printf"),
......@@ -49,7 +49,7 @@
(r'grep.*-q', "don't use 'grep -q', redirect to /dev/null"),
(r'echo.*\\n', "don't use 'echo \\n', use printf"),
(r'echo -n', "don't use 'echo -n', use printf"),
(r'^diff.*-\w*N', "don't use 'diff -N'"),
(r'(^|\n)diff.*-\w*N', "don't use 'diff -N'"),
(r'(^| )wc[^|\n]*$', "filter wc output"),
(r'head -c', "don't use 'head -c', use 'dd'"),
(r'ls.*-\w*R', "don't use 'ls -R', use 'find'"),
......@@ -63,6 +63,6 @@
(r'\$PWD', "don't use $PWD, use `pwd`"),
(r'[^\n]\Z', "no trailing newline"),
(r'export.*=', "don't export and assign at once"),
('^([^"\'\n]|("[^"\n]*")|(\'[^\'\n]*\'))*\\^', "^ must be quoted"),
(r'^source\b', "don't use 'source', use '.'"),
('(^|\n)([^"\'\n]|("[^"\n]*")|(\'[^\'\n]*\'))*\\^', "^ must be quoted"),
(r'(^|\n)source\b', "don't use 'source', use '.'"),
(r'touch -d', "don't use 'touch -d', use 'touch -t' instead"),
......@@ -68,5 +68,5 @@
(r'touch -d', "don't use 'touch -d', use 'touch -t' instead"),
(r'ls\s+[^|\n-]+\s+-', "options to 'ls' must come before filenames"),
(r'ls +[^|\n-]+ +-', "options to 'ls' must come before filenames"),
(r'[^>\n]>\s*\$HGRCPATH', "don't overwrite $HGRCPATH, append to it"),
(r'stop\(\)', "don't use 'stop' as a shell function name"),
(r'(\[|\btest\b).*-e ', "don't use 'test -e', use 'test -f'"),
......@@ -80,7 +80,7 @@
(r"<<(\S+)((.|\n)*?\n\1)", rephere),
]
uprefix = r"^ \$ "
uprefixc = r"^ > "
uprefix = r"(^|\n) \$\s*"
uprefixc = r"(^|\n) > "
utestpats = [
[
......@@ -85,6 +85,6 @@
utestpats = [
[
(r'^(\S| $ ).*(\S[ \t]+|^[ \t]+)\n', "trailing whitespace on non-output"),
(r'(^|\n)(\S| $ ).*(\S[ \t]+|^[ \t]+)\n', "trailing whitespace on non-output"),
(uprefix + r'.*\|\s*sed', "use regex test output patterns instead of sed"),
(uprefix + r'(true|exit 0)', "explicit zero exit unnecessary"),
(uprefix + r'.*\$\?', "explicit exit code checks unnecessary"),
......@@ -99,8 +99,8 @@
for i in [0, 1]:
for p, m in testpats[i]:
if p.startswith('^'):
p = uprefix + p[1:]
if p.startswith(r'(^|\n)'):
p = uprefix + p[6:]
else:
p = uprefix + p
utestpats[i].append((p, m))
......
......@@ -168,7 +168,7 @@
abort: repository nosuchrepo not found!
[255]
$ hg share -q -U bigfile-repo shared
$ echo -n bogus > shared/.hg/sharedpath
$ printf 'bogus' > shared/.hg/sharedpath
$ hg lfconvert shared foo
abort: .hg/sharedpath points to nonexistent directory $TESTTMP/bogus!
[255]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment