Merge branch 'fixflaky' of https://github.com/ethereum/remix-project into fixflaky

pull/5370/head
filip mertens 3 years ago
commit 83263b4fa4
  1. 6
      apps/remix-ide/src/app/tabs/test-tab.js
  2. 7
      libs/remix-core-plugin/src/lib/compiler-content-imports.ts

@ -13,7 +13,7 @@ var { UnitTestRunner, assertLibCode } = require('@remix-project/remix-tests')
const profile = { const profile = {
name: 'solidityUnitTesting', name: 'solidityUnitTesting',
displayName: 'Solidity unit testing', displayName: 'Solidity unit testing',
methods: ['testFromPath', 'testFromSource', 'setTestFolderPath', 'getTestlibs'], methods: ['testFromPath', 'testFromSource', 'setTestFolderPath', 'getTestlibs', 'createTestLibs'],
events: [], events: [],
icon: 'assets/img/unitTesting.webp', icon: 'assets/img/unitTesting.webp',
description: 'Fast tool to generate unit tests for your contracts', description: 'Fast tool to generate unit tests for your contracts',
@ -63,8 +63,8 @@ module.exports = class TestTab extends ViewPlugin {
async createTestLibs () { async createTestLibs () {
const provider = await this.fileManager.currentFileProvider() const provider = await this.fileManager.currentFileProvider()
if (provider) { if (provider) {
provider.addExternal('.deps/remix-tests/remix_tests.sol', assertLibCode, 'remix_tests.sol') await provider.addExternal('.deps/remix-tests/remix_tests.sol', assertLibCode, 'remix_tests.sol')
provider.addExternal('.deps/remix-tests/remix_accounts.sol', this.testRunner.accountsLibCode, 'remix_accounts.sol') await provider.addExternal('.deps/remix-tests/remix_accounts.sol', this.testRunner.accountsLibCode, 'remix_accounts.sol')
} }
} }

@ -129,14 +129,17 @@ export class CompilerImports extends Plugin {
if (provider.type === 'localhost' && !provider.isConnected()) { if (provider.type === 'localhost' && !provider.isConnected()) {
throw new Error(`file provider ${provider.type} not available while trying to resolve ${url}`) throw new Error(`file provider ${provider.type} not available while trying to resolve ${url}`)
} }
const exist = await provider.exists(url) let exist = await provider.exists(url)
/* /*
if the path is absolute and the file does not exist, we can stop here if the path is absolute and the file does not exist, we can stop here
Doesn't make sense to try to resolve "localhost/node_modules/localhost/node_modules/<path>" and we'll end in an infinite loop. Doesn't make sense to try to resolve "localhost/node_modules/localhost/node_modules/<path>" and we'll end in an infinite loop.
*/ */
if (!exist && (url === 'remix_tests.sol' || url === 'remix_accounts.sol')) {
await this.call('solidityUnitTesting', 'createTestLibs')
exist = await provider.exists(url)
}
if (!exist && url.startsWith('browser/')) throw new Error(`not found ${url}`) if (!exist && url.startsWith('browser/')) throw new Error(`not found ${url}`)
if (!exist && url.startsWith('localhost/')) throw new Error(`not found ${url}`) if (!exist && url.startsWith('localhost/')) throw new Error(`not found ${url}`)
if (exist) { if (exist) {
const content = await (() => { const content = await (() => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {

Loading…
Cancel
Save