JoinColony / solcover

Code coverage for solidity
MIT License
64 stars 8 forks source link

runCoveredTests does not traverse sub-directories in contracts folder #24

Closed adklempner closed 7 years ago

adklempner commented 7 years ago

If there are sub-directories in the original contracts folder, runCoveredTests does not copy the sub-directories or create instrumented versions of the contracts in those directories.

area commented 7 years ago

Huh, I didn't actually know truffle supported this. Do you happen to have an example repo I can test against?

adklempner commented 7 years ago

I ran into the issue trying to run SolCover for Zeppelin

area commented 7 years ago

Try the feature/contract-directories branch.

adklempner commented 7 years ago

That works! Thank you!

area commented 7 years ago

Can I get you to try the feature/contract-directories2 branch, which I will merge into master if it works for you? Be sure to rm -rf ./node_modules && np install, as I have made changes to package.json.

area commented 7 years ago

Edited the above comment to have the correct branch in it (i.e. feature/contract-directories2).

adklempner commented 7 years ago

Getting fatal: Couldn't find remote ref feature/contract-directories2

area commented 7 years ago

Yep, it sure would be a lot easier for you to test it if I actually pushed the branch.

(Done)

adklempner commented 7 years ago

That branch gives an error in instrumentSolidity.js:

/Users/aklempner/Repos/zeppelin-solidity/solcover/instrumentSolidity.js:337
                parse[expression.body[x].type](expression.body[x], instrument);
                                              ^

TypeError: parse[expression.body[x].type] is not a function
    at Object.parse.ContractStatement (/Users/aklempner/Repos/zeppelin-solidity/solcover/instrumentSolidity.js:337:35)
    at Object.parse.Program (/Users/aklempner/Repos/zeppelin-solidity/solcover/instrumentSolidity.js:369:34)
    at module.exports (/Users/aklempner/Repos/zeppelin-solidity/solcover/instrumentSolidity.js:431:39)
    at /Users/aklempner/Repos/zeppelin-solidity/solcover/runCoveredTests.js:37:40
    at Array.forEach (native)
    at Object.<anonymous> (/Users/aklempner/Repos/zeppelin-solidity/solcover/runCoveredTests.js:31:45)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)

Where expression.body[x] is

{ type: 'StateVariableDeclaration',
  name: 'target',
  literal: 
   { type: 'Type',
     literal: 'Target',
     members: [],
     array_parts: [],
     start: 238,
     end: 244 },
  visibility: null,
  is_constant: false,
  value: null,
  start: 238,
  end: 252 }

Looking at the code, there is no function for parse["StateVariableDeclaration"]

cgewecke commented 7 years ago

@adklempner Fix in progress... very sorry.

cgewecke commented 7 years ago

@adklempner as a quick fix, if you

$ npm uninstall --save solidity-parser
$ npm install --save solidity-parser

the error above should disappear.

area commented 7 years ago

rm -rf ./node_modules && npm install should also now get it working.

area commented 7 years ago

I've merged this, so now master should work for you.