Skip to content
This repository has been archived by the owner on Jun 14, 2018. It is now read-only.

Run test command if --tests flag is specified on watch #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/commands/watch.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var testCommand = require('./test');

var command = {
command: 'watch',
description: 'Watch filesystem for changes and rebuild the project automatically',
Expand Down Expand Up @@ -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,
Expand All @@ -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;

Expand Down
32 changes: 16 additions & 16 deletions test/ethpm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down