diff --git a/lib/commands/watch.js b/lib/commands/watch.js index 46b03ef..f9265e7 100644 --- a/lib/commands/watch.js +++ b/lib/commands/watch.js @@ -1,3 +1,5 @@ +var testCommand = require('./test'); + var command = { command: 'watch', description: 'Watch filesystem for changes and rebuild the project automatically', @@ -38,6 +40,10 @@ var command = { path.join(config.working_directory, "truffle.js") ]; + if(config.tests) { + watchPaths.push(path.join(config.working_directory, "test/**/*")); + } + chokidar.watch(watchPaths, { ignored: /[\/\\]\./, // Ignore files prefixed with "." cwd: config.working_directory, @@ -60,6 +66,17 @@ var command = { return; } + if(config.tests && (needs_rebuild || needs_recompile)){ + needs_rebuild = false; + needs_recompile = false; + working = true; + + testCommand.run(options,function(err){ + if(err) printFailure(err); + working = false; + }); + } + if (needs_rebuild == true) { needs_rebuild = false; diff --git a/test/ethpm.js b/test/ethpm.js index 2080185..171d60e 100644 --- a/test/ethpm.js +++ b/test/ethpm.js @@ -77,22 +77,22 @@ describe('EthPM integration', function() { }); }); - // afterEach("stop ipfs server", function(done) { - // this.timeout(10000); - // - // var called = false; - // // The callback gets called more than once... - // try { - // ipfs_daemon.stopDaemon(function() { - // if (called == false) { - // called = true; - // done(); - // } - // }); - // } catch (e) { - // // do nothing - // } - // }); + afterEach("stop ipfs server", function(done) { + this.timeout(10000); + + var called = false; + // The callback gets called more than once... + try { + ipfs_daemon.stopDaemon(function() { + if (called == false) { + called = true; + done(); + } + }); + } catch (e) { + // do nothing + } + }); it("successfully installs single dependency from EthPM", function(done) { this.timeout(20000); // Giving ample time for requests to time out.