From 5cf9048099e5cc22116317ce5ccf8be8118b5688 Mon Sep 17 00:00:00 2001 From: DeviateFish Date: Sun, 26 Feb 2017 14:33:14 -0800 Subject: [PATCH 1/2] Add more options to testing setup Ability to retrieve the logger from contract deployment, as well as override the default `embark.json` --- lib/core/test.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/core/test.js b/lib/core/test.js index 7f00f8a2a..0d01cf554 100644 --- a/lib/core/test.js +++ b/lib/core/test.js @@ -11,9 +11,9 @@ var Config = require('./config.js'); var RunCode = require('./runCode.js'); var TestLogger = require('./test_logger.js'); -var Test = function(_options) { - var options = _options || {}; - var simOptions = options.simulatorOptions || {}; +var Test = function(options) { + this.options = _options || {}; + var simOptions = this.options.simulatorOptions || {}; try { this.sim = require('ethereumjs-testrpc'); @@ -39,12 +39,14 @@ var Test = function(_options) { Test.prototype.deployAll = function(contractsConfig, cb) { var self = this; - var logger = new TestLogger({logLevel: 'debug'}); + var logger = new TestLogger({logLevel: this.options.logLevel || 'debug'}); async.waterfall([ function getConfig(callback) { var config = new Config({env: 'test', logger: logger}); - config.loadConfigFiles({embarkConfig: 'embark.json', interceptLogs: false}); + config.loadConfigFiles({ + interceptLogs: false + }); config.contractsConfig = {contracts: contractsConfig}; callback(null, config); }, @@ -86,7 +88,10 @@ Test.prototype.deployAll = function(contractsConfig, cb) { } self.web3.eth.defaultAccount = accounts[0]; RunCode.doEval(result, self.web3); // jshint ignore:line - cb(); + cb(logger); + } else { + cb(); + } }); }); }; From 2642325868267e5fb79dd9284051da91504275de Mon Sep 17 00:00:00 2001 From: DeviateFish Date: Sun, 26 Feb 2017 14:33:58 -0800 Subject: [PATCH 2/2] Fix scoping --- lib/core/test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/core/test.js b/lib/core/test.js index 0d01cf554..34374701c 100644 --- a/lib/core/test.js +++ b/lib/core/test.js @@ -45,6 +45,7 @@ Test.prototype.deployAll = function(contractsConfig, cb) { function getConfig(callback) { var config = new Config({env: 'test', logger: logger}); config.loadConfigFiles({ + embarkConfig: self.options.embarkConfig || 'embark.json', interceptLogs: false }); config.contractsConfig = {contracts: contractsConfig}; @@ -88,6 +89,7 @@ Test.prototype.deployAll = function(contractsConfig, cb) { } self.web3.eth.defaultAccount = accounts[0]; RunCode.doEval(result, self.web3); // jshint ignore:line + if (self.options.logging) { cb(logger); } else { cb();