#!/usr/bin/env node

var child_process = require('child_process');

var operation_tests = require('./lib/operation');
var client_tests = require('./lib/client');
var server_tests = require('./lib/server');
var client_server_tests = require('./lib/client_server');

function isPhantomJSInstalled (cb) {
  child_process.exec('which phantomjs', function (err) {
    cb(!err);
  });
}

function runPhantomJSTests () {
  isPhantomJSInstalled(function (isIt) {
    if (!isIt) {
      console.log("Skipping PhantomJS tests because it is not installed.");
      return;
    }

    require('../bin/server'); // Start server
    setTimeout(function () {
      var cmd = 'phantomjs test/phantomjs/codemirror-integration.js';
      child_process.exec(cmd, function (code, stdout) {
        if (code !== 0) {
          throw new Error('PhantomJS test failed:\n' + stdout.toString());
        }
      });
    }, 2000);
  });
}

function main () {
  operation_tests.run();
  client_tests.run();
  server_tests.run();
  client_server_tests.run();
  runPhantomJSTests();
}

main();
@@ -747,20 +747,19 @@
 nction (
-code
+err
 , stdout
@@ -778,18 +778,11 @@
 if (
-code !== 0
+err
 ) %7B%0A

fix detection of return code in phantomjs test