Skip to content

Commit ca695f0

Browse files
authored
Add missing onPreCompile stage hook (#851)
1 parent dc9d976 commit ca695f0

File tree

7 files changed

+60
-11
lines changed

7 files changed

+60
-11
lines changed

plugins/hardhat.plugin.js

+2
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ task("coverage", "Generates a code coverage report for tests")
196196
config.paths.cache = nomiclabsUtils.tempCacheDir(config);
197197
}
198198

199+
await api.onPreCompile(config);
200+
199201
await env.run(TASK_COMPILE);
200202

201203
await api.onCompileComplete(config);

test/integration/standard.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ describe('Hardhat Plugin: standard use cases', function() {
223223
});
224224

225225
it('config: "onServerReady", "onTestsComplete", ...', async function() {
226-
mock.installFullProject('test-files');
226+
mock.installFullProject('task-hooks');
227227

228228
mock.hardhatSetupEnv(this);
229229

@@ -232,6 +232,7 @@ describe('Hardhat Plugin: standard use cases', function() {
232232
assert(
233233
mock.loggerOutput.val.includes('running onServerReady') &&
234234
mock.loggerOutput.val.includes('running onTestsComplete') &&
235+
mock.loggerOutput.val.includes('running onPreCompile') &&
235236
mock.loggerOutput.val.includes('running onCompileComplete') &&
236237
mock.loggerOutput.val.includes('running onIstanbulComplete'),
237238

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Testing hooks
2+
const fn = (msg, config) => config.logger.log(msg);
3+
4+
module.exports = {
5+
skipFiles: [],
6+
silent: process.env.SILENT ? true : false,
7+
istanbulReporter: ['json-summary', 'text'],
8+
onPreCompile: fn.bind(null, 'running onPreCompile'),
9+
onServerReady: fn.bind(null, 'running onServerReady'),
10+
onTestsComplete: fn.bind(null, 'running onTestsComplete'),
11+
onCompileComplete: fn.bind(null, 'running onCompileComplete'),
12+
onIstanbulComplete: fn.bind(null, 'running onIstanbulComplete')
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pragma solidity >=0.8.0 <0.9.0;
2+
3+
4+
contract ContractA {
5+
uint x;
6+
constructor() public {
7+
}
8+
9+
function sendFn() public {
10+
x = 5;
11+
}
12+
13+
function callFn() public pure returns (uint){
14+
uint y = 5;
15+
return y;
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require("@nomiclabs/hardhat-truffle5");
2+
require(__dirname + "/../plugins/nomiclabs.plugin");
3+
4+
module.exports = {
5+
solidity: {
6+
version: "0.8.17"
7+
},
8+
logger: process.env.SILENT ? { log: () => {} } : console,
9+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const ContractA = artifacts.require("ContractA");
2+
3+
contract("contracta", function(accounts) {
4+
let instance;
5+
6+
before(async () => instance = await ContractA.new())
7+
8+
it('sends', async function(){
9+
await instance.sendFn();
10+
});
11+
12+
it('calls', async function(){
13+
await instance.callFn();
14+
})
15+
});
+2-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
// Testing hooks
2-
const fn = (msg, config) => config.logger.log(msg);
3-
41
module.exports = {
5-
skipFiles: ['Migrations.sol'],
2+
skipFiles: [],
63
silent: process.env.SILENT ? true : false,
7-
istanbulReporter: ['json-summary', 'text'],
8-
onPreCompile: fn.bind(null, 'running onPreCompile'),
9-
onServerReady: fn.bind(null, 'running onServerReady'),
10-
onTestsComplete: fn.bind(null, 'running onTestsComplete'),
11-
onCompileComplete: fn.bind(null, 'running onCompileComplete'),
12-
onIstanbulComplete: fn.bind(null, 'running onIstanbulComplete')
4+
istanbulReporter: ['json-summary', 'text']
135
}

0 commit comments

Comments
 (0)