From cd709272149ea9ca6ed84076eab6f55cb6da01a0 Mon Sep 17 00:00:00 2001 From: Joshua Appelman Date: Mon, 16 Jun 2014 19:36:34 +0200 Subject: [PATCH 1/2] Adds PhantomJS test runner. Allows for easy command line test execution, where the exit code will inform of the result. --- test/TestRunner.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/TestRunner.js diff --git a/test/TestRunner.js b/test/TestRunner.js new file mode 100644 index 0000000..45e6e39 --- /dev/null +++ b/test/TestRunner.js @@ -0,0 +1,29 @@ +// Run tests in PhantomJS +// +// Exits with status code 0 is all tests pass, or 1 if any fail. +// Pipes successful assertions to stdout and errors to stderr +// +// Run with $ phantomjs TestRunner.js +// +var page = require('webpage').create(); +page.open('./test.html', function() { + + // get an array, with as the first element the test strings and second the test results + var testOutput = page.evaluate(function () { + return document.getElementById('test-output').textContent.split('Tests: '); + }); + + var passed = testOutput[0].match(/✔[^✔✘]*/g) || []; + for (var i = 0; i < passed.length; i++) { + console.log(passed[i]); + } + + var failed = testOutput[0].match(/✘[^✔✘]*/g) || []; + for (var j = 0; j < failed.length; j++) { + console.error(failed[j]); + } + + console.log('Tests: ' + testOutput[1]); + phantom.exit(failed.length ? 1 : 0); +}); + From b38e4e1896a8b567607e43db81a338831eba4007 Mon Sep 17 00:00:00 2001 From: Joshua Appelman Date: Mon, 16 Jun 2014 19:41:05 +0200 Subject: [PATCH 2/2] Adds travis test runner. --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ffded2b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +install: + - git submodule update --init --recursive + +script: cd test && phantomjs TestRunner.js