Merge branch 'master' into SUTFixes2

pull/1952/head
David Disu 3 years ago committed by GitHub
commit 330a1ee1c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      libs/remix-tests/src/compiler.ts
  2. 22
      libs/remix-tests/src/runTestSources.ts
  3. 5
      libs/remix-ui/editor/src/lib/remix-ui-editor.css
  4. 1
      libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.css
  5. 20
      libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx

@ -1,6 +1,7 @@
import fs from './fileSystem' import fs from './fileSystem'
import async from 'async' import async from 'async'
import path from 'path' import path from 'path'
import deepequal from 'deep-equal'
import Log from './logger' import Log from './logger'
import { Compiler as RemixCompiler } from '@remix-project/remix-solidity' import { Compiler as RemixCompiler } from '@remix-project/remix-solidity'
import { SrcIfc, CompilerConfiguration, CompilationErrors } from './types' import { SrcIfc, CompilerConfiguration, CompilationErrors } from './types'
@ -170,7 +171,8 @@ export function compileFileOrFiles (filename: string, isDirectory: boolean, opts
* @param opts Options * @param opts Options
* @param cb Callback * @param cb Callback
*/ */
export function compileContractSources (sources: SrcIfc, compiler: any, opts: any, cb): void { export function compileContractSources (sources: SrcIfc, newCompConfig: any, importFileCb, UTRunner, opts: any, cb): void {
let compiler
const filepath = opts.testFilePath || '' const filepath = opts.testFilePath || ''
const testFileImportRegEx = /^(import)\s['"](remix_tests.sol|tests.sol)['"];/gm const testFileImportRegEx = /^(import)\s['"](remix_tests.sol|tests.sol)['"];/gm
@ -183,8 +185,28 @@ export function compileContractSources (sources: SrcIfc, compiler: any, opts: an
} }
async.waterfall([ async.waterfall([
function doCompilation (next) { (next) => {
if (!deepequal(UTRunner.compilerConfig, newCompConfig)) {
UTRunner.compilerConfig = newCompConfig
const { currentCompilerUrl, evmVersion, optimize, runs, usingWorker } = newCompConfig
compiler = new RemixCompiler(importFileCb)
compiler.set('evmVersion', evmVersion)
compiler.set('optimize', optimize)
compiler.set('runs', runs)
compiler.loadVersion(usingWorker, currentCompilerUrl)
// @ts-ignore
compiler.event.register('compilerLoaded', this, (version) => {
next()
})
} else {
compiler = UTRunner.compiler
next()
}
},
(next) => {
const compilationFinishedCb = (success, data, source) => { const compilationFinishedCb = (success, data, source) => {
// data.error usually exists for exceptions like worker error etc.
if (!data.error) UTRunner.compiler = compiler
if (opts && opts.event) opts.event.emit('compilationFinished', success, data, source) if (opts && opts.event) opts.event.emit('compilationFinished', success, data, source)
next(null, data) next(null, data)
} }

@ -1,6 +1,4 @@
import async, { ErrorCallback } from 'async' import async, { ErrorCallback } from 'async'
import deepequal from 'deep-equal'
import { Compiler as RemixCompiler } from '@remix-project/remix-solidity'
import { compileContractSources, writeTestAccountsContract } from './compiler' import { compileContractSources, writeTestAccountsContract } from './compiler'
import { deployAll } from './deployer' import { deployAll } from './deployer'
import { runTest } from './testRunner' import { runTest } from './testRunner'
@ -50,29 +48,13 @@ export class UnitTestRunner {
* @param importFileCb Import file callback * @param importFileCb Import file callback
* @param opts Options * @param opts Options
*/ */
async runTestSources (contractSources: SrcIfc, compilerConfig: CompilerConfiguration, testCallback, resultCallback, deployCb:any, finalCallback: any, importFileCb, opts: Options) { async runTestSources (contractSources: SrcIfc, newCompilerConfig: CompilerConfiguration, testCallback, resultCallback, deployCb:any, finalCallback: any, importFileCb, opts: Options) {
opts = opts || {} opts = opts || {}
const sourceASTs: any = {} const sourceASTs: any = {}
if (opts.web3 || opts.accounts) this.init(opts.web3, opts.accounts) if (opts.web3 || opts.accounts) this.init(opts.web3, opts.accounts)
async.waterfall([ async.waterfall([
(next) => { (next) => {
if (!deepequal(this.compilerConfig, compilerConfig)) { compileContractSources(contractSources, newCompilerConfig, importFileCb, this, { accounts: this.testsAccounts, testFilePath: opts.testFilePath, event: this.event }, next)
this.compilerConfig = compilerConfig
const { currentCompilerUrl, evmVersion, optimize, runs, usingWorker } = compilerConfig
this.compiler = new RemixCompiler(importFileCb)
this.compiler.set('evmVersion', evmVersion)
this.compiler.set('optimize', optimize)
this.compiler.set('runs', runs)
this.compiler.loadVersion(usingWorker, currentCompilerUrl)
// @ts-ignore
this.compiler.event.register('compilerLoaded', this, (version) => {
next()
})
} else next()
},
(next) => {
compileContractSources(contractSources, this.compiler, { accounts: this.testsAccounts, testFilePath: opts.testFilePath, event: this.event }, next)
}, },
(compilationResult: compilationInterface, asts: ASTInterface, next) => { (compilationResult: compilationInterface, asts: ASTInterface, next) => {
for (const filename in asts) { for (const filename in asts) {

@ -10,6 +10,11 @@
width: auto; width: auto;
} }
.monaco-hover .markdown-hover > .hover-contents:not(.code-hover-contents) {
max-width: none !important;
word-wrap: break-word;
}
.contextview { .contextview {
opacity: 1; opacity: 1;
position: absolute; position: absolute;

@ -1,5 +1,6 @@
.remixui_home_text { .remixui_home_text {
cursor: pointer; cursor: pointer;
font-size: 0.8rem;
font-weight: normal; font-weight: normal;
max-width: 300px; max-width: 300px;
} }

@ -125,6 +125,7 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => {
} }
const createNewFile = async () => { const createNewFile = async () => {
plugin.verticalIcons.select('filePanel')
await plugin.call('filePanel', 'createNewFile') await plugin.call('filePanel', 'createNewFile')
} }
@ -261,21 +262,22 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => {
<h4>File</h4> <h4>File</h4>
<p className="mb-1"> <p className="mb-1">
<i className="mr-2 far fa-file"></i> <i className="mr-2 far fa-file"></i>
<span className="ml-1 mb-1 remixui_home_text" onClick={() => createNewFile()}>New File</span> <label className="ml-1 mb-1 remixui_home_text" onClick={() => createNewFile()}>New File</label>
</p> </p>
<p className="mb-1"> <p className="mb-1">
<i className="mr-2 far fa-file-alt"></i> <i className="mr-2 far fa-file-alt"></i>
<span className="ml-1 remixui_home_labelIt remixui_home_bigLabelSize remixui_home_text"> <label className="ml-1 remixui_home_labelIt remixui_home_bigLabelSize} remixui_home_text" htmlFor="openFileInput">
Open Files Open Files
<input title="open file" type="file" onChange={(event) => { </label>
event.stopPropagation() <input title="open file" type="file" id="openFileInput" onChange={(event) => {
uploadFile(event.target) event.stopPropagation()
}} multiple /> plugin.verticalIcons.select('filePanel')
</span> uploadFile(event.target)
}} multiple />
</p> </p>
<p className="mb-1"> <p className="mb-1">
<i className="mr-1 far fa-hdd"></i> <i className="mr-1 far fa-hdd"></i>
<span className="ml-1 remixui_home_text" onClick={() => connectToLocalhost()}>Connect to Localhost</span> <label className="ml-1 remixui_home_text" onClick={() => connectToLocalhost()}>Connect to Localhost</label>
</p> </p>
<p className="mt-3 mb-0"><label>LOAD FROM:</label></p> <p className="mt-3 mb-0"><label>LOAD FROM:</label></p>
<div className="btn-group"> <div className="btn-group">
@ -301,7 +303,7 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => {
</p> </p>
<p className="mb-1"> <p className="mb-1">
<i className="mr-2 fab fa-ethereum remixui_home_image"></i> <i className="mr-2 fab fa-ethereum remixui_home_image"></i>
<span className="remixui_home_text" onClick={() => switchToPreviousVersion()}>Old experience</span> <label className="remixui_home_text" onClick={() => switchToPreviousVersion()}>Old experience</label>
</p> </p>
</div> </div>
</div> </div>

Loading…
Cancel
Save