|
|
@ -36,34 +36,42 @@ commander.command('help').description('output usage information').action(functio |
|
|
|
// get current version
|
|
|
|
// get current version
|
|
|
|
commander |
|
|
|
commander |
|
|
|
.option('-v, --verbose <level>', 'run with verbosity', mapVerbosity) |
|
|
|
.option('-v, --verbose <level>', 'run with verbosity', mapVerbosity) |
|
|
|
.action(async (filename) => { |
|
|
|
.action(async (testsPath) => { |
|
|
|
if(!filename.endsWith('_test.sol')){ |
|
|
|
|
|
|
|
|
|
|
|
// Check if path exists
|
|
|
|
|
|
|
|
if (!fs.existsSync(testsPath)) { |
|
|
|
|
|
|
|
console.error(testsPath + ' not found') |
|
|
|
|
|
|
|
process.exit(1) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if path is for a directory
|
|
|
|
|
|
|
|
const isDirectory = fs.lstatSync(testsPath).isDirectory() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If path is for a file, file name must have `_test.sol` suffix
|
|
|
|
|
|
|
|
if(!isDirectory && !testsPath.endsWith('_test.sol')) { |
|
|
|
log.error('Test filename should end with "_test.sol"') |
|
|
|
log.error('Test filename should end with "_test.sol"') |
|
|
|
process.exit() |
|
|
|
process.exit() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Console message
|
|
|
|
// Console message
|
|
|
|
console.log(colors.white('\n\t👁\t:: Running remix-tests - Unit testing for solidity ::\t👁\n')) |
|
|
|
console.log(colors.white('\n\t👁\t:: Running remix-tests - Unit testing for solidity ::\t👁\n')) |
|
|
|
// set logger verbosity
|
|
|
|
|
|
|
|
|
|
|
|
// Set logger verbosity
|
|
|
|
if (commander.verbose) { |
|
|
|
if (commander.verbose) { |
|
|
|
logger.setVerbosity(commander.verbose) |
|
|
|
logger.setVerbosity(commander.verbose) |
|
|
|
log.info('verbosity level set to ' + commander.verbose.blue) |
|
|
|
log.info('verbosity level set to ' + commander.verbose.blue) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const web3 = new Web3() |
|
|
|
const web3 = new Web3() |
|
|
|
const provider: any = new Provider() |
|
|
|
const provider: any = new Provider() |
|
|
|
await provider.init() |
|
|
|
await provider.init() |
|
|
|
web3.setProvider(provider) |
|
|
|
web3.setProvider(provider) |
|
|
|
|
|
|
|
|
|
|
|
if (!fs.existsSync(filename)) { |
|
|
|
runTestFiles(path.resolve(testsPath), isDirectory, web3) |
|
|
|
console.error(filename + ' not found') |
|
|
|
|
|
|
|
process.exit(1) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isDirectory = fs.lstatSync(filename).isDirectory() |
|
|
|
|
|
|
|
runTestFiles(path.resolve(filename), isDirectory, web3) |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
if (!process.argv.slice(2).length) { |
|
|
|
if (!process.argv.slice(2).length) { |
|
|
|
log.error('Please specify a filename') |
|
|
|
log.error('Please specify a file or directory path') |
|
|
|
process.exit() |
|
|
|
process.exit() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|