//    (The MIT License)
//
//    Copyright (c) 2012 Richard S Allinson <rsa@mountainmansoftware.com>
//
//    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.

"use strict";

/*
 * Module dependencies.
 */

var fs = require('fs'),
    basename = require('path').basename,
    Y = require('yui').use('test');

/*
 * All the test cases
 */

var cases = [];

/**
 * Auto-load all the cases.
 */

fs.readdirSync(__dirname + '/cases').forEach(function (filename) {

    if (!/\.js$/.test(filename)) {
        return;
    }

    var name = basename(filename, '.js');

    /*
     * We store the name of the test-case so it can be filtered later.
     */
    cases.push({
        name: name,
        test: require('./cases/' + name)
    });

});

/*
 * Attach all the tests we want to run to the runner.
 */

cases.forEach(function (testCase) {
    Y.Test.Runner.add(testCase.test);
});

/*
 * run all tests
 */

Y.Test.Runner.run();

@@ -1417,16 +1417,208 @@
  = %5B%5D;%0A%0A
+/*%0A * Make sure we fail when we fail.%0A */%0A%0Aprocess.on(%22exit%22, function()%7B%0A    var results = Y.Test.Runner.getResults();%0A    if (results && results.failed)%7B%0A        process.exit(1);%0A    %7D%0A%7D);%0A%0A
 /**%0A * A

Update test run.js so it fails on failure.