Chromium Code Reviews| Index: test/lib/TestGyp.py |
| diff --git a/test/lib/TestGyp.py b/test/lib/TestGyp.py |
| index 306bf3d3ad2caadb7a6826d0118feeca8e387031..af75f96cd81616bc2eebc96161d15b12794a0a25 100644 |
| --- a/test/lib/TestGyp.py |
| +++ b/test/lib/TestGyp.py |
| @@ -7,6 +7,7 @@ TestGyp.py: a testing framework for GYP integration tests. |
| """ |
| import collections |
| +from contextlib import contextmanager |
| import itertools |
| import os |
| import re |
| @@ -24,9 +25,10 @@ __all__.extend([ |
| 'TestGyp', |
| ]) |
| + |
| def remove_debug_line_numbers(contents): |
| """Function to remove the line numbers from the debug output |
| - of gyp and thus remove the exremem fragility of the stdout |
| + of gyp and thus reduce the extreme fragility of the stdout |
| comparison tests. |
| """ |
| lines = contents.splitlines() |
| @@ -37,12 +39,24 @@ def remove_debug_line_numbers(contents): |
| lines = [len(l) > 3 and ":".join(l[3:]) or l for l in lines] |
| return "\n".join(lines) |
| + |
| def match_modulo_line_numbers(contents_a, contents_b): |
| """File contents matcher that ignores line numbers.""" |
| contents_a = remove_debug_line_numbers(contents_a) |
| contents_b = remove_debug_line_numbers(contents_b) |
| return TestCommon.match_exact(contents_a, contents_b) |
| + |
| +@contextmanager |
|
Nils Barth (inactive)
2014/04/08 08:56:32
This is a simple single-use context manager (CM),
|
| +def LocalEnv(local_env): |
| + """Context manager to provide a local OS environment.""" |
| + env_copy = os.environ.copy() |
| + os.environ.update(local_env) |
| + yield |
|
Stefan Haller
2014/04/08 17:05:41
Sorry for jumping in here: for correctness, this s
Nils Barth (inactive)
2014/04/09 03:09:18
Oh, good catch -- thanks!
*don't* need try: ... fi
|
| + os.environ.clear() |
| + os.environ.update(env_copy) |
| + |
| + |
| class TestGypBase(TestCommon.TestCommon): |
| """ |
| Class for controlling end-to-end tests of gyp generators. |