src: don't error at startup when cwd doesn't exist
[platform/upstream/nodejs.git] / test / parallel / test-fs-open.js
1 var constants = require('constants');
2 var common = require('../common');
3 var assert = require('assert');
4 var fs = require('fs');
5
6 var caughtException = false;
7 try {
8   // should throw ENOENT, not EBADF
9   // see https://github.com/joyent/node/pull/1228
10   fs.openSync('/path/to/file/that/does/not/exist', 'r');
11 }
12 catch (e) {
13   assert.equal(e.code, 'ENOENT');
14   caughtException = true;
15 }
16 assert.ok(caughtException);
17
18 var openFd;
19 fs.open(__filename, 'r', function(err, fd) {
20   if (err) {
21     throw err;
22   }
23   openFd = fd;
24 });
25
26 var openFd2;
27 fs.open(__filename, 'rs', function(err, fd) {
28   if (err) {
29     throw err;
30   }
31   openFd2 = fd;
32 });
33
34 process.on('exit', function() {
35   assert.ok(openFd);
36   assert.ok(openFd2);
37 });
38