Mercurial > hgsubversion
annotate tests/run.py @ 612:2c15e4c50a54
setup: check for Subversion by importing the `svnwrap' module.
| author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
|---|---|
| date | Fri, 14 May 2010 20:27:14 +0200 |
| parents | 300b917d23c5 |
| children | 58f397523604 |
| rev | line source |
|---|---|
|
610
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
1 import optparse |
|
16
48a44546c12f
Add a basic system for running the hgsubversion tests (although not the svnwrap ones) without requiring Nose. Nose is still the recommended way to run the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
2 import os |
|
48a44546c12f
Add a basic system for running the hgsubversion tests (although not the svnwrap ones) without requiring Nose. Nose is still the recommended way to run the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
3 import sys |
|
48a44546c12f
Add a basic system for running the hgsubversion tests (although not the svnwrap ones) without requiring Nose. Nose is still the recommended way to run the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 import unittest |
|
48a44546c12f
Add a basic system for running the hgsubversion tests (although not the svnwrap ones) without requiring Nose. Nose is still the recommended way to run the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 |
|
347
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
338
diff
changeset
|
6 import test_util |
|
169
f1919e1c35bf
fetch_command: cancel patching when encountering binary diffs
Patrick Mezard <pmezard@gmail.com>
parents:
168
diff
changeset
|
7 import test_binaryfiles |
|
153
46f6b872c988
tests: Fix some missing suite definitions so that running the full testsuite
Augie Fackler <durin42@gmail.com>
parents:
126
diff
changeset
|
8 import test_diff |
|
174
f80132c5fea5
Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents:
169
diff
changeset
|
9 import test_externals |
|
117
3afe404042a3
Add a disabled test for unrelated branches
Patrick Mezard <pmezard@gmail.com>
parents:
96
diff
changeset
|
10 import test_fetch_branches |
|
16
48a44546c12f
Add a basic system for running the hgsubversion tests (although not the svnwrap ones) without requiring Nose. Nose is still the recommended way to run the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
11 import test_fetch_command |
|
48a44546c12f
Add a basic system for running the hgsubversion tests (although not the svnwrap ones) without requiring Nose. Nose is still the recommended way to run the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 import test_fetch_command_regexes |
|
125
c35f59aa200e
Move and complete execute bit conversion tests into test_fetch_exec.py
Patrick Mezard <pmezard@gmail.com>
parents:
117
diff
changeset
|
13 import test_fetch_exec |
|
168
4f26fa049452
authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents:
155
diff
changeset
|
14 import test_fetch_mappings |
|
67
e319c9168910
hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents:
23
diff
changeset
|
15 import test_fetch_renames |
|
126
24a64fb0e74b
run.py: register and develop test_fetch_symlinks
Patrick Mezard <pmezard@gmail.com>
parents:
125
diff
changeset
|
16 import test_fetch_symlinks |
|
88
3b60f223893a
fetch_command: handle nullid parent in stupid non-diffy mode
Patrick Mezard <pmezard@gmail.com>
parents:
83
diff
changeset
|
17 import test_fetch_truncated |
|
283
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
235
diff
changeset
|
18 import test_pull |
|
16
48a44546c12f
Add a basic system for running the hgsubversion tests (although not the svnwrap ones) without requiring Nose. Nose is still the recommended way to run the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
19 import test_push_command |
|
83
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
20 import test_push_renames |
|
6c9b7cf1c5aa
push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
67
diff
changeset
|
21 import test_push_dirs |
|
96
9b5e528f67f8
Add a test to check EOLs are correctly converted
Patrick Mezard <pmezard@gmail.com>
parents:
88
diff
changeset
|
22 import test_push_eol |
|
155
ba801f44d240
utility_commands: Implement rebuildmeta so that metadata can be rebuilt.
Augie Fackler <durin42@gmail.com>
parents:
153
diff
changeset
|
23 import test_rebuildmeta |
|
577
930bb6df19a0
tests: make sure single dir clone tests get run by non-nose users
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
571
diff
changeset
|
24 import test_single_dir_clone |
|
347
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
338
diff
changeset
|
25 import test_svnwrap |
|
23
1f8854804795
Add tests for tags and fix a bug in the tag-finding code that was found by the tests.
Augie Fackler <durin42@gmail.com>
parents:
17
diff
changeset
|
26 import test_tags |
|
153
46f6b872c988
tests: Fix some missing suite definitions so that running the full testsuite
Augie Fackler <durin42@gmail.com>
parents:
126
diff
changeset
|
27 import test_utility_commands |
|
235
2969a20e0eef
Add support for user:pass@url repositories to be hg-like
Daniel Tang <dytang@cs.purdue.edu>
parents:
174
diff
changeset
|
28 import test_urls |
|
16
48a44546c12f
Add a basic system for running the hgsubversion tests (although not the svnwrap ones) without requiring Nose. Nose is still the recommended way to run the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
29 |
|
426
72e63999722f
tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents:
395
diff
changeset
|
30 sys.path.append(os.path.join(os.path.dirname(__file__), 'comprehensive')) |
|
72e63999722f
tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents:
395
diff
changeset
|
31 |
|
72e63999722f
tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents:
395
diff
changeset
|
32 import test_stupid_pull |
|
72e63999722f
tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents:
395
diff
changeset
|
33 import test_verify |
|
394
d70c8e45cb9e
tests: add -A option to run.py for running comprehensive tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
393
diff
changeset
|
34 |
|
d70c8e45cb9e
tests: add -A option to run.py for running comprehensive tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
393
diff
changeset
|
35 def comprehensive(mod): |
|
d70c8e45cb9e
tests: add -A option to run.py for running comprehensive tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
393
diff
changeset
|
36 dir = os.path.basename(os.path.dirname(mod.__file__)) |
|
d70c8e45cb9e
tests: add -A option to run.py for running comprehensive tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
393
diff
changeset
|
37 return dir == 'comprehensive' |
|
d70c8e45cb9e
tests: add -A option to run.py for running comprehensive tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
393
diff
changeset
|
38 |
|
16
48a44546c12f
Add a basic system for running the hgsubversion tests (although not the svnwrap ones) without requiring Nose. Nose is still the recommended way to run the tests.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 if __name__ == '__main__': |
|
610
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
40 description = ("This script runs the hgsubversion tests. If no tests are " |
|
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
41 "specified, all known tests are implied.") |
|
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
42 parser = optparse.OptionParser(usage="%prog [options] [TESTS ...]", |
|
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
43 description=description) |
|
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
44 parser.add_option("-A", "--all", |
|
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
45 dest="comprehensive", action="store_true", default=False, |
|
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
46 help="include slow, but comprehensive tests") |
|
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
47 parser.add_option("-v", "--verbose", |
|
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
48 dest="verbose", action="store_true", default=False, |
|
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
49 help="enable verbose output") |
|
357
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
50 |
|
610
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
51 (options, args) = parser.parse_args() |
|
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
52 |
|
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
53 if options.verbose: |
|
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
54 testargs = { 'descriptions': 3, 'verbosity': 2 } |
|
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
55 else: |
|
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
56 testargs = {'descriptions': 2} |
|
303
f423a8780832
Minor tweaks to how the tests are run.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
174
diff
changeset
|
57 |
|
338
47c0110046dc
tests: silence tests when using run.py
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
337
diff
changeset
|
58 # silence output when running outside nose |
|
47c0110046dc
tests: silence tests when using run.py
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
337
diff
changeset
|
59 sys.stdout = os.tmpfile() |
|
47c0110046dc
tests: silence tests when using run.py
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
337
diff
changeset
|
60 |
|
357
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
61 all = globals() |
|
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
62 all = dict((k, v) for (k, v) in all.iteritems() if k.startswith('test_')) |
|
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
63 del all['test_util'] |
|
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
64 |
|
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
65 args = [i.split('.py')[0].replace('-', '_') for i in args] |
|
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
66 |
|
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
67 if not args: |
|
610
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
68 check = lambda x: options.comprehensive or not comprehensive(x) |
|
394
d70c8e45cb9e
tests: add -A option to run.py for running comprehensive tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
393
diff
changeset
|
69 mods = [m for (n, m) in sorted(all.iteritems()) if check(m)] |
|
d70c8e45cb9e
tests: add -A option to run.py for running comprehensive tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
393
diff
changeset
|
70 suite = [m.suite() for m in mods] |
|
357
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
71 else: |
|
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
72 suite = [] |
|
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
73 for arg in args: |
|
610
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
74 if arg == 'test_util': |
|
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
75 continue |
|
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
76 elif arg not in all: |
|
393
e857e5cfc10f
tests: send warning to stderr instead of redirected stdout
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
357
diff
changeset
|
77 print >> sys.stderr, 'test module %s not available' % arg |
|
357
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
78 else: |
|
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
79 suite.append(all[arg].suite()) |
|
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
80 |
|
610
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
81 runner = unittest.TextTestRunner(**testargs) |
|
571
f3e5ef8760cb
tests.run: exit nonzero if tests did not pass
Augie Fackler <durin42@gmail.com>
parents:
426
diff
changeset
|
82 result = runner.run(unittest.TestSuite(suite)) |
|
f3e5ef8760cb
tests.run: exit nonzero if tests did not pass
Augie Fackler <durin42@gmail.com>
parents:
426
diff
changeset
|
83 if not result.wasSuccessful(): |
|
f3e5ef8760cb
tests.run: exit nonzero if tests did not pass
Augie Fackler <durin42@gmail.com>
parents:
426
diff
changeset
|
84 sys.exit(1) |
