Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
508dd8e7
Commit
508dd8e7
authored
Jan 18, 2021
by
aniket-engg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
custom compiler in progress
parent
56286543
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
7 deletions
+56
-7
compiler.ts
libs/remix-solidity/src/compiler/compiler.ts
+35
-0
package.json
libs/remix-tests/package.json
+1
-1
compiler.ts
libs/remix-tests/src/compiler.ts
+4
-5
run.ts
libs/remix-tests/src/run.ts
+1
-1
testRunner.cli.spec.ts
libs/remix-tests/tests/testRunner.cli.spec.ts
+15
-0
No files found.
libs/remix-solidity/src/compiler/compiler.ts
View file @
508dd8e7
...
@@ -164,6 +164,41 @@ export class Compiler {
...
@@ -164,6 +164,41 @@ export class Compiler {
}
}
/**
/**
* @dev Load compiler using given version (used by remix-tests CLI)
* @param version compiler version
*/
loadRemoteVersion
(
version
:
string
):
void
{
console
.
log
(
'Loading remote solc version '
+
version
)
const
compiler
:
any
=
require
(
'solc'
)
compiler
.
loadRemoteVersion
(
version
,
(
err
,
remoteCompiler
)
=>
{
if
(
err
)
{
console
.
error
(
'Error in loading remote solc compiler: '
,
err
)
}
else
{
this
.
state
.
compileJSON
=
(
source
:
SourceWithTarget
)
=>
{
const
missingInputs
:
string
[]
=
[]
const
missingInputsCallback
=
(
path
:
string
)
=>
{
missingInputs
.
push
(
path
)
return
{
error
:
'Deferred import'
}
}
let
result
:
CompilationResult
=
{}
try
{
if
(
source
&&
source
.
sources
)
{
const
{
optimize
,
runs
,
evmVersion
,
language
}
=
this
.
state
const
input
=
compilerInput
(
source
.
sources
,
{
optimize
,
runs
,
evmVersion
,
language
})
result
=
JSON
.
parse
(
remoteCompiler
.
compile
(
input
,
{
import
:
missingInputsCallback
}))
}
}
catch
(
exception
)
{
result
=
{
error
:
{
formattedMessage
:
'Uncaught JavaScript exception:
\
n'
+
exception
,
severity
:
'error'
,
mode
:
'panic'
}
}
}
this
.
onCompilationFinished
(
result
,
missingInputs
,
source
)
}
this
.
onCompilerLoaded
(
version
)
}
})
}
/**
* @dev Load compiler using given URL (used by IDE)
* @dev Load compiler using given URL (used by IDE)
* @param usingWorker if true, load compiler using worker
* @param usingWorker if true, load compiler using worker
* @param url URL to load compiler from
* @param url URL to load compiler from
...
...
libs/remix-tests/package.json
View file @
508dd8e7
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
"dependencies"
:
{
"dependencies"
:
{
"@remix-project/remix-lib"
:
"^0.4.31"
,
"@remix-project/remix-lib"
:
"^0.4.31"
,
"@remix-project/remix-simulator"
:
"^0.1.9-beta.8"
,
"@remix-project/remix-simulator"
:
"^0.1.9-beta.8"
,
"@remix-project/remix-solidity"
:
"
^0.3.32
"
,
"@remix-project/remix-solidity"
:
"
file:../remix-solidity
"
,
"ansi-gray"
:
"^0.1.1"
,
"ansi-gray"
:
"^0.1.1"
,
"async"
:
"^2.6.0"
,
"async"
:
"^2.6.0"
,
"change-case"
:
"^3.0.1"
,
"change-case"
:
"^3.0.1"
,
...
...
libs/remix-tests/src/compiler.ts
View file @
508dd8e7
...
@@ -130,11 +130,10 @@ export function compileFileOrFiles(filename: string, isDirectory: boolean, opts:
...
@@ -130,11 +130,10 @@ export function compileFileOrFiles(filename: string, isDirectory: boolean, opts:
evmVersion
?
compiler
.
set
(
'evmVersion'
,
evmVersion
)
:
evmVersion
?
compiler
.
set
(
'evmVersion'
,
evmVersion
)
:
optimize
?
compiler
.
set
(
'optimize'
,
optimize
)
:
optimize
?
compiler
.
set
(
'optimize'
,
optimize
)
:
runs
?
compiler
.
set
(
'runs'
,
runs
)
:
runs
?
compiler
.
set
(
'runs'
,
runs
)
:
currentCompilerUrl
?
compiler
.
loadVersion
(
'false'
,
currentCompilerUrl
)
:
currentCompilerUrl
?
compiler
.
loadRemoteVersion
(
currentCompilerUrl
)
:
compiler
.
onInternalCompilerLoaded
()
compiler
.
onInternalCompilerLoaded
()
compiler
.
event
.
register
(
'compilerLoaded'
,
this
,
function
(
version
)
{
// compiler.event.register('compilerLoaded', this, function (version) {
next
()
next
()
});
// });
},
},
function
doCompilation
(
next
)
{
function
doCompilation
(
next
)
{
// @ts-ignore
// @ts-ignore
...
...
libs/remix-tests/src/run.ts
View file @
508dd8e7
...
@@ -89,7 +89,7 @@ commander
...
@@ -89,7 +89,7 @@ commander
process
.
exit
()
process
.
exit
()
}
else
{
}
else
{
log
.
info
(
`Compiler version set to
${
compVersion
}
. Latest version is
${
latestRelease
}
`
)
log
.
info
(
`Compiler version set to
${
compVersion
}
. Latest version is
${
latestRelease
}
`
)
compilerConfig
.
currentCompilerUrl
=
baseURL
+
'/'
+
compString
compilerConfig
.
currentCompilerUrl
=
compString
.
replace
(
'soljson-'
,
''
).
replace
(
'.js'
,
''
)
}
}
}
}
...
...
libs/remix-tests/tests/testRunner.cli.spec.ts
View file @
508dd8e7
...
@@ -50,5 +50,19 @@ Commands:
...
@@ -50,5 +50,19 @@ Commands:
expect
(
res
.
stdout
.
toString
().
trim
()).
toMatch
(
/expected value to be ok to: true/
)
expect
(
res
.
stdout
.
toString
().
trim
()).
toMatch
(
/expected value to be ok to: true/
)
expect
(
res
.
stdout
.
toString
().
trim
()).
toMatch
(
/returned: false/
)
expect
(
res
.
stdout
.
toString
().
trim
()).
toMatch
(
/returned: false/
)
})
})
test
(
'remix-tests running a test file with custom compiler version'
,
()
=>
{
const
res
=
spawnSync
(
executablePath
,
[
'--compiler'
,
'0.7.4'
,
resolve
(
__dirname
+
'/examples_0/assert_ok_test.sol'
)])
console
.
log
(
'res.stdout.toString().trim()---------->'
,
res
.
stdout
.
toString
().
trim
())
// match initial lines
expect
(
res
.
stdout
.
toString
().
trim
()).
toMatch
(
/Loading remote solc version v0.7.4+commit.3f05b770/
)
expect
(
res
.
stdout
.
toString
().
trim
()).
toMatch
(
/:: Running remix-tests - Unit testing for solidity ::/
)
expect
(
res
.
stdout
.
toString
().
trim
()).
toMatch
(
/creation of library remix_tests.sol:Assert pending.../
)
// match test result
expect
(
res
.
stdout
.
toString
().
trim
()).
toMatch
(
/Ok pass test/
)
expect
(
res
.
stdout
.
toString
().
trim
()).
toMatch
(
/Ok fail test/
)
// macth fail test details
expect
(
res
.
stdout
.
toString
().
trim
()).
toMatch
(
/error: okFailTest fails/
)
})
})
})
})
})
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment