diff options
-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() |