Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf-test.git/shortlog/9016c7becd7536f01ed767519279024201a6be41
...commit 
http://git.netsurf-browser.org/netsurf-test.git/commit/9016c7becd7536f01ed767519279024201a6be41
...tree 
http://git.netsurf-browser.org/netsurf-test.git/tree/9016c7becd7536f01ed767519279024201a6be41

The branch, master has been updated
       via  9016c7becd7536f01ed767519279024201a6be41 (commit)
      from  ce27c1e2609687a2a2d71b3ceca82c595d0da005 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf-test.git/commit/?id=9016c7becd7536f01ed767519279024201a6be41
commit 9016c7becd7536f01ed767519279024201a6be41
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>

    make test plan generator cgi take a division parameter and be pylint clean

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


-----------------------------------------------------------------------

Summary of changes:
 cgi-bin/monkey-index.cgi |   63 ++++++++++++++++++++++++++++++----------------
 1 file 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()


-- 
NetSurf test cases

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to