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

Tests fail #28

Closed
guimard opened this issue Jan 23, 2019 · 7 comments
Closed

Tests fail #28

guimard opened this issue Jan 23, 2019 · 7 comments

Comments

@guimard
Copy link

guimard commented Jan 23, 2019

Hello,

test reports this now :

  15 passing (59ms)
  6 failing

  1) Tempdir
       rmdir
         should remove the directory:
     TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
      at makeCallback (fs.js:137:11)                                                                                                                                                        
      at Object.rmdir (fs.js:667:14)                                                                                                                                                        
      at Function.invoke (node_modules/sinon/lib/sinon/spy.js:143:59)                                                                                                                       
      at Object.proxy [as rmdir] (node_modules/sinon/lib/sinon/spy.js:110:34)                                                                                                               
      at Dir.rmdir (lib/dir.js:45:12)                                                                                                                                                       
      at Context.<anonymous> (test/dir.test.js:29:11)                                                                                                                                       
      at callFn (/usr/lib/nodejs/mocha/lib/runnable.js:354:21)                                                                                                                              
      at Test.Runnable.run (/usr/lib/nodejs/mocha/lib/runnable.js:346:7)                                                                                                                    
      at Runner.runTest (/usr/lib/nodejs/mocha/lib/runner.js:442:10)                                                                                                                        
      at /usr/lib/nodejs/mocha/lib/runner.js:560:12                                                                                                                                         
      at next (/usr/lib/nodejs/mocha/lib/runner.js:356:14)                                                                                                                                  
      at /usr/lib/nodejs/mocha/lib/runner.js:366:7                                                                                                                                          
      at next (/usr/lib/nodejs/mocha/lib/runner.js:290:14)                                                                                                                                  
      at Immediate._onImmediate (/usr/lib/nodejs/mocha/lib/runner.js:334:5)                                                                                                                 

  2) Tempfile
       readFile
         should call fs.readfile:
     TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
      at maybeCallback (fs.js:129:9)                                                                                                                                                        
      at Object.readFile (fs.js:278:14)                                                                                                                                                     
      at Function.invoke (node_modules/sinon/lib/sinon/spy.js:143:59)                                                                                                                       
      at Object.proxy [as readFile] (node_modules/sinon/lib/sinon/spy.js:110:34)                                                                                                            
      at File.readFile (lib/file.js:44:15)                                                                                                                                                  
      at Context.<anonymous> (test/file.test.js:29:11)                                                                                                                                      
      at callFn (/usr/lib/nodejs/mocha/lib/runnable.js:354:21)                                                                                                                              
      at Test.Runnable.run (/usr/lib/nodejs/mocha/lib/runnable.js:346:7)                                                                                                                    
      at Runner.runTest (/usr/lib/nodejs/mocha/lib/runner.js:442:10)                                                                                                                        
      at /usr/lib/nodejs/mocha/lib/runner.js:560:12                                                                                                                                         
      at next (/usr/lib/nodejs/mocha/lib/runner.js:356:14)                                                                                                                                  
      at /usr/lib/nodejs/mocha/lib/runner.js:366:7                                                                                                                                          
      at next (/usr/lib/nodejs/mocha/lib/runner.js:290:14)                                                                                                                                  
      at Immediate._onImmediate (/usr/lib/nodejs/mocha/lib/runner.js:334:5)                                                                                                                 

  3) Tempfile
       writeFile
         should call fs.readfile:
     TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
      at maybeCallback (fs.js:129:9)                                                                                                                                                        
      at Object.writeFile (fs.js:1159:14)                                                                                                                                                   
      at Function.invoke (node_modules/sinon/lib/sinon/spy.js:143:59)                                                                                                                       
      at Object.proxy [as writeFile] (node_modules/sinon/lib/sinon/spy.js:110:34)                                                                                                           
      at File.writeFile (lib/file.js:58:16)                                                                                                                                                 
      at Context.<anonymous> (test/file.test.js:49:11)                                                                                                                                      
      at callFn (/usr/lib/nodejs/mocha/lib/runnable.js:354:21)                                                                                                                              
      at Test.Runnable.run (/usr/lib/nodejs/mocha/lib/runnable.js:346:7)                                                                                                                    
      at Runner.runTest (/usr/lib/nodejs/mocha/lib/runner.js:442:10)                                                                                                                        
      at /usr/lib/nodejs/mocha/lib/runner.js:560:12                                                                                                                                         
      at next (/usr/lib/nodejs/mocha/lib/runner.js:356:14)                                                                                                                                  
      at /usr/lib/nodejs/mocha/lib/runner.js:366:7                                                                                                                                          
      at next (/usr/lib/nodejs/mocha/lib/runner.js:290:14)                                                                                                                                  
      at Immediate._onImmediate (/usr/lib/nodejs/mocha/lib/runner.js:334:5)                                                                                                                 

  4) Tempfile
       open
         should call fs.open:
     TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
      at makeCallback (fs.js:137:11)                                                                                                                                                        
      at Object.open (fs.js:416:16)                                                                                                                                                         
      at Function.invoke (node_modules/sinon/lib/sinon/spy.js:143:59)                                                                                                                       
      at Object.proxy [as open] (node_modules/sinon/lib/sinon/spy.js:110:34)                                                                                                                
      at File.open (lib/file.js:72:11)
      at Context.<anonymous> (test/file.test.js:69:11)
      at callFn (/usr/lib/nodejs/mocha/lib/runnable.js:354:21)
      at Test.Runnable.run (/usr/lib/nodejs/mocha/lib/runnable.js:346:7)
      at Runner.runTest (/usr/lib/nodejs/mocha/lib/runner.js:442:10)
      at /usr/lib/nodejs/mocha/lib/runner.js:560:12
      at next (/usr/lib/nodejs/mocha/lib/runner.js:356:14)
      at /usr/lib/nodejs/mocha/lib/runner.js:366:7
      at next (/usr/lib/nodejs/mocha/lib/runner.js:290:14)
      at Immediate._onImmediate (/usr/lib/nodejs/mocha/lib/runner.js:334:5)

  5) Tempfile
       close
         should call fs.close:
     TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
      at makeCallback (fs.js:137:11)
      at Object.close (fs.js:395:20)
      at Function.invoke (node_modules/sinon/lib/sinon/spy.js:143:59)
      at Object.proxy [as close] (node_modules/sinon/lib/sinon/spy.js:110:34)
      at File.close (lib/file.js:86:12)
      at Context.<anonymous> (test/file.test.js:90:11)
      at callFn (/usr/lib/nodejs/mocha/lib/runnable.js:354:21)
      at Test.Runnable.run (/usr/lib/nodejs/mocha/lib/runnable.js:346:7)
      at Runner.runTest (/usr/lib/nodejs/mocha/lib/runner.js:442:10)
      at /usr/lib/nodejs/mocha/lib/runner.js:560:12
      at next (/usr/lib/nodejs/mocha/lib/runner.js:356:14)
      at /usr/lib/nodejs/mocha/lib/runner.js:366:7
      at next (/usr/lib/nodejs/mocha/lib/runner.js:290:14)
      at Immediate._onImmediate (/usr/lib/nodejs/mocha/lib/runner.js:334:5)

  6) Tempfile
       unlink
         should call fs.unlink:
     TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
      at makeCallback (fs.js:137:11)
      at Object.unlink (fs.js:939:14)
      at Function.invoke (node_modules/sinon/lib/sinon/spy.js:143:59)
      at Object.proxy [as unlink] (node_modules/sinon/lib/sinon/spy.js:110:34)
      at File.unlink (lib/file.js:100:13)
      at Context.<anonymous> (test/file.test.js:111:11)
      at callFn (/usr/lib/nodejs/mocha/lib/runnable.js:354:21)
      at Test.Runnable.run (/usr/lib/nodejs/mocha/lib/runnable.js:346:7)
      at Runner.runTest (/usr/lib/nodejs/mocha/lib/runner.js:442:10)
      at /usr/lib/nodejs/mocha/lib/runner.js:560:12
      at next (/usr/lib/nodejs/mocha/lib/runner.js:356:14)
      at /usr/lib/nodejs/mocha/lib/runner.js:366:7
      at next (/usr/lib/nodejs/mocha/lib/runner.js:290:14)
      at Immediate._onImmediate (/usr/lib/nodejs/mocha/lib/runner.js:334:5)
@guimard
Copy link
Author

guimard commented Jan 23, 2019

I wrote a quick-and-dirty patch :

--- a/lib/dir.js
+++ b/lib/dir.js
@@ -41,7 +41,9 @@
  * Asynchronous dir.
  */
 Dir.prototype.rmdir = function() {
-  fs.rmdir.apply(fs, this.prepareArgs(arguments));
+  var a = this.prepareArgs(arguments);
+  a.push(function(err){throw Error(err)});
+  fs.rmdir.apply(fs, a);
 };

 /**
--- a/lib/file.js
+++ b/lib/file.js
@@ -41,7 +41,9 @@
  * Asynchronously reads the entire contents of a file.
  */
 File.prototype.readFile = function() {
-  fs.readFile.apply(fs, this.prepareArgs(arguments));
+  var a = this.prepareArgs(arguments);
+  a.push(function(err){throw Error(err)});
+  fs.readFile.apply(fs, a);
 };

 /**
@@ -55,7 +57,12 @@
  * Asynchronously writes data to a file.
  */
 File.prototype.writeFile = function() {
-  fs.writeFile.apply(fs, this.prepareArgs(arguments));
+  var a = this.prepareArgs(arguments);
+  if(a.length < 2) {
+    a.push('');
+  }
+  a.push(function(err){throw Error(err)});
+  fs.writeFile.apply(fs, a);
 };

 /**
@@ -69,7 +76,9 @@
  * Asynchronous file open.
  */
 File.prototype.open = function() {
-  fs.open.apply(fs, this.prepareArgs(arguments));
+  var a = this.prepareArgs(arguments);
+  a.push(function(err){throw Error(err)});
+  fs.open.apply(fs, a);
 };

 /**
@@ -83,7 +92,9 @@
  * Asynchronous close.
  */
 File.prototype.close = function() {
-  fs.close.apply(fs, Array.prototype.slice.call(arguments));
+  var a = Array.prototype.slice.call(arguments);
+  a.push(function(err){throw Error(err)});
+  fs.close.apply(fs, a);
 };

 /**
@@ -97,7 +108,9 @@
  * Asynchronous unlink.
  */
 File.prototype.unlink = function() {
-  fs.unlink.apply(fs, this.prepareArgs(arguments));
+  var a = this.prepareArgs(arguments);
+  a.push(function(err){throw Error(err)});
+  fs.unlink.apply(fs, a);
 };

 /**

@willscott
Copy link
Collaborator

If you create this as a pull request, we can merge it in on GitHub, however only @vesln , who has disappeared for some years, is able to update the published package on NPM. As such, it's probably best to think of this official repository as deprecated.

@guimard
Copy link
Author

guimard commented Jan 23, 2019

@willscott: you can take ownership : write a mail to @vesln, CC to support@npmjs.com. If you don't have any response, you can write a second mail explaining that you're the current maintainer, no GitHub repo changes,...

Cheers,
Xavier

@willscott
Copy link
Collaborator

Transition has occurred, and I should be able to act as maintainer now. I'll work on getting this cleanup into a new version.

@guimard
Copy link
Author

guimard commented Jan 24, 2019

Thanks @willscott !

My proposed patch is quick-and-dirty. I don't know if arguments may contain more than one value. Also this has to be review:

@@ -55,7 +57,12 @@
  * Asynchronously writes data to a file.
  */
 File.prototype.writeFile = function() {
-  fs.writeFile.apply(fs, this.prepareArgs(arguments));
+  var a = this.prepareArgs(arguments);
+  if(a.length < 2) {
+    a.push('');
+  }
+  a.push(function(err){throw Error(err)});
+  fs.writeFile.apply(fs, a);
 };

 /**

Is there never any data to write ?

@willscott willscott mentioned this issue Jan 24, 2019
Merged
@willscott
Copy link
Collaborator

Thanks, for jumpstarting this. v1.0 should address the default arguments issue for the current node fs api.

@guimard
Copy link
Author

guimard commented Jan 28, 2019

Thanks ! I'll upload this to Debian

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

No branches or pull requests

2 participants