Allow nested contract directories

uport
Alex Rea 8 years ago
parent e118454511
commit b2420ec1ca
  1. 1
      package.json
  2. 10
      runCoveredTests.js

@ -14,6 +14,7 @@
"dependencies": { "dependencies": {
"ethereumjs-testrpc": "^3.0.3", "ethereumjs-testrpc": "^3.0.3",
"istanbul": "^0.4.5", "istanbul": "^0.4.5",
"mkdirp": "^0.5.1",
"shelljs": "^0.7.4", "shelljs": "^0.7.4",
"sol-explore": "^1.6.2", "sol-explore": "^1.6.2",
"solidity-parser": "git+https://github.com/ConsenSys/solidity-parser.git#master" "solidity-parser": "git+https://github.com/ConsenSys/solidity-parser.git#master"

@ -8,6 +8,7 @@ var path = require('path');
var getInstrumentedVersion = require('./instrumentSolidity.js'); var getInstrumentedVersion = require('./instrumentSolidity.js');
var CoverageMap = require('./coverageMap.js'); var CoverageMap = require('./coverageMap.js');
var coverage = new CoverageMap(); var coverage = new CoverageMap();
var mkdirp = require('mkdirp');
var childprocess = require('child_process'); var childprocess = require('child_process');
@ -27,14 +28,15 @@ if (shell.test('-d','../originalContracts')){
shell.mv('./../contracts/', './../originalContracts/'); shell.mv('./../contracts/', './../originalContracts/');
shell.mkdir('./../contracts/'); shell.mkdir('./../contracts/');
//For each contract in originalContracts, get the instrumented version //For each contract in originalContracts, get the instrumented version
shell.ls('./../originalContracts/*.sol').forEach(function(file) { shell.ls('./../originalContracts/**/*.sol').forEach(function(file) {
if (file !== 'originalContracts/Migrations.sol') { if (file !== 'originalContracts/Migrations.sol') {
console.log("instrumenting ", file); console.log("instrumenting ", file);
var contract = fs.readFileSync("./" + file).toString(); var contract = fs.readFileSync("./" + file).toString();
var fileName = path.basename(file); var fileName = path.basename(file);
var instrumentedContractInfo = getInstrumentedVersion(contract, fileName, true); var instrumentedContractInfo = getInstrumentedVersion(contract, file, true);
fs.writeFileSync('./../contracts/' + path.basename(file), instrumentedContractInfo.contract); mkdirp.sync(path.dirname(file.replace('originalContracts', 'contracts')));
var canonicalContractPath = path.resolve('./../originalContracts/' + path.basename(file)); fs.writeFileSync(file.replace('originalContracts','contracts'), instrumentedContractInfo.contract);
var canonicalContractPath = path.resolve(file);
coverage.addContract(instrumentedContractInfo, canonicalContractPath); coverage.addContract(instrumentedContractInfo, canonicalContractPath);
} }
}); });

Loading…
Cancel
Save