All files / solidity-coverage/plugins/resources nomiclabs.ui.js

100% Statements 14/14
50% Branches 1/2
100% Functions 3/3
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 9239x             77x   77x                                             98x 98x 98x 98x   98x                                         98x                   2x 2x   2x                               2x       39x
const UI = require('./../../lib/ui').UI;
 
/**
 * Nomiclabs Plugin logging
 */
class PluginUI extends UI {
  constructor(log){
    super(log);
 
    this.flags = {
      testfiles:  `Path (or glob) defining a subset of tests to run`,
 
      testMatrix: `Generate a json object which maps which unit tests hit which lines of code.`,
 
      abi:        `Generate a json object which can be used to produce a unified diff of your ` +
                  `contracts public interface between two commits.`,
 
      solcoverjs: `Relative path from working directory to config. ` +
                  `Useful for monorepo packages that share settings.`,
 
      temp:       `Path to a disposable folder to store compilation artifacts in. ` +
                  `Useful when your test setup scripts include hard-coded paths to ` +
                  `a build directory.`,
    }
  }
 
  /**
   * Writes a formatted message via log
   * @param  {String}   kind  message selector
   * @param  {String[]} args  info to inject into template
   */
  report(kind, args=[]){
    const c = this.chalk;
    const ct = c.bold.green('>');
    const ds = c.bold.yellow('>');
    const w = ":warning:";
 
    const kinds = {
 
      'instr-skip':  `\n${c.bold('Coverage skipped for:')}` +
                     `\n${c.bold('=====================')}\n`,
 
      'compilation':  `\n${c.bold('Compilation:')}` +
                      `\n${c.bold('============')}\n`,
 
      'instr-skipped': `${ds} ${c.grey(args[0])}`,
 
      'hardhat-versions': `\n${c.bold('Version')}` +
                          `\n${c.bold('=======')}\n` +
                          `${ct} ${c.bold('solidity-coverage')}: v${args[0]}`,
 
      'hardhat-network': `\n${c.bold('Network Info')}` +
                         `\n${c.bold('============')}\n` +
                         `${ct} ${c.bold('HardhatEVM')}: v${args[0]}\n` +
                         `${ct} ${c.bold('network')}:    ${args[1]}\n`,
 
    }
 
    this._write(kinds[kind]);
  }
 
  /**
   * Returns a formatted message. Useful for error message.
   * @param  {String}   kind  message selector
   * @param  {String[]} args  info to inject into template
   * @return {String}         message
   */
  generate(kind, args=[]){
    const c = this.chalk;
    const x = ":x:";
 
    const kinds = {
      'network-fail': `${c.red('--network cli flag is not supported for the coverage task. ')}` +
                      `${c.red('Beginning with v0.8.7, coverage must use the default "hardhat" network.')}`,
 
      'sources-fail': `${c.red('Cannot locate expected contract sources folder: ')} ${args[0]}`,
 
      'solcoverjs-fail': `${c.red('Could not load .solcover.js config file. ')}` +
                         `${c.red('This can happen if it has a syntax error or ')}` +
                         `${c.red('the path you specified for it is wrong.')}`,
 
      'tests-fail': `${x} ${c.bold(args[0])} ${c.red('test(s) failed under coverage.')}`,
 
 
    }
 
 
    return this._format(kinds[kind])
  }
}
 
module.exports = PluginUI;