@@ -170,34 +170,18 @@ class App {
170170 * Changes here should be also be added to the before() block of test/run.js).
171171 * @return {Promise } Resolves when testrpc prints 'Listening' to std out / norpc is true.
172172 */
173- launchTestrpc ( ) {
174- return new Promise ( ( resolve , reject ) => {
175- if ( ! this . norpc ) {
176- const defaultRpcOptions = `--accounts ${ this . accounts } --port ${ this . port } ` ;
177- const options = ( this . testrpcOptions || defaultRpcOptions ) + ` --gasLimit ${ gasLimitHex } ` ;
178- const command = './node_modules/ganache-cli/build/cli.node.js ' ;
179-
180- // Launch
181- const execOpts = { maxBuffer : 1024 * 1024 * 10 } ;
182- this . testrpcProcess = childprocess . exec ( command + options , execOpts , ( err , stdout , stderr ) => {
183- if ( err ) {
184- if ( stdout ) this . log ( `testRpc stdout:\n${ stdout } ` ) ;
185- if ( stderr ) this . log ( `testRpc stderr:\n${ stderr } ` ) ;
186- this . cleanUp ( 'testRpc errored after launching as a childprocess.' ) ;
173+ async launchTestrpc ( ) {
174+ if ( this . norpc ) {
175+ return Promise . resolve ( ) ;
187176 }
188- } ) ;
177+ let truffleConfig = reqCwd . silent ( `${ this . workingDir } /truffle.js` ) ;
178+ let networkOpts = truffleConfig . networks . coverage ;
189179
190- // Resolve when testrpc logs that it's listening.
191- this . testrpcProcess . stdout . on ( 'data' , data => {
192- if ( data . includes ( 'Listening' ) ) {
193- this . log ( `Launched testrpc on port ${ this . port } ` ) ;
194- return resolve ( ) ;
195- }
196- } ) ;
197- } else {
198- return resolve ( ) ;
199- }
200- } ) ;
180+ let ganache = require ( "ganache-cli" ) ;
181+ let server = ganache . server ( networkOpts ) ;
182+
183+ let { promisify } = require ( 'util' ) ;
184+ await promisify ( server . listen ) ( networkOpts . port ) ;
201185 }
202186
203187 /**
@@ -206,7 +190,26 @@ class App {
206190 * as its own statement for command line options to work, apparently.
207191 * Also reads the 'allFiredEvents' log.
208192 */
209- runTestCommand ( ) {
193+ async runTestCommand ( ) {
194+
195+ let testCommand = require ( "truffle-core/lib/commands/test" ) ;
196+ let options = { logger : console , network : 'coverage' , _ : [ ] } ;
197+
198+ shell . cd ( this . coverageDir ) ;
199+
200+ await new Promise ( ( resolve , reject ) => {
201+ testCommand . run ( options , ( err , res ) => {
202+ if ( err ) {
203+ reject ( err ) ;
204+ }
205+ resolve ( res ) ;
206+ } ) ;
207+ } ) ;
208+
209+ shell . cd ( './..' ) ;
210+
211+ return ;
212+
210213 try {
211214 const defaultCommand = `truffle test ${ this . network } ${ this . silence } ` ;
212215 const command = this . testCommand || defaultCommand ;
0 commit comments