diff --git a/exec.js b/bin/exec.js similarity index 98% rename from exec.js rename to bin/exec.js index 852d19f..8a987e9 100644 --- a/exec.js +++ b/bin/exec.js @@ -5,9 +5,9 @@ const fs = require('fs'); const reqCwd = require('req-cwd'); const path = require('path'); const childprocess = require('child_process'); -const getInstrumentedVersion = require('./instrumentSolidity.js'); -const CoverageMap = require('./coverageMap.js'); const istanbul = require('istanbul'); +const getInstrumentedVersion = require('./../lib/instrumentSolidity.js'); +const CoverageMap = require('./../lib/coverageMap.js'); const istanbulCollector = new istanbul.Collector(); const istanbulReporter = new istanbul.Reporter(); diff --git a/coverageMap.js b/lib/coverageMap.js similarity index 100% rename from coverageMap.js rename to lib/coverageMap.js diff --git a/injector.js b/lib/injector.js similarity index 100% rename from injector.js rename to lib/injector.js diff --git a/instrumentSolidity.js b/lib/instrumentSolidity.js similarity index 96% rename from instrumentSolidity.js rename to lib/instrumentSolidity.js index 05de292..34f9014 100644 --- a/instrumentSolidity.js +++ b/lib/instrumentSolidity.js @@ -3,8 +3,6 @@ const preprocessor = require('./preprocessor'); const injector = require('./injector'); const parse = require('./parse'); -// var solparse = require("solparse"); - const path = require('path'); module.exports = function instrumentSolidity(contractSource, fileName) { @@ -47,8 +45,6 @@ module.exports = function instrumentSolidity(contractSource, fileName) { parse[ast.type](contract, ast); - // var result = solparse.parse(contract); - // We have to iterate through these injection points in descending order to not mess up // the injection process. const sortedPoints = Object.keys(contract.injectionPoints).sort((a, b) => b - a); diff --git a/instrumenter.js b/lib/instrumenter.js similarity index 100% rename from instrumenter.js rename to lib/instrumenter.js diff --git a/parse.js b/lib/parse.js similarity index 89% rename from parse.js rename to lib/parse.js index 02262e0..805d869 100644 --- a/parse.js +++ b/lib/parse.js @@ -71,17 +71,11 @@ const instrumenter = require('./instrumenter'); parse.AssignmentExpression = function parseAssignmentExpression(contract, expression) { instrumenter.instrumentStatement(contract, expression); instrumenter.instrumentAssignmentExpression(contract, expression); - // parse[expression.left.type](contract, expression.left); - // parse[expression.right.type](contract, expression.right); }; parse.ConditionalExpression = function parseConditionalExpression(contract, expression) { instrumenter.instrumentStatement(contract, expression); instrumenter.instrumentConditionalExpression(contract, expression); - // parse[expression.test.left.type](contract, expression.test.left); - // parse[expression.test.right.type](contract, expression.test.right); - // parse[expression.consequent.type](contract, expression.consequent); - // parse[expression.alternate.type](contract, expression.alternate); }; parse.Modifiers = function parseModifier(contract, modifiers) { @@ -94,21 +88,14 @@ parse.Modifiers = function parseModifier(contract, modifiers) { parse.ReturnStatement = function parseReturnStatement(contract, expression) { instrumenter.instrumentStatement(contract, expression); - // if (expression.argument){ - // parse[expression.argument.type](contract, expression.argument); - // } }; parse.NewExpression = function parseNewExpression(contract, expression) { parse[expression.callee.type](contract, expression.callee); - // expression.arguments.forEach(construct => { - // parse[construct.type](construct); - // }); }; parse.MemberExpression = function parseMemberExpression(contract, expression) { parse[expression.object.type](contract, expression.object); - // parse[expression.property.type](contract, expression.property); }; parse.CallExpression = function parseCallExpression(contract, expression) { @@ -145,7 +132,6 @@ parse.IfStatement = function parseIfStatement(contract, expression) { }; parse.ExpressionStatement = function parseExpressionStatement(contract, content) { - // if (instrument){instrumentStatement(content.expression)} parse[content.expression.type](contract, content.expression); }; @@ -166,7 +152,6 @@ parse.VariableDeclaration = function parseVariableDeclaration(contract, expressi console.log('more than one declaration'); } parse[expression.declarations[0].id.type](contract, expression.declarations[0].id); - // parse[expression.declarations[0].init.type](contract, expression.declarations[0].init); }; parse.UsingStatement = function parseUsingStatement(contract, expression) { diff --git a/preprocessor.js b/lib/preprocessor.js similarity index 100% rename from preprocessor.js rename to lib/preprocessor.js diff --git a/package.json b/package.json index 5fb4c93..19c8321 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.0.1", "description": "", "bin": { - "solidity-coverage": "./exec.js" + "solidity-coverage": "./bin/exec.js" }, "directories": { "test": "test" diff --git a/test/cli.js b/test/cli.js index aa889ed..b2bc55a 100644 --- a/test/cli.js +++ b/test/cli.js @@ -16,7 +16,7 @@ function collectGarbage() { describe('cli', () => { let testrpcProcess = null; - const script = 'node ./exec.js'; + const script = 'node ./bin/exec.js'; const port = 8555; const config = { diff --git a/test/conditional.js b/test/conditional.js index 6385daa..d22a899 100644 --- a/test/conditional.js +++ b/test/conditional.js @@ -1,9 +1,9 @@ /* eslint-env node, mocha */ const path = require('path'); -const getInstrumentedVersion = require('./../instrumentSolidity.js'); +const getInstrumentedVersion = require('./../lib/instrumentSolidity.js'); const util = require('./util/util.js'); -const CoverageMap = require('./../coverageMap'); +const CoverageMap = require('./../lib/coverageMap'); const vm = require('./util/vm'); const assert = require('assert'); diff --git a/test/expressions.js b/test/expressions.js index d0033d4..fd3558b 100644 --- a/test/expressions.js +++ b/test/expressions.js @@ -1,7 +1,7 @@ /* eslint-env node, mocha */ const solc = require('solc'); -const getInstrumentedVersion = require('./../instrumentSolidity.js'); +const getInstrumentedVersion = require('./../lib/instrumentSolidity.js'); const util = require('./util/util.js'); const path = require('path'); diff --git a/test/function.js b/test/function.js index a2553bc..070552a 100644 --- a/test/function.js +++ b/test/function.js @@ -1,10 +1,10 @@ /* eslint-env node, mocha */ const solc = require('solc'); -const getInstrumentedVersion = require('./../instrumentSolidity.js'); +const getInstrumentedVersion = require('./../lib/instrumentSolidity.js'); const util = require('./util/util.js'); const path = require('path'); -const CoverageMap = require('./../coverageMap'); +const CoverageMap = require('./../lib/coverageMap'); const vm = require('./util/vm'); const assert = require('assert'); diff --git a/test/if.js b/test/if.js index ed3816f..4c8fd82 100644 --- a/test/if.js +++ b/test/if.js @@ -1,9 +1,9 @@ /* eslint-env node, mocha */ const path = require('path'); -const getInstrumentedVersion = require('./../instrumentSolidity.js'); +const getInstrumentedVersion = require('./../lib/instrumentSolidity.js'); const util = require('./util/util.js'); -const CoverageMap = require('./../coverageMap'); +const CoverageMap = require('./../lib/coverageMap'); const vm = require('./util/vm'); const assert = require('assert'); diff --git a/test/loops.js b/test/loops.js index 186ca28..6cba5e5 100644 --- a/test/loops.js +++ b/test/loops.js @@ -1,9 +1,9 @@ /* eslint-env node, mocha */ const path = require('path'); -const getInstrumentedVersion = require('./../instrumentSolidity.js'); +const getInstrumentedVersion = require('./../lib/instrumentSolidity.js'); const util = require('./util/util.js'); -const CoverageMap = require('./../coverageMap'); +const CoverageMap = require('./../lib/coverageMap'); const vm = require('./util/vm'); const assert = require('assert'); diff --git a/test/return.js b/test/return.js index b625686..a8ebaa3 100644 --- a/test/return.js +++ b/test/return.js @@ -1,7 +1,7 @@ /* eslint-env node, mocha */ const solc = require('solc'); -const getInstrumentedVersion = require('./../instrumentSolidity.js'); +const getInstrumentedVersion = require('./../lib/instrumentSolidity.js'); const util = require('./util/util.js'); describe('return statements', () => { diff --git a/test/statements.js b/test/statements.js index eb70b4c..564db65 100644 --- a/test/statements.js +++ b/test/statements.js @@ -1,9 +1,9 @@ /* eslint-env node, mocha */ const solc = require('solc'); -const getInstrumentedVersion = require('./../instrumentSolidity.js'); +const getInstrumentedVersion = require('./../lib/instrumentSolidity.js'); const util = require('./util/util.js'); -const CoverageMap = require('./../coverageMap'); +const CoverageMap = require('./../lib/coverageMap'); const path = require('path'); const vm = require('./util/vm'); const assert = require('assert'); diff --git a/test/zeppelin.js b/test/zeppelin.js index 39caf84..e5b1c83 100644 --- a/test/zeppelin.js +++ b/test/zeppelin.js @@ -1,7 +1,7 @@ /* eslint-env node, mocha */ const solc = require('solc'); -const getInstrumentedVersion = require('./../instrumentSolidity.js'); +const getInstrumentedVersion = require('./../lib/instrumentSolidity.js'); const util = require('./util/util.js'); describe('Battery test of production contracts: OpenZeppelin', () => {