Mercurial > hg
annotate tests/silenttestrunner.py @ 34107:4f60720cf0df
blackbox: fix rotation with chg
The added test will show:
$ $PYTHON showsize.py .hg/blackbox*
.hg/blackbox.log: < 500
.hg/blackbox.log.1: < 500
.hg/blackbox.log.2: < 500
.hg/blackbox.log.3: < 500
.hg/blackbox.log.4: < 500
.hg/blackbox.log.5: >= 500
with previous code.
The issue is caused by blackbox caching file objects *by path*, and the
rotation size check could run on a wrong file object (i.e. it should check
"blackbox.log", but `filehandles["blackbox.log"]` contains a file object
that has been renamed to "blackbox.log.5").
This patch removes the "filehandlers" global cache added by 45313f5a3a8c to
solve the issue.
I think the original patch was trying to make different ui objects use a same
file object if their blackbox.log path is the same. In theory it could also
be problematic in the rotation case. Anyway, that should become unnecessary
after D650.
Differential Revision: https://phab.mercurial-scm.org/D648
author | Jun Wu <quark@fb.com> |
---|---|
date | Wed, 06 Sep 2017 19:27:30 -0700 |
parents | 403b0a7ab410 |
children | 2372284d9457 |
rev | line source |
---|---|
28730
73437077753c
py3: use print_function in silenttestrunner.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28729
diff
changeset
|
1 from __future__ import absolute_import, print_function |
28736
403b0a7ab410
tests: lexicographical imports in silenttestrunner.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28730
diff
changeset
|
2 import os |
403b0a7ab410
tests: lexicographical imports in silenttestrunner.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28730
diff
changeset
|
3 import sys |
28729
fc2268b9a07c
py3: use absolute_import in silenttestrunner.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
23308
diff
changeset
|
4 import unittest |
18665
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
5 |
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
6 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
|
7 '''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
|
8 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
|
9 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
|
10 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
|
11 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
|
12 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
|
13 for tc, exc in results.errors: |
28730
73437077753c
py3: use print_function in silenttestrunner.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28729
diff
changeset
|
14 print('ERROR:', tc) |
73437077753c
py3: use print_function in silenttestrunner.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28729
diff
changeset
|
15 print() |
18665
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
16 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
|
17 for tc, exc in results.failures: |
28730
73437077753c
py3: use print_function in silenttestrunner.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28729
diff
changeset
|
18 print('FAIL:', tc) |
73437077753c
py3: use print_function in silenttestrunner.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28729
diff
changeset
|
19 print() |
18665
2cbfb8c497ee
tests: add a test runner utility that prints nothing when all tests pass
Idan Kamara <idankk86@gmail.com>
parents:
diff
changeset
|
20 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
|
21 sys.exit(1) |
23308
dadcd40b62d8
silenttestrunner: add environment variable to make tests noisy again
Augie Fackler <augie@google.com>
parents:
18665
diff
changeset
|
22 |
dadcd40b62d8
silenttestrunner: add environment variable to make tests noisy again
Augie Fackler <augie@google.com>
parents:
18665
diff
changeset
|
23 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
|
24 main = unittest.main |