From 5f8640e440768e8e0afe699737275ad67e1862f9 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Wed, 22 Sep 2021 16:08:57 +0530 Subject: [PATCH 1/7] type for error passed --- apps/remix-ide/src/app/tabs/test-tab.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index afa3d1bc1c..559d5428ca 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -380,9 +380,9 @@ module.exports = class TestTab extends ViewPlugin { this.setHeader(false) } if (_errors && _errors.errors) { - _errors.errors.forEach((err) => this.renderer.error(err.formattedMessage || err.message, this.testsOutput, { type: err.severity })) + _errors.errors.forEach((err) => this.renderer.error(err.formattedMessage || err.message, this.testsOutput, { type: err.severity, errorType: err.type})) } else if (_errors && Array.isArray(_errors) && (_errors[0].message || _errors[0].formattedMessage)) { - _errors.forEach((err) => this.renderer.error(err.formattedMessage || err.message, this.testsOutput, { type: err.severity })) + _errors.forEach((err) => this.renderer.error(err.formattedMessage || err.message, this.testsOutput, { type: err.severity, errorType: err.type })) } else if (_errors && !_errors.errors && !Array.isArray(_errors)) { // To track error like this: https://github.com/ethereum/remix/pull/1438 this.renderer.error(_errors.formattedMessage || _errors.message, this.testsOutput, { type: 'error' }) From dd271ec4847da921318f5e2a3efd537eb82a9cba Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Wed, 22 Sep 2021 16:21:34 +0530 Subject: [PATCH 2/7] linting fix --- apps/remix-ide/src/app/tabs/test-tab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index 559d5428ca..a316756c4f 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -380,7 +380,7 @@ module.exports = class TestTab extends ViewPlugin { this.setHeader(false) } if (_errors && _errors.errors) { - _errors.errors.forEach((err) => this.renderer.error(err.formattedMessage || err.message, this.testsOutput, { type: err.severity, errorType: err.type})) + _errors.errors.forEach((err) => this.renderer.error(err.formattedMessage || err.message, this.testsOutput, { type: err.severity, errorType: err.type })) } else if (_errors && Array.isArray(_errors) && (_errors[0].message || _errors[0].formattedMessage)) { _errors.forEach((err) => this.renderer.error(err.formattedMessage || err.message, this.testsOutput, { type: err.severity, errorType: err.type })) } else if (_errors && !_errors.errors && !Array.isArray(_errors)) { From df34c5a446a1daaaee2c45b54ae44465adbbde17 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Wed, 22 Sep 2021 17:17:57 +0530 Subject: [PATCH 3/7] error disappearing fixed --- apps/remix-ide/src/app/tabs/test-tab.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index a316756c4f..277abab11d 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -44,6 +44,7 @@ module.exports = class TestTab extends ViewPlugin { this.offsetToLineColumnConverter = offsetToLineColumnConverter this.allFilesInvolved = [] this.isDebugging = false + this.currentErrors = [] appManager.event.on('activate', (name) => { if (name === 'solidity') this.updateRunAction() @@ -117,6 +118,14 @@ module.exports = class TestTab extends ViewPlugin { } async updateForNewCurrent (file) { + // Ensure that when someone clicks on compilation error and that opens a new file + // Test result, which is compilation error in this case, is not cleared + if (this.currentErrors) { + if (Array.isArray(this.currentErrors) && this.currentErrors.length > 0) { + const errFiles = this.currentErrors.map(err => { if (err.sourceLocation && err.sourceLocation.file) return err.sourceLocation.file }) + if (errFiles.includes(file)) return + } else if (this.currentErrors.sourceLocation && this.currentErrors.sourceLocation.file && this.currentErrors.sourceLocation.file === file) return + } // if current file is changed while debugging and one of the files imported in test file are opened // do not clear the test results in SUT plugin if (this.isDebugging && this.allFilesInvolved.includes(file)) return @@ -377,6 +386,7 @@ module.exports = class TestTab extends ViewPlugin { this.testsOutput.hidden = false if (!result && (_errors && (_errors.errors || (Array.isArray(_errors) && (_errors[0].message || _errors[0].formattedMessage))))) { this.testCallback({ type: 'contract', filename }) + this.currentErrors = _errors.errors this.setHeader(false) } if (_errors && _errors.errors) { From 37cbff80804ba966a2e28b489795a26c4600586c Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Thu, 23 Sep 2021 14:06:47 +0530 Subject: [PATCH 4/7] e2e tests update for failed compilation --- .../src/tests/solidityUnittests.spec.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts index 84061517fa..09788a88e1 100644 --- a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts +++ b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts @@ -93,8 +93,7 @@ module.exports = { 'Should fail on compilation': function (browser: NightwatchBrowser) { browser.waitForElementPresent('*[data-id="verticalIconsKindfilePanel"]') .addFile('tests/compilationError_test.sol', sources[0]['compilationError_test.sol']) - .clickLaunchIcon('filePanel') - .openFile('tests/compilationError_test.sol') + .click('div[title="default_workspace/tests/compilationError_test.sol"] span[class="close"]') .clickLaunchIcon('solidityUnitTesting') .pause(2000) .click('*[data-id="testTabCheckAllTests"]') @@ -102,6 +101,17 @@ module.exports = { .scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]') .waitForElementContainsText('*[data-id="testTabSolidityUnitTestsOutput"]', 'SyntaxError: No visibility specified', 120000) .waitForElementContainsText('*[data-id="testTabTestsExecutionStoppedError"]', 'The test execution has been stopped because of error(s) in your test file', 120000) + .click('*[data-id="tests/compilationError_test.sol"]') + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(` + contract failOnCompilation { + fallback() { + + } + }`) !== -1, + 'current displayed content is not from the compilationError_test source code') + }) + .pause(20000) }, 'Should fail on deploy': function (browser: NightwatchBrowser) { From 727315fae50d5b3e459fcd8fb34241d24c21c7a1 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Thu, 23 Sep 2021 14:46:15 +0530 Subject: [PATCH 5/7] final e2e tests for compilation error check --- .../src/tests/solidityUnittests.spec.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts index 09788a88e1..7c5e9322aa 100644 --- a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts +++ b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts @@ -90,7 +90,7 @@ module.exports = { .waitForElementContainsText('*[data-id="testTabTestsExecutionStopped"]', 'The test execution has been stopped', 60000) }, - 'Should fail on compilation': function (browser: NightwatchBrowser) { + 'Should fail on compilation, open file on error click, not disappear error': function (browser: NightwatchBrowser) { browser.waitForElementPresent('*[data-id="verticalIconsKindfilePanel"]') .addFile('tests/compilationError_test.sol', sources[0]['compilationError_test.sol']) .click('div[title="default_workspace/tests/compilationError_test.sol"] span[class="close"]') @@ -102,16 +102,9 @@ module.exports = { .waitForElementContainsText('*[data-id="testTabSolidityUnitTestsOutput"]', 'SyntaxError: No visibility specified', 120000) .waitForElementContainsText('*[data-id="testTabTestsExecutionStoppedError"]', 'The test execution has been stopped because of error(s) in your test file', 120000) .click('*[data-id="tests/compilationError_test.sol"]') - .getEditorValue((content) => { - browser.assert.ok(content.indexOf(` - contract failOnCompilation { - fallback() { - - } - }`) !== -1, - 'current displayed content is not from the compilationError_test source code') - }) - .pause(20000) + .pause(1000) + .getEditorValue((content) => browser.assert.ok(content.indexOf(`contract failOnCompilation {`) !== -1)) + .verify.elementPresent('*[data-id="tests/compilationError_test.sol"]') }, 'Should fail on deploy': function (browser: NightwatchBrowser) { @@ -451,7 +444,7 @@ const sources = [ }, 'compilationError_test.sol': { content: ` - pragma solidity ^0.7.0; + pragma solidity ^0.8.0; contract failOnCompilation { fallback() { From 68c1e709e774a68435ca473657245916d0a1f311 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Thu, 23 Sep 2021 15:20:50 +0530 Subject: [PATCH 6/7] linting fix --- apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts index 7c5e9322aa..59f8b8d050 100644 --- a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts +++ b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts @@ -103,7 +103,7 @@ module.exports = { .waitForElementContainsText('*[data-id="testTabTestsExecutionStoppedError"]', 'The test execution has been stopped because of error(s) in your test file', 120000) .click('*[data-id="tests/compilationError_test.sol"]') .pause(1000) - .getEditorValue((content) => browser.assert.ok(content.indexOf(`contract failOnCompilation {`) !== -1)) + .getEditorValue((content) => browser.assert.ok(content.indexOf('contract failOnCompilation {') !== -1)) .verify.elementPresent('*[data-id="tests/compilationError_test.sol"]') }, From ef17ba298162b63a18984b8b936e8edd9936cd50 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Fri, 24 Sep 2021 00:19:14 +0530 Subject: [PATCH 7/7] comment added --- apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts index 59f8b8d050..da986f4898 100644 --- a/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts +++ b/apps/remix-ide-e2e/src/tests/solidityUnittests.spec.ts @@ -104,6 +104,8 @@ module.exports = { .click('*[data-id="tests/compilationError_test.sol"]') .pause(1000) .getEditorValue((content) => browser.assert.ok(content.indexOf('contract failOnCompilation {') !== -1)) + // Verify that compilation error is still present after a file is opened + // usually, tests result is cleared on opening a new file .verify.elementPresent('*[data-id="tests/compilationError_test.sol"]') },