@@ -8,7 +8,7 @@ const mock = require('../../util/integration.truffle');
88const plugin = require ( '../../../dist/truffle.plugin' ) ;
99
1010// =======================
11- // Standard Use-case Tests
11+ // CLI Options / Flags
1212// =======================
1313
1414describe ( 'Truffle Plugin: command line options' , function ( ) {
@@ -28,8 +28,11 @@ describe('Truffle Plugin: command line options', function() {
2828 it ( 'truffle run coverage --file test/<fileName>' , async function ( ) {
2929 verify . cleanInitialState ( ) ;
3030
31- const testPath = path . join ( truffleConfig . working_directory , 'test/specific_a.js' ) ;
32- truffleConfig . file = testPath ;
31+ truffleConfig . file = path . join (
32+ truffleConfig . working_directory ,
33+ 'test/specific_a.js'
34+ ) ;
35+
3336 mock . installFullProject ( 'test-files' ) ;
3437 await plugin ( truffleConfig ) ;
3538
@@ -54,8 +57,11 @@ describe('Truffle Plugin: command line options', function() {
5457 it ( 'truffle run coverage --file test/<glob*>' , async function ( ) {
5558 verify . cleanInitialState ( ) ;
5659
57- const testPath = path . join ( truffleConfig . working_directory , 'test/globby*' ) ;
58- truffleConfig . file = testPath ;
60+ truffleConfig . file = path . join (
61+ truffleConfig . working_directory ,
62+ 'test/globby*'
63+ ) ;
64+
5965 mock . installFullProject ( 'test-files' ) ;
6066 await plugin ( truffleConfig ) ;
6167
@@ -80,8 +86,11 @@ describe('Truffle Plugin: command line options', function() {
8086 it ( 'truffle run coverage --file test/gl{o,b}*.js' , async function ( ) {
8187 verify . cleanInitialState ( ) ;
8288
83- const testPath = path . join ( truffleConfig . working_directory , 'test/gl{o,b}*.js' ) ;
84- truffleConfig . file = testPath ;
89+ truffleConfig . file = path . join (
90+ truffleConfig . working_directory ,
91+ 'test/gl{o,b}*.js'
92+ ) ;
93+
8594 mock . installFullProject ( 'test-files' ) ;
8695 await plugin ( truffleConfig ) ;
8796
@@ -110,17 +119,20 @@ describe('Truffle Plugin: command line options', function() {
110119 silent : process . env . SILENT ? true : false ,
111120 istanbulReporter : [ 'json-summary' , 'text' ]
112121 } ;
113- fs . writeFileSync ( '.solcover.js' , `module.exports=${ JSON . stringify ( solcoverConfig ) } ` ) ;
114122
115- // This relative path has to be ./ prefixed
116- // (because it's path.joined to truffle's working_directory)
123+ // Write solcoverjs to parent dir of sc_temp (where the test project is installed)
124+ fs . writeFileSync (
125+ '.solcover.js' ,
126+ `module.exports=${ JSON . stringify ( solcoverConfig ) } `
127+ ) ;
128+
129+ // This relative path has to be ./ prefixed (it's path.joined to truffle's working_directory)
117130 truffleConfig . solcoverjs = './../.solcover.js' ;
118131
119132 mock . install ( 'Simple' , 'simple.js' ) ;
120133 await plugin ( truffleConfig ) ;
121134
122- // The relative solcoverjs uses the json-summary reporter which
123- // this assertion requires
135+ // The relative solcoverjs uses the json-summary reporter
124136 const expected = [ {
125137 file : mock . pathToContract ( truffleConfig , 'Simple.sol' ) ,
126138 pct : 100
@@ -132,68 +144,72 @@ describe('Truffle Plugin: command line options', function() {
132144
133145 it ( 'truffle run coverage --help' , async function ( ) {
134146 verify . cleanInitialState ( ) ;
135- truffleConfig . help = "true" ;
136147
148+ truffleConfig . help = "true" ;
137149 truffleConfig . logger = mock . testLogger ;
150+
138151 mock . install ( 'Simple' , 'simple.js' , solcoverConfig ) ;
139152 await plugin ( truffleConfig ) ;
140153
141154 assert (
142155 mock . loggerOutput . val . includes ( 'Usage' ) ,
143- `Should output help with Usage instruction (output --> ${ mock . loggerOutput . val } `
156+ `Should output help with Usage instruction : ${ mock . loggerOutput . val } `
144157 ) ;
145158 } )
146159
147160 it ( 'truffle run coverage --version' , async function ( ) {
148161 verify . cleanInitialState ( ) ;
149- truffleConfig . version = "true" ;
150162
163+ truffleConfig . version = "true" ;
151164 truffleConfig . logger = mock . testLogger ;
165+
152166 mock . install ( 'Simple' , 'simple.js' , solcoverConfig ) ;
153167 await plugin ( truffleConfig ) ;
154168
155169 assert (
156170 mock . loggerOutput . val . includes ( 'truffle' ) ,
157- `Should output truffle version (output --> ${ mock . loggerOutput . val } `
171+ `Should output truffle version: ${ mock . loggerOutput . val } `
158172 ) ;
159173
160174 assert (
161175 mock . loggerOutput . val . includes ( 'ganache-core' ) ,
162- `Should output ganache-core version (output --> ${ mock . loggerOutput . val } `
176+ `Should output ganache-core version: ${ mock . loggerOutput . val } `
163177 ) ;
164178
165179 assert (
166180 mock . loggerOutput . val . includes ( 'solidity-coverage' ) ,
167- `Should output solidity-coverage version (output --> ${ mock . loggerOutput . val } `
181+ `Should output solidity-coverage version: ${ mock . loggerOutput . val } `
168182 ) ;
169183
170184 } )
171185
172186 it ( 'truffle run coverage --useGlobalTruffle' , async function ( ) {
173187 verify . cleanInitialState ( ) ;
174- truffleConfig . useGlobalTruffle = true ;
175188
189+ truffleConfig . useGlobalTruffle = true ;
176190 truffleConfig . logger = mock . testLogger ;
191+
177192 mock . install ( 'Simple' , 'simple.js' , solcoverConfig ) ;
178193 await plugin ( truffleConfig ) ;
179194
180195 assert (
181196 mock . loggerOutput . val . includes ( 'global node_modules' ) ,
182- `Should notify it's using global truffle (output --> ${ mock . loggerOutput . val } `
197+ `Should notify it's using global truffle: ${ mock . loggerOutput . val } `
183198 ) ;
184199 } ) ;
185200
186201 it ( 'truffle run coverage --usePluginTruffle' , async function ( ) {
187202 verify . cleanInitialState ( ) ;
188- truffleConfig . usePluginTruffle = true ;
189203
204+ truffleConfig . usePluginTruffle = true ;
190205 truffleConfig . logger = mock . testLogger ;
206+
191207 mock . install ( 'Simple' , 'simple.js' , solcoverConfig ) ;
192208 await plugin ( truffleConfig ) ;
193209
194210 assert (
195211 mock . loggerOutput . val . includes ( 'fallback Truffle library module' ) ,
196- `Should notify it's using plugin truffle lib copy (output --> ${ mock . loggerOutput . val } `
212+ `Should notify it's using plugin truffle lib copy: ${ mock . loggerOutput . val } `
197213 ) ;
198214 } ) ;
199215} ) ;
0 commit comments