Mercurial > hgsubversion
annotate tests/run.py @ 658:d101b39f6c51
test_startrev: add a few assertions about clone lengths
A few tweaks are added to the test to ensure that all tests pass these
assertions:
Some fixtures fail them by resulting in empty clones. Explicitly
blacklisting such fixtures allows as to ensure that the other fixtures
continue to work as expected.
Other fixtures contain no files in trunk at HEAD, so we test them with
other subdirectories instead.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Wed, 11 Aug 2010 19:57:34 +0200 |
parents | ab454ee515d4 |
children | 52fbb272a147 |
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 |
613
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
6 def tests(): |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
7 import test_binaryfiles |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
8 import test_diff |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
9 import test_externals |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
10 import test_fetch_branches |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
11 import test_fetch_command |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
12 import test_fetch_command_regexes |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
13 import test_fetch_exec |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
14 import test_fetch_mappings |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
15 import test_fetch_renames |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
16 import test_fetch_symlinks |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
17 import test_fetch_truncated |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
18 import test_pull |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
19 import test_push_command |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
20 import test_push_renames |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
21 import test_push_dirs |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
22 import test_push_eol |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
23 import test_rebuildmeta |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
24 import test_single_dir_clone |
653
ab454ee515d4
test_startrev: new tests inspired by test_rebuildmeta
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
644
diff
changeset
|
25 import test_startrev |
613
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
26 import test_svnwrap |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
27 import test_tags |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
28 import test_utility_commands |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
29 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
|
30 |
613
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
31 sys.path.append(os.path.dirname(__file__)) |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
32 sys.path.append(os.path.join(os.path.dirname(__file__), 'comprehensive')) |
426
72e63999722f
tests: make comprehensive tests work properly with nose and run.py
Augie Fackler <durin42@gmail.com>
parents:
395
diff
changeset
|
33 |
613
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
34 import test_stupid_pull |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
35 import test_verify |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
36 |
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
37 return locals() |
394
d70c8e45cb9e
tests: add -A option to run.py for running comprehensive tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
393
diff
changeset
|
38 |
d70c8e45cb9e
tests: add -A option to run.py for running comprehensive tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
393
diff
changeset
|
39 def comprehensive(mod): |
d70c8e45cb9e
tests: add -A option to run.py for running comprehensive tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
393
diff
changeset
|
40 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
|
41 return dir == 'comprehensive' |
d70c8e45cb9e
tests: add -A option to run.py for running comprehensive tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
393
diff
changeset
|
42 |
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
|
43 if __name__ == '__main__': |
610
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
44 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
|
45 "specified, all known tests are implied.") |
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
46 parser = optparse.OptionParser(usage="%prog [options] [TESTS ...]", |
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
47 description=description) |
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
48 parser.add_option("-A", "--all", |
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
49 dest="comprehensive", action="store_true", default=False, |
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
50 help="include slow, but comprehensive tests") |
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
51 parser.add_option("-v", "--verbose", |
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
52 dest="verbose", action="store_true", default=False, |
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
53 help="enable verbose output") |
614
4f6017ba4d3d
testrunner: use demandimport, with an option to disable it
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
613
diff
changeset
|
54 parser.add_option("", "--no-demandimport", |
4f6017ba4d3d
testrunner: use demandimport, with an option to disable it
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
613
diff
changeset
|
55 dest="demandimport", action="store_false", default=True, |
4f6017ba4d3d
testrunner: use demandimport, with an option to disable it
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
613
diff
changeset
|
56 help="disable Mercurial demandimport loading") |
357
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
57 |
610
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
58 (options, args) = parser.parse_args() |
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
59 |
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
60 if options.verbose: |
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
61 testargs = { 'descriptions': 3, 'verbosity': 2 } |
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
62 else: |
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
63 testargs = {'descriptions': 2} |
303
f423a8780832
Minor tweaks to how the tests are run.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
174
diff
changeset
|
64 |
615
edd112855189
tests/run.py: make sure our hgsubversion loads correctly
Augie Fackler <durin42@gmail.com>
parents:
614
diff
changeset
|
65 sys.path.append(os.path.dirname(os.path.dirname(__file__))) |
edd112855189
tests/run.py: make sure our hgsubversion loads correctly
Augie Fackler <durin42@gmail.com>
parents:
614
diff
changeset
|
66 |
614
4f6017ba4d3d
testrunner: use demandimport, with an option to disable it
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
613
diff
changeset
|
67 if options.demandimport: |
4f6017ba4d3d
testrunner: use demandimport, with an option to disable it
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
613
diff
changeset
|
68 from mercurial import demandimport |
4f6017ba4d3d
testrunner: use demandimport, with an option to disable it
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
613
diff
changeset
|
69 demandimport.enable() |
4f6017ba4d3d
testrunner: use demandimport, with an option to disable it
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
613
diff
changeset
|
70 |
644
95abc4cfc78f
tests: improve import logic
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
629
diff
changeset
|
71 # make sure our copy of hgsubversion gets imported by loading test_util |
95abc4cfc78f
tests: improve import logic
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
629
diff
changeset
|
72 import test_util |
95abc4cfc78f
tests: improve import logic
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
629
diff
changeset
|
73 test_util.TestBase |
95abc4cfc78f
tests: improve import logic
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
629
diff
changeset
|
74 |
338
47c0110046dc
tests: silence tests when using run.py
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
337
diff
changeset
|
75 # silence output when running outside nose |
629
c38fe89a5cbc
tests: Use tempfile.TemporaryFile instead of os.tmpfile() to redirect stdout.
James McKay <code@jamesmckay.net>
parents:
615
diff
changeset
|
76 import tempfile |
c38fe89a5cbc
tests: Use tempfile.TemporaryFile instead of os.tmpfile() to redirect stdout.
James McKay <code@jamesmckay.net>
parents:
615
diff
changeset
|
77 sys.stdout = tempfile.TemporaryFile() |
338
47c0110046dc
tests: silence tests when using run.py
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
337
diff
changeset
|
78 |
613
58f397523604
testrunner: delay and `simplify' importing of tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
610
diff
changeset
|
79 all = tests() |
357
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
80 |
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
81 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
|
82 |
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
83 if not args: |
610
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
84 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
|
85 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
|
86 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
|
87 else: |
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
88 suite = [] |
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
89 for arg in args: |
610
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
90 if arg == 'test_util': |
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
91 continue |
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
92 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
|
93 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
|
94 else: |
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
95 suite.append(all[arg].suite()) |
d19843ac13c9
Allow passing in module arguments to the test runs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
347
diff
changeset
|
96 |
610
300b917d23c5
testrunner: use optparse
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
97 runner = unittest.TextTestRunner(**testargs) |
571
f3e5ef8760cb
tests.run: exit nonzero if tests did not pass
Augie Fackler <durin42@gmail.com>
parents:
426
diff
changeset
|
98 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
|
99 if not result.wasSuccessful(): |
f3e5ef8760cb
tests.run: exit nonzero if tests did not pass
Augie Fackler <durin42@gmail.com>
parents:
426
diff
changeset
|
100 sys.exit(1) |