James E. Blair | 6cdf2f2 | 2016-07-25 16:07:02 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
| 15 | import argparse |
| 16 | import os |
| 17 | import sys |
| 18 | |
James E. Blair | 8a3729d | 2017-01-26 09:55:33 -0800 | [diff] [blame] | 19 | FIXTURE_DIR = os.path.join(os.path.dirname(__file__), |
| 20 | 'fixtures') |
| 21 | CONFIG_DIR = os.path.join(FIXTURE_DIR, 'config') |
James E. Blair | 6cdf2f2 | 2016-07-25 16:07:02 -0700 | [diff] [blame] | 22 | |
| 23 | |
| 24 | def print_file(title, path): |
| 25 | print('') |
| 26 | print(title) |
| 27 | print('-' * 78) |
| 28 | with open(path) as f: |
| 29 | print(f.read()) |
| 30 | print('-' * 78) |
| 31 | |
| 32 | |
| 33 | def main(): |
| 34 | parser = argparse.ArgumentParser(description='Print test layout.') |
| 35 | parser.add_argument(dest='config', nargs='?', |
| 36 | help='the test configuration name') |
| 37 | args = parser.parse_args() |
| 38 | if not args.config: |
| 39 | print('Available test configurations:') |
| 40 | for d in os.listdir(CONFIG_DIR): |
| 41 | print(' ' + d) |
| 42 | sys.exit(1) |
| 43 | configdir = os.path.join(CONFIG_DIR, args.config) |
| 44 | |
| 45 | title = ' Configuration: %s ' % args.config |
| 46 | print('=' * len(title)) |
| 47 | print(title) |
| 48 | print('=' * len(title)) |
| 49 | print_file('Main Configuration', |
| 50 | os.path.join(configdir, 'main.yaml')) |
| 51 | |
| 52 | gitroot = os.path.join(configdir, 'git') |
| 53 | for gitrepo in os.listdir(gitroot): |
| 54 | reporoot = os.path.join(gitroot, gitrepo) |
| 55 | print('') |
| 56 | print('=== Git repo: %s ===' % gitrepo) |
| 57 | filenames = os.listdir(reporoot) |
| 58 | for fn in filenames: |
| 59 | if fn in ['zuul.yaml', '.zuul.yaml']: |
| 60 | print_file('File: ' + os.path.join(gitrepo, fn), |
| 61 | os.path.join(reporoot, fn)) |
| 62 | |
| 63 | |
| 64 | if __name__ == '__main__': |
| 65 | main() |