Skip to content

Commit af997d9

Browse files
committed
refactored test execution to use makefile
integration tests all running in the same process were stepping on eachother. each test file is now run within its own node process
1 parent f34470d commit af997d9

File tree

3 files changed

+37
-44
lines changed

3 files changed

+37
-44
lines changed

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
SHELL := /bin/bash
2+
3+
user=postgres
4+
password=1234
5+
host=localhost
6+
port=5432
7+
database=postgres
8+
9+
test-unit:
10+
@find test/unit -name "*-tests.js" | xargs -n 1 -I file node file
11+
12+
test-integration:
13+
@find test/integration -name "*-tests.js" | xargs -n 1 -I file node file -u $(user) --password $(password) -p $(port) -d $(database) -h $(host)
14+
15+
test-all: test-unit test-integration
16+
test: test-unit
17+
18+
.PHONY : test

test/run.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

test/test-helper.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
require.paths.unshift(__dirname + '/../lib/');
32

43
Client = require('client');
@@ -101,14 +100,6 @@ assert.isNull = function(item, message) {
101100
assert.ok(item === null, message);
102101
};
103102

104-
['equal', 'length', 'empty', 'strictEqual', 'emits', 'equalBuffers', 'same', 'calls', 'ok'].forEach(function(name) {
105-
var old = assert[name];
106-
assert[name] = function() {
107-
test.assertCount++
108-
return old.apply(this, arguments);
109-
};
110-
});
111-
112103
test = function(name, action) {
113104
test.testCount ++;
114105
var result = action();
@@ -120,26 +111,35 @@ test = function(name, action) {
120111
}
121112
};
122113

123-
test.assertCount = test.assertCount || 0;
114+
//print out the filename
115+
process.stdout.write(require('path').basename(process.argv[1]));
116+
124117
test.testCount = test.testCount || 0;
125118
test.ignored = test.ignored || [];
126119
test.errors = test.errors || [];
127-
test.start = test.start || new Date();
128120

129121
process.on('exit', function() {
130122
console.log('');
131-
var duration = ((new Date() - test.start)/1000);
132-
console.log(test.testCount + ' tests ' + test.assertCount + ' assertions in ' + duration + ' seconds');
133-
test.ignored.forEach(function(name) {
134-
console.log("Ignored: " + name);
135-
});
136-
test.errors.forEach(function(error) {
137-
console.log("Error: " + error.name);
138-
});
123+
if(test.ignored.length || test.errors.length) {
124+
test.ignored.forEach(function(name) {
125+
console.log("Ignored: " + name);
126+
});
127+
test.errors.forEach(function(error) {
128+
console.log("Error: " + error.name);
129+
});
130+
console.log('');
131+
}
139132
test.errors.forEach(function(error) {
140133
throw error.e;
141134
});
142135
});
136+
137+
process.on('uncaughtException', function(err) {
138+
console.error("\n %s", err.stack || err.toString())
139+
//causes xargs to abort right away
140+
process.exit(255);
141+
});
142+
143143
var count = 0;
144144

145145
var Sink = function(expected, timeout, callback) {

0 commit comments

Comments
 (0)