Skip to content

Commit e25728a

Browse files
authored
Allow Truffle V4 style solc config (#449)
1 parent d9af5ac commit e25728a

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

plugins/resources/truffle.utils.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,12 @@ function normalizeConfig(config){
200200
delete config.mocha.reporterOptions;
201201
}
202202

203+
// Truffle V4 style solc settings are honored over V5 settings. Apparently it's common
204+
// for both to be present in the same config (as an error).
205+
if (typeof config.solc === "object" ){
206+
config.solc.optimizer = { enabled: false };
207+
}
208+
203209
return config;
204210
}
205211

test/units/truffle/standard.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,36 @@ describe('Truffle Plugin: standard use cases', function() {
216216
});
217217

218218
// This test errors if the reporter is not re-designated as 'spec' correctly
219-
it('gracefully disables eth-gas-reporter', async function(){
219+
it('disables eth-gas-reporter', async function(){
220220
truffleConfig.mocha = { reporter: 'eth-gas-reporter' };
221221

222222
mock.install('Simple', 'simple.js', solcoverConfig);
223223
await plugin(truffleConfig);
224224
});
225225

226+
it('disables optimization when truffle-config uses V4 format', async function(){
227+
solcoverConfig = {
228+
silent: process.env.SILENT ? true : false,
229+
istanbulReporter: ['json-summary', 'text']
230+
};
231+
232+
truffleConfig.solc = {
233+
optimizer: { enabled: true, runs: 200 }
234+
};
235+
236+
mock.install('Simple', 'simple.js', solcoverConfig);
237+
await plugin(truffleConfig);
238+
239+
const expected = [
240+
{
241+
file: mock.pathToContract(truffleConfig, 'Simple.sol'),
242+
pct: 100
243+
}
244+
];
245+
246+
verify.lineCoverage(expected);
247+
});
248+
226249
// This test tightly coupled to the ganache version in production deps
227250
// "test-files" project solcoverjs includes `client: require('ganache-cli')`
228251
it('config: client', async function(){

0 commit comments

Comments
 (0)