nornagon / node-zap

a tiny testing tool for node.js
MIT License
10 stars 4 forks source link

Fails running CoffeeScript tests #11

Open Leonidas-from-XIV opened 10 years ago

Leonidas-from-XIV commented 10 years ago

When I run a test in CoffeeScript (1.7.1) it fails:

% zap test/bom.test.coffee                                                                                                    

/home/leonidas/node-xml2js/test/bom.test.coffee:1
exports, require, module, __filename, __dirname) { xml2js = require '../lib/xm
                                                                    ^^^^^^^^^^^^^^^
SyntaxError: Unexpected string
  at Module._compile (module.js:439:25)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:312:12)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at output (/usr/lib/node_modules/zap/bin/zap:114:15)
  at Array.forEach (native)
  at Object.<anonymous> (/usr/lib/node_modules/zap/bin/zap:113:13)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:312:12)
  at Function.Module.runMain (module.js:497:10)
  at startup (node.js:119:16)
  at node.js:902:3

If I compile that manually, it works fine:

% zap test/bom.test.js                                                                                                             
bom/test decoded BOM... passed

I suppose it has something to do with CoffeeScript 1.7, but no idea what broke.

nornagon commented 10 years ago

this commit doesn't fix it for you? What version of zap are you using?

Leonidas-from-XIV commented 10 years ago

I hoped it would, so I updated to 0.2.6, but the error remained the same. Maybe you could try running the tests.

That is actually quite strange, since Travis seems to be running the tests fine.

nornagon commented 10 years ago

What is adding exports, require, module, __filename, __dirname) { to the beginning of that file?

Leonidas-from-XIV commented 10 years ago

I have no idea. That doesn't even make any sense.

nornagon commented 10 years ago

I successfully ran this on my machine:

$ git clone https://github.com/toddrbryan/node-xml2js
$ cd node-xml2js
$ git checkout sax-error
$ npm install
$ ./node_modules/zap/bin/zap
$ coffee --version
CoffeeScript version 1.7.1
Leonidas-from-XIV commented 10 years ago

Seems to be something wrong with my installation. I already reinstalled CoffeeScript, no idea. I'll write here if I find out what is happening. Thanks for checking!

shinnn commented 10 years ago

@Leonidas-from-XIV Have you updated global zap module by running [sudo] npm update -g zap? The command npm test uses the module installed to node_modules of your project (cf. https://www.npmjs.org/doc/misc/npm-scripts.html#path), but the command zap uses the module installed globally.

Leonidas-from-XIV commented 10 years ago

Yes, I used the global zap which I reinstalled for checking:

% ls -l /usr/bin/zap
lrwxrwxrwx 1 root root 31 Mar 25 20:27 /usr/bin/zap -> ../lib/node_modules/zap/bin/zap

/usr/lib/node_modules/zap/package.json says the version is 0.2.6, which seems to be correct, too.

This odd prefix seems to be somehow coming from Node.js itself: http://eli.thegreenplace.net/2013/05/27/how-require-loads-modules-in-node-js/ and http://stackoverflow.com/a/13622513

shinnn commented 10 years ago

How about npm test, instead of zap?

nornagon commented 10 years ago

Can you paste the output of node --version and coffee --version (and, for good measure, which zap)?