Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix issue with X_OK and fs.access() #602

@humphd

Description

@humphd

In #601 we finished our fs.access() implementation. We have one test that is not working as expected, and currently being skipped in tests/spec/fs.access.spec.js:

  it.skip('should return an error if file is not executable and mode = X_OK', function (done) {
    var fs = util.fs();
    var contents = 'This is a file.';
   
    fs.writeFile('/myfile', contents, function (error) {
      if (error) throw error;
      fs.chmod('/myfile', 0o644, function(error){
        if (error) throw error;
      
        fs.access('/myfile', fs.constants.X_OK, function (error) {
          expect(error).to.exist;
          expect(error.code).to.equal('EACCES');
          done();
        });  
      });
    });
  });

This should be failing, but isn't. We need to figure out why.

NOTE: our implementation of access() is based on the idea that the user is uid==0 (root), and generally has elevated access rights. However, if a file isn't executable (the one above is 644), we should be able to get EACCESS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions