Commit 25d30843 authored by Iuri Matias's avatar Iuri Matias

run all contracts in test file; determine contractName

parent e2fb6464
var async = require('async'); const async = require('async');
const path = require('path');
require('colors'); require('colors');
let Compiler = require('./src/compiler.js'); let Compiler = require('./src/compiler.js');
...@@ -15,9 +16,16 @@ var runTestFile = function(filename, web3) { ...@@ -15,9 +16,16 @@ var runTestFile = function(filename, web3) {
Compiler.compileFile(filename, next); Compiler.compileFile(filename, next);
}, },
function deployAllContracts(compilationResult, next) { function deployAllContracts(compilationResult, next) {
Deployer.deployAll(compilationResult, web3, next); Deployer.deployAll(compilationResult, web3, function(err, contracts) {
if (err) {
next(err);
}
let contractsToTest = Object.keys(compilationResult[path.basename(filename)]);
next(null, contractsToTest, contracts);
});
}, },
function runTests(contracts, next) { function runTests(contractsToTest, contracts, next) {
var testCallback = function(result) { var testCallback = function(result) {
if (result.type === 'contract') { if (result.type === 'contract') {
console.log(("#" + result.value).green); console.log(("#" + result.value).green);
...@@ -37,11 +45,11 @@ var runTestFile = function(filename, web3) { ...@@ -37,11 +45,11 @@ var runTestFile = function(filename, web3) {
if (result.failureNum > 0) { if (result.failureNum > 0) {
console.log((result.failureNum + " failing").red); console.log((result.failureNum + " failing").red);
} }
next();
} }
// TODO: MyTest should be determined from filename async.eachLimit(contractsToTest, 1, (contractName, cb) => {
runTest(filename, contracts.MyTest, testCallback, resultsCallback); runTest(contractName, contracts[contractName], testCallback, resultsCallback);
}, next);
} }
], function() { ], function() {
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment