Skip to content

Commit

Permalink
added deep-debug option for more debugging info
Browse files Browse the repository at this point in the history
  • Loading branch information
arunoda committed Jul 4, 2013
1 parent 3ada0ce commit 86f55ce
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 89 deletions.
8 changes: 7 additions & 1 deletion bin/_laika
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ var ended = false;

module.exports = {
run: function(argv) {
//adding addition support for the --debug
if(argv.debug) {
//adding addition support for the --debug
argv.reporter = 'tap';
logger.setVerbose(true);
} else if(argv['deep-debug']) {
//adding addition support for the --deep-debug
argv.reporter = 'tap';
logger.setVerbose(true);
logger.setDeepVerbose(true);
}

helpers.makeAssertFiberFriendly();

//laika drops dbs after the test without any problem
Expand Down
4 changes: 4 additions & 0 deletions bin/laika
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ var argv = optimist
.default('debug', false)
.alias('debug', 'd')

.describe('deep-debug', 'print more debug logs')
.default('deep-debug', false)
.alias('deep-debug', 'D')

.describe('help', 'show this help')
.alias('help', 'h')

Expand Down
186 changes: 99 additions & 87 deletions examples/hello-meteor/tests/posts.js
Original file line number Diff line number Diff line change
@@ -1,91 +1,103 @@
var assert = require('assert');

suite('Posts', function() {
// test('insert in client and observe in client too', function(done, server, c1, c2) {
// var insertObject = { k: Math.random() };
// server.eval(function() {
// console.log('some server message');
// console.error('some server debug');
// Posts.remove({});
// emit('done');
// }).once('done', function() {
// c1.eval(observePosts);
// })

// function observePosts() {
// Posts.find().observe({
// added: onAdded
// });

// function onAdded(doc) {
// emit('doc', doc);
// }

// emit('done');
// }

// c1.once('done', function() {
// c2.eval(insertDoc, insertObject);
// });

// function insertDoc(obj) {
// Posts.insert(obj);
// }

// c1.once('doc', function(doc) {
// assert.equal(doc.k, insertObject.k);
// done();
// });
// });

test('insert and observe2', function(done, server, client) {
server.eval(function() {
console.log('some server message');
Posts.remove({});
Posts.find().observe({
added: notifyTest
})

function notifyTest(doc) {
emit('doc', doc);
}
});

server.once('doc', function(doc) {
delete doc._id;
assert.deepEqual(doc, {a: 10});
done();
});

client.eval(function() {
console.log('some client message');
console.log('some client message2');
Posts.insert({a: 10});
// suite('Posts', function() {
// // test('insert in client and observe in client too', function(done, server, c1, c2) {
// // var insertObject = { k: Math.random() };
// // server.eval(function() {
// // console.log('some server message');
// // console.error('some server debug');
// // Posts.remove({});
// // emit('done');
// // }).once('done', function() {
// // c1.eval(observePosts);
// // })

// // function observePosts() {
// // Posts.find().observe({
// // added: onAdded
// // });

// // function onAdded(doc) {
// // emit('doc', doc);
// // }

// // emit('done');
// // }

// // c1.once('done', function() {
// // c2.eval(insertDoc, insertObject);
// // });

// // function insertDoc(obj) {
// // Posts.insert(obj);
// // }

// // c1.once('doc', function(doc) {
// // assert.equal(doc.k, insertObject.k);
// // done();
// // });
// // });

// test('insert and observe2', function(done, server, client) {
// server.eval(function() {
// console.log('some server message');
// Posts.remove({});
// Posts.find().observe({
// added: notifyTest
// })

// function notifyTest(doc) {
// emit('doc', doc);
// }
// });

// server.once('doc', function(doc) {
// delete doc._id;
// assert.deepEqual(doc, {a: 10});
// done();
// });

// client.eval(function() {
// console.log('some client message');
// console.log('some client message2');
// Posts.insert({a: 10});
// });
// });

// // test('insert in client and observe in client too using evalSync()', function(done, server, c1, c2) {
// // var insertObject = { k: Math.random() };
// // c1.evalSync(function() {
// // Posts.find().observe({
// // added: onAdded
// // });

// // function onAdded(doc) {
// // emit('doc', doc);
// // }

// // emit('return');
// // });

// // c1.once('doc', function(doc) {
// // assert.equal(doc.k, insertObject.k);
// // done();
// // });

// // c2.eval(function(obj) {
// // Posts.insert(obj);
// // }, insertObject);

// // });
// });

suite('aa', function() {
test("can't create when not logged in", function(done, server, client) {
console.log('here');

var ret = client.evalSync(function() {
emit('return', 'foo');
});
console.log(ret);
done();
});

// test('insert in client and observe in client too using evalSync()', function(done, server, c1, c2) {
// var insertObject = { k: Math.random() };
// c1.evalSync(function() {
// Posts.find().observe({
// added: onAdded
// });

// function onAdded(doc) {
// emit('doc', doc);
// }

// emit('return');
// });

// c1.once('doc', function(doc) {
// assert.equal(doc.k, insertObject.k);
// done();
// });

// c2.eval(function(obj) {
// Posts.insert(obj);
// }, insertObject);

// });
});
});
12 changes: 12 additions & 0 deletions lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ require('colors');

function Logger() {
var verbose = false;
var deepVerbose = false;

this.setVerbose = function setVerbose(v) {
verbose = v;
};

this.setDeepVerbose = function setVerbose(v) {
deepVerbose = v;
};

this.info = function info(message) {
console.log(message.blue.bold);
};
Expand Down Expand Up @@ -47,6 +52,13 @@ function Logger() {
process.stdout.write(message);
}
};

this.laika = function touch(message) {
if(deepVerbose) {
message = '[laika log] '.blue.bold + message;
console.log(message);
}
};
}

module.exports = new Logger();
6 changes: 5 additions & 1 deletion lib/test_logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module.exports = function(appPool, phantom) {
this._it(message, mockTest);
}

function mockTest(done) {
function mockTest(done) {
logger.laika('start running test');
var completed = false;
var args = [];

Expand Down Expand Up @@ -45,6 +46,7 @@ module.exports = function(appPool, phantom) {
}

Fiber(function() {
logger.laika('running test');
callback.apply(null, args);
if(args.length == 0) {
completeTest();
Expand All @@ -62,7 +64,9 @@ module.exports = function(appPool, phantom) {
}

function completeTest() {
logger.laika('test completed');
app.close(function() {
logger.laika('closing app');
completed = true;
done();
});
Expand Down

0 comments on commit 86f55ce

Please sign in to comment.