Permalink
Browse files

Version that loads plugin directly without searching paths.

  • Loading branch information...
godsflaw committed Mar 22, 2012
1 parent 3fa00c0 commit 1f0ca580259a2fed0f08d658c697b36e6ad1f4d8
View
@@ -2,17 +2,6 @@
"use strict";
-var new_node_path = __dirname + "/tests/fixtures" + ":" +
- __dirname + "/plugins" + ":" +
- __dirname;
-
-if (process.env.ENV_NODE_PATH) {
- process.env.ENV_NODE_PATH = new_node_path + ":" + new_node_path;
-}
-else {
- process.env.ENV_NODE_PATH = new_node_path;
-}
-
try {
var reporter = require('nodeunit').reporters.default;
}
@@ -20,37 +20,23 @@ function Plugin(name) {
Plugin.prototype.load_plugin = function(name) {
var rf;
- var last_err;
- var full_paths = []
- var env_paths = process.env.ENV_NODE_PATH.split(":");
+ var full_path = __dirname + "/../../plugins/" + name + ".js";
- env_paths.forEach(function (pp) {
- full_paths.push(pp + '/' + name + '.js');
- });
-
- for (var i=0, j=full_paths.length; i<j; i++) {
- try {
- rf = fs.readFileSync(full_paths[i]);
- break;
- }
- catch (err) {
- last_err = err;
- continue;
- }
+ try {
+ rf = fs.readFileSync(full_path);
}
- if (!rf) {
- throw "Loading test plugin " + name + " failed: " + last_err;
+ catch (err) {
+ throw "Loading test plugin " + name + " failed: " + err;
}
-
var code = '"use strict";' + rf;
// hax for testing
code = code.replace("./address", "../../address");
var sandbox = {
require: require,
- __filename: full_paths[i],
- __dirname: path.dirname(full_paths[i]),
+ __filename: full_path,
+ __dirname: path.dirname(full_path),
exports: this,
console: console,
setTimeout: setTimeout,
View
@@ -11,7 +11,7 @@ function _set_up(callback) {
this.backup = {};
// needed for tests
- this.plugin = new Plugin('plugins/aliases');
+ this.plugin = new Plugin('aliases');
this.connection = Connection.createConnection();
this.recip = new Address('<test1@example.com>');
this.params = [this.recip];
@@ -10,7 +10,7 @@ function _set_up(callback) {
this.backup = {};
// needed for tests
- this.plugin = new Plugin('plugins/log.syslog');
+ this.plugin = new Plugin('log.syslog');
this.logger = Logger.createLogger();
// backup modifications
@@ -10,7 +10,7 @@ function _set_up(callback) {
this.backup = {};
// needed for tests
- this.plugin = new Plugin('plugins/queue/queue_base');
+ this.plugin = new Plugin('queue/queue_base');
this.connection = Connection.createConnection();
// backup modifications
@@ -10,7 +10,7 @@ function _set_up(callback) {
this.backup = {};
// needed for tests
- this.plugin = Plugin('plugins/relay_all');
+ this.plugin = Plugin('relay_all');
this.connection = Connection.createConnection();
this.params = ['foo@bar.com'];

0 comments on commit 1f0ca58

Please sign in to comment.