Commit 11178b2c authored by LianaHus's avatar LianaHus Committed by Aniket

handle errors

parent 9ad00485
...@@ -32,6 +32,7 @@ module.exports = class TestTab extends ViewPlugin { ...@@ -32,6 +32,7 @@ module.exports = class TestTab extends ViewPlugin {
this.hasBeenStopped = false this.hasBeenStopped = false
this.runningTestsNumber = 0 this.runningTestsNumber = 0
this.readyTestsNumber = 0 this.readyTestsNumber = 0
this.areTestsRunning = false
this.baseurl = 'https://solc-bin.ethereum.org/bin' this.baseurl = 'https://solc-bin.ethereum.org/bin'
appManager.event.on('activate', (name) => { appManager.event.on('activate', (name) => {
if (name === 'solidity') this.updateRunAction(fileManager.currentFile()) if (name === 'solidity') this.updateRunAction(fileManager.currentFile())
...@@ -63,7 +64,7 @@ module.exports = class TestTab extends ViewPlugin { ...@@ -63,7 +64,7 @@ module.exports = class TestTab extends ViewPlugin {
this.fileManager.events.on('currentFileChanged', (file, provider) => { this.fileManager.events.on('currentFileChanged', (file, provider) => {
this.updateGenerateFileAction(file) this.updateGenerateFileAction(file)
this.updateRunAction(file) if (!this.areTestsRunning) this.updateRunAction(file)
this.testTabLogic.getTests((error, tests) => { this.testTabLogic.getTests((error, tests) => {
if (error) return tooltip(error) if (error) return tooltip(error)
this.data.allTests = tests this.data.allTests = tests
...@@ -139,22 +140,18 @@ module.exports = class TestTab extends ViewPlugin { ...@@ -139,22 +140,18 @@ module.exports = class TestTab extends ViewPlugin {
updateFinalResult (_errors, result, filename) { updateFinalResult (_errors, result, filename) {
this.testsSummary.hidden = false this.testsSummary.hidden = false
++this.readyTestsNumber
if (_errors && _errors.errors) { if (_errors && _errors.errors) {
_errors.errors.forEach((err) => this.renderer.error(err.formattedMessage || err.message, this.testsSummary, {type: err.severity})) _errors.errors.forEach((err) => this.renderer.error(err.formattedMessage || err.message, this.testsSummary, {type: err.severity}))
return
} else if (_errors && Array.isArray(_errors) && (_errors[0].message || _errors[0].formattedMessage)) { } else if (_errors && Array.isArray(_errors) && (_errors[0].message || _errors[0].formattedMessage)) {
_errors.forEach((err) => this.renderer.error(err.formattedMessage || err.message, this.testsSummary, {type: err.severity})) _errors.forEach((err) => this.renderer.error(err.formattedMessage || err.message, this.testsSummary, {type: err.severity}))
return
} else if (_errors && !_errors.errors && !Array.isArray(_errors)) { } else if (_errors && !_errors.errors && !Array.isArray(_errors)) {
// To track error like this: https://github.com/ethereum/remix/pull/1438 // To track error like this: https://github.com/ethereum/remix/pull/1438
this.renderer.error(_errors.formattedMessage || _errors.message, this.testsSummary, {type: 'error'}) this.renderer.error(_errors.formattedMessage || _errors.message, this.testsSummary, {type: 'error'})
return
} }
this.testsSummary.appendChild(yo`<div class=${css.summaryTitle}> ${filename} </div>`) this.testsSummary.appendChild(yo`<div class=${css.summaryTitle}> ${filename} </div>`)
yo.update(this.resultStatistics, this.createResultLabel())
if (result) { if (result) {
++this.readyTestsNumber
yo.update(this.resultStatistics, this.createResultLabel())
if (result.totalPassing > 0) { if (result.totalPassing > 0) {
this.testsSummary.appendChild(yo`<div class="text-success">${result.totalPassing} passing (${result.totalTime}s)</div>`) this.testsSummary.appendChild(yo`<div class="text-success">${result.totalPassing} passing (${result.totalTime}s)</div>`)
this.testsSummary.appendChild(yo`<br>`) this.testsSummary.appendChild(yo`<br>`)
...@@ -170,6 +167,7 @@ module.exports = class TestTab extends ViewPlugin { ...@@ -170,6 +167,7 @@ module.exports = class TestTab extends ViewPlugin {
}) })
} }
if (this.hasBeenStopped && (this.readyTestsNumber !== this.runningTestsNumber)) { if (this.hasBeenStopped && (this.readyTestsNumber !== this.runningTestsNumber)) {
// if all tests has been through before stopping no need to print this.
this.testsExecutionStopped.hidden = false this.testsExecutionStopped.hidden = false
} }
if (this.hasBeenStopped || this.readyTestsNumber === this.runningTestsNumber) { if (this.hasBeenStopped || this.readyTestsNumber === this.runningTestsNumber) {
...@@ -182,6 +180,7 @@ module.exports = class TestTab extends ViewPlugin { ...@@ -182,6 +180,7 @@ module.exports = class TestTab extends ViewPlugin {
const runBtn = document.getElementById('runTestsTabRunAction') const runBtn = document.getElementById('runTestsTabRunAction')
runBtn.removeAttribute('disabled') runBtn.removeAttribute('disabled')
} }
this.areTestsRunning = false
} }
} }
...@@ -249,6 +248,7 @@ module.exports = class TestTab extends ViewPlugin { ...@@ -249,6 +248,7 @@ module.exports = class TestTab extends ViewPlugin {
} }
runTests () { runTests () {
this.areTestsRunning = true
this.hasBeenStopped = false this.hasBeenStopped = false
this.readyTestsNumber = 0 this.readyTestsNumber = 0
this.runningTestsNumber = this.data.selectedTests.length this.runningTestsNumber = this.data.selectedTests.length
...@@ -275,7 +275,7 @@ module.exports = class TestTab extends ViewPlugin { ...@@ -275,7 +275,7 @@ module.exports = class TestTab extends ViewPlugin {
stopTests () { stopTests () {
this.hasBeenStopped = true this.hasBeenStopped = true
const stopBtnLabel = document.getElementById('runTestsTabStopActionLabel') const stopBtnLabel = document.getElementById('runTestsTabStopActionLabel')
stopBtnLabel.innerText = 'Stopping...' stopBtnLabel.innerText = 'Stopping'
const stopBtn = document.getElementById('runTestsTabStopAction') const stopBtn = document.getElementById('runTestsTabStopAction')
stopBtn.setAttribute('disabled', 'disabled') stopBtn.setAttribute('disabled', 'disabled')
const runBtn = document.getElementById('runTestsTabRunAction') const runBtn = document.getElementById('runTestsTabRunAction')
......
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