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
e5a3959e
Commit
e5a3959e
authored
Aug 27, 2018
by
0mkar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inject import statement only if not present
parent
eb22e684
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
+10
-3
simple_storage2_test.sol
remix-tests/examples/simple_storage2_test.sol
+1
-0
compiler.js
remix-tests/src/compiler.js
+9
-3
No files found.
remix-tests/examples/simple_storage2_test.sol
View file @
e5a3959e
pragma solidity ^0.4.7;
import "remix_test.sol";
import "./simple_storage.sol";
contract MyTest2 {
...
...
remix-tests/src/compiler.js
View file @
e5a3959e
/* eslint no-extend-native: "warn" */
let
fs
=
require
(
'fs'
)
var
async
=
require
(
'async'
)
var
path
=
require
(
'path'
)
const
signale
=
require
(
'signale'
)
let
RemixCompiler
=
require
(
'remix-solidity'
).
Compiler
// TODO: replace this with remix's own compiler code
String
.
prototype
.
regexIndexOf
=
function
(
regex
,
startpos
)
{
var
indexOf
=
this
.
substring
(
startpos
||
0
).
search
(
regex
)
return
(
indexOf
>=
0
)
?
(
indexOf
+
(
startpos
||
0
))
:
indexOf
}
// TODO: replace this with remix's own compiler code
function
compileFileOrFiles
(
filename
,
isDirectory
,
cb
)
{
let
compiler
,
filepath
...
...
@@ -23,7 +28,8 @@ function compileFileOrFiles (filename, isDirectory, cb) {
// only process .sol files
if
(
file
.
split
(
'.'
).
pop
()
===
'sol'
)
{
let
c
=
fs
.
readFileSync
(
path
.
join
(
filepath
,
file
)).
toString
()
if
(
file
.
indexOf
(
'_test.sol'
)
>
0
)
{
const
s
=
/^
(
import
)\s[
'"
](
remix_tests.sol|tests.sol
)[
'"
]
;/gm
if
(
file
.
indexOf
(
'_test.sol'
)
>
0
&&
c
.
regexIndexOf
(
s
)
<
0
)
{
c
=
c
.
replace
(
/
(
pragma solidity
\^\d
+
\.\d
+
\.\d
+;
)
/
,
'$1
\
nimport
\'
remix_tests.sol
\'
;'
)
}
sources
[
file
]
=
{
content
:
c
}
...
...
@@ -58,7 +64,7 @@ function compileContractSources (sources, importFileCb, cb) {
let
compiler
,
filepath
if
(
!
sources
[
'remix_tests.sol'
])
{
sources
[
'remix_tests.sol'
]
=
{
content
:
require
(
'../sol/tests.sol.js'
)
}
sources
[
'remix_tests.sol'
]
=
{
content
:
require
(
'../sol/tests.sol.js'
)
}
}
async
.
waterfall
([
...
...
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