Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The stages/hooks are (in order of execution):

| Stage | Post-stage hook |
|----------------------------------------|--------------------|
| Before compiling | onPreCompile |
| Launch server | onServerReady |
| Instrument and compile contracts | onCompileComplete |
| Run tests using instrumented artifacts | onTestsComplete |
Expand Down Expand Up @@ -85,6 +86,14 @@ This option allows you to avoid that but it's important to realise that the temp
folder is **automatically deleted** when coverage completes. You shouldn't use it if your preferred
build target contains information you want to preserve between test runs.

## Setting a custom temporary contracts directory

A custom disposable folder to be used for the contracts can be specified by setting the
```
coverage_contracts_temp
```
property in the configuration file. If not set, this directory defaults to `.coverage_contracts`.

## Reducing the instrumentation footprint

If your project is very large or if you have logic that's gas sensitive, it can be useful to
Expand Down
1 change: 1 addition & 0 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class API {
this.onTestsComplete = config.onTestsComplete || this.defaultHook;
this.onCompileComplete = config.onCompileComplete || this.defaultHook;
this.onIstanbulComplete = config.onIstanbulComplete || this.defaultHook;
this.onPreCompile = config.onPreCompile || this.defaultHook;

this.server = null;
this.defaultPort = 8555;
Expand Down
2 changes: 1 addition & 1 deletion plugins/resources/plugin.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function toRelativePath(pathToFile, pathToParent){
function getTempLocations(config){
const contractsRoot = path.parse(config.contractsDir).dir
const cwd = config.workingDir;
const contractsDirName = '.coverage_contracts';
const contractsDirName = config.coverage_contracts_temp || '.coverage_contracts';
const artifactsDirName = config.temp || '.coverage_artifacts';

return {
Expand Down
3 changes: 3 additions & 0 deletions plugins/truffle.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ async function plugin(config){
config.all = true;
config.compilers.solc.settings.optimizer.enabled = false;

// Run pre-compile hook;
await api.onPreCompile(config);

// Compile Instrumented Contracts
await truffle.contracts.compile(config);
await api.onCompileComplete(config);
Expand Down
1 change: 1 addition & 0 deletions test/integration/projects/test-files/.solcover.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = {
skipFiles: ['Migrations.sol'],
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'),
Expand Down
1 change: 1 addition & 0 deletions test/units/truffle/standard.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ describe('Truffle Plugin: standard use cases', function() {
await plugin(truffleConfig);

assert(
mock.loggerOutput.val.includes('running onPreCompile') &&
mock.loggerOutput.val.includes('running onServerReady') &&
mock.loggerOutput.val.includes('running onTestsComplete') &&
mock.loggerOutput.val.includes('running onCompileComplete') &&
Expand Down