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
52b2e468
Commit
52b2e468
authored
Sep 03, 2021
by
aniket-engg
Committed by
Aniket
Sep 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save compiler artifacts to show data on debugging
parent
6edbb46b
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
103 additions
and
11 deletions
+103
-11
test-tab.js
apps/remix-ide/src/app/tabs/test-tab.js
+12
-3
compiler-artefacts.ts
libs/remix-core-plugin/src/lib/compiler-artefacts.ts
+5
-0
compiler.ts
libs/remix-tests/src/compiler.ts
+1
-0
index.ts
libs/remix-tests/src/index.ts
+1
-1
eventManager.ts
libs/remix-tests/src/lib/eventManager.ts
+68
-0
runTestSources.ts
libs/remix-tests/src/runTestSources.ts
+16
-7
No files found.
apps/remix-ide/src/app/tabs/test-tab.js
View file @
52b2e468
...
...
@@ -7,7 +7,7 @@ var async = require('async')
var
tooltip
=
require
(
'../ui/tooltip'
)
var
Renderer
=
require
(
'../ui/renderer'
)
var
css
=
require
(
'./styles/test-tab-styles'
)
var
remixTests
=
require
(
'@remix-project/remix-tests'
)
var
{
UnitTestRunner
}
=
require
(
'@remix-project/remix-tests'
)
const
TestTabLogic
=
require
(
'./testTab/testTab'
)
...
...
@@ -33,6 +33,7 @@ module.exports = class TestTab extends ViewPlugin {
this
.
data
=
{}
this
.
appManager
=
appManager
this
.
renderer
=
new
Renderer
(
this
)
this
.
testRunner
=
new
UnitTestRunner
()
this
.
hasBeenStopped
=
false
this
.
runningTestsNumber
=
0
this
.
readyTestsNumber
=
0
...
...
@@ -95,6 +96,14 @@ module.exports = class TestTab extends ViewPlugin {
this
.
setCurrentPath
(
this
.
defaultPath
)
})
this
.
testRunner
.
event
.
register
(
'compilationFinished'
,
(
success
,
data
,
source
)
=>
{
if
(
success
)
{
// forwarding the event to the appManager infra
// This is listened by compilerArtefacts to show data while debugging
this
.
emit
(
'compilationFinished'
,
source
.
target
,
source
,
'soljson'
,
data
)
}
})
this
.
fileManager
.
events
.
on
(
'noFileSelected'
,
()
=>
{
})
...
...
@@ -462,7 +471,7 @@ module.exports = class TestTab extends ViewPlugin {
usingWorker
:
canUseWorker
(
currentVersion
),
runs
}
remixTests
.
runTestSources
(
runningTest
,
compilerConfig
,
()
=>
{},
()
=>
{},
(
error
,
result
)
=>
{
this
.
testRunner
.
runTestSources
(
runningTest
,
compilerConfig
,
()
=>
{},
()
=>
{},
(
error
,
result
)
=>
{
if
(
error
)
return
reject
(
error
)
resolve
(
result
)
},
(
url
,
cb
)
=>
{
...
...
@@ -489,7 +498,7 @@ module.exports = class TestTab extends ViewPlugin {
usingWorker
:
canUseWorker
(
currentVersion
),
runs
}
remixTests
.
runTestSources
(
this
.
testRunner
.
runTestSources
(
runningTests
,
compilerConfig
,
(
result
)
=>
this
.
testCallback
(
result
,
runningTests
),
...
...
libs/remix-core-plugin/src/lib/compiler-artefacts.ts
View file @
52b2e468
...
...
@@ -52,6 +52,11 @@ export class CompilerArtefacts extends Plugin {
this
.
compilersArtefacts
.
__last
=
new
CompilerAbstract
(
languageVersion
,
data
,
source
)
saveCompilationPerFileResult
(
file
,
source
,
languageVersion
,
data
)
})
this
.
on
(
'solidityUnitTesting'
,
'compilationFinished'
,
(
file
,
source
,
languageVersion
,
data
)
=>
{
this
.
compilersArtefacts
.
__last
=
new
CompilerAbstract
(
languageVersion
,
data
,
source
)
saveCompilationPerFileResult
(
file
,
source
,
languageVersion
,
data
)
})
}
getAllContractDatas
()
{
...
...
libs/remix-tests/src/compiler.ts
View file @
52b2e468
...
...
@@ -205,6 +205,7 @@ export function compileContractSources (sources: SrcIfc, compilerConfig: Compile
function
doCompilation
(
next
)
{
// @ts-ignore
compiler
.
event
.
register
(
'compilationFinished'
,
this
,
(
success
,
data
,
source
)
=>
{
if
(
opts
&&
opts
.
event
)
opts
.
event
.
trigger
(
'compilationFinished'
,
[
success
,
data
,
source
])
next
(
null
,
data
)
})
compiler
.
compile
(
sources
,
filepath
)
...
...
libs/remix-tests/src/index.ts
View file @
52b2e468
export
{
runTestFiles
}
from
'./runTestFiles'
export
{
runTestSources
}
from
'./runTestSources'
export
{
UnitTestRunner
}
from
'./runTestSources'
export
{
runTest
}
from
'./testRunner'
export
*
from
'./types'
export
const
assertLibCode
=
require
(
'../sol/tests.sol'
)
libs/remix-tests/src/lib/eventManager.ts
0 → 100644
View file @
52b2e468
'use strict'
export
default
class
EventManager
{
registered
:
any
=
{}
// eslint-disable-line
anonymous
:
any
=
{}
// eslint-disable-line
/*
* Unregister a listener.
* Note that if obj is a function. the unregistration will be applied to the dummy obj {}.
*
* @param {String} eventName - the event name
* @param {Object or Func} obj - object that will listen on this event
* @param {Func} func - function of the listeners that will be executed
*/
unregister
(
eventName
:
any
,
obj
:
any
,
func
:
any
):
void
{
// eslint-disable-line
if
(
!
this
.
registered
[
eventName
])
{
return
}
if
(
obj
instanceof
Function
)
{
func
=
obj
obj
=
this
.
anonymous
}
for
(
const
reg
in
this
.
registered
[
eventName
])
{
if
(
this
.
registered
[
eventName
][
reg
].
obj
===
obj
&&
this
.
registered
[
eventName
][
reg
].
func
===
func
)
{
this
.
registered
[
eventName
].
splice
(
reg
,
1
)
}
}
}
/*
* Register a new listener.
* Note that if obj is a function, the function registration will be associated with the dummy object {}
*
* @param {String} eventName - the event name
* @param {Object or Func} obj - object that will listen on this event
* @param {Func} func - function of the listeners that will be executed
*/
register
(
eventName
:
any
,
obj
:
any
,
func
:
any
):
void
{
// eslint-disable-line
if
(
!
this
.
registered
[
eventName
])
{
this
.
registered
[
eventName
]
=
[]
}
if
(
obj
instanceof
Function
)
{
func
=
obj
obj
=
this
.
anonymous
}
this
.
registered
[
eventName
].
push
({
obj
:
obj
,
func
:
func
})
}
/*
* trigger event.
* Every listener have their associated function executed
*
* @param {String} eventName - the event name
* @param {Array}j - argument that will be passed to the executed function.
*/
trigger
(
eventName
:
any
,
args
:
any
):
void
{
// eslint-disable-line
if
(
!
this
.
registered
[
eventName
])
{
return
}
for
(
const
listener
in
this
.
registered
[
eventName
])
{
const
l
=
this
.
registered
[
eventName
][
listener
]
if
(
l
.
func
)
l
.
func
.
apply
(
l
.
obj
===
this
.
anonymous
?
{}
:
l
.
obj
,
args
)
}
}
}
libs/remix-tests/src/runTestSources.ts
View file @
52b2e468
...
...
@@ -5,6 +5,7 @@ import { deployAll } from './deployer'
import
{
runTest
}
from
'./testRunner'
import
Web3
from
'web3'
import
EventManager
from
'./lib/eventManager'
import
{
Provider
,
extend
}
from
'@remix-project/remix-simulator'
import
{
FinalResult
,
SrcIfc
,
compilationInterface
,
ASTInterface
,
Options
,
...
...
@@ -12,16 +13,23 @@ import {
}
from
'./types'
require
(
'colors'
)
const
createWeb3Provider
=
async
function
()
{
export
class
UnitTestRunner
{
event
constructor
()
{
this
.
event
=
new
EventManager
()
}
async
createWeb3Provider
()
{
const
web3
=
new
Web3
()
const
provider
:
any
=
new
Provider
()
await
provider
.
init
()
web3
.
setProvider
(
provider
)
extend
(
web3
)
return
web3
}
}
/**
/**
* @dev Run tests from source of a test contract file (used for IDE)
* @param contractSources Sources of contract
* @param compilerConfig current compiler configuration
...
...
@@ -31,10 +39,10 @@ const createWeb3Provider = async function () {
* @param importFileCb Import file callback
* @param opts Options
*/
export
async
function
runTestSources
(
contractSources
:
SrcIfc
,
compilerConfig
:
CompilerConfiguration
,
testCallback
,
resultCallback
,
finalCallback
:
any
,
importFileCb
,
opts
:
Options
)
{
async
runTestSources
(
contractSources
:
SrcIfc
,
compilerConfig
:
CompilerConfiguration
,
testCallback
,
resultCallback
,
finalCallback
:
any
,
importFileCb
,
opts
:
Options
)
{
opts
=
opts
||
{}
const
sourceASTs
:
any
=
{}
const
web3
=
opts
.
web3
||
await
createWeb3Provider
()
const
web3
=
opts
.
web3
||
await
this
.
createWeb3Provider
()
let
accounts
:
string
[]
|
null
=
opts
.
accounts
||
null
async
.
waterfall
([
function
getAccountList
(
next
)
{
...
...
@@ -44,8 +52,8 @@ export async function runTestSources (contractSources: SrcIfc, compilerConfig: C
next
()
})
},
function
compile
(
next
)
{
compileContractSources
(
contractSources
,
compilerConfig
,
importFileCb
,
{
accounts
},
next
)
(
next
)
=>
{
compileContractSources
(
contractSources
,
compilerConfig
,
importFileCb
,
{
accounts
,
event
:
this
.
event
},
next
)
},
function
deployAllContracts
(
compilationResult
:
compilationInterface
,
asts
:
ASTInterface
,
next
)
{
for
(
const
filename
in
asts
)
{
...
...
@@ -134,4 +142,5 @@ export async function runTestSources (contractSources: SrcIfc, compilerConfig: C
})
}
],
finalCallback
)
}
}
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