diff --git a/libs/remix-tests/src/compiler.ts b/libs/remix-tests/src/compiler.ts index c14ba4080b..5451fb89ff 100644 --- a/libs/remix-tests/src/compiler.ts +++ b/libs/remix-tests/src/compiler.ts @@ -1,6 +1,9 @@ import fs from './fileSystem' import async from 'async' import path from 'path' +import Log from './logger' +const logger = new Log() +const log = logger.logger import { Compiler as RemixCompiler } from '@remix-project/remix-solidity' import { SrcIfc, CompilerConfiguration, CompilationErrors } from './types' @@ -100,12 +103,21 @@ export function compileFileOrFiles(filename: string, isDirectory: boolean, opts: } } else { // walkSync only if it is a directory + let solFileCount = 0; fs.walkSync(filepath, (foundpath: string) => { // only process .sol files if (foundpath.split('.').pop() === 'sol') { + solFileCount++; processFile(foundpath, sources, true) } }) + if(solFileCount > 0) { + log.info(`${solFileCount} Solidity files found`) + } + else { + log.error(`No Solidity files found`) + process.exit() + } } } catch (e) { // eslint-disable-line no-useless-catch diff --git a/libs/remix-tests/src/run.ts b/libs/remix-tests/src/run.ts index 93725d02ad..9c785de22d 100644 --- a/libs/remix-tests/src/run.ts +++ b/libs/remix-tests/src/run.ts @@ -36,34 +36,42 @@ commander.command('help').description('output usage information').action(functio // get current version commander .option('-v, --verbose ', 'run with verbosity', mapVerbosity) - .action(async (filename) => { - if(!filename.endsWith('_test.sol')){ + .action(async (testsPath) => { + + // 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"') process.exit() } + // Console message 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) { logger.setVerbosity(commander.verbose) log.info('verbosity level set to ' + commander.verbose.blue) } + const web3 = new Web3() const provider: any = new Provider() await provider.init() web3.setProvider(provider) - if (!fs.existsSync(filename)) { - console.error(filename + ' not found') - process.exit(1) - } - - const isDirectory = fs.lstatSync(filename).isDirectory() - runTestFiles(path.resolve(filename), isDirectory, web3) + runTestFiles(path.resolve(testsPath), isDirectory, web3) }) if (!process.argv.slice(2).length) { - log.error('Please specify a filename') + log.error('Please specify a file or directory path') process.exit() }