/**
 * Run this file to execute tests
 */
var args = process.argv;
for (var i = 0; i < args.length; i++) {
  if (args[i] === '--coverage') {
    doCoverage = true;
    break;
  }
}

var Jasmine = require('jasmine');
var jasmine = new Jasmine();
var istanbulRunReports = require('./istanbul');
jasmine.onComplete(function() {
  // Restore console functions so reports work
  for (var name in global.console) {
    console[name] = _console[name];
  }
  // if the tests were instrumented, run the reports
  if (global.__coverage__) {
    istanbulRunReports();
  }
});

// Override console methods as spies
// Allows test to run without output getting into test output
global._console = {};
for (var name in global.console) {
  _console[name] = console[name].bind(console);
  console[name] = jasmine.jasmine.createSpy('console.' + name);
}

// Include event simulator to install global.triggerEvent
require('./event_simulator.js');

jasmine.loadConfig({
  'spec_dir': 'test',
  'spec_files': [
    './testbuild.prod.js',
    './testbuild.debug.js'
  ],
  'helpers': [
    'environment.js',
    '../precompile/tungsten_template/inline.js'
  ]
});
jasmine.execute();

@@ -314,16 +314,22 @@
 unction(
+passed
 ) %7B%0A  //
@@ -559,16 +559,75 @@
 s();%0A  %7D
+%0A%0A  var failedTests = !passed;%0A  process.exit(failedTests);
 %0A%7D);%0A%0A//

For tests: exit 0 on success, exit 1 on failure.