From 8886d7247a934d998ceedac9011cd04dcb03e63e Mon Sep 17 00:00:00 2001 From: Dean Chapman Date: Wed, 14 Jun 2017 15:38:00 +0100 Subject: [PATCH 1/2] Add --tests flag to watch, re-enable ipfs server cleanup on test run --- lib/commands/watch.js | 17 +++++++++++++++++ test/ethpm.js | 32 ++++++++++++++++---------------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/lib/commands/watch.js b/lib/commands/watch.js index 46b03ef..5df04ca 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', @@ -37,6 +39,10 @@ var command = { path.join(config.working_directory, "truffle-config.js"), path.join(config.working_directory, "truffle.js") ]; +console.log(JSON.stringify(config)) + if(config.tests) { + watchPaths.push(path.join(config.working_directory, "test/**/*")); + } chokidar.watch(watchPaths, { ignored: /[\/\\]\./, // Ignore files prefixed with "." @@ -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. From 1a43d72a304d5d60293f2725c34aeafc1407183b Mon Sep 17 00:00:00 2001 From: Dean Chapman Date: Wed, 21 Jun 2017 17:10:53 +0100 Subject: [PATCH 2/2] Get rid of commented out code --- lib/commands/watch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commands/watch.js b/lib/commands/watch.js index 5df04ca..f9265e7 100644 --- a/lib/commands/watch.js +++ b/lib/commands/watch.js @@ -39,7 +39,7 @@ var command = { path.join(config.working_directory, "truffle-config.js"), path.join(config.working_directory, "truffle.js") ]; -console.log(JSON.stringify(config)) + if(config.tests) { watchPaths.push(path.join(config.working_directory, "test/**/*")); }