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": {
"ethereumjs-testrpc": "^3.0.3",
"istanbul": "^0.4.5",
"mkdirp": "^0.5.1",
"shelljs": "^0.7.4",
"sol-explore": "^1.6.2",
"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 CoverageMap = require('./coverageMap.js');
var coverage = new CoverageMap();
var mkdirp = require('mkdirp');
var childprocess = require('child_process');
@ -27,14 +28,15 @@ if (shell.test('-d','../originalContracts')){
shell.mv('./../contracts/', './../originalContracts/');
shell.mkdir('./../contracts/');
//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') {
console.log("instrumenting ", file);
var contract = fs.readFileSync("./" + file).toString();
var fileName = path.basename(file);
var instrumentedContractInfo = getInstrumentedVersion(contract, fileName, true);
fs.writeFileSync('./../contracts/' + path.basename(file), instrumentedContractInfo.contract);
var canonicalContractPath = path.resolve('./../originalContracts/' + path.basename(file));
var instrumentedContractInfo = getInstrumentedVersion(contract, file, true);
mkdirp.sync(path.dirname(file.replace('originalContracts', 'contracts')));
fs.writeFileSync(file.replace('originalContracts','contracts'), instrumentedContractInfo.contract);
var canonicalContractPath = path.resolve(file);
coverage.addContract(instrumentedContractInfo, canonicalContractPath);
}
});

Loading…
Cancel
Save