Mercurial > hg
annotate tests/silenttestrunner.py @ 23896:becfecaf9087
changegroup.writebundle: HG2Y support
This diff adds support to writebundle to generate a bundle2 wrapper; upcoming
diffs will add an option to write a v2 changegroup part instead of v1 in these
bundles.
author | Eric Sumner <ericsumner@fb.com> |
---|---|
date | Thu, 15 Jan 2015 15:39:16 -0800 |
parents | dadcd40b62d8 |
children | fc2268b9a07c |
rev | line source |
---|---|
23308
dadcd40b62d8
silenttestrunner: add environment variable to make tests noisy again
Augie Fackler <augie@google.com>
parents:
18665
diff
changeset
|
1 import unittest, sys, os |
18665
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
2 |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
3 def main(modulename): |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
4 '''run the tests found in module, printing nothing when all tests pass''' |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
5 module = sys.modules[modulename] |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
6 suite = unittest.defaultTestLoader.loadTestsFromModule(module) |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
7 results = unittest.TestResult() |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
8 suite.run(results) |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
9 if results.errors or results.failures: |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
10 for tc, exc in results.errors: |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
11 print 'ERROR:', tc |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
12 print |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
13 sys.stdout.write(exc) |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
14 for tc, exc in results.failures: |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
15 print 'FAIL:', tc |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
16 print |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
17 sys.stdout.write(exc) |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
18 sys.exit(1) |
23308
dadcd40b62d8
silenttestrunner: add environment variable to make tests noisy again
Augie Fackler <augie@google.com>
parents:
18665
diff
changeset
|
19 |
dadcd40b62d8
silenttestrunner: add environment variable to make tests noisy again
Augie Fackler <augie@google.com>
parents:
18665
diff
changeset
|
20 if os.environ.get('SILENT_BE_NOISY'): |
dadcd40b62d8
silenttestrunner: add environment variable to make tests noisy again
Augie Fackler <augie@google.com>
parents:
18665
diff
changeset
|
21 main = unittest.main |