diff --git a/test/core/run b/test/core/run new file mode 100755 index 000000000..df20bc5ab --- /dev/null +++ b/test/core/run @@ -0,0 +1,71 @@ +#!/usr/bin/env node +/* + run.js: test runner for core tests + + Copyright (c) 2011 Nodejitsu + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +var path = require('path'), + spawn = require('child_process').spawn, + async = require('async'), + colors = require('colors'); + +var testTimeout = 15000; +var results = {}; + +function runTest(test, callback) { + var child = spawn(path.join(__dirname, 'run-single'), [ test ]); + + var killTimeout = setTimeout(function () { + child.kill(); + console.log(test.yellow + ' timed out'.red); + }, testTimeout); + + child.on('exit', function (exitCode) { + clearTimeout(killTimeout); + + console.log(test.yellow + ' exited with ' + + ((exitCode) ? exitCode.toString().red : exitCode.toString().green)); + results[test] = { exitCode: exitCode }; + callback(); + // + // We don't want tests to be stopped after first failure, and that's what + // async does when it receives truthy value in callback. + // + }); +}; + +var tests = process.argv.slice(2); +async.forEachSeries(tests, runTest, function () { + var failed = [], ok = []; + for (var test in results) { + (results[test].exitCode != 0 ? failed : ok).push(test); + } + + console.log('\nSummary:'); + console.log((' ' + failed.length + '\tfailed tests').red); + console.log((' ' + ok.length + '\tpassed tests').green); +}); + +// vim:filetype=javascript +