summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2019-02-16 14:57:11 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2019-02-16 14:57:17 +0000
commitceefe452052c58ee092da5cdc9c505c3b84f0392 (patch)
tree1deac13164553873b4041366e76a409bee31222e
parent1698a752827858125e3e4626168cdaa29f13d6d3 (diff)
downloadnetsurf-ceefe452052c58ee092da5cdc9c505c3b84f0392.tar.gz
netsurf-ceefe452052c58ee092da5cdc9c505c3b84f0392.tar.bz2
Enable running of the tests from test.netsurf-browser.org
-rwxr-xr-xtest/monkey-see-monkey-do71
-rwxr-xr-xtest/monkey_driver.py (renamed from test/monkey-driver.py)11
2 files changed, 80 insertions, 2 deletions
diff --git a/test/monkey-see-monkey-do b/test/monkey-see-monkey-do
new file mode 100755
index 000000000..2733e6f4a
--- /dev/null
+++ b/test/monkey-see-monkey-do
@@ -0,0 +1,71 @@
+#!/usr/bin/python3
+
+# If you have any poo, fling it now!
+
+BASE_PATH="https://test.netsurf-browser.org/cgi-bin/monkey-index.cgi"
+MONKEY_PATH="./nsmonkey"
+
+# Otherwise let's begin...
+
+import sys
+
+import yaml
+
+import multiprocessing as mp
+
+from urllib import request
+from io import StringIO
+
+import monkey_driver as driver
+
+mp.set_start_method('fork')
+
+def child_run_test(parts):
+ outcapture = StringIO()
+ errcapture = StringIO()
+ oldout = sys.stdout
+ olderr = sys.stderr
+ sys.stdout = outcapture
+ sys.stderr = errcapture
+ try:
+ driver.run_preloaded_test(MONKEY_PATH, parts)
+ except:
+ sys.stdout = oldout
+ sys.stderr = olderr
+ print("FAIL:")
+ print("STDOUT:\n{}\n", outcapture.getvalue())
+ print("STDERR:\n{}\n", errcapture.getvalue())
+ print("RERAISE:")
+ raise
+
+def run_test(parts):
+ p = mp.Process(target=child_run_test, args=(parts, ))
+ p.start()
+ p.join()
+ return p.exitcode
+
+
+print("Fetching tests...")
+index = request.urlopen(BASE_PATH)
+index = index.read()
+print("Parsing tests...")
+test_set = yaml.load_all(index)
+
+print("Running tests...")
+ret = 0
+for test in test_set:
+ if test["kind"] == 'group':
+ print("Start group: {}".format(test["group"]))
+ print(" => {}".format(test["description"]))
+ elif test["kind"] == 'test':
+ print(" => Run test: {}".format(test["filename"]))
+ ret = run_test(test["content"])
+ if ret != 0:
+ break
+
+if ret != 0:
+ print("FAIL")
+ sys.exit(1)
+else:
+ print("PASS")
+ sys.exit(0)
diff --git a/test/monkey-driver.py b/test/monkey_driver.py
index 6463d96f0..ee23cffde 100755
--- a/test/monkey-driver.py
+++ b/test/monkey_driver.py
@@ -317,14 +317,21 @@ def walk_test_plan(ctx, plan):
for step in plan["steps"]:
run_test_step(ctx, step)
+def run_test_plan(ctx, plan):
+ print_test_plan_info(ctx, plan)
+ walk_test_plan(ctx, plan)
+
+def run_preloaded_test(path_monkey, plan):
+ ctx = {
+ "monkey": path_monkey,
+ }
+ run_test_plan(ctx, plan)
def main(argv):
ctx = {}
path_monkey, path_test = parse_argv(argv)
plan = load_test_plan(path_test)
ctx["monkey"] = path_monkey
- print_test_plan_info(ctx, plan)
- walk_test_plan(ctx, plan)
# Some python weirdness to get to main().
if __name__ == "__main__":