|
|
@ -56,6 +56,7 @@ const config = reqCwd.silent('./.solcover.js') || {}; |
|
|
|
const workingDir = config.dir || '.'; // Relative path to contracts folder
|
|
|
|
const workingDir = config.dir || '.'; // Relative path to contracts folder
|
|
|
|
const port = config.port || 8555; // Port testrpc listens on
|
|
|
|
const port = config.port || 8555; // Port testrpc listens on
|
|
|
|
const accounts = config.accounts || 35; // Number of accounts to testrpc launches with
|
|
|
|
const accounts = config.accounts || 35; // Number of accounts to testrpc launches with
|
|
|
|
|
|
|
|
const isTruffle = config.isTruffle || true; // Is target a truffle project?
|
|
|
|
|
|
|
|
|
|
|
|
// Set testrpc options
|
|
|
|
// Set testrpc options
|
|
|
|
const defaultRpcOptions = `--gasLimit ${gasLimitString} --accounts ${accounts} --port ${port}`; |
|
|
|
const defaultRpcOptions = `--gasLimit ${gasLimitString} --accounts ${accounts} --port ${port}`; |
|
|
@ -71,21 +72,24 @@ if (config.silent) { |
|
|
|
// (Changes here should be also be added to the before() block of test/run.js).
|
|
|
|
// (Changes here should be also be added to the before() block of test/run.js).
|
|
|
|
if (!config.norpc) { |
|
|
|
if (!config.norpc) { |
|
|
|
const command = './node_modules/.bin/testrpc-sc '; |
|
|
|
const command = './node_modules/.bin/testrpc-sc '; |
|
|
|
testrpcProcess = childprocess.exec(command + testrpcOptions, null, (err) => { |
|
|
|
testrpcProcess = childprocess.exec(command + testrpcOptions, null, err => { |
|
|
|
if (err) cleanUp('testRpc errored after launching as a childprocess.'); |
|
|
|
if (err) cleanUp('testRpc errored after launching as a childprocess.'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
log(`Launching testrpc on port ${port}`); |
|
|
|
log(`Launching testrpc on port ${port}`); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Generate a copy of the target truffle project configured for solcover and save to the coverage
|
|
|
|
// Generate a copy of the target project configured for solcover and save to the coverage
|
|
|
|
// environment folder.
|
|
|
|
// environment folder.
|
|
|
|
log('Generating coverage environment'); |
|
|
|
log('Generating coverage environment'); |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
// Common environment: /contracts/ & /test/
|
|
|
|
shell.mkdir(`${coverageDir}`); |
|
|
|
shell.mkdir(`${coverageDir}`); |
|
|
|
shell.cp('-R', `${workingDir}/contracts`, `${coverageDir}`); |
|
|
|
shell.cp('-R', `${workingDir}/contracts`, `${coverageDir}`); |
|
|
|
shell.cp('-R', `${workingDir}/migrations`, `${coverageDir}`); |
|
|
|
|
|
|
|
shell.cp('-R', `${workingDir}/test`, `${coverageDir}`); |
|
|
|
shell.cp('-R', `${workingDir}/test`, `${coverageDir}`); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Truffle environment: + /migrations/, truffle.js
|
|
|
|
|
|
|
|
if (isTruffle) { |
|
|
|
|
|
|
|
shell.cp('-R', `${workingDir}/migrations`, `${coverageDir}`); |
|
|
|
const truffleConfig = reqCwd(`${workingDir}/truffle.js`); |
|
|
|
const truffleConfig = reqCwd(`${workingDir}/truffle.js`); |
|
|
|
|
|
|
|
|
|
|
|
// Coverage network opts specified: copy truffle.js whole to coverage environment
|
|
|
|
// Coverage network opts specified: copy truffle.js whole to coverage environment
|
|
|
@ -111,6 +115,7 @@ try { |
|
|
|
coverageOption = ''; |
|
|
|
coverageOption = ''; |
|
|
|
fs.writeFileSync(`${coverageDir}/truffle.js`, trufflejs); |
|
|
|
fs.writeFileSync(`${coverageDir}/truffle.js`, trufflejs); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} catch (err) { |
|
|
|
} catch (err) { |
|
|
|
const msg = ('There was a problem generating the coverage environment: '); |
|
|
|
const msg = ('There was a problem generating the coverage environment: '); |
|
|
|
cleanUp(msg + err); |
|
|
|
cleanUp(msg + err); |
|
|
@ -144,7 +149,7 @@ try { |
|
|
|
cleanUp(msg + err); |
|
|
|
cleanUp(msg + err); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Run solcover's fork of truffle over instrumented contracts in the
|
|
|
|
// Run truffle over instrumented contracts in the
|
|
|
|
// coverage environment folder. Shell cd command needs to be invoked
|
|
|
|
// coverage environment folder. Shell cd command needs to be invoked
|
|
|
|
// as its own statement for command line options to work, apparently.
|
|
|
|
// as its own statement for command line options to work, apparently.
|
|
|
|
try { |
|
|
|
try { |
|
|
|