Commit Graph

109 Commits

Author SHA1 Message Date
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
Matt Mackall
cc8b3a2b01 pvec: introduce pvecs 2012-03-12 13:37:39 -05:00
Matt Mackall
bd04c54a71 check-code: check for % inside _() 2012-03-08 15:59:44 -06:00
Jim Hague
78a686772b tests: tighten checks for octal escapes in shell printf.
printf on AIX default shell ksh (89) says \1 is an invalid escape. It insists
on at least 2 digits. This causes failures in test-keyword.t and test-status.t.

check-code.py already looks out for \NNN and recommends using Python
for outputting octal values. Extend the check to \NN and \N and fix up
resulting failures.
2012-02-08 16:56:00 +00:00
Mads Kiilerich
e347788597 tests: don't use alias
alias doesn't work in Solaris sh.
2012-01-27 03:00:03 +01:00
Mads Kiilerich
9acd1868fa tests: keep track of all check-code.py warnings 2012-01-11 01:56:05 +01:00
Matt Mackall
e82c2e671f merge with stable 2011-12-05 17:48:40 -06:00
Patrick Mezard
7a8d1bb9db test-svn-subrepo: fix reference output for svn 1.7
I modified check-code.py "$?" detection because I thought my use was legit, we
cannot test exit status of pipelines commands except for the last one without
this. So it now tolerates "[$?" which is unlikely to be added by mistake.

Tested on:
- OSX + svn 1.7.1
- Linux + svn 1.6.12
2011-12-02 16:50:48 +01:00
Mads Kiilerich
1cbfae386c check-code: fix return code initialization
Don't crash when nothing is tested, but return failure when other files than
the last one fails.
2011-11-22 01:37:26 +01:00
Mads Kiilerich
ef0024b865 check-code: add --nolineno option for hiding line numbers
This makes the output more stable when it is used as a whitelist.
2011-11-11 01:25:47 +01:00
Matt Mackall
a5d3d42e92 tests: use md5sum.py instead of sha1sum, add check 2011-10-31 14:22:11 -05:00
Matt Mackall
8971e5af3c check-code: fix issues with finding patterns in unified tests, fix tests
- old-style patterns without ^ were getting improperly anchored
- finditer was matching against beginning of line poorly
- \s was matching newlines
- [^x] was matching newlines

so we:

- remove earlier hacks for multiline matching
- fix unified test anchoring by adding .*
- replace \s with [ \t]
- replace [^x] with [^\nx]
- force all matches into multiline mode so ^ anchors work

This uncovers a number of test issues that are then repaired.
2011-10-27 17:22:04 -05:00
Matt Mackall
4b52621903 tests: fix check-code detection of anchored expressions, fix echo -n usage 2011-10-26 12:56:27 -05:00
Matt Mackall
b7430f065a check-code: catch BaseException and os.path.relpath 2011-10-21 16:52:23 -05:00
Matt Mackall
b22c536335 check-code: report suspicious string joins
This detects patterns of the form:

ui.write("this is missing"
         "a space at the join\n")
2011-10-17 17:27:33 -05:00
Matt Mackall
e1cab56645 merge with crew 2011-10-16 22:15:43 -05:00
Matt Mackall
db1431fe95 check-code: support multiline matches like try/except/finally
- match one pattern at a time against entire file
- find line containing match
- sort matches by line number
2011-10-16 20:26:20 -05:00
Mads Kiilerich
4578a9a76b tests: don't use 'test -e'
On Solaris 10:

  $ test -e f
  test: argument expected
2011-10-17 00:11:56 +02:00
Matt Mackall
d0885370c9 check-code: enable camelcase check, fix up problems 2011-11-09 16:36:54 -06:00
Augie Fackler
3a3e79d5b5 check-code: disallow use of hasattr()
The hasattr() builtin from Python < 3.2 [1] has slightly surprising
behavior: it catches all exceptions, even KeyboardInterrupt. This
causes it to have several surprising side effects, such as hiding
warnings that occur during attribute load and causing mysterious
failure modes when ^Cing an application. In later versions of Python
2.x [0], exception classes which do not inherit from Exception (such
as SystemExit and KeyboardInterrupt) are not caught, but other types
of exceptions may still silently cause returning False instead of
getting a reasonable exception.

[0] http://bugs.python.org/issue2196
[1] http://docs.python.org/dev/whatsnew/3.2.html
2011-07-25 14:59:31 -05:00
Jim Hague
f6f49b778c treediscovery: rename stop() in tests to fix failures on AIX.
It seems ksh, the default shell on AIX, does not permit the creation of a
function called stop(). test-treediscovery.t and test-treediscovery-legacy.t
both fail on AIX with error 'syntax error at line 25 : `(' unexpected'.

Fix by renaming stop() in the scripts to tstop(). For completeness
rename start() to tstart() to match. Both tests then pass on AIX.

Add check for the use of stop() in a shell script to check-code.
2011-07-05 11:53:32 +01:00
Thomas Arendsen Hein
4575d54a81 check-code: fix class style checking (with tests)
- old-style classes were only checked for one-letter class names
- add check for new-style classes with empty parent class, because
  this is not available in Python 2.4
2011-06-29 13:45:51 +02:00
Matt Mackall
f65681314b check-code: don't mark debug messages for translation 2011-06-21 15:21:57 -05:00
Matt Mackall
1b52b02896 check-code: catch misspellings of descendant
This word is fairly common in Mercurial, and easy to misspell.
2011-06-07 17:02:54 -05:00
Martin Geisler
af8a35e078 check-code: flag 0/1 used as constant Boolean expression 2011-06-01 12:38:46 +02:00
Sune Foldager
58e1e8aaa9 check-code: add /= to operator list 2011-05-12 18:19:28 +02:00
Matt Mackall
81206f7383 check-code: complain about set.isdisjoint 2011-05-08 11:39:24 -05:00
Mads Kiilerich
938d75f22d check-code: fix checking for sh style in .t tests
Restore checks after they were disabled by a1f828662ac8.
2011-05-06 00:34:10 +02:00
Dan Villiom Podlaski Christiansen
c1ff9b1ec7 check-code: disallow calling opener(...).read() and opener(..).write() 2011-05-02 10:11:24 +02:00
timeless
849f249718 check-code: check for repo in revlog and ui in util 2011-05-01 16:11:42 +02:00
timeless
153cb7a67b check-code: allow for checking multiple pattern sets per file 2011-05-01 16:10:51 +02:00
timeless
f74ce7db63 check-code: adding debug flag 2011-05-01 15:55:00 +02:00
Idan Kamara
169899ab9c check-code: separate warnings to avoid repetitive str.startswith 2011-04-25 13:03:26 +03:00
Idan Kamara
83e05de083 check-code: warn about naked except clauses 2011-04-23 00:52:21 +03:00
Dan Villiom Podlaski Christiansen
ecb9e72af1 osutil: replace #import with #include, and add a check for it 2011-03-23 23:05:32 +01:00
Matt Mackall
b156bda724 osutil: fix up check-code issues 2011-03-23 09:41:58 -05:00