Skip to content
This repository
Browse code

Version that loads plugin directly without searching paths.

  • Loading branch information...
commit 1f0ca580259a2fed0f08d658c697b36e6ad1f4d8 1 parent 3fa00c0
Christopher Mooney godsflaw authored
11 run_tests
@@ -2,17 +2,6 @@
2 2
3 3 "use strict";
4 4
5   -var new_node_path = __dirname + "/tests/fixtures" + ":" +
6   - __dirname + "/plugins" + ":" +
7   - __dirname;
8   -
9   -if (process.env.ENV_NODE_PATH) {
10   - process.env.ENV_NODE_PATH = new_node_path + ":" + new_node_path;
11   -}
12   -else {
13   - process.env.ENV_NODE_PATH = new_node_path;
14   -}
15   -
16 5 try {
17 6 var reporter = require('nodeunit').reporters.default;
18 7 }
28 tests/fixtures/stub_plugin.js
@@ -20,28 +20,14 @@ function Plugin(name) {
20 20
21 21 Plugin.prototype.load_plugin = function(name) {
22 22 var rf;
23   - var last_err;
24   - var full_paths = []
25   - var env_paths = process.env.ENV_NODE_PATH.split(":");
  23 + var full_path = __dirname + "/../../plugins/" + name + ".js";
26 24
27   - env_paths.forEach(function (pp) {
28   - full_paths.push(pp + '/' + name + '.js');
29   - });
30   -
31   - for (var i=0, j=full_paths.length; i<j; i++) {
32   - try {
33   - rf = fs.readFileSync(full_paths[i]);
34   - break;
35   - }
36   - catch (err) {
37   - last_err = err;
38   - continue;
39   - }
  25 + try {
  26 + rf = fs.readFileSync(full_path);
40 27 }
41   - if (!rf) {
42   - throw "Loading test plugin " + name + " failed: " + last_err;
  28 + catch (err) {
  29 + throw "Loading test plugin " + name + " failed: " + err;
43 30 }
44   -
45 31 var code = '"use strict";' + rf;
46 32
47 33 // hax for testing
@@ -49,8 +35,8 @@ Plugin.prototype.load_plugin = function(name) {
49 35
50 36 var sandbox = {
51 37 require: require,
52   - __filename: full_paths[i],
53   - __dirname: path.dirname(full_paths[i]),
  38 + __filename: full_path,
  39 + __dirname: path.dirname(full_path),
54 40 exports: this,
55 41 console: console,
56 42 setTimeout: setTimeout,
2  tests/plugins/aliases.js
@@ -11,7 +11,7 @@ function _set_up(callback) {
11 11 this.backup = {};
12 12
13 13 // needed for tests
14   - this.plugin = new Plugin('plugins/aliases');
  14 + this.plugin = new Plugin('aliases');
15 15 this.connection = Connection.createConnection();
16 16 this.recip = new Address('<test1@example.com>');
17 17 this.params = [this.recip];
2  tests/plugins/log.syslog.js
@@ -10,7 +10,7 @@ function _set_up(callback) {
10 10 this.backup = {};
11 11
12 12 // needed for tests
13   - this.plugin = new Plugin('plugins/log.syslog');
  13 + this.plugin = new Plugin('log.syslog');
14 14 this.logger = Logger.createLogger();
15 15
16 16 // backup modifications
2  tests/plugins/queue/queue_base.js
@@ -10,7 +10,7 @@ function _set_up(callback) {
10 10 this.backup = {};
11 11
12 12 // needed for tests
13   - this.plugin = new Plugin('plugins/queue/queue_base');
  13 + this.plugin = new Plugin('queue/queue_base');
14 14 this.connection = Connection.createConnection();
15 15
16 16 // backup modifications
2  tests/plugins/relay_all.js
@@ -10,7 +10,7 @@ function _set_up(callback) {
10 10 this.backup = {};
11 11
12 12 // needed for tests
13   - this.plugin = Plugin('plugins/relay_all');
  13 + this.plugin = Plugin('relay_all');
14 14 this.connection = Connection.createConnection();
15 15 this.params = ['foo@bar.com'];
16 16

0 comments on commit 1f0ca58

Please sign in to comment.
Something went wrong with that request. Please try again.