aaronm67 / node-phash

Phash Bindings for Node.js
163 stars 41 forks source link

Test failed #9

Closed xissy closed 5 years ago

xissy commented 11 years ago

Hello, @aaronm67!

I'm going to update NPM now, but errors are occurred when I try npm test. I tested with MacOS and Ubuntu. They splited same the error message as below.

Do you have any idea?

xissy-MBP:node-phash xissysnd$ npm test

> phash@0.0.4 test /Users/xissysnd/recom.io/node-phash
> node-gyp configure build && mocha

make: Nothing to be done for `all'.

  ....
[CImg] *** CImgIOException *** [instance(0,0,0,0,0x0,non-shared)] CImg<unsigned char>::load(): Failed to recognize format of file './examples/f.png'.
..assert.js:3657: Uncaught AssertionError: "54086765383280" == "2816561582497829945"
...
[CImg] *** CImgIOException *** [instance(0,0,0,0,0x0,non-shared)] CImg<unsigned char>::load(): Failed to recognize format of file './examples/f.png'.
...
[CImg] *** CImgIOException *** [instance(0,0,0,0,0x0,non-shared)] CImg<unsigned char>::load(): Failed to recognize format of file './examples/f.png'.
..

  ✖ 3 of 14 tests failed:

  1) pHash sync test ./examples/b.png:

      actual expected

      25408165761538324978299450

  AssertionError: "54086765383280" == "2816561582497829945"
      at Context.<anonymous> (/Users/xissysnd/recom.io/node-phash/test/test.js:16:24)
      at Test.Runnable.run (/Users/xissysnd/recom.io/node-phash/node_modules/mocha/lib/runnable.js:184:32)
      at Runner.runTest (/Users/xissysnd/recom.io/node-phash/node_modules/mocha/lib/runner.js:300:10)
      at /Users/xissysnd/recom.io/node-phash/node_modules/mocha/lib/runner.js:346:12
      at next (/Users/xissysnd/recom.io/node-phash/node_modules/mocha/lib/runner.js:228:14)
      at /Users/xissysnd/recom.io/node-phash/node_modules/mocha/lib/runner.js:237:7
      at next (/Users/xissysnd/recom.io/node-phash/node_modules/mocha/lib/runner.js:185:23)
      at /Users/xissysnd/recom.io/node-phash/node_modules/mocha/lib/runner.js:205:5
      at process._tickCallback (node.js:415:13)
      at Function.Module.runMain (module.js:499:11)
      at startup (node.js:119:16)
      at node.js:901:3

  2) pHash async test ./examples/b.png:
     Error: timeout of 2000ms exceeded
      at null.<anonymous> (/Users/xissysnd/recom.io/node-phash/node_modules/mocha/lib/runnable.js:142:14)
      at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

  3) pHash legacy test should match:

      actual expected

      25408165761538324978299450

  AssertionError: "54086765383280" == "2816561582497829945"
      at /Users/xissysnd/recom.io/node-phash/test/test.js:59:24
      at Array.forEach (native)
      at Context.<anonymous> (/Users/xissysnd/recom.io/node-phash/test/test.js:57:22)
      at Test.Runnable.run (/Users/xissysnd/recom.io/node-phash/node_modules/mocha/lib/runnable.js:184:32)
      at Runner.runTest (/Users/xissysnd/recom.io/node-phash/node_modules/mocha/lib/runner.js:300:10)
      at /Users/xissysnd/recom.io/node-phash/node_modules/mocha/lib/runner.js:346:12
      at next (/Users/xissysnd/recom.io/node-phash/node_modules/mocha/lib/runner.js:228:14)
      at /Users/xissysnd/recom.io/node-phash/node_modules/mocha/lib/runner.js:237:7
      at next (/Users/xissysnd/recom.io/node-phash/node_modules/mocha/lib/runner.js:185:23)
      at /Users/xissysnd/recom.io/node-phash/node_modules/mocha/lib/runner.js:205:5
      at process._tickCallback (node.js:415:13)
      at process._tickFromSpinner (node.js:390:15)

npm ERR! Test failed.  See above for more details.
npm ERR! not ok code 0
aaronm67 commented 11 years ago

I saw that -- there is definitely a difference between the pHash version that runs on 32-bit and the version that runs on 64-bit, and we don't account for that.

I would like to take a look at figuring out what is causing the difference between these. I added an automated testing service (https://travis-ci.org/aaronm67/node-phash) that will run our tests automatically on checkins, and since it's on 32-bit ubuntu, they currently pass on the automated testing and fail on OSX (as most macs are 64-bit).

I will probably end up re-writing some of the tests shortly, possibly either comparing them with the Ruby pHash bindings (pHashion) or writing a small C++ program that will just output the hashes (rather than hardcoding them into the test). Unfortunately, that makes our Build/testing program significantly more complicated.

-Aaron

aaronm67 commented 11 years ago

I went ahead and removed the test on b.png for now, as it is different between systems.

I will look into rewriting the tests at a later point -- I don't really think there is any value in testing what the exact hashes are, as they seem to vary depending on the system you're on -- our tests should really just ensure the various functions are working (i.e. not returning "0" and not throwing an exception), and that we test for issues like #4 and #8 .