Add --version cli flag

pull/393/head
cgewecke 5 years ago
parent 49d7f3fe99
commit d80eb051fe
  1. 4
      README.md
  2. 7
      dist/truffle.plugin.js
  3. 10
      lib/ui.js
  4. 7
      test/units/app.js

@ -24,8 +24,8 @@ $ npm install --save-dev solidity-coverage
+ Tests run more slowly while coverage is being generated.
+ Contracts consume more gas while coverage is being generated.
+ solidity-coverage launches its own in-process ganache instance. You can
set its [options] via the `providerOptions` key in your .solcover.js
config file.
set its [options](https://github.com/trufflesuite/ganache-core#options) via
the `providerOptions` key in your `.solcover.js` config file.
### Truffle >= V5: setup and run

@ -26,6 +26,7 @@
*/
const App = require('./../lib/app');
const pkg = require('./../package.json');
const req = require('req-cwd');
const death = require('death');
const path = require('path');
@ -66,7 +67,7 @@ async function plugin(truffleConfig){
// Instrument and test..
try {
death(app.cleanUp);
death(app.cleanUp); // This doesn't work...
// Launch in-process provider
const provider = await app.provider(truffle.ganache);
@ -77,6 +78,10 @@ async function plugin(truffleConfig){
app.ui.report('truffle-version', [truffle.version]);
app.ui.report('ganache-version', [ganacheVersion]);
app.ui.report('coverage-version',[pkg.version]);
// Bail early if user ran: --version
if (truffleConfig.version) return;
// Write instrumented sources to temp folder
app.instrument();

@ -28,11 +28,13 @@ class UI {
'truffle-help': `Usage: truffle run coverage [options]\n\n` +
`Options:\n` +
` --file: path (or glob) to run subset of JS test files\n` +
` --solcoverjs: relative path to .solcover.js (ex: ./../.solcover.js)\n`,
` --file: path (or glob) to subset of JS test files. (Quote your globs)\n` +
` --solcoverjs: relative path to .solcover.js (ex: ./../.solcover.js)\n` +
` --version: version info\n`,
'truffle-version': `${ct} ${c.bold('truffle')}: v${args[0]}`,
'ganache-version': `${ct} ${c.bold('ganache-core')}: ${args[0]}`,
'truffle-version': `${ct} ${c.bold('truffle')}: v${args[0]}`,
'ganache-version': `${ct} ${c.bold('ganache-core')}: ${args[0]}`,
'coverage-version': `${ct} ${c.bold('solidity-coverage')}: v${args[0]}`,
'instr-start': `\n${c.bold('Instrumenting for coverage...')}` +
`\n${c.bold('=============================')}\n`,

@ -183,6 +183,13 @@ describe('app', function() {
await plugin(truffleConfig);
})
it('truffle run coverage --version', async function(){
assertCleanInitialState();
truffleConfig.version = "true";
mock.install('Simple', 'simple.js', solcoverConfig);
await plugin(truffleConfig);
})
it('truffle run coverage --file test/<fileName>', async function() {
assertCleanInitialState();

Loading…
Cancel
Save