Add missing onPreCompile stage hook (#851)

pull/856/head
cgewecke 10 months ago committed by GitHub
parent dc9d976c0d
commit ca695f0223
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      plugins/hardhat.plugin.js
  2. 3
      test/integration/standard.js
  3. 13
      test/sources/projects/task-hooks/.solcover.js
  4. 17
      test/sources/projects/task-hooks/contracts/Hooks.sol
  5. 9
      test/sources/projects/task-hooks/hardhat.config.js
  6. 15
      test/sources/projects/task-hooks/test/hooks.js
  7. 12
      test/sources/projects/test-files/.solcover.js

@ -196,6 +196,8 @@ task("coverage", "Generates a code coverage report for tests")
config.paths.cache = nomiclabsUtils.tempCacheDir(config); config.paths.cache = nomiclabsUtils.tempCacheDir(config);
} }
await api.onPreCompile(config);
await env.run(TASK_COMPILE); await env.run(TASK_COMPILE);
await api.onCompileComplete(config); await api.onCompileComplete(config);

@ -223,7 +223,7 @@ describe('Hardhat Plugin: standard use cases', function() {
}); });
it('config: "onServerReady", "onTestsComplete", ...', async function() { it('config: "onServerReady", "onTestsComplete", ...', async function() {
mock.installFullProject('test-files'); mock.installFullProject('task-hooks');
mock.hardhatSetupEnv(this); mock.hardhatSetupEnv(this);
@ -232,6 +232,7 @@ describe('Hardhat Plugin: standard use cases', function() {
assert( assert(
mock.loggerOutput.val.includes('running onServerReady') && mock.loggerOutput.val.includes('running onServerReady') &&
mock.loggerOutput.val.includes('running onTestsComplete') && mock.loggerOutput.val.includes('running onTestsComplete') &&
mock.loggerOutput.val.includes('running onPreCompile') &&
mock.loggerOutput.val.includes('running onCompileComplete') && mock.loggerOutput.val.includes('running onCompileComplete') &&
mock.loggerOutput.val.includes('running onIstanbulComplete'), mock.loggerOutput.val.includes('running onIstanbulComplete'),

@ -0,0 +1,13 @@
// Testing hooks
const fn = (msg, config) => config.logger.log(msg);
module.exports = {
skipFiles: [],
silent: process.env.SILENT ? true : false,
istanbulReporter: ['json-summary', 'text'],
onPreCompile: fn.bind(null, 'running onPreCompile'),
onServerReady: fn.bind(null, 'running onServerReady'),
onTestsComplete: fn.bind(null, 'running onTestsComplete'),
onCompileComplete: fn.bind(null, 'running onCompileComplete'),
onIstanbulComplete: fn.bind(null, 'running onIstanbulComplete')
}

@ -0,0 +1,17 @@
pragma solidity >=0.8.0 <0.9.0;
contract ContractA {
uint x;
constructor() public {
}
function sendFn() public {
x = 5;
}
function callFn() public pure returns (uint){
uint y = 5;
return y;
}
}

@ -0,0 +1,9 @@
require("@nomiclabs/hardhat-truffle5");
require(__dirname + "/../plugins/nomiclabs.plugin");
module.exports = {
solidity: {
version: "0.8.17"
},
logger: process.env.SILENT ? { log: () => {} } : console,
};

@ -0,0 +1,15 @@
const ContractA = artifacts.require("ContractA");
contract("contracta", function(accounts) {
let instance;
before(async () => instance = await ContractA.new())
it('sends', async function(){
await instance.sendFn();
});
it('calls', async function(){
await instance.callFn();
})
});

@ -1,13 +1,5 @@
// Testing hooks
const fn = (msg, config) => config.logger.log(msg);
module.exports = { module.exports = {
skipFiles: ['Migrations.sol'], skipFiles: [],
silent: process.env.SILENT ? true : false, silent: process.env.SILENT ? true : false,
istanbulReporter: ['json-summary', 'text'], istanbulReporter: ['json-summary', 'text']
onPreCompile: fn.bind(null, 'running onPreCompile'),
onServerReady: fn.bind(null, 'running onServerReady'),
onTestsComplete: fn.bind(null, 'running onTestsComplete'),
onCompileComplete: fn.bind(null, 'running onCompileComplete'),
onIstanbulComplete: fn.bind(null, 'running onIstanbulComplete')
} }

Loading…
Cancel
Save