mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-20 01:18:52 +00:00
make tests work by using events
This commit is contained in:
parent
ca3aea7923
commit
ddc8b36329
@ -537,16 +537,14 @@ class EmbarkController {
|
|||||||
client: options.client,
|
client: options.client,
|
||||||
locale: options.locale,
|
locale: options.locale,
|
||||||
version: this.version,
|
version: this.version,
|
||||||
embarkConfig: 'embark.json',
|
embarkConfig: options.embarkConfig || 'embark.json',
|
||||||
interceptLogs: false,
|
|
||||||
logFile: options.logFile,
|
logFile: options.logFile,
|
||||||
logLevel: options.logLevel,
|
logLevel: options.logLevel,
|
||||||
events: options.events,
|
|
||||||
logger: options.logger,
|
|
||||||
config: options.config,
|
|
||||||
plugins: options.plugins,
|
|
||||||
context: this.context,
|
context: this.context,
|
||||||
webpackConfigName: options.webpackConfigName
|
useDashboard: options.useDashboard,
|
||||||
|
webpackConfigName: options.webpackConfigName,
|
||||||
|
ipcRole: 'client',
|
||||||
|
interceptLogs: false
|
||||||
});
|
});
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
@ -555,8 +553,10 @@ class EmbarkController {
|
|||||||
},
|
},
|
||||||
function startServices(callback) {
|
function startServices(callback) {
|
||||||
engine.startService("processManager");
|
engine.startService("processManager");
|
||||||
|
engine.startService("libraryManager");
|
||||||
engine.startService("web3", {wait: true}); // Empty web3 as Test changes it
|
engine.startService("web3", {wait: true}); // Empty web3 as Test changes it
|
||||||
engine.startService("deployment");
|
engine.startService("deployment");
|
||||||
|
engine.startService("codeGenerator");
|
||||||
engine.startService("testRunner");
|
engine.startService("testRunner");
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
|
@ -13,7 +13,7 @@ const unitRegex = /([0-9]+) ([a-zA-Z]+)/;
|
|||||||
|
|
||||||
var Config = function(options) {
|
var Config = function(options) {
|
||||||
const self = this;
|
const self = this;
|
||||||
this.env = options.env;
|
this.env = options.env || 'default';
|
||||||
this.blockchainConfig = {};
|
this.blockchainConfig = {};
|
||||||
this.contractsConfig = {};
|
this.contractsConfig = {};
|
||||||
this.pipelineConfig = {};
|
this.pipelineConfig = {};
|
||||||
|
@ -67,9 +67,11 @@ class BlockchainConnector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'vm') {
|
if (type === 'vm') {
|
||||||
this.provider = this._getSimulator().provider;
|
const sim = this._getSimulator();
|
||||||
this.web3.setProvider(this.provider(this.contractsConfig.deployment));
|
this.provider = sim.provider(this.contractsConfig.deployment);
|
||||||
return self._emitWeb3Ready();
|
this.web3.setProvider(this.provider);
|
||||||
|
this._emitWeb3Ready();
|
||||||
|
return cb();
|
||||||
}
|
}
|
||||||
|
|
||||||
protocol = (type === "rpc") ? protocol : 'ws';
|
protocol = (type === "rpc") ? protocol : 'ws';
|
||||||
|
@ -55,7 +55,6 @@ class Solidity {
|
|||||||
|
|
||||||
self.logger.info(__("loading solc compiler") + "..");
|
self.logger.info(__("loading solc compiler") + "..");
|
||||||
self.solcW.load_compiler(function (err) {
|
self.solcW.load_compiler(function (err) {
|
||||||
console.log('LOADED');
|
|
||||||
self.solcAlreadyLoaded = true;
|
self.solcAlreadyLoaded = true;
|
||||||
callback(err);
|
callback(err);
|
||||||
});
|
});
|
||||||
@ -147,7 +146,6 @@ class Solidity {
|
|||||||
callback(null, compiled_object);
|
callback(null, compiled_object);
|
||||||
}
|
}
|
||||||
], function (err, result) {
|
], function (err, result) {
|
||||||
console.log('COMPLETED COMPILATION', err);
|
|
||||||
cb(err, result);
|
cb(err, result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ const NpmTimer = require('../library_manager/npmTimer');
|
|||||||
class SolcProcess extends ProcessWrapper {
|
class SolcProcess extends ProcessWrapper {
|
||||||
|
|
||||||
constructor(options){
|
constructor(options){
|
||||||
console.error('ALLO');
|
|
||||||
super({pingParent: false});
|
super({pingParent: false});
|
||||||
this._logger = options.logger;
|
this._logger = options.logger;
|
||||||
this._showSpinner = options.showSpinner === true;
|
this._showSpinner = options.showSpinner === true;
|
||||||
@ -67,7 +66,6 @@ class SolcProcess extends ProcessWrapper {
|
|||||||
|
|
||||||
let solcProcess;
|
let solcProcess;
|
||||||
process.on('message', (msg) => {
|
process.on('message', (msg) => {
|
||||||
console.error('MSG', msg.action);
|
|
||||||
if (msg.action === "init") {
|
if (msg.action === "init") {
|
||||||
solcProcess = new SolcProcess(msg.options);
|
solcProcess = new SolcProcess(msg.options);
|
||||||
return process.send({result: "initiated"});
|
return process.send({result: "initiated"});
|
||||||
|
@ -45,7 +45,6 @@ class SolcW {
|
|||||||
events: self.events,
|
events: self.events,
|
||||||
silent: false
|
silent: false
|
||||||
});
|
});
|
||||||
console.log(utils.joinPath(__dirname, 'solcP.js'));
|
|
||||||
|
|
||||||
this.solcProcess.once("result", "initiated", () => {
|
this.solcProcess.once("result", "initiated", () => {
|
||||||
this.events.request("version:get:solc", function(solcVersion) {
|
this.events.request("version:get:solc", function(solcVersion) {
|
||||||
|
@ -64,7 +64,7 @@ class TestRunner {
|
|||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
console.log(`Coverage report created. You can find it here: ${fs.dappPath('coverage/__root__/index.html')}\n`);
|
self.logger.info(`Coverage report created. You can find it here: ${fs.dappPath('coverage/__root__/index.html')}\n`);
|
||||||
const opn = require('opn');
|
const opn = require('opn');
|
||||||
const _next = () => { next(null, results); };
|
const _next = () => { next(null, results); };
|
||||||
if (options.noBrowser) {
|
if (options.noBrowser) {
|
||||||
@ -78,14 +78,14 @@ class TestRunner {
|
|||||||
}
|
}
|
||||||
], (err, results) => {
|
], (err, results) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
self.logger.error(err);
|
||||||
return cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
let totalFailures = results.reduce((acc, result) => acc + result.failures, 0);
|
let totalFailures = results.reduce((acc, result) => acc + result.failures, 0);
|
||||||
if (totalFailures) {
|
if (totalFailures) {
|
||||||
return cb(` > Total number of failures: ${totalFailures}`.red.bold);
|
return cb(` > Total number of failures: ${totalFailures}`.red.bold);
|
||||||
}
|
}
|
||||||
console.log(' > All tests passed'.green.bold);
|
self.logger.info(' > All tests passed'.green.bold);
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -131,8 +131,8 @@ class TestRunner {
|
|||||||
global.config = test.config.bind(test);
|
global.config = test.config.bind(test);
|
||||||
|
|
||||||
let deprecatedWarning = function () {
|
let deprecatedWarning = function () {
|
||||||
console.error(__('%s are not supported anymore', 'EmbarkSpec & deployAll').red);
|
self.logger.error(__('%s are not supported anymore', 'EmbarkSpec & deployAll').red);
|
||||||
console.info(__('You can learn about the new revamped tests here: %s', 'https://embark.status.im/docs/testing.html'.underline));
|
self.logger.info(__('You can learn about the new revamped tests here: %s', 'https://embark.status.im/docs/testing.html'.underline));
|
||||||
process.exit();
|
process.exit();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ class TestRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runSolidityTests(files, options, cb) {
|
runSolidityTests(files, options, cb) {
|
||||||
console.log('Running solc tests');
|
self.logger.info('Running solc tests');
|
||||||
const loglevel = options.loglevel || 'warn';
|
const loglevel = options.loglevel || 'warn';
|
||||||
let solcTest = new SolcTest({loglevel, node: options.node});
|
let solcTest = new SolcTest({loglevel, node: options.node});
|
||||||
global.embark = solcTest;
|
global.embark = solcTest;
|
||||||
|
@ -101,6 +101,7 @@ class Test {
|
|||||||
this.configObj.contractsConfig.deployment = this.simOptions;
|
this.configObj.contractsConfig.deployment = this.simOptions;
|
||||||
this.blockchainConnector.contractsConfig = this.configObj.contractsConfig;
|
this.blockchainConnector.contractsConfig = this.configObj.contractsConfig;
|
||||||
this.blockchainConnector.isWeb3Ready = false;
|
this.blockchainConnector.isWeb3Ready = false;
|
||||||
|
this.blockchainConnector.wait = false;
|
||||||
|
|
||||||
// TODO change this
|
// TODO change this
|
||||||
if (this.simOptions.host || (this.options.node && this.options.node !== 'vm')) {
|
if (this.simOptions.host || (this.options.node && this.options.node !== 'vm')) {
|
||||||
@ -123,11 +124,11 @@ class Test {
|
|||||||
isDev: false,
|
isDev: false,
|
||||||
web3Endpoint: endpoint
|
web3Endpoint: endpoint
|
||||||
};
|
};
|
||||||
console.info(`Connecting to node at ${endpoint}`.cyan);
|
self.logger.info(`Connecting to node at ${endpoint}`.cyan);
|
||||||
|
|
||||||
return utils.pingEndpoint(host, port, type, protocol, this.configObj.blockchainConfig.wsOrigins.split(',')[0], (err) => {
|
return utils.pingEndpoint(host, port, type, protocol, this.configObj.blockchainConfig.wsOrigins.split(',')[0], (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(`Error connecting to the node, there might be an error in ${endpoint}`.red);
|
self.logger.error(`Error connecting to the node, there might be an error in ${endpoint}`.red);
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,6 +304,12 @@ class Test {
|
|||||||
function checkDeploymentOpts(next) {
|
function checkDeploymentOpts(next) {
|
||||||
self.checkDeploymentOptions(options, next);
|
self.checkDeploymentOptions(options, next);
|
||||||
},
|
},
|
||||||
|
function updateWeb3(next) {
|
||||||
|
self.events.request("blockchain:get", function(web3) {
|
||||||
|
self.web3 = web3;
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
},
|
||||||
function compileContracts(next) {
|
function compileContracts(next) {
|
||||||
if (!self.firstDeployment) {
|
if (!self.firstDeployment) {
|
||||||
return next();
|
return next();
|
||||||
@ -407,7 +414,8 @@ class Test {
|
|||||||
}
|
}
|
||||||
], function (err, accounts) {
|
], function (err, accounts) {
|
||||||
if (err) {
|
if (err) {
|
||||||
self.logger.log(__('terminating due to error'));
|
self.logger.error(__('terminating due to error'));
|
||||||
|
self.logger.error(err.message || err);
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
callback(null, accounts);
|
callback(null, accounts);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user