From d3bb04068bef79f74632800a1e5c3e92574c58d3 Mon Sep 17 00:00:00 2001 From: serapath Date: Tue, 10 Apr 2018 04:26:53 +0100 Subject: [PATCH 01/12] add test-tab (WIP) --- src/app/tabs/test-tab.js | 87 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 src/app/tabs/test-tab.js diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js new file mode 100644 index 0000000000..864fbfcb52 --- /dev/null +++ b/src/app/tabs/test-tab.js @@ -0,0 +1,87 @@ +// var yo = require('yo-yo') +// var csjs = require('csjs-inject') +// var remixLib = require('remix-lib') +// +// var EventManager = remixLib.EventManager +// var styles = remixLib.ui.themeChooser.chooser() +// +// module.exports = class TestTab { +// constructor (opts = { api: {}, events: {} }) { +// const self = this +// self.event = new EventManager() +// self._api = opts.api +// self._events = opts.events +// self._view = { el: null } +// self.data = {} +// self._components = {} +// } +// render () { +// const self = this +// if (self._view.el) return self._view.el +// self._view.el = yo` +//
+// Test Tab +//
` +// return self._view.el +// } +// } +// const css = csjs` +// .testTab { +// position : relative; +// box-sizing : border-box; +// display : flex; +// flex-direction : column; +// align-items : center; +// } +// ` + +/* +.opts_li { + display: block; + font-weight: bold; + color: ${styles.rightPanel.text_Teriary}; +} +.opts_li.active { + color: ${styles.rightPanel.text_Primary}; +} +.opts_li:hover { + color: ${styles.rightPanel.icon_HoverColor_TogglePanel}; +} +.solIcon { + margin-left: 10px; + margin-right: 30px; + display: flex; + align-self: center; + height: 29px; + width: 20px; + background-color: ${styles.colors.transparent}; +} +a { + color: ${styles.rightPanel.text_link}; +} +#optionViews > div { + display: none; +} +#optionViews .pre { + word-wrap: break-word; + background-color: ${styles.rightPanel.BackgroundColor_Pre}; + border-radius: 3px; + display: inline-block; + padding: 0 0.6em; +} +#optionViews .hide { + display: none; +} +.infoBox { + ${styles.infoTextBox} + margin-bottom: 1em; +} +.textBox { + ${styles.textBoxL} + margin-bottom: 1em; +} +.icon { + height: 70%; + margin-right: 2%; +} +*/ From 43ae6a2eb41ff7eed711fe1d510e79242774f3fe Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 12 May 2018 13:04:54 -0400 Subject: [PATCH 02/12] add poc test tab --- .gitignore | 2 + package.json | 9 +- src/app/panels/righthand-panel.js | 4 + src/app/tabs/styles/test-tab-styles.js | 56 +++++++++++ src/app/tabs/test-tab.js | 128 +++++++++---------------- 5 files changed, 112 insertions(+), 87 deletions(-) create mode 100644 src/app/tabs/styles/test-tab-styles.js diff --git a/.gitignore b/.gitignore index af13303645..c664a6e412 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ package-lock.json remix .DS_Store contracts +TODO +.tern-port diff --git a/package.json b/package.json index b9175f126e..2e9a37cf57 100644 --- a/package.json +++ b/package.json @@ -36,9 +36,10 @@ "npm-link-local": "^1.1.0", "npm-run-all": "^4.0.2", "onchange": "^3.2.1", - "remix-core": "latest", - "remix-lib": "latest", - "remix-solidity": "latest", + "remix-core": "/Users/iurimatias/Projects/EthereumFoundation/remix/remix-core", + "remix-lib": "/Users/iurimatias/Projects/EthereumFoundation/remix/remix-lib", + "remix-solidity": "/Users/iurimatias/Projects/EthereumFoundation/remix/remix-solidity", + "remix-tests": "/Users/iurimatias/Projects/EthereumFoundation/remix-tests", "remixd": "git+https://github.com/ethereum/remixd.git", "request": "^2.83.0", "rimraf": "^2.6.1", @@ -52,7 +53,7 @@ "web3": "^0.18.0", "webworkify": "^1.2.1", "yo-yo": "^1.2.2", - "yo-yoify": "^3.1.0" + "yo-yoify": "^3.7.3" }, "dependencies": { "http-server": "0.9.0", diff --git a/src/app/panels/righthand-panel.js b/src/app/panels/righthand-panel.js index 84aff7cceb..bc0136146f 100644 --- a/src/app/panels/righthand-panel.js +++ b/src/app/panels/righthand-panel.js @@ -9,6 +9,7 @@ var AnalysisTab = require('../tabs/analysis-tab') var DebuggerTab = require('../tabs/debugger-tab') var SupportTab = require('../tabs/support-tab') var PluginTab = require('../tabs/plugin-tab') +var TestTab = require('../tabs/test-tab') var PluginManager = require('../plugin/pluginManager') var css = require('./styles/righthand-panel-styles') @@ -54,12 +55,15 @@ function RighthandPanel (appAPI = {}, events = {}, opts = {}) { optionViews.appendChild(debuggerTab.render()) var supportTab = new SupportTab(appAPI, events, opts) optionViews.appendChild(supportTab.render()) + var testTab = new TestTab(appAPI, events, opts) + optionViews.appendChild(testTab.render()) this._view.tabbedMenu.addTab('Compile', 'compileView', optionViews.querySelector('#compileTabView')) this._view.tabbedMenu.addTab('Run', 'runView', optionViews.querySelector('#runTabView')) this._view.tabbedMenu.addTab('Settings', 'settingsView', optionViews.querySelector('#settingsView')) this._view.tabbedMenu.addTab('Analysis', 'staticanalysisView', optionViews.querySelector('#staticanalysisView')) this._view.tabbedMenu.addTab('Debugger', 'debugView', optionViews.querySelector('#debugView')) this._view.tabbedMenu.addTab('Support', 'supportView', optionViews.querySelector('#supportView')) + this._view.tabbedMenu.addTab('Test', 'testView', optionViews.querySelector('#testView')) this._view.tabbedMenu.selectTabByTitle('Compile') self.pluginManager = new PluginManager(opts.pluginAPI, events) diff --git a/src/app/tabs/styles/test-tab-styles.js b/src/app/tabs/styles/test-tab-styles.js new file mode 100644 index 0000000000..882ef5f7eb --- /dev/null +++ b/src/app/tabs/styles/test-tab-styles.js @@ -0,0 +1,56 @@ +var csjs = require('csjs-inject') +var styleGuide = require('../../ui/styles-guide/theme-chooser') +var styles = styleGuide.chooser() + +var css = csjs` +.opts_li { + display: block; + font-weight: bold; + color: ${styles.rightPanel.text_Teriary}; +} +.opts_li.active { + color: ${styles.rightPanel.text_Primary}; +} +.opts_li:hover { + color: ${styles.rightPanel.icon_HoverColor_TogglePanel}; +} +.solIcon { + margin-left: 10px; + margin-right: 30px; + display: flex; + align-self: center; + height: 29px; + width: 20px; + background-color: ${styles.colors.transparent}; +} +a { + color: ${styles.rightPanel.text_link}; +} +#optionViews > div { + display: none; +} +#optionViews .pre { + word-wrap: break-word; + background-color: ${styles.rightPanel.BackgroundColor_Pre}; + border-radius: 3px; + display: inline-block; + padding: 0 0.6em; +} +#optionViews .hide { + display: none; +} +.infoBox { + ${styles.infoTextBox} + margin-bottom: 1em; +} +.textBox { + ${styles.textBoxL} + margin-bottom: 1em; +} +.icon { + height: 70%; + margin-right: 2%; +} +` + +module.exports = css diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index 864fbfcb52..904e9b1493 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -1,87 +1,49 @@ -// var yo = require('yo-yo') -// var csjs = require('csjs-inject') -// var remixLib = require('remix-lib') -// -// var EventManager = remixLib.EventManager -// var styles = remixLib.ui.themeChooser.chooser() -// -// module.exports = class TestTab { -// constructor (opts = { api: {}, events: {} }) { -// const self = this -// self.event = new EventManager() -// self._api = opts.api -// self._events = opts.events -// self._view = { el: null } -// self.data = {} -// self._components = {} -// } -// render () { -// const self = this -// if (self._view.el) return self._view.el -// self._view.el = yo` -//
-// Test Tab -//
` -// return self._view.el -// } -// } -// const css = csjs` -// .testTab { -// position : relative; -// box-sizing : border-box; -// display : flex; -// flex-direction : column; -// align-items : center; -// } -// ` +var yo = require('yo-yo') -/* -.opts_li { - display: block; - font-weight: bold; - color: ${styles.rightPanel.text_Teriary}; -} -.opts_li.active { - color: ${styles.rightPanel.text_Primary}; -} -.opts_li:hover { - color: ${styles.rightPanel.icon_HoverColor_TogglePanel}; -} -.solIcon { - margin-left: 10px; - margin-right: 30px; - display: flex; - align-self: center; - height: 29px; - width: 20px; - background-color: ${styles.colors.transparent}; -} -a { - color: ${styles.rightPanel.text_link}; -} -#optionViews > div { - display: none; -} -#optionViews .pre { - word-wrap: break-word; - background-color: ${styles.rightPanel.BackgroundColor_Pre}; - border-radius: 3px; - display: inline-block; - padding: 0 0.6em; -} -#optionViews .hide { - display: none; -} -.infoBox { - ${styles.infoTextBox} - margin-bottom: 1em; +var css = require('./styles/test-tab-styles') + +var remixTests = require('remix-tests') + +function runTests () { + // remixTests.runTest(testName, testObject, testCallback, resultsCallback) + let contractSources = api.compilerContracts.getSources() + remixTests.runTestSources(contractSources) } -.textBox { - ${styles.textBoxL} - margin-bottom: 1em; + +function testTabView () { + return yo` +
+
+
+
+
+
+

+
+
+ ` } -.icon { - height: 70%; - margin-right: 2%; + +function testTab (api = {}, events = {}, opts = {}) { + window.api = api + console.dir('------') + console.dir(api) + let el = testTabView('') + let gitterIsLoaded = false + + // api.compilerContracts.getSources() + + events.app.register('tabChanged', (tabName) => { + if (tabName !== 'test' || gitterIsLoaded) { + return + } + + yo.update(el, testTabView()) + el.style.display = 'block' + gitterIsLoaded = true + }) + + return { render () { return el } } } -*/ + +module.exports = testTab From 3e872d6ec0cec1495f253e16b402f335ac5ec3e1 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 19 May 2018 07:24:01 -0400 Subject: [PATCH 03/12] add api to get contract sources --- src/app/tabs/test-tab.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index 904e9b1493..30395ac783 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -5,8 +5,7 @@ var css = require('./styles/test-tab-styles') var remixTests = require('remix-tests') function runTests () { - // remixTests.runTest(testName, testObject, testCallback, resultsCallback) - let contractSources = api.compilerContracts.getSources() + let contractSources = window.api.getAllSources() remixTests.runTestSources(contractSources) } From 029485d275f75e220564837d3516598ca25f7d8a Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 19 May 2018 07:34:36 -0400 Subject: [PATCH 04/12] clean up test-tab --- src/app/tabs/test-tab.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index 30395ac783..319ee364cb 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -1,15 +1,13 @@ var yo = require('yo-yo') - var css = require('./styles/test-tab-styles') - var remixTests = require('remix-tests') -function runTests () { - let contractSources = window.api.getAllSources() - remixTests.runTestSources(contractSources) -} +function testTabView (api) { + let runTests = function () { + let contractSources = api.getAllSources() + remixTests.runTestSources(contractSources) + } -function testTabView () { return yo`
@@ -24,20 +22,15 @@ function testTabView () { } function testTab (api = {}, events = {}, opts = {}) { - window.api = api - console.dir('------') - console.dir(api) - let el = testTabView('') + let el = testTabView(api) let gitterIsLoaded = false - // api.compilerContracts.getSources() - events.app.register('tabChanged', (tabName) => { if (tabName !== 'test' || gitterIsLoaded) { return } - yo.update(el, testTabView()) + yo.update(el, testTabView(api)) el.style.display = 'block' gitterIsLoaded = true }) From c32ef28b37d24a7f093a8104a424e4b91afea3cb Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 19 May 2018 10:14:53 -0400 Subject: [PATCH 05/12] update runTestSources to use callbacks --- src/app/tabs/test-tab.js | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index 319ee364cb..d759f3e278 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -3,9 +3,46 @@ var css = require('./styles/test-tab-styles') var remixTests = require('remix-tests') function testTabView (api) { + let testCallback = function (result) { + if (result.type === 'contract') { + console.log('\n ' + result.value) + } else if (result.type === 'testPass') { + console.log('\t✓ ' + result.value) + } else if (result.type === 'testFailure') { + console.log('\t✘ ' + result.value) + } + } + + let resultsCallback = function (_err, result, cb) { + console.dir(result) + console.dir('testName ' + result.context) + console.dir(result.passingNum) + console.dir(result.failureNum) + console.dir(result.timePassed) + cb() + } + + let finalCallback = function (_err, result) { + console.dir('finalCallback') + + if (result.totalPassing > 0) { + console.log((' ' + result.totalPassing + ' passing ') + ('(' + result.totalTime + 's)')) + } + if (result.totalFailing > 0) { + console.log((' ' + result.totalFailing + ' failing')) + } + + result.errors.forEach((error, index) => { + console.log(' ' + (index + 1) + ') ' + error.context + ' ' + error.value) + console.log('') + console.log(('\t error: ' + error.message)) + }) + } + let runTests = function () { let contractSources = api.getAllSources() - remixTests.runTestSources(contractSources) + + remixTests.runTestSources(contractSources, testCallback, resultsCallback, finalCallback) } return yo` From bdc4fd7aae2897e96e65029bc32dd2dad8996bc5 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 19 May 2018 10:36:50 -0400 Subject: [PATCH 06/12] add test results to the view --- src/app/tabs/test-tab.js | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index d759f3e278..9b8e60d319 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -2,40 +2,44 @@ var yo = require('yo-yo') var css = require('./styles/test-tab-styles') var remixTests = require('remix-tests') +function append (container, txt) { + let child = yo`
${txt}
` + container.appendChild(child) +} + function testTabView (api) { + var container = yo`
` + let testCallback = function (result) { if (result.type === 'contract') { - console.log('\n ' + result.value) + append(container, '\n ' + result.value) } else if (result.type === 'testPass') { - console.log('\t✓ ' + result.value) + append(container, '\t✓ ' + result.value) } else if (result.type === 'testFailure') { - console.log('\t✘ ' + result.value) + append(container, '\t✘ ' + result.value) } } let resultsCallback = function (_err, result, cb) { - console.dir(result) - console.dir('testName ' + result.context) - console.dir(result.passingNum) - console.dir(result.failureNum) - console.dir(result.timePassed) + // total stats for the test + // result.passingNum + // result.failureNum + // result.timePassed cb() } let finalCallback = function (_err, result) { - console.dir('finalCallback') - if (result.totalPassing > 0) { - console.log((' ' + result.totalPassing + ' passing ') + ('(' + result.totalTime + 's)')) + append(container, (' ' + result.totalPassing + ' passing ') + ('(' + result.totalTime + 's)')) } if (result.totalFailing > 0) { - console.log((' ' + result.totalFailing + ' failing')) + append(container, (' ' + result.totalFailing + ' failing')) } result.errors.forEach((error, index) => { - console.log(' ' + (index + 1) + ') ' + error.context + ' ' + error.value) - console.log('') - console.log(('\t error: ' + error.message)) + append(container, ' ' + (index + 1) + ') ' + error.context + ' ' + error.value) + append(container, '') + append(container, ('\t error: ' + error.message)) }) } @@ -53,6 +57,7 @@ function testTabView (api) {

+ ${container}
` From 64351e7b681a22a2067edae7f02f9ce7504d90e6 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 19 May 2018 10:53:30 -0400 Subject: [PATCH 07/12] update package.json --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 2e9a37cf57..e358d0cdf6 100644 --- a/package.json +++ b/package.json @@ -36,10 +36,10 @@ "npm-link-local": "^1.1.0", "npm-run-all": "^4.0.2", "onchange": "^3.2.1", - "remix-core": "/Users/iurimatias/Projects/EthereumFoundation/remix/remix-core", - "remix-lib": "/Users/iurimatias/Projects/EthereumFoundation/remix/remix-lib", - "remix-solidity": "/Users/iurimatias/Projects/EthereumFoundation/remix/remix-solidity", - "remix-tests": "/Users/iurimatias/Projects/EthereumFoundation/remix-tests", + "remix-core": "latest", + "remix-lib": "latest", + "remix-solidity": "latest", + "remix-tests": "latest", "remixd": "git+https://github.com/ethereum/remixd.git", "request": "^2.83.0", "rimraf": "^2.6.1", From ae515bd3e729ec3dc212c1d00e6b7f9cc052eea6 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 24 May 2018 15:59:40 +0200 Subject: [PATCH 08/12] reset container --- src/app/tabs/test-tab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index 9b8e60d319..2a06779310 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -45,7 +45,7 @@ function testTabView (api) { let runTests = function () { let contractSources = api.getAllSources() - + container.innerHTML = '' remixTests.runTestSources(contractSources, testCallback, resultsCallback, finalCallback) } From aba399e12c4b8caf7b477f99c8517235b348f5bc Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 30 May 2018 18:09:11 -0400 Subject: [PATCH 09/12] find import for remix-tests --- src/app/compiler/compiler-imports.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/compiler/compiler-imports.js b/src/app/compiler/compiler-imports.js index e306ac9fee..a832f843d8 100644 --- a/src/app/compiler/compiler-imports.js +++ b/src/app/compiler/compiler-imports.js @@ -2,6 +2,7 @@ var base64 = require('js-base64').Base64 var swarmgw = require('swarmgw') var request = require('request') +var assertLibCode = require('remix-tests').assertLibCode module.exports = class CompilerImports { constructor () { @@ -70,6 +71,9 @@ module.exports = class CompilerImports { import (url, loadingCb, cb) { var self = this + if (url === 'remix_tests.sol') { + return cb(null, assertLibCode, 'remix_tests.sol', 'remix_tests', 'remix_tests.sol') + } var imported = this.previouslyHandled[url] if (imported) { return cb(null, imported.content, imported.cleanUrl, imported.type, url) From 81dfe515d016f56af671196995962414ea0451f4 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 30 May 2018 18:09:29 -0400 Subject: [PATCH 10/12] fix handling of remix tests sol file --- src/app.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app.js b/src/app.js index f970ddb079..8cb910ebe9 100644 --- a/src/app.js +++ b/src/app.js @@ -242,7 +242,9 @@ Please make a backup of your contracts and start using http://remix.ethereum.org }, (error, content, cleanUrl, type, url) => { if (!error) { - filesProviders[type].addReadOnly(cleanUrl, content, url) + if (filesProviders[type]) { + filesProviders[type].addReadOnly(cleanUrl, content, url) + } cb(null, content) } else { cb(error) From 0e96c32c1957570f76ab26496b27b9e5644d68c6 Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 1 Jun 2018 09:25:40 +0200 Subject: [PATCH 11/12] loop over _test.sol to run test move test injection in importFileCb --- src/app.js | 8 ++++++++ src/app/compiler/compiler-imports.js | 4 ---- src/app/files/fileManager.js | 8 ++++++++ src/app/tabs/test-tab.js | 21 +++++++++++++++++++-- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/app.js b/src/app.js index 8cb910ebe9..1afff93e76 100644 --- a/src/app.js +++ b/src/app.js @@ -6,6 +6,7 @@ var yo = require('yo-yo') var async = require('async') var request = require('request') var remixLib = require('remix-lib') +var remixTests = require('remix-tests') var EventManager = remixLib.EventManager var UniversalDApp = require('./universal-dapp.js') @@ -253,6 +254,9 @@ Please make a backup of your contracts and start using http://remix.ethereum.org } function importFileCb (url, filecb) { + if (url.indexOf('/remix_tests.sol') !== -1) { + return filecb(null, remixTests.assertLibCode) + } var provider = fileManager.fileProviderOf(url) if (provider) { provider.exists(url, (error, exist) => { @@ -714,6 +718,10 @@ Please make a backup of your contracts and start using http://remix.ethereum.org // ---------------- Righthand-panel -------------------- var rhpAPI = { + importFileCb: importFileCb, + filesFromPath: (path, cb) => { + fileManager.filesFromPath(path, cb) + }, newAccount: (pass, cb) => { udapp.newAccount(pass, cb) }, diff --git a/src/app/compiler/compiler-imports.js b/src/app/compiler/compiler-imports.js index a832f843d8..e306ac9fee 100644 --- a/src/app/compiler/compiler-imports.js +++ b/src/app/compiler/compiler-imports.js @@ -2,7 +2,6 @@ var base64 = require('js-base64').Base64 var swarmgw = require('swarmgw') var request = require('request') -var assertLibCode = require('remix-tests').assertLibCode module.exports = class CompilerImports { constructor () { @@ -71,9 +70,6 @@ module.exports = class CompilerImports { import (url, loadingCb, cb) { var self = this - if (url === 'remix_tests.sol') { - return cb(null, assertLibCode, 'remix_tests.sol', 'remix_tests', 'remix_tests.sol') - } var imported = this.previouslyHandled[url] if (imported) { return cb(null, imported.content, imported.cleanUrl, imported.type, url) diff --git a/src/app/files/fileManager.js b/src/app/files/fileManager.js index 0d974200fb..9af4d38420 100644 --- a/src/app/files/fileManager.js +++ b/src/app/files/fileManager.js @@ -155,6 +155,14 @@ class FileManager { } } + filesFromPath (path, cb) { + var provider = this.fileProviderOf(path) + if (provider) { + return provider.resolveDirectory(path, (error, filesTree) => { cb(error, filesTree) }) + } + cb(`provider for path ${path} not found`) + } + fileProviderOf (file) { var provider = file.match(/[^/]*/) if (provider !== null && this.opt.filesProviders[provider[0]]) { diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index 2a06779310..c5dffd88c0 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -43,10 +43,27 @@ function testTabView (api) { }) } + function runTest (testFilePath) { + var provider = api.fileProviderOf(testFilePath) + provider.get(testFilePath, (error, content) => { + if (!error) { + var runningTest = {} + runningTest[testFilePath] = { content } + remixTests.runTestSources(runningTest, testCallback, resultsCallback, finalCallback, api.importFileCb) + } + }) + } + let runTests = function () { - let contractSources = api.getAllSources() container.innerHTML = '' - remixTests.runTestSources(contractSources, testCallback, resultsCallback, finalCallback) + var path = api.currentPath() + api.filesFromPath(path, (error, files) => { + if (!error) { + for (var file in files) { + if (/.(_test.sol)$/.exec(file)) runTest(path + file) + } + } + }) } return yo` From a55172d4a4f0276b44dcd1fa5ef43e931105f4ce Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 1 Jun 2018 10:16:09 +0200 Subject: [PATCH 12/12] run each test in series --- src/app/tabs/test-tab.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index c5dffd88c0..ae778bad3d 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -1,4 +1,5 @@ var yo = require('yo-yo') +var async = require('async') var css = require('./styles/test-tab-styles') var remixTests = require('remix-tests') @@ -28,7 +29,7 @@ function testTabView (api) { cb() } - let finalCallback = function (_err, result) { + let updateFinalResult = function (_err, result) { if (result.totalPassing > 0) { append(container, (' ' + result.totalPassing + ' passing ') + ('(' + result.totalTime + 's)')) } @@ -43,13 +44,16 @@ function testTabView (api) { }) } - function runTest (testFilePath) { + function runTest (testFilePath, callback) { var provider = api.fileProviderOf(testFilePath) provider.get(testFilePath, (error, content) => { if (!error) { var runningTest = {} runningTest[testFilePath] = { content } - remixTests.runTestSources(runningTest, testCallback, resultsCallback, finalCallback, api.importFileCb) + remixTests.runTestSources(runningTest, testCallback, resultsCallback, (error, result) => { + updateFinalResult(error, result) + callback(error) + }, api.importFileCb) } }) } @@ -57,11 +61,13 @@ function testTabView (api) { let runTests = function () { container.innerHTML = '' var path = api.currentPath() + var tests = [] api.filesFromPath(path, (error, files) => { if (!error) { for (var file in files) { - if (/.(_test.sol)$/.exec(file)) runTest(path + file) + if (/.(_test.sol)$/.exec(file)) tests.push(path + file) } + async.eachOfSeries(tests, (value, key, callback) => { runTest(value, callback) }) } }) }