Skip to content

Commit 49f5da8

Browse files
committed
make the test name printing an option via the "verbose" command line argument
1 parent 1bf617d commit 49f5da8

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ password=1234
55
host=localhost
66
port=5432
77
database=postgres
8+
verbose=false
89

910
test-unit:
10-
@find test/unit -name "*-tests.js" | xargs -n 1 -I file node file
11+
@find test/unit -name "*-tests.js" | xargs -n 1 -I file node file --verbose $(verbose)
1112

1213
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+
@find test/integration -name "*-tests.js" | xargs -n 1 -I file node file -u $(user) --password $(password) -p $(port) -d $(database) -h $(host) --verbose $(verbose)
1415

1516
test-all: test-unit test-integration
1617
test: test-unit

test/cli.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ for(var i = 0; i < args.length; i++) {
1717
case '--password':
1818
config.password = args[++i];
1919
break;
20+
case '--verbose':
21+
config.verbose = (args[++i] == "true");
22+
break;
2023
case '-d':
2124
case '--database':
2225
config.database = args[++i];
@@ -45,5 +48,10 @@ var log = function(keys) {
4548
console.log(key + ": '" + config[key] + "'");
4649
});
4750
}
48-
//log(['user','password','database','port','host'])
51+
52+
if(config.verbose) {
53+
log(['user','password','database','port','host'])
54+
55+
}
56+
4957
module.exports = config;

test/test-helper.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,28 @@ assert.isNull = function(item, message) {
111111

112112
test = function(name, action) {
113113
test.testCount ++;
114-
console.log('\n' + name);
114+
if(args.verbose) {
115+
console.log(name);
116+
}
115117
var result = action();
116118
if(result === false) {
117119
test.ignored.push(name);
118-
process.stdout.write('?');
120+
if(!args.verbose) {
121+
process.stdout.write('?');
122+
}
119123
}else{
120-
process.stdout.write('.');
124+
if(!args.verbose) {
125+
process.stdout.write('.');
126+
}
121127
}
122128
};
123129

124130
//print out the filename
125131
process.stdout.write(require('path').basename(process.argv[1]));
126-
132+
//print a new line since we'll be printing test names
133+
if(args.verbose) {
134+
console.log();
135+
}
127136
test.testCount = test.testCount || 0;
128137
test.ignored = test.ignored || [];
129138
test.errors = test.errors || [];

0 commit comments

Comments
 (0)