diff --git a/lib/app.js b/lib/app.js index 5f316f5..16088a2 100644 --- a/lib/app.js +++ b/lib/app.js @@ -293,7 +293,8 @@ class App { return vm; } - await pify(this.server.listen)(this.port); + // NB: EADDRINUSE errors are uncatch-able? + pify(this.server.listen)(this.port); } assertHasBlockchain(provider){ diff --git a/lib/ui.js b/lib/ui.js index cf6e2ee..eb5fc54 100644 --- a/lib/ui.js +++ b/lib/ui.js @@ -100,10 +100,6 @@ class AppUI extends UI { 'istanbul-fail': `${c.red('Istanbul coverage reports could not be generated. ')}`, 'sources-fail': `${c.red('Cannot locate expected contract sources folder: ')} ${args[0]}`, - - 'server-fail': `${c.red('Could not launch ganache server. Is ')}` + - `${args[0]} ${c.red('already in use? ')}` + - `${c.red('Run "lsof -i" in your terminal to check.\n')}`, } return this._format(kinds[kind]) diff --git a/test/units/truffle/errors.js b/test/units/truffle/errors.js index e1865c3..2e1448c 100644 --- a/test/units/truffle/errors.js +++ b/test/units/truffle/errors.js @@ -1,7 +1,9 @@ const assert = require('assert'); const fs = require('fs'); const path = require('path') +const pify = require('pify') const shell = require('shelljs'); +const ganache = require('ganache-core-sc'); const verify = require('../../util/verifiers') const mock = require('../../util/integration.truffle'); @@ -123,6 +125,26 @@ describe('Truffle Plugin: error cases', function() { } }); + // This case *does* throw an error, but it's uncatch-able; + it.skip('tries to launch with a port already in use', async function(){ + verify.cleanInitialState(); + const server = ganache.server(); + + truffleConfig.network = 'development'; + mock.install('Simple', 'simple.js', solcoverConfig); + + await pify(server.listen)(8545); + + try { + await plugin(truffleConfig); + assert.fail(); + } catch(err){ + assert(err.message.includes('EADDRINUSE: address already in use :::8545')) + } + + await pify(server.close)(); + }); + // Truffle test contains syntax error it('truffle crashes', async function() { verify.cleanInitialState();