Commit Graph

144 Commits

Author SHA1 Message Date
Kevin Bullock
2f2218183e check-code: expand sed rule to include more offenders
Expands the rule added in a3f00ef2b622 to include cases where the
address is a line number instead of a regular expression, and fixes an
instance of this pattern in test-unionrepo.t.
2013-04-22 16:50:08 -05:00
Kevin Bullock
5747742d25 check-code: add a rule against a GNU sed-ism
BSD sed requires the 'i' command to be followed with a backslash and a
newline, like so:

  $ sed -e '/^@/i\
  > other'

We've encountered this problem before, e.g. in test-mq.t (215a8789129e).
This change adds a check-code rule and fixes two instances of the
problem in test-record.t.
2013-04-22 16:33:28 -05:00
Matt Mackall
3109d84a82 check-code: add check for lock release order 2013-04-17 14:38:02 -05:00
Mads Kiilerich
eeb6ef563e check-code: check txt files for trailing whitespace 2013-04-15 01:37:23 +02:00
Mads Kiilerich
b7f720181a check-code: catch trailing space in comments 2013-04-15 01:37:23 +02:00
Bryan O'Sullivan
1d04c93909 check-code: fix a check-code failure in check-code
The irony is delicious.
2013-03-27 08:57:45 -07:00
Simon Heimberg
7dfe048bd9 check-code: re-add check for missing glob
As suggested by mpm reintroducing this test failure on windows is
prevented by a code-check. One line in a unix test is ignored.

This pattern matches 20 windows glob lines.
2013-03-01 00:59:22 +01:00
Simon Heimberg
6321f3dc40 tests: append missing glob to filename output and check-code it 2013-03-01 00:03:51 +01:00
Simon Heimberg
f94731fd38 check-code: extract windows glob warning message
it will be used often
2013-02-28 23:45:51 +01:00
Simon Heimberg
0e27bb618e check-code: do not prepend "warning" to a failure message
The prefix has not been removed when this check changed from a warning to a
failure.
2013-03-09 22:14:46 +01:00
Simon Heimberg
4be0e80cbe check-code: warn about line glob match with no glob character (?*/) 2013-02-13 21:51:47 +01:00
Kevin Bullock
72b1fbb751 check-code: warn to use killdaemons instead of kill cat PIDFILE
We have a bunch of tests that still use

    kill `cat hg.pid`

or worse,

    kill `cat hg.pid`; while kill -0 `cat hg.pid`; sleep 0; done

Cleaning these up to use tests/killdaemons.py is non-trivial, so for now
we just add a warning.
2013-02-08 19:32:56 +00:00
Mads Kiilerich
8d4726b241 tests: use pwd instead of ${PWD} in test-convert-git.t - because of Solaris 2013-01-31 02:39:55 +01:00
Augie Fackler
6f81622e24 check-code: disallow defunct <> operator
Added a test for that and one other python3 check in
test-check-code.t.
2013-01-01 13:05:22 -06:00
Augie Fackler
a52590ca42 check-code: disallow two-argument form of raise
Using this old form makes any attempt to port to Python 3 harder, and
the new syntax is supported in 2.4 already.
2013-01-01 12:58:21 -06:00
Mads Kiilerich
0c831b0b94 check-code: make 'missing whitespace in assignment' more aggressive
New warnings:

 >     a.b=ab
 missing whitespace in assignment
(the pattern did not accept '.' on the left hand side)

 >     a=a
 missing whitespace in assignment
(the right hand side pattern never matched a single character)

 >     a=a + 7
 missing whitespace in assignment
(the pattern only matched one character after the identifier following =)
2012-12-09 23:33:16 +01:00
Mads Kiilerich
ac8e1fc147 check-code: there must also be whitespace between ')' and operator
The check pattern only checked for whitespace between keyword and operator.

Now it also warns:
 >     x = f(),7
 missing whitespace after ,
 >     x = f()+7
 missing whitespace in expression
2012-12-09 23:33:16 +01:00
Matt Mackall
90a48b1c9f check-code: move i18n check from warning to error 2012-11-25 13:57:00 -06:00
Idan Kamara
4922480923 check-code: replace heredocs in unified tests
Heredocs are usually fed to other commands and
shouldn't follow the standard conventions of shell
commands.

This restores the old behaviour of how heredocs
were handled in old-style test files.
2012-10-03 22:09:18 +02:00
Thomas Arendsen Hein
23c6bfee41 check-code: catch yield inside try/finally (with tests)
This is not allowed in Python 2.4.
2012-09-19 12:29:12 +02:00
Mads Kiilerich
5e3dc3e383 avoid using abbreviations that look like spelling errors 2012-08-27 23:14:27 +02:00
Mads Kiilerich
2f4504e446 fix trivial spelling errors 2012-08-15 22:38:42 +02:00
Mads Kiilerich
59664fd950 check-code: fix check for trailing whitespace on continued lines too
The tests in test-annotate.t and test-import-git.t that relied on trailing
space in a file created by a here string is now masked by a literal 'EOL'
string that is removed.
2012-08-08 18:10:37 +02:00
Mads Kiilerich
cdcad9a14c check-code: fix check for trailing whitespace on empty lines
It seems like the intention with c4ecbbd282fe was to catch lines with only
one whitespace too.
2012-08-08 18:10:30 +02:00
Mads Kiilerich
9cddfd19ab check-code: fix check for trailing whitespace on sh command lines
The $ has been without necessary escaping since introduced in c4ecbbd282fe.
2012-08-08 18:10:16 +02:00
Mads Kiilerich
688b9e2048 check-code: indent 4 spaces in py files 2012-07-31 03:30:42 +02:00
Pierre-Yves David
6bb5e54b11 check-code: recognise %= as an operator 2012-07-06 19:48:19 +02:00
Mads Kiilerich
2108c6e927 check-code: verify that 'saved backup bundle to ...' is '(glob)'ed
This is the most frequent trivial reason tests fail on Windows.
2012-07-05 00:49:26 +02:00
Mads Kiilerich
a4be6ed644 test-alias: adapt for Windows
The test used 'echo' to test '!' style aliases. On Windows 'echo' is handled
by cmd and thus behaves very differently from the 'normal' echo command.

The simple workaround used here for using the same alias on all platforms
is to use 'printf' instead. Msys 'printf' will also handle sh quoting and
escaping in cmd.

Environment variable expansion with sh syntax is handled by launching sh.
2012-06-16 21:57:42 +02:00
Brodie Rao
7f47d4e347 check-code: ignore naked excepts with a "re-raise" comment
This also promotes the naked except check from a warning to an error.
2012-05-13 13:18:06 +02:00
Brodie Rao
391c9b5bf1 check-code: improve detection of naked except clauses 2012-05-13 13:17:50 +02:00
Brodie Rao
47a3ca1c2f check-code: promote 80+ character line warning to an error 2012-05-13 13:17:27 +02:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
Mads Kiilerich
80eee013e1 tests: unify the last sh tests
This requires a slightly smarter check-code check for sed output filtering.
2012-04-25 01:35:39 +02:00
Mads Kiilerich
f4efda66d8 tests: run most check-code sh checks on continued lines too
Some false errors are degraded to warnings and whitelisted.
2012-04-25 01:35:39 +02:00
Martin Geisler
24e4bf05a3 check-code: catch unnecessary s.strip().split() calls 2012-05-07 10:02:50 +02:00
Mads Kiilerich
b7e85cefa1 tests: avoid tab indent on all kinds of lines of sh commands 2012-04-23 01:56:48 +02:00
Mads Kiilerich
f64bae7ea3 tests: use 'do sleep 0' instead of 'do true', also on first line of command
2cd44a791e66 established that '... do true ...' shouldn't be used, but that was
only enforced on continued lines.
2012-04-23 01:56:48 +02:00
Mads Kiilerich
ca99a3d167 check-code: put grouping around regexps generated from testpats
This removes the pitfall that would make the testpath r'a|b' match 'b' on all
lines in .t tests.
2012-04-23 01:56:48 +02:00
Mads Kiilerich
b1160b7ec5 tests: don't use /dev/urandom for largefiles testing
There is no need to use entropy here just to create some content that only will
be used for hashing and ignored.

This avoids a problem where dd from /dev/urandom on solaris generates too short
output.
2012-04-23 01:56:48 +02:00
Mads Kiilerich
4c1897dde5 tests: fix incorrect markup of continued lines of sh commands 2012-04-23 01:39:26 +02:00
Mads Kiilerich
9f4ca6b4df check-code: 'printf \0' is apparently fine - accept it in check-code
Nobody complained over '\0' in test-eol.t.

The too strict check becomes a problem when this check is applied to more
lines.
2012-04-23 01:39:26 +02:00
Mads Kiilerich
e5bed4bfb4 tests: solaris sh can not negate exit status with '!' 2012-04-23 01:39:26 +02:00
Mads Kiilerich
d63ff4f9a5 tests: ^ must be quoted when used on solaris sh
The check was broken when it was introduced in 8924361c0202.
2012-04-23 01:39:26 +02:00
Matt Mackall
4ca25d50f9 merge with stable 2012-04-14 01:39:35 -05:00
Patrick Mezard
bdf6ede885 mq: replace hasattr() with util.safehasattr(), update check-code.py 2012-04-13 15:07:13 +02:00
Matt Mackall
05bbeed32b check-code: avoid false-positive on ++ 2012-04-12 20:22:18 -05:00
Jim Hague
77587a4c7a tests: avoid test-hup hanging on AIX
test-hup hangs on AIX. Under ksh89 on AIX (the default shell),

echo Hello; while [ ! -s not-there ]; do true; done

produces no output while the loop executes. Replacing 'true' with 'sleep 0'
fixes, as does using a less broken shell. ksh93 is fine.

Update check-code.py to look for this, and make same change in test-serve.t.
In fact test-serve works fine, probably because of additional commands between
echo and the loop, but that's a subtlety not easy to test for.
2012-04-05 12:31:21 +01:00
Matt Mackall
560dd93d34 merge with stable 2012-04-06 15:18:14 -05:00
Matt Mackall
4325ad525f tests: remove sed -i from test-record 2012-04-01 13:59:11 -05:00