Code coverage for Solidity smart-contracts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
solidity-coverage/lib/ui.js

61 lines
2.0 KiB

const c = require('chalk');
const emoji = require('node-emoji');
/**
* Coverage tool output handler. This is where any logging solidity-coverage does on its
* own behalf is managed. NB, most output is generated by the host dev stack (e.g. truffle,
* buidler or by the coverage generator (e.g. Istanbul).
* )
*/
class UI {
constructor(log){
this.log = log || console.log;
}
/**
* Writes a formatted message to console
* @param {String} kind message selector
* @param {String[]} args info to inject into template
*/
report(kind, args=[]){
const ct = c.bold.green('>');
const ds = c.bold.yellow('>');
const kinds = {
'vm-fail': `:warning: ${c.red('There was a problem attaching to the ganache-core VM.')} `+
`${c.red('Check the provider option syntax in solidity-coverage docs.')}\n`+
`:warning: ${c.red('Using ganache-core-sc (eq. core v2.7.0) instead.')}\n`,
'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`,
'truffle-version': `${ct} ${c.bold('truffle')}: v${args[0]}`,
'ganache-version': `${ct} ${c.bold('ganache-core')}: ${args[0]}`,
'instr-start': `\n${c.bold('Instrumenting for coverage...')}` +
`\n${c.bold('=============================')}\n`,
'instr-skip': `\n${c.bold('Coverage skipped for:')}` +
`\n${c.bold('=====================')}\n`,
'instr-item': `${ct} ${args[0]}`,
'instr-skipped': `${ds} ${c.grey(args[0])}`,
}
this.log(emoji.emojify(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){
}
}
module.exports = UI;