|
|
@ -1,7 +1,7 @@ |
|
|
|
import async from 'async' |
|
|
|
import async from 'async' |
|
|
|
import fs from './fileSystem' |
|
|
|
import fs from './fileSystem' |
|
|
|
import { runTest } from './testRunner' |
|
|
|
import { runTest } from './testRunner' |
|
|
|
import { TestResultInterface, ResultsInterface } from './types' |
|
|
|
import { TestResultInterface, ResultsInterface, compilationInterface, ASTInterface } from './types' |
|
|
|
import colors from 'colors' |
|
|
|
import colors from 'colors' |
|
|
|
import Web3 = require('web3') |
|
|
|
import Web3 = require('web3') |
|
|
|
|
|
|
|
|
|
|
@ -18,7 +18,7 @@ import { deployAll } from './deployer' |
|
|
|
|
|
|
|
|
|
|
|
export function runTestFiles(filepath: string, isDirectory: boolean, web3: Web3, opts?: object) { |
|
|
|
export function runTestFiles(filepath: string, isDirectory: boolean, web3: Web3, opts?: object) { |
|
|
|
opts = opts || {} |
|
|
|
opts = opts || {} |
|
|
|
let sourceASTs: any = {} |
|
|
|
const sourceASTs: any = {} |
|
|
|
const { Signale } = require('signale') |
|
|
|
const { Signale } = require('signale') |
|
|
|
// signale configuration
|
|
|
|
// signale configuration
|
|
|
|
const options = { |
|
|
|
const options = { |
|
|
@ -53,10 +53,9 @@ export function runTestFiles(filepath: string, isDirectory: boolean, web3: Web3, |
|
|
|
function compile(next: Function) { |
|
|
|
function compile(next: Function) { |
|
|
|
compileFileOrFiles(filepath, isDirectory, { accounts }, next) |
|
|
|
compileFileOrFiles(filepath, isDirectory, { accounts }, next) |
|
|
|
}, |
|
|
|
}, |
|
|
|
function deployAllContracts (compilationResult, asts, next: Function) { |
|
|
|
function deployAllContracts (compilationResult: compilationInterface, asts: ASTInterface, next: Function) { |
|
|
|
// Extract AST of test contract file source
|
|
|
|
// Extract AST of test contract file source
|
|
|
|
for(const filename in asts) |
|
|
|
for(const filename in asts) { |
|
|
|
{ |
|
|
|
|
|
|
|
if(filename.includes('_test.sol')) |
|
|
|
if(filename.includes('_test.sol')) |
|
|
|
sourceASTs[filename] = asts[filename].ast |
|
|
|
sourceASTs[filename] = asts[filename].ast |
|
|
|
} |
|
|
|
} |
|
|
@ -67,8 +66,8 @@ export function runTestFiles(filepath: string, isDirectory: boolean, web3: Web3, |
|
|
|
next(null, compilationResult, contracts) |
|
|
|
next(null, compilationResult, contracts) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
function determineTestContractsToRun (compilationResult, contracts, next: Function) { |
|
|
|
function determineTestContractsToRun (compilationResult: compilationInterface, contracts: any, next: Function) { |
|
|
|
let contractsToTest: any[] = [] |
|
|
|
let contractsToTest: string[] = [] |
|
|
|
let contractsToTestDetails: any[] = [] |
|
|
|
let contractsToTestDetails: any[] = [] |
|
|
|
const gatherContractsFrom = function(filename: string) { |
|
|
|
const gatherContractsFrom = function(filename: string) { |
|
|
|
if (filename.indexOf('_test.sol') < 0) { |
|
|
|
if (filename.indexOf('_test.sol') < 0) { |
|
|
@ -92,7 +91,7 @@ export function runTestFiles(filepath: string, isDirectory: boolean, web3: Web3, |
|
|
|
} |
|
|
|
} |
|
|
|
next(null, contractsToTest, contractsToTestDetails, contracts) |
|
|
|
next(null, contractsToTest, contractsToTestDetails, contracts) |
|
|
|
}, |
|
|
|
}, |
|
|
|
function runTests(contractsToTest, contractsToTestDetails, contracts, next: Function) { |
|
|
|
function runTests(contractsToTest: string[], contractsToTestDetails: any[], contracts: any, next: Function) { |
|
|
|
let totalPassing: number = 0 |
|
|
|
let totalPassing: number = 0 |
|
|
|
let totalFailing: number = 0 |
|
|
|
let totalFailing: number = 0 |
|
|
|
let totalTime: number = 0 |
|
|
|
let totalTime: number = 0 |
|
|
@ -118,7 +117,8 @@ export function runTestFiles(filepath: string, isDirectory: boolean, web3: Web3, |
|
|
|
|
|
|
|
|
|
|
|
async.eachOfLimit(contractsToTest, 1, (contractName: string, index, cb) => { |
|
|
|
async.eachOfLimit(contractsToTest, 1, (contractName: string, index, cb) => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
runTest(contractName, contracts[contractName], contractsToTestDetails[index], sourceASTs[contracts[contractName]['filename']], { accounts }, _testCallback, (err, result) => { |
|
|
|
const fileAST = sourceASTs[contracts[contractName]['filename']] |
|
|
|
|
|
|
|
runTest(contractName, contracts[contractName], contractsToTestDetails[index], fileAST, { accounts }, _testCallback, (err, result) => { |
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
|
console.log(err) |
|
|
|
console.log(err) |
|
|
|
return cb(err) |
|
|
|
return cb(err) |
|
|
|