Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENOENT, no such file or directory 'coverage/' #63

Open
Kikobeats opened this issue Oct 18, 2015 · 2 comments
Open

ENOENT, no such file or directory 'coverage/' #63

Kikobeats opened this issue Oct 18, 2015 · 2 comments
Assignees

Comments

@Kikobeats
Copy link

I really don't know why this happens.

I use a shellscript to run the tests:

"$PWD"/node_modules/.bin/mocha \
  -b \
  --compilers coffee:coffee-script/register \
  --require coffee-coverage/register-istanbul \
  --require should \
  --reporter spec \
  --timeout 120000 \
  --slow 300 \
  "$@"

You can see all the code here

The problem is that --require coffee-coverage/register-istanbul line throw an Error related with the coverage folder:

✓ release a new version and hook pre releases plugins in order (163ms)


  16 passing (300ms)

Failed to write coverage data Error: ENOENT, no such file or directory 'coverage/'
  at Error (native)
  at Object.fs.mkdirSync (fs.js:747:18)
  at exports.mkdirs (/Users/josefranciscoverdugambin/Projects/bumped/bumped/node_modules/coffee-coverage/lib/utils/helpers.js:43:14)
  at process.<anonymous> (/Users/josefranciscoverdugambin/Projects/bumped/bumped/node_modules/coffee-coverage/lib/register.js:116:11)
  at process.emit (events.js:107:17)
  at process.exit (node.js:600:17)
  at done (/Users/josefranciscoverdugambin/Projects/bumped/bumped/node_modules/mocha/bin/_mocha:406:32)
  at afterWrite (_stream_writable.js:361:3)
  at _stream_writable.js:349:9
  at process._tickCallback (node.js:355:11)

the strange thing is that the folder doesn't exist before I run the script (good) and after the exceptions exists.

Any idea of what happens?

@jwalton
Copy link
Contributor

jwalton commented Oct 30, 2015

No. I'm doing (almost) exactly this, and I'm not seeing this issue. The error is in mkdirs, too, which is supposed to be creating folders. Is $PWD in fact, the current working directory here? Or is this part of a script that's setting $PWD and then changing the directory?

You can add some debug logging in ./node_modules/coffee-coverage/lib/helpers.js, inside exports.mkdirs(), and see if you can figure out the full path of the folder it's trying to create. Feels like some kind of relative path problem...

@jwalton jwalton self-assigned this Oct 30, 2015
@Kikobeats
Copy link
Author

You're right. Some debug logs before call mkdirs method:

if (options.writeOnExit) {
      return process.on('exit', function() {
        var dirName, ref1;
        try {
          dirName = path.dirname(options.writeOnExit);
          console.log('DEBUG ::');
          console.log(dirName);
          console.log(process.cwd());
          console.log(__dirname);
          mkdirs(dirName);
          return fs.writeFileSync(options.writeOnExit, JSON.stringify(global[options.coverageVar]));

output:

DEBUG ::
coverage
/Users/josefranciscoverdugambin/Projects/bumped/bumped/test/plugin_directory
/Users/josefranciscoverdugambin/Projects/bumped/bumped/node_modules/coffee-coverage/lib
Failed to write coverage data Error: ENOENT, no such file or directory 'coverage/'
  at Object.fs.mkdirSync (fs.js:654:18)
  at exports.mkdirs (/Users/josefranciscoverdugambin/Projects/bumped/bumped/node_modules/coffee-coverage/lib/utils/helpers.js:48:14)
  at process.<anonymous> (/Users/josefranciscoverdugambin/Projects/bumped/bumped/node_modules/coffee-coverage/lib/register.js:154:11)
  at process.emit (events.js:95:17)
  at process.exit (node.js:740:17)
  at done (/Users/josefranciscoverdugambin/Projects/bumped/bumped/node_modules/mocha/bin/_mocha:406:32)
  at afterWrite (_stream_writable.js:278:3)
  at _stream_writable.js:267:9
  at process._tickCallback (node.js:448:13)

I suppose that is important that I'm running the command using a script. I have the script in test/test.sh, so when I call the script from the root of my project using npm test could be a conflict with process.cwd and/or __dirname...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants