annotate tests/test-check-code-hg.py @ 11762:8b03c988efb3

tests: run check-code.py on working directory files If we insist on Mercurial sources to pass check-code.py, let automate the process and make it part of the tests. Objections?
author Patrick Mezard <pmezard@gmail.com>
date Sat, 07 Aug 2010 15:38:05 +0200
parents
children b0e3d3973440
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11762
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
1 # Pass all working directory files through check-code.py
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
2
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
3 import sys, os, imp
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
4 rootdir = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..'))
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
5 if not os.path.isdir(os.path.join(rootdir, '.hg')):
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
6 sys.stderr.write('skipped: cannot check code on non-repository sources\n')
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
7 sys.exit(80)
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
8
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
9 checkpath = os.path.join(rootdir, 'contrib/check-code.py')
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
10 checkcode = imp.load_source('checkcode', checkpath)
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
11
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
12 from mercurial import hg, ui
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
13 u = ui.ui()
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
14 repo = hg.repository(u, rootdir)
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
15 checked = 0
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
16 for f in repo[None]:
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
17 checked += 1
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
18 checkcode.checkfile(os.path.join(rootdir, f))
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
19 if not checked:
8b03c988efb3 tests: run check-code.py on working directory files
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
20 sys.stderr.write('no file checked!\n')