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.
70 lines
1.9 KiB
70 lines
1.9 KiB
6 years ago
|
import commander from 'commander'
|
||
5 years ago
|
import Web3 from 'web3';
|
||
6 years ago
|
import { runTestFiles } from './runTestFiles'
|
||
|
import fs from './fileSystem'
|
||
6 years ago
|
import { Provider } from 'remix-simulator'
|
||
6 years ago
|
import Log from './logger'
|
||
6 years ago
|
const logger = new Log()
|
||
|
const log = logger.logger
|
||
6 years ago
|
import colors from 'colors'
|
||
6 years ago
|
|
||
|
// parse verbosity
|
||
6 years ago
|
function mapVerbosity (v: number) {
|
||
6 years ago
|
const levels = {
|
||
|
0: 'error',
|
||
|
1: 'warn',
|
||
|
2: 'info',
|
||
|
3: 'verbose',
|
||
|
4: 'debug',
|
||
|
5: 'silly'
|
||
|
}
|
||
|
return levels[v]
|
||
|
}
|
||
|
const version = require('../package.json').version
|
||
|
|
||
|
commander.version(version)
|
||
|
|
||
|
commander.command('version').description('output the version number').action(function () {
|
||
|
console.log(version)
|
||
|
})
|
||
|
|
||
|
commander.command('help').description('output usage information').action(function () {
|
||
|
commander.help()
|
||
|
})
|
||
|
|
||
|
// get current version
|
||
|
commander
|
||
|
.option('-v, --verbose <level>', 'run with verbosity', mapVerbosity)
|
||
5 years ago
|
.action(async (filename) => {
|
||
5 years ago
|
if(!filename.endsWith('_test.sol')){
|
||
|
log.error('Test filename should end with "_test.sol"')
|
||
|
process.exit()
|
||
|
}
|
||
6 years ago
|
// Console message
|
||
6 years ago
|
console.log(colors.white('\n\t👁\t:: Running remix-tests - Unit testing for solidity ::\t👁\n'))
|
||
6 years ago
|
// set logger verbosity
|
||
|
if (commander.verbose) {
|
||
|
logger.setVerbosity(commander.verbose)
|
||
|
log.info('verbosity level set to ' + commander.verbose.blue)
|
||
|
}
|
||
|
let web3 = new Web3()
|
||
5 years ago
|
const provider = new Provider()
|
||
5 years ago
|
await provider.init()
|
||
|
web3.setProvider(provider)
|
||
6 years ago
|
|
||
|
if (!fs.existsSync(filename)) {
|
||
|
console.error(filename + ' not found')
|
||
|
process.exit(1)
|
||
|
}
|
||
|
|
||
|
let isDirectory = fs.lstatSync(filename).isDirectory()
|
||
|
runTestFiles(filename, isDirectory, web3)
|
||
|
})
|
||
|
|
||
|
if (!process.argv.slice(2).length) {
|
||
|
log.error('Please specify a filename')
|
||
|
process.exit()
|
||
|
}
|
||
|
|
||
|
commander.parse(process.argv)
|