In terminal 1:
when i tried following commands
Windows error
Thanks for reporting!
Yes, same issue here. I've tried messing with the source as well but haven't had any luck getting it to work on Windows.
Why is this issue closed? Is windows not supported?
@phiferd Reopening, thank you. Yes, we try to support windows - unfortunately I don't think either of the maintainers have a windows box and the original poster closed the issue.
This stack overflow post seems like it might be relevant.
https://stackoverflow.com/questions/20765337/how-to-fix-is-not-an-internal-or-external-command-error
Just to be clear, the issue isn't the command I'm entering (which would be an easy fix), it's a command that is issued internally by solidity coverage. Here's the full output:
C:\Users\Dan\WebstormProjects\zeppelin-solidity>node_modules\.bin\solidity-coverage
Generating coverage environment
Instrumenting ./coverageEnv/contracts/Bounty.sol
... (suppressing other output this for clarity)
Instrumenting ./coverageEnv/contracts/token/VestedToken.sol
testRpc stderr:
'.' is not recognized as an internal or external command,
operable program or batch file.
Cleaning up...
testRpc errored after launching as a childprocess.
Exiting without generating coverage...
This seems to be related to starting testrpc-sc, so if I can us norpc and start testrpc-sc manually to get further in the process. However, it runs out of memory.
Using 'node --max-old-space-size=4096 ../node_modules/.bin/truffle test --network coverage' fails with:
C:\Users\Dan\WebstormProjects\zeppelin-solidity>node_modules\.bin\solidity-coverage
Generating coverage environment
Instrumenting ./coverageEnv/contracts/Bounty.sol
...
Instrumenting ./coverageEnv/contracts/token/VestedToken.sol
Running: node --max-old-space-size=4096 ../node_modules/.bin/truffle test --network coverage
(this can take a few seconds)...
C:\Users\Dan\WebstormProjects\zeppelin-solidity\node_modules\.bin\truffle:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
Changing the command to force the script to use the .cmd version of the truffle command gives:
C:\Users\Dan\WebstormProjects\zeppelin-solidity>node_modules\.bin\solidity-coverage
Generating coverage environment
Instrumenting ./coverageEnv/contracts/Bounty.sol
...
Instrumenting ./coverageEnv/contracts/token/VestedToken.sol
Running: node --max-old-space-size=4096 ../node_modules/.bin/truffle.cmd test --network coverage
(this can take a few seconds)...
C:\Users\Dan\WebstormProjects\zeppelin-solidity\node_modules\.bin\truffle.cmd:1
(function (exports, require, module, __filename, __dirname) { @IF EXIST "%~dp0\node.exe" (
^
SyntaxError: Invalid or unexpected token
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
Cleaning up...
There was an error generating coverage. Possible reasons include:
1. Another application is using port 8555
2. Truffle crashed because your tests errored
Error: ENOENT: no such file or directory, open 'C:\Users\Dan\WebstormProjects\zeppelin-solidity\allFiredEvents'
Exiting without generating coverage...
@phiferd - thanks a lot for looking into this.
What happens if you create a Truffle metacoin project (truffle init) and launch the testrpc externally (with norpc set to true)? With the regular command to launch solidity-coverage. Does that fail?
@phiferd Also I just remembered this issue at Zeppelin. We fixed a specific problem around the truffle.js file there but then maybe they got it working? Might be worth pinging those OPs and asking.
Yes, I ran into that issue as well be managed to figure out the renaming trick.
I setup a new project:
truffle init (truffle is already installed globally)truffle.js to truffle-config.jsmodule.exports = {
networks: {
development: {
host: "localhost",
port: 8555,
network_id: "*" // Match any network id
},
coverage: {
host: "localhost",
network_id: "*",
port: 8555,
gas: 0xfffffffffff,
gasPrice: 0x01
}
}
};
.solcover.js in project root with module.exports = { norpc: true }package.json in project root with required dev dependencies (solidity-covereage, truffle)npm install node_modules\.bin\testrpc-sc --port 8555node_modules\.bin\solidity-coverageThe coverage seems to run ok (tests pass) but it fails at the end:
C:\Users\Dan\WebstormProjects\SolcoverTest>node_modules\.bin\solidity-coverage
Generating coverage environment
Instrumenting ./coverageEnv/contracts/ConvertLib.sol
Instrumenting ./coverageEnv/contracts/MetaCoin.sol
Skipping instrumentation of ./coverageEnv/contracts/Migrations.sol
Running: truffle test --network coverage
(this can take a few seconds)...
Using network 'coverage'.
Compiling .\contracts\ConvertLib.sol...
Compiling .\contracts\MetaCoin.sol...
Compiling .\contracts\Migrations.sol...
Compiling .\test\TestMetacoin.sol...
Compiling truffle/Assert.sol...
Compiling truffle/DeployedAddresses.sol...
Compilation warnings encountered:
truffle/Assert.sol:114:20: Warning: This declaration shadows an existing declaration.
function equal(string A, string B, string message) constant returns (bool result) {
^------^
(suppressing other warnings for readability)
TestMetacoin
√ testInitialBalanceUsingDeployedContract (254ms)
√ testInitialBalanceWithNewMetaCoin (260ms)
Contract: MetaCoin
√ should put 10000 MetaCoin in the first account (125ms)
√ should call a function that depends on a linked library (263ms)
√ should send coin correctly (653ms)
5 passing (3s)
Cleaning up...
There was an error generating coverage. Possible reasons include:
1. Another application is using port 8555
2. Truffle crashed because your tests errored
Error: ENOENT: no such file or directory, open 'C:\Users\Dan\WebstormProjects\SolcoverTest\allFiredEvents'
Exiting without generating coverage...
Haha. Ok, one step further.
I ran node_modules\.bin\testrpc-sc --port 8555 from another directory. However, it looks like solidity-coverage assumes that it will be running in the same directory as truffle, because apparently the output file is generated by testrpc-sc, not the solidity-coverage process.
So, after restarting testrpc-sc in the project root, I get:
... same as before
TestMetacoin
√ testInitialBalanceUsingDeployedContract (225ms)
√ testInitialBalanceWithNewMetaCoin (214ms)
Contract: MetaCoin
√ should put 10000 MetaCoin in the first account (136ms)
√ should call a function that depends on a linked library (262ms)
√ should send coin correctly (638ms)
5 passing (2s)
Cleaning up...
There was a problem generating the coverage map / running Istanbul.
TypeError: Cannot read property 'f' of undefined
Exiting without generating coverage...
Getting really close....but there are a bunch of paths in app.js that are ./ prefixed.
Yes, it looks like the issue is with the way the path is handled. on this line:
this.coverage[canonicalContractPath].f[data[1].toNumber()] += 1;
I printed the canonical path variable:
C:UsersDanWebstormProjectsSolcoverTestcoverageEnvcontractsMetaCoin.sol
However, the data structure has this property:
"C:\\Users\\Dan\\WebstormProjects\\SolcoverTest\\coverageEnv\\contracts\\MetaCoin.sol"
So close ..... In app.js, replacing
const contractPath = path.resolve(file)
with
const contractPath = path.resolve(file).split('\\').join('/');
Gets the output:
After generate
-------------------------------------------------------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
-------------------------------------------------------|----------|----------|----------|----------|----------------|
C:/Users/Dan/WebstormProjects/SolcoverTest/contracts\ | 90 | 50 | 100 | 100 | |
ConvertLib.sol | 100 | 100 | 100 | 100 | |
MetaCoin.sol | 88.89 | 50 | 100 | 100 | |
-------------------------------------------------------|----------|----------|----------|----------|----------------|
All files | 90 | 50 | 100 | 100 | |
-------------------------------------------------------|----------|----------|----------|----------|----------------|
Istanbul coverage reports generated
Cleaning up...
But the report doesn't seem to be functioning quite right in the browser.
Actually, maybe it's ok. Does this output look right?
coverage.zip
Yes, i'm on a phone but the numbers look good! Great job.
On Sep 24, 2017 8:36 PM, "phiferd" notifications@github.com wrote:
Actually, maybe it's ok. Does this output look right?
coverage.zip
https://github.com/sc-forks/solidity-coverage/files/1328188/coverage.zip—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/sc-forks/solidity-coverage/issues/112#issuecomment-331769407,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AG_gun9Yx3oN6BiSwLqdlt0M7rb7uVAhks5slx_MgaJpZM4Pagpp
.
After #124 this just needs a Running on Windows FAQ about launching externally, possibly about using the phiferd fork.
Fixed with ed1490f609004e7be9a943dc201be0c81d6a728a. There are caveats - you can't really develop this project on Windows, it's torturously slow on Windows IDES if you need node_modules and you need to set the norpc option to true and launch testrpc-sc from the command line.
Published: 0.2.6
For an automated solution:
--kill-others switch from concurrently)|| true to the npm command.Final solution is:
"coverage": "concurrently --names \"TestRPC,Coverage\" --kill-others \"node_modules\\.bin\\testrpc-sc --port 8555\" \"node_modules\\.bin\\solidity-coverage\" || true",
I hope this solution can also help others.
More reference:
https://github.com/kimmobrunfeldt/concurrently/issues/127
You need to do some configuration manually so that it can run on Windows 10.
â‘ install: npm install --save-dev solidity-coverage
â‘¡Create a file named .solcover.js with module.exports = { norpc: true } inside
â‘¢run: ./node_modules/.bin/solidity-coverage
Hi folks. Unfortunately, I'm still seeing errors running this on Windows. After trying the above, I got:
Error: ENOENT: no such file or directory, open 'YOUR_PATH\allFiredEvents'
..and manually adding that directory resulted in:
Error: EISDIR: illegal operation on a directory, read
I'll keep on digging!
Most helpful comment
You need to do some configuration manually so that it can run on Windows 10.
â‘ install:
npm install --save-dev solidity-coverageâ‘¡Create a file named
.solcover.jswithmodule.exports = { norpc: true }insideâ‘¢run:
./node_modules/.bin/solidity-coverage