diff --git a/package.json b/package.json index a28002930..366d668b5 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "test": "tests" }, "scripts": { - "test": "node tests.js" + "test": "./run-tests" }, "license": "AGPL3" } diff --git a/run-tests b/run-tests new file mode 100755 index 000000000..749fcf750 --- /dev/null +++ b/run-tests @@ -0,0 +1,29 @@ +#!/usr/bin/env coffee + +# Tests runner. +$mocha = require 'mocha' + +# Used to find the specification files. +$glob = require 'glob' + +#===================================================================== + +do -> + # Instantiates the tests runner. + mocha = new $mocha { + reporter: 'spec' + } + + # Processes arguments. + do -> + {argv} = process + i = 2 + n = argv.length + mocha.grep argv[i++] while i < n + + $glob 'src/**/*.spec.{coffee,js}', (error, files) -> + console.error(error) if error + + mocha.addFile file for file in files + + mocha.run() diff --git a/tests.js b/tests.js deleted file mode 100644 index 4a913dfec..000000000 --- a/tests.js +++ /dev/null @@ -1,38 +0,0 @@ -var $mocha = require('mocha'); - -var $glob = require('glob'); - -require('coffee-script'); - -//==================================================================== - -var mocha = new $mocha({ - reporter: 'spec', -}); - -var argv = process.argv; -for (var i = 2, n = argv.length; i < n; ++i) { - mocha.grep(new RegExp(argv[i])); -} - -$glob('src/**/*.spec.coffee', function (error, files) { - if (error) { - console.error(error) ; - } - - files.forEach(function (file) { - mocha.addFile(file); - }); - - $glob('src/**/*.spec.js', function (error, files) { - if (error) { - console.error(error) ; - } - - files.forEach(function (file) { - mocha.addFile(file); - }); - - mocha.run(); - }); -});