diff options
author | Craig Tiller <craig.tiller@gmail.com> | 2015-01-19 20:51:28 -0800 |
---|---|---|
committer | Craig Tiller <craig.tiller@gmail.com> | 2015-01-19 20:58:56 -0800 |
commit | d4eeff8a2d7722e231ab38b5c33f6d1ff9646b09 (patch) | |
tree | 91321d18b3360ca2558824e31c824f8ec791ccfb /tools/buildgen/build-cleaner.py | |
parent | cf1d6eb4ae1b48958454259f7e26bee9140cbf65 (diff) |
Add ability to test
Diffstat (limited to 'tools/buildgen/build-cleaner.py')
-rwxr-xr-x | tools/buildgen/build-cleaner.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/buildgen/build-cleaner.py b/tools/buildgen/build-cleaner.py index 00821cc9cc..f9307360c3 100755 --- a/tools/buildgen/build-cleaner.py +++ b/tools/buildgen/build-cleaner.py @@ -6,6 +6,8 @@ import json import os import sys +TEST = (os.environ.get('TEST', 'false') == 'true') + _TOP_LEVEL_KEYS = ['settings', 'filegroups', 'libs', 'targets'] _VERSION_KEYS = ['major', 'minor', 'micro', 'build'] _ELEM_KEYS = [ @@ -51,6 +53,11 @@ for filename in sys.argv[1:]: lines = [] for line in output.splitlines(): lines.append(line.rstrip() + '\n') - with open(filename, 'w') as f: - f.write(''.join(lines)) + output = ''.join(lines) + if TEST: + with open(filename) as f: + assert f.read() == output + else: + with open(filename, 'w') as f: + f.write(output) |