diff options
author | Vincent Sanders <vince@kyllikki.org> | 2019-11-27 22:50:59 +0000 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2019-11-28 14:53:12 +0000 |
commit | 9016c7becd7536f01ed767519279024201a6be41 (patch) | |
tree | ed142a8b6de2c2cbcbda6d4607d4cbf824413e6d | |
parent | ce27c1e2609687a2a2d71b3ceca82c595d0da005 (diff) | |
download | netsurf-test-9016c7becd7536f01ed767519279024201a6be41.tar.gz netsurf-test-9016c7becd7536f01ed767519279024201a6be41.tar.bz2 |
make test plan generator cgi take a division parameter and be pylint clean
-rwxr-xr-x | cgi-bin/monkey-index.cgi | 63 |
1 files changed, 42 insertions, 21 deletions
diff --git a/cgi-bin/monkey-index.cgi b/cgi-bin/monkey-index.cgi index 371011e..a54125a 100755 --- a/cgi-bin/monkey-index.cgi +++ b/cgi-bin/monkey-index.cgi @@ -1,35 +1,56 @@ #!/usr/bin/python3 +''' +NetSurf test plan generator + +The division form parameter may be given to select different groups of tests + to include. +''' + +import os +import re import cgi import cgitb +import yaml + cgitb.enable() -import os +def main(): + ''' + The test plan generator + ''' + docroot = os.environ["DOCUMENT_ROOT"] -import yaml + files = {} + + testroot = os.path.join(docroot, "monkey-test") + + params = cgi.FieldStorage() -docroot = os.environ["DOCUMENT_ROOT"] + division = 'index' -files = {} + if 'division' in params and re.match('^[A-Za-z0-9-]+$', params['division']): + division = params['division'] -testroot = os.path.join(docroot, "monkey-test") + print('Content-Type: text/plain') + print('') -print('Content-Type: text/plain') -print('') + for fname in os.listdir(testroot): + if not fname.endswith(".yaml"): + continue + with open(os.path.join(testroot, fname), "r") as file_handle: + files[fname] = yaml.load(file_handle) -for fname in os.listdir(testroot): - if not fname.endswith(".yaml"): - continue - with open(os.path.join(testroot, fname), "r") as fh: - files[fname] = yaml.load(fh) + for group in files[division + '.yaml']: + print("---") + group["kind"] = "group" + print(yaml.dump(group, default_flow_style=False)) + for filename, content in files.items(): + if isinstance(content, dict) and content.get("group") == group["group"]: + group_data = {"kind": "test", "filename": filename, "content": content} + print("---") + print(yaml.dump(group_data, default_flow_style=False)) -for group in files["index.yaml"]: - print("---") - group["kind"] = "group" - print(yaml.dump(group, default_flow_style=False)) - for f, content in files.items(): - if type(content) == dict and content.get("group") == group["group"]: - d = {"kind": "test", "filename": f, "content": content} - print("---") - print(yaml.dump(d, default_flow_style=False)) +if __name__ == "__main__": + main() |