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
d0a08d4f
Commit
d0a08d4f
authored
Nov 27, 2019
by
aniket-engg
Committed by
Aniket
Nov 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test file suffix check improved
parent
f820dbe1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
8 deletions
+12
-8
compiler.ts
remix-tests/src/compiler.ts
+2
-2
deployer.ts
remix-tests/src/deployer.ts
+1
-1
run.ts
remix-tests/src/run.ts
+4
-0
runTestFiles.ts
remix-tests/src/runTestFiles.ts
+2
-2
runTestSources.ts
remix-tests/src/runTestSources.ts
+2
-2
testRunner.ts
remix-tests/tests/testRunner.ts
+1
-1
No files found.
remix-tests/src/compiler.ts
View file @
d0a08d4f
...
@@ -54,7 +54,7 @@ function processFile(filePath: string, sources: SrcIfc, isRoot: boolean = false)
...
@@ -54,7 +54,7 @@ function processFile(filePath: string, sources: SrcIfc, isRoot: boolean = false)
const
testFileImportRegEx
:
RegExp
=
/^
(
import
)\s[
'"
](
remix_tests.sol|tests.sol
)[
'"
]
;/gm
const
testFileImportRegEx
:
RegExp
=
/^
(
import
)\s[
'"
](
remix_tests.sol|tests.sol
)[
'"
]
;/gm
// import 'remix_tests.sol', if file is a root test contract file and doesn't already have it
// import 'remix_tests.sol', if file is a root test contract file and doesn't already have it
if
(
isRoot
&&
filePath
.
includes
(
'_test.sol'
)
&&
regexIndexOf
(
content
,
testFileImportRegEx
)
<
0
)
{
if
(
isRoot
&&
filePath
.
endsWith
(
'_test.sol'
)
&&
regexIndexOf
(
content
,
testFileImportRegEx
)
<
0
)
{
const
includeTestLibs
:
string
=
'
\
nimport
\'
remix_tests.sol
\'
;
\
n'
const
includeTestLibs
:
string
=
'
\
nimport
\'
remix_tests.sol
\'
;
\
n'
content
=
includeTestLibs
.
concat
(
content
)
content
=
includeTestLibs
.
concat
(
content
)
}
}
...
@@ -161,7 +161,7 @@ export function compileContractSources(sources: SrcIfc, versionUrl: any, usingWo
...
@@ -161,7 +161,7 @@ export function compileContractSources(sources: SrcIfc, versionUrl: any, usingWo
let
includeTestLibs
:
string
=
'
\
nimport
\'
remix_tests.sol
\'
;
\
n'
let
includeTestLibs
:
string
=
'
\
nimport
\'
remix_tests.sol
\'
;
\
n'
for
(
let
file
in
sources
)
{
for
(
let
file
in
sources
)
{
const
c
:
string
=
sources
[
file
].
content
const
c
:
string
=
sources
[
file
].
content
if
(
file
.
includes
(
'_test.sol'
)
&&
c
&&
regexIndexOf
(
c
,
testFileImportRegEx
)
<
0
)
{
if
(
file
.
endsWith
(
'_test.sol'
)
&&
c
&&
regexIndexOf
(
c
,
testFileImportRegEx
)
<
0
)
{
sources
[
file
].
content
=
includeTestLibs
.
concat
(
c
)
sources
[
file
].
content
=
includeTestLibs
.
concat
(
c
)
}
}
}
}
...
...
remix-tests/src/deployer.ts
View file @
d0a08d4f
...
@@ -32,7 +32,7 @@ export function deployAll(compileResult: object, web3: Web3, callback) {
...
@@ -32,7 +32,7 @@ export function deployAll(compileResult: object, web3: Web3, callback) {
compiledObject
[
className
].
className
=
className
compiledObject
[
className
].
className
=
className
compiledObject
[
className
].
raw
=
contract
compiledObject
[
className
].
raw
=
contract
if
(
contractFile
.
indexOf
(
'_test.sol'
)
>=
0
)
{
if
(
contractFile
.
endsWith
(
'_test.sol'
)
)
{
compiledObject
[
className
].
isTest
=
true
compiledObject
[
className
].
isTest
=
true
}
}
}
}
...
...
remix-tests/src/run.ts
View file @
d0a08d4f
...
@@ -36,6 +36,10 @@ commander.command('help').description('output usage information').action(functio
...
@@ -36,6 +36,10 @@ commander.command('help').description('output usage information').action(functio
commander
commander
.
option
(
'-v, --verbose <level>'
,
'run with verbosity'
,
mapVerbosity
)
.
option
(
'-v, --verbose <level>'
,
'run with verbosity'
,
mapVerbosity
)
.
action
(
async
(
filename
)
=>
{
.
action
(
async
(
filename
)
=>
{
if
(
!
filename
.
endsWith
(
'_test.sol'
)){
log
.
error
(
'Test filename should end with "_test.sol"'
)
process
.
exit
()
}
// Console message
// Console message
console
.
log
(
colors
.
white
(
'
\
n
\
t👁
\
t:: Running remix-tests - Unit testing for solidity ::
\
t👁
\
n'
))
console
.
log
(
colors
.
white
(
'
\
n
\
t👁
\
t:: Running remix-tests - Unit testing for solidity ::
\
t👁
\
n'
))
// set logger verbosity
// set logger verbosity
...
...
remix-tests/src/runTestFiles.ts
View file @
d0a08d4f
...
@@ -56,7 +56,7 @@ export function runTestFiles(filepath: string, isDirectory: boolean, web3: Web3,
...
@@ -56,7 +56,7 @@ export function runTestFiles(filepath: string, isDirectory: boolean, web3: Web3,
function
deployAllContracts
(
compilationResult
:
compilationInterface
,
asts
:
ASTInterface
,
next
:
Function
)
{
function
deployAllContracts
(
compilationResult
:
compilationInterface
,
asts
:
ASTInterface
,
next
:
Function
)
{
// Extract AST of test contract file source
// Extract AST of test contract file source
for
(
const
filename
in
asts
)
{
for
(
const
filename
in
asts
)
{
if
(
filename
.
includes
(
'_test.sol'
))
if
(
filename
.
endsWith
(
'_test.sol'
))
sourceASTs
[
filename
]
=
asts
[
filename
].
ast
sourceASTs
[
filename
]
=
asts
[
filename
].
ast
}
}
deployAll
(
compilationResult
,
web3
,
(
err
,
contracts
)
=>
{
deployAll
(
compilationResult
,
web3
,
(
err
,
contracts
)
=>
{
...
@@ -70,7 +70,7 @@ export function runTestFiles(filepath: string, isDirectory: boolean, web3: Web3,
...
@@ -70,7 +70,7 @@ export function runTestFiles(filepath: string, isDirectory: boolean, web3: Web3,
let
contractsToTest
:
string
[]
=
[]
let
contractsToTest
:
string
[]
=
[]
let
contractsToTestDetails
:
any
[]
=
[]
let
contractsToTestDetails
:
any
[]
=
[]
const
gatherContractsFrom
=
function
(
filename
:
string
)
{
const
gatherContractsFrom
=
function
(
filename
:
string
)
{
if
(
filename
.
indexOf
(
'_test.sol'
)
<
0
)
{
if
(
!
filename
.
endsWith
(
'_test.sol'
)
)
{
return
return
}
}
try
{
try
{
...
...
remix-tests/src/runTestSources.ts
View file @
d0a08d4f
...
@@ -46,7 +46,7 @@ export async function runTestSources(contractSources: SrcIfc, versionUrl: string
...
@@ -46,7 +46,7 @@ export async function runTestSources(contractSources: SrcIfc, versionUrl: string
},
},
function
deployAllContracts
(
compilationResult
:
compilationInterface
,
asts
:
ASTInterface
,
next
)
{
function
deployAllContracts
(
compilationResult
:
compilationInterface
,
asts
:
ASTInterface
,
next
)
{
for
(
const
filename
in
asts
)
{
for
(
const
filename
in
asts
)
{
if
(
filename
.
includes
(
'_test.sol'
))
if
(
filename
.
endsWith
(
'_test.sol'
))
sourceASTs
[
filename
]
=
asts
[
filename
].
ast
sourceASTs
[
filename
]
=
asts
[
filename
].
ast
}
}
deployAll
(
compilationResult
,
web3
,
(
err
,
contracts
)
=>
{
deployAll
(
compilationResult
,
web3
,
(
err
,
contracts
)
=>
{
...
@@ -62,7 +62,7 @@ export async function runTestSources(contractSources: SrcIfc, versionUrl: string
...
@@ -62,7 +62,7 @@ export async function runTestSources(contractSources: SrcIfc, versionUrl: string
let
contractsToTestDetails
:
any
[]
=
[]
let
contractsToTestDetails
:
any
[]
=
[]
for
(
let
filename
in
compilationResult
)
{
for
(
let
filename
in
compilationResult
)
{
if
(
filename
.
indexOf
(
'_test.sol'
)
<
0
)
{
if
(
!
filename
.
endsWith
(
'_test.sol'
)
)
{
continue
continue
}
}
Object
.
keys
(
compilationResult
[
filename
]).
forEach
(
contractName
=>
{
Object
.
keys
(
compilationResult
[
filename
]).
forEach
(
contractName
=>
{
...
...
remix-tests/tests/testRunner.ts
View file @
d0a08d4f
...
@@ -62,7 +62,7 @@ async function compileAndDeploy(filename: string, callback: Function) {
...
@@ -62,7 +62,7 @@ async function compileAndDeploy(filename: string, callback: Function) {
},
},
function
deployAllContracts
(
compilationResult
:
object
,
asts
,
next
:
Function
):
void
{
function
deployAllContracts
(
compilationResult
:
object
,
asts
,
next
:
Function
):
void
{
for
(
const
filename
in
asts
)
{
for
(
const
filename
in
asts
)
{
if
(
filename
.
includes
(
'_test.sol'
))
if
(
filename
.
endsWith
(
'_test.sol'
))
sourceASTs
[
filename
]
=
asts
[
filename
].
ast
sourceASTs
[
filename
]
=
asts
[
filename
].
ast
}
}
try
{
try
{
...
...
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