Sha256: b5a70b3e22be48d296db11a60f005efcaef9f7650f884e7fd62507d0e737ee16

Contents?: true

Size: 1.38 KB

Versions: 17

Compression:

Stored size: 1.38 KB

Contents

var log = require('./logger').create();

var Executor = function(capturedBrowsers, config, emitter) {
  var self = this;
  var executionScheduled = false;
  var pendingCount = 0;
  var runningBrowsers;

  var schedule = function() {
    var nonReady = [];

    if (!capturedBrowsers.length) {
      log.warn('No captured browser, open http://%s:%s%s', config.hostname, config.port,
          config.urlRoot);
      return false;
    }

    if (capturedBrowsers.areAllReady(nonReady)) {
      log.debug('All browsers are ready, executing');
      executionScheduled = false;
      capturedBrowsers.clearResults();
      capturedBrowsers.setAllToExecuting();
      pendingCount = capturedBrowsers.length;
      runningBrowsers = capturedBrowsers.clone();
      emitter.emit('run_start', runningBrowsers);
      self.socketIoSockets.emit('execute', config.client);
      return true;
    }

    log.info('Delaying execution, these browsers are not ready: ' + nonReady.join(', '));
    executionScheduled = true;
    return false;
  };

  this.schedule = schedule;

  this.onRunComplete = function() {
    if (executionScheduled) {
      schedule();
    }
  };

  this.onBrowserComplete = function() {
    pendingCount--;

    if (!pendingCount) {
      emitter.emit('run_complete', runningBrowsers, runningBrowsers.getResults());
    }
  };

  // bind all the events
  emitter.bind(this);
};


module.exports = Executor;

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma/lib/executor.js
hooch-0.4.1 jasmine/node_modules/karma/lib/executor.js
hooch-0.4.0 jasmine/node_modules/karma/lib/executor.js
hooch-0.3.0 jasmine/node_modules/karma/lib/executor.js
hooch-0.2.1 jasmine/node_modules/karma/lib/executor.js
hooch-0.2.0 jasmine/node_modules/karma/lib/executor.js
hooch-0.1.0 jasmine/node_modules/karma/lib/executor.js
hooch-0.0.8 jasmine/node_modules/karma/lib/executor.js
hooch-0.0.7 jasmine/node_modules/karma/lib/executor.js
hooch-0.0.6 jasmine/node_modules/karma/lib/executor.js
entangled-0.0.16 spec/dummy/public/node_modules/karma/lib/executor.js
entangled-0.0.15 spec/dummy/public/node_modules/karma/lib/executor.js
entangled-0.0.14 spec/dummy/public/node_modules/karma/lib/executor.js
entangled-0.0.13 spec/dummy/public/node_modules/karma/lib/executor.js
entangled-0.0.12 spec/dummy/public/node_modules/karma/lib/executor.js
entangled-0.0.11 spec/dummy/public/node_modules/karma/lib/executor.js
entangled-0.0.10 spec/dummy/public/node_modules/karma/lib/executor.js