Skip to content
This repository has been archived by the owner on Jul 15, 2019. It is now read-only.

Added start/end events for Arrow #183

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/interface/arrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
var log4js = require("log4js");
var path = require("path");
var fs = require("fs");
var events = require("events");

function Arrow(config, args) {
this.logger = log4js.getLogger("Arrow");
Expand All @@ -23,11 +24,18 @@ Arrow.getInstance = function () {
return Arrow.instance;
};

Arrow.prototype.__proto__ = events.EventEmitter.prototype;

Arrow.prototype.run = function () {
var SessionFactory = require("../session/sessionfactory"),
sf;
sf,
arrow = this;

this.emit('start');
sf = new SessionFactory(this.config, this.args);
sf.on('end', function(e) {
arrow.emit('end', e)
});
sf.runAllTestSessions();
};

Expand All @@ -39,6 +47,8 @@ Arrow.prototype.runController = function (controllerName, testConfig, testParams
getControllerFromShareLib,
errorMsg;

this.emit('start');

if (!testConfig) {
testConfig = {};
}
Expand Down Expand Up @@ -127,6 +137,7 @@ Arrow.prototype.runController = function (controllerName, testConfig, testParams
}

// error, data from previous controller, controller instance
self.emit('end');
callback(error, data, controller);
}

Expand Down
4 changes: 4 additions & 0 deletions lib/session/sessionfactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var os = require("os");
var ProxyManager = require("../proxy/proxymanager");
var Servermanager = require("../../arrow_server/arrowservermanager.js");
var PhantomJsSetup = require("../util/phantomJsSetup.js");
var events = require("events");

/**
* SessionFactory is the main entry point for all Arrow Tests.
Expand Down Expand Up @@ -106,6 +107,8 @@ function SessionFactory(config, args) {

}

SessionFactory.prototype.__proto__ = events.EventEmitter.prototype;

SessionFactory.prototype.runAllTestSessions = function () {
var self = this,
testExecutor = new TestExecutor(self);
Expand Down Expand Up @@ -401,6 +404,7 @@ SessionFactory.prototype.tearDown = function (testQueue, wdSessions) {
PhantomJsSetup.stopPhantomJs();
}

this.emit('end');

if (global.workingDirectory) {
failed = false;
Expand Down
28 changes: 28 additions & 0 deletions tests/unit/lib/interface/arrow-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,34 @@ YUI.add('arrow-tests', function (Y, NAME) {
});
A.isTrue(executed, 'Should have executed controller with testName');

},

'test start event': function() {
var driver = new StubDriver(),
arrow = new Arrow(),
got_event = false;

arrow.on('start', function() {
got_event = true;
});

arrow.runController(controllerName, {}, {}, driver, function(error, data, controller) {
A.isTrue(got_event, 'should be true');
});
},

'test end event': function() {
var driver = new StubDriver(),
arrow = new Arrow(),
got_event = false;

arrow.on('end', function() {
got_event = true;
});

arrow.runController(controllerName, {}, {}, driver, function(error, data, controller) {
A.isTrue(got_event, 'should be true');
});
}
}));

Expand Down