Gitweb links:

...log 
http://git.netsurf-browser.org/buildsystem.git/shortlog/c0152aae2d6741799a60782c56d4988b935275d1
...commit 
http://git.netsurf-browser.org/buildsystem.git/commit/c0152aae2d6741799a60782c56d4988b935275d1
...tree 
http://git.netsurf-browser.org/buildsystem.git/tree/c0152aae2d6741799a60782c56d4988b935275d1

The branch, tlsa/python-testrunner has been created
        at  c0152aae2d6741799a60782c56d4988b935275d1 (commit)

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/buildsystem.git/commit/?id=c0152aae2d6741799a60782c56d4988b935275d1
commit c0152aae2d6741799a60782c56d4988b935275d1
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    Buildsystem: Change test tool to the Python implementation.

diff --git a/Makefile b/Makefile
index d1fd44b..e221973 100644
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,7 @@ MAKEFILES := $(patsubst %,Makefile.%, \
        clang gcc norcroft open64       \
 )
 
-TESTTOOLS := testrunner.pl
+TESTTOOLS := testrunner.py
 
 CITOOLS := jenkins-build.sh
 
diff --git a/makefiles/Makefile.tools b/makefiles/Makefile.tools
index 86fac4c..2dde372 100644
--- a/makefiles/Makefile.tools
+++ b/makefiles/Makefile.tools
@@ -281,6 +281,7 @@ MKDIRFLAGS ?= -p
 MV ?= mv
 
 PERL ?= perl
+PYTHON ?= python
 
 PKGCONFIG ?= PKG_CONFIG_PATH="$(PREFIX)/lib/pkgconfig:$(PKG_CONFIG_PATH)" 
pkg-config
 


commitdiff 
http://git.netsurf-browser.org/buildsystem.git/commit/?id=0b023edcdea4f34822828e8a7fbed503101fcc49
commit 0b023edcdea4f34822828e8a7fbed503101fcc49
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    Testrunner: Add Python implementation of testrunner.pl

diff --git a/testtools/testrunner.py b/testtools/testrunner.py
new file mode 100644
index 0000000..a2d3c3c
--- /dev/null
+++ b/testtools/testrunner.py
@@ -0,0 +1,172 @@
+#!/bin/python
+#
+# Testcase runner for NetSurf projects
+#
+# Usage: testrunner <builddir> <testdir> <prefix> [<executable extension>]
+#
+# Operates upon INDEX files described in the README.
+# Locates and executes testcases, feeding data files to programs 
+# as appropriate.
+# Logs testcase output to file.
+# Aborts test sequence on detection of error.
+#
+
+import os
+import sys
+import Queue
+import threading
+import subprocess
+
+global builddir
+global directory
+global prefix
+global exeext
+
+if len(sys.argv) < 4:
+    print("Usage: testrunner.pl <builddir> <testdir> <prefix> [<exeext>]")
+    sys.exit(1)
+
+# Get directories
+builddir = sys.argv[1]
+directory = sys.argv[2]
+prefix = sys.argv[3]
+
+# Get EXE extension (if any)
+exeext = None
+if len(sys.argv) > 4:
+    exeext = sys.argv[4]
+
+# Open log file and /dev/null
+LOG = open(os.path.join(builddir, "testlog"), "w")
+NULL = open(os.devnull, "r+")
+
+
+def run_test(test_exe, test_data):
+    io_q = Queue.Queue()
+
+    def output_collector(identifier, stream):
+        for line in stream:
+            io_q.put((identifier, line.rstrip()))
+
+        if not stream.closed:
+            stream.close()
+
+    # Run the test
+    proc = subprocess.Popen([test_exe, test_data],
+            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+    # Threads for sticking output into queue
+    tout = threading.Thread(target=output_collector, name='stdout-watcher',
+            args=('STDOUT', proc.stdout))
+    terr = threading.Thread(target=output_collector, name='stderr-watcher',
+            args=('STDERR', proc.stderr))
+
+    tout.start()
+    terr.start()
+
+    # Wait for test to finish
+    ret = proc.wait()
+
+    # And join the output collector threads
+    tout.join()
+    terr.join()
+
+    # If last line of STDOUT is "PASS", then the test passed
+    last_line = None
+
+    # The STDERR output is just collected up and put at the end of LOG
+    error_lines = []
+
+    while not io_q.empty():
+        identifier, line = io_q.get()
+        if identifier == "STDOUT":
+            LOG.write("%s\n" % line)
+            last_line = line
+        else:
+            error_lines += line
+
+    # Check for test process returning error
+    if ret != 0:
+        LOG.write("    FAIL: Exit status %i\n" % ret)
+        last_line = "FAIL"
+
+    # Dump stderr to log
+    for error_line in error_lines:
+        LOG.write("%s\n" % line)
+
+    if not last_line == "PASS":
+        last_line = "FAIL"
+
+    # Print rest result
+    print(last_line)
+    return
+
+# Open testcase index
+with open(os.path.join(directory, "INDEX"), "r") as TINDEX:
+    # Parse testcase index, looking for testcases
+    for line in TINDEX:
+        # Skip comments
+        if line[0] == '#' or line.isspace():
+            continue
+
+        # Found one; decompose
+        decomposed = filter(None, line.split('\t'))
+
+        # Strip whitespace
+        test = decomposed[0].strip()
+        desc = decomposed[1].strip()
+        data = None
+        if len(decomposed) > 2:
+            data = decomposed[2].strip()
+
+        # Append prefix & EXE extension to binary name
+        test = prefix + test
+        if exeext:
+            test += exeext
+
+        print("Test: " + desc)
+
+        if data:
+            # Testcase has external data files
+
+            # Open datafile index
+            with open(os.path.join(directory, "data/" + data + "/INDEX"), "r") 
as DINDEX:
+                # Parse datafile index, looking for datafiles
+                for dline in DINDEX:
+                    if dline[0] == '#' or dline.isspace():
+                        continue
+
+                    # Found one; decompose
+                    ddecomposed = filter(None, dline.split('\t'))
+
+                    # Strip whitespace
+                    dtest = ddecomposed[0].strip()
+                    ddesc = ddecomposed[1].strip()
+
+                    LOG.write("Running %s %s\n" % (
+                            os.path.join(builddir, test),
+                            os.path.join(directory, "data/" + data + "/" + 
dtest)))
+
+                    # Make message fit on an 80 column terminal
+                    msg = "    ==> " + test + " [" + data + "/" + dtest + "]"
+                    msg += "." * (80 - len(msg) - 8)
+
+                    sys.stdout.write(msg)
+
+                    # Run testcase
+                    run_test(os.path.join(builddir, test),
+                             os.path.join(directory, "data/" + data + "/" + 
dtest))
+        else:
+            # Testcase has no external data files
+            LOG.write("Running %s\n" % (os.path.join(builddir, test)))
+
+            # Make message fit on an 80 column terminal
+            msg = "    ==> " + test
+            msg += "." * (80 - len(msg) - 8)
+
+            sys.stdout.write(msg)
+
+            # Run testcase
+            run_test(os.path.join(builddir, test))
+
+        print("")


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


-- 
NetSurf Project build system

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

Reply via email to