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
cc860e89
Commit
cc860e89
authored
Sep 24, 2020
by
aniket-engg
Committed by
Aniket
Sep 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
location for failed tests
parent
d50bd168
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
3 deletions
+25
-3
testRunner.ts
libs/remix-tests/src/testRunner.ts
+24
-3
types.ts
libs/remix-tests/src/types.ts
+1
-0
testRunner.spec.ts
libs/remix-tests/tests/testRunner.spec.ts
+0
-0
No files found.
libs/remix-tests/src/testRunner.ts
View file @
cc860e89
...
@@ -84,6 +84,24 @@ function getAvailableFunctions (fileAST: AstNode, testContractName: string): str
...
@@ -84,6 +84,24 @@ function getAvailableFunctions (fileAST: AstNode, testContractName: string): str
return
funcList
;
return
funcList
;
}
}
function
getAssertMethodLocation
(
fileAST
:
AstNode
,
testContractName
:
string
,
functionName
:
string
,
assertMethod
:
string
):
string
{
let
location
if
(
fileAST
.
nodes
&&
fileAST
.
nodes
.
length
>
0
)
{
const
contractAST
:
AstNode
=
fileAST
.
nodes
.
find
(
node
=>
node
.
name
===
testContractName
&&
node
.
nodeType
===
'ContractDefinition'
)
if
(
contractAST
&&
contractAST
.
nodes
)
{
const
funcNode
:
AstNode
=
contractAST
.
nodes
.
find
(
node
=>
(
node
.
name
===
functionName
&&
node
.
nodeType
===
"FunctionDefinition"
))
const
expressions
=
funcNode
.
body
.
statements
.
filter
(
s
=>
s
.
nodeType
===
'ExpressionStatement'
&&
s
.
expression
.
nodeType
===
'FunctionCall'
)
const
assetExpression
=
expressions
.
find
(
e
=>
e
.
expression
.
expression
&&
e
.
expression
.
expression
.
nodeType
===
'MemberAccess'
&&
e
.
expression
.
expression
.
memberName
===
assertMethod
&&
e
.
expression
.
expression
.
expression
.
name
===
'Assert'
)
location
=
assetExpression
.
expression
.
src
}
}
return
location
}
/**
/**
* @dev returns ABI of passed method list from passed interface
* @dev returns ABI of passed method list from passed interface
* @param jsonInterface Json Interface
* @param jsonInterface Json Interface
...
@@ -238,19 +256,22 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
...
@@ -238,19 +256,22 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
if
(
eIndex
>=
0
)
{
if
(
eIndex
>=
0
)
{
const
testEvent
=
web3
.
eth
.
abi
.
decodeParameters
(
assertionEvents
[
eIndex
].
params
,
event
.
raw
.
data
)
const
testEvent
=
web3
.
eth
.
abi
.
decodeParameters
(
assertionEvents
[
eIndex
].
params
,
event
.
raw
.
data
)
if
(
!
testEvent
[
0
])
{
if
(
!
testEvent
[
0
])
{
if
(
testEvent
[
2
]
===
'ok'
)
{
// for 'Assert.ok' method
const
assertMethod
=
testEvent
[
2
]
if
(
assertMethod
===
'ok'
)
{
// for 'Assert.ok' method
testEvent
[
3
]
=
'false'
testEvent
[
3
]
=
'false'
testEvent
[
4
]
=
'true'
testEvent
[
4
]
=
'true'
}
}
const
location
=
getAssertMethodLocation
(
fileAST
,
testName
,
func
.
name
,
assertMethod
)
const
resp
:
TestResultInterface
=
{
const
resp
:
TestResultInterface
=
{
type
:
'testFailure'
,
type
:
'testFailure'
,
value
:
changeCase
.
sentenceCase
(
func
.
name
),
value
:
changeCase
.
sentenceCase
(
func
.
name
),
time
:
time
,
time
:
time
,
errMsg
:
testEvent
[
1
],
errMsg
:
testEvent
[
1
],
context
:
testName
,
context
:
testName
,
assertMethod
:
testEvent
[
2
]
,
assertMethod
,
returned
:
testEvent
[
3
],
returned
:
testEvent
[
3
],
expected
:
testEvent
[
4
]
expected
:
testEvent
[
4
],
location
};
};
testCallback
(
undefined
,
resp
)
testCallback
(
undefined
,
resp
)
failureNum
+=
1
failureNum
+=
1
...
...
libs/remix-tests/src/types.ts
View file @
cc860e89
...
@@ -35,6 +35,7 @@ export interface TestResultInterface {
...
@@ -35,6 +35,7 @@ export interface TestResultInterface {
assertMethod
?:
string
assertMethod
?:
string
returned
?:
string
|
number
returned
?:
string
|
number
expected
?:
string
|
number
expected
?:
string
|
number
location
?:
string
}
}
export
interface
TestCbInterface
{
export
interface
TestCbInterface
{
(
error
:
Error
|
null
|
undefined
,
result
:
TestResultInterface
)
:
void
;
(
error
:
Error
|
null
|
undefined
,
result
:
TestResultInterface
)
:
void
;
...
...
libs/remix-tests/tests/testRunner.spec.ts
View file @
cc860e89
This diff is collapsed.
Click to expand it.
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