jsdoc / jsdoc

An API documentation generator for JavaScript.
https://jsdoc.app/
Apache License 2.0
14.98k stars 1.44k forks source link

tests failing on windows #201

Closed matthewkastor closed 11 years ago

matthewkastor commented 11 years ago

I tried running the tests on Win7 64 but all I get is a screen full of gibberish and some notes at the end about failed tests.

hegemonic commented 11 years ago

Possible duplicate of #168.

matthewkastor commented 11 years ago

Sort of, except I'm getting a lot of gibberish before the failure messages:


C:\Users\kastor\Desktop\jsdoc>jsdoc -T
Running Tests
[  Envjs/1.6 (Rhino; U; Windows 7 amd64 6.1; en-US; rv:1.7.0.rc2) Resig/20070309
 PilotFish/1.2.13  ]
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[31mF←[0m←[31mF←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[31mF←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m
←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m

Failures:

jsdoc/config constructor with empty


  1) should be possible to construct a Config with an empty arguments
  Message:
    ←[31mExpected undefined to equal [  ].←[0m
  Stacktrace:
    undefined

jsdoc/config constructor with {}


  1) should be possible to construct a Config with JSON of an object literal tha
t is emptys
  Message:
    ←[31mExpected undefined to equal [  ].←[0m
  Stacktrace:
    undefined

jsdoc/readme


  1) should parse html out of markdown
  Message:
    ←[31mExpected '<p>This is a header
</p>

</p>his is some text.

<pre><code>this is some code</code></pre>

</p>

</li><li>list</li></ul>' to contain '<h2>'.←[0m
  Stacktrace:
    undefined

Finished in 8.939 seconds
←[31m372 tests, 675 assertions, 3 failures
←[0m
[[string0]]
←[32m.←[0m←[31mF←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m←[32m.←[0m

Failures:

escapeHtml plugin


  1) should escape '&', '<' and newlines in doclet descriptions
  Message:
<br>        Replaces &lt;, &amp; and newlines' to equal 'Translate HTML tags in
descriptions into safe entities.<br>        Replaces &lt;, &amp; and newlines'.←
[0m
  Stacktrace:
    undefined

Finished in 0.047 seconds
←[31m6 tests, 8 assertions, 1 failure
←[0m
 

hegemonic commented 11 years ago

You weren't kidding when you said "gibberish." I think those are ANSI color codes, but I have no idea why they'd be showing up like that.

The test failures are definitely a dupe of #168. It looks like you're picking up the wrong version of Rhino as well (see the Dependencies section of the README), but once you fix that, I expect that you'll see a different set of test failures.

Any insight into the color-code issue would be most welcome.

matthewkastor commented 11 years ago

@hegemonic XD Either that or shellcode! XD Whatever it is, it looks like it's stuck in some loop and spitting out the same thing over and over again. I'll check out the dependencies thing but, I don't have rhino installed on this machine. The only one I have is what came with jsdoc and I haven't changed anything about jsdoc at all. . .

I have been using jsdoc-toolkit for quite awhile now and it works great on windows. Thought it would be good to switch to the new version...

I'll try messing with the code a bit and let you know if I find anything interesting.

hegemonic commented 11 years ago

Rhino is packaged with some other apps/libraries/whatever, so it may have wound up in your classpath without your knowledge. But I have no idea how to figure out where it might be lurking...

Yes, please let me know if you make any headway on this!

matthewkastor commented 11 years ago

There is no CLASSPATH environment variable on my machine so I can only think that maybe it's getting the wrong version from something in my PATH, which wouldn't be a problem if the desired path gets prefixed to my existing path in the jsdoc.cmd file. I will look there first. Hold please. :D

matthewkastor commented 11 years ago

I do have node installed. The jsdoc.cmd doesn't change the PATH at all, so whatever the system decides to find when it's lost ...

jsdoc.cmd produces the following command when trying to run the tests:

java -classpath "C:/Users/kastor/Desktop/jsdoc/lib/js.jar" org.mozilla.javascript.tools.shell.Main -opt -1 -modules "file:/C:/Users/kastor/Desktop/jsdoc/nodejs_modules" -modules "file:/C:/Users/kastor/Desktop/jsdoc/rhino_modules" -modules "file:/C:/Users/kastor/Desktop/jsdoc" "C:/Users/kastor/Desktop/jsdoc/jsdoc.js" -T --dirname="C:/Users/kastor/Desktop/jsdoc/

jsdoc.cmd produces the following command when no arguments or options are given:

java -classpath "C:/Users/kastor/Desktop/jsdoc/lib/js.jar" org.mozilla.javascript.tools.shell.Main -modules "file:/C:/Users/kastor/Desktop/jsdoc/nodejs_modules" -modules "file:/C:/Users/kastor/Desktop/jsdoc/rhino_modules" -modules "file:/C:/Users/kastor/Desktop/jsdoc" "C:/Users/kastor/Desktop/jsdoc/jsdoc.js" --dirname="C:/Users/kastor/Desktop/jsdoc/

In both cases the jsdoc folder is at C:\Users\kastor\Desktop\jsdoc

matthewkastor commented 11 years ago

I keep looking for some way that java would find an alternate version of rhino but I'm not finding anything. I'm not going to run all over my system, blaming other programs, just to find out that jsdoc3 is broken. I already know that. :P

hegemonic commented 11 years ago

Rather than running all over your system, let's try this. Find the following line in jsdoc.js:

load(env.dirname + '/lib/rhino-shim.js');

After that line, add this little monstrosity:

(function() {
    var substr = new Packages.org.mozilla.javascript.regexp.SubString();
    var p = new java.io.File(substr.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
    for (var item in p) {
        if (item + '' == 'path') {
            console.log("Rhino .jar path: " + p[item]);
        }
    }
}());

Then run jsdoc jsdoc.js and let me know what path is logged to the console. If it's anything other than C:/Users/kastor/Desktop/jsdoc/lib/js.jar, we've found our culprit.

matthewkastor commented 11 years ago

Sorry about taking forever to get back to you. My nephew tried to fix his computer by pressing every key with his arm. Then he calls me and tells me "Uncle Matt, my computer's stupid". When I asked him why he told me "because I turn it on and it doesn't work" :D He's about 6 years old, already a top notch diagnostician. :D

Then I got distracted trying to figure out how to get PEAR to install PHP packages reliably, only to "rediscover" that it would probably be a better use of my time to make a serious attempt at writing a content management system in brainfuck

Ah :D now on to the good part. I slapped the provided monstrosity into jsdoc.js and ran jsdoc jsdoc.js and it spit out Rhino .jar path: C:\Users\kastor\Desktop\jsdoc\lib\js.jar Which is almost what you said it should spit out. It seems all the slashes are having some kind of rebellion and leaning the opposite direction... I've had issues with paths like C:\superBadassProjekt\tools\reallyAwesome\nuggets before where the \t, \r, and \n are misinterpreted as TAB, RETURN, and NEWLINE. I'm not saying that that's what's happening here, just that when I have doubts I sometimes replace backslashes with forwardslashes since windows generally accepts either as a path separator. I don't know, the end result is the same though. I still can't use jsdoc3 on windows which makes me super sad and stuff. :*(

Any other ideas? Is the rhino that I get when gitin' this project really the right version? I swear I did a search on my whole system for rhino and the only thing that came up was the jsdoc files and a bunch of hidden files in my porn archive. :)

hegemonic commented 11 years ago

Oh, for the love of God. It turns out that the old Rhino version number is hardcoded into one of the test framework's files. I don't know why that is, or why I get the correct, current version number when I run the tests. Sorry for the wild goose chase.

I'm currently updating the test framework, which should allow me to get rid of the nefarious env.rhino.js. The updates will also give you a way to disable output colors, so you won't have to see the crazy ANSI codes. And who knows, maybe it'll even make output colors work correctly for you.

No idea whether the changes will fix the test issues on Windows...probably that'll still need doing, but we'll see.

hegemonic commented 11 years ago

In light of the above, I'm closing this as a duplicate of #168 (for the issues with running tests) and #204 (for the ANSI color code weirdness).

matthewkastor commented 11 years ago

XD Awesome! So I managed to help find stuff! XD

Is it ready for testing again?

hegemonic commented 11 years ago

The color-code issue is now fixed via #204. Haven't looked into the test failures yet.

matthewkastor commented 11 years ago

Wohoo! XD I'll test it out. :D

matthewkastor commented 11 years ago

It's good :D I can read it now. :D

It looks like the tests are failing faster. In the post above where I was seeing the rainbow puke, the first "finished in" message reported 8.939 seconds to finish, this time it says they took 1.373 seconds. The second "finished in" message reports the same time, 0.047 seconds.

Now the test failures look like this:

C:\Users\kastor\Desktop\jsdoc>jsdoc.cmd -T
Running Tests
................................................................................
................................................................................
........F...................................................F...................
................................................................................
.........................................................................

Failures:

jsdoc/readme

  1) should parse html out of markdown
  Message:
    Expected '<p>This is a header
</p>

</p>his is some text.

<pre><code>this is some code</code></pre>

</p>

</li><li>list</li></ul>' to contain '<h2>'.
  Stacktrace:
    undefined

jsdoc/src/scanner

  1) should return the correct source files
  Message:
    Expected 5 to equal 3.
  Stacktrace:
    undefined

  2) should return the correct source files
  Message:
    Expected -1 to be greater than -1.
  Stacktrace:
    undefined

  3) should return the correct source files
  Message:
    Expected -1 to be greater than -1.
  Stacktrace:
    undefined

  4) should return the correct source files
  Message:
    Expected -1 to be greater than -1.
  Stacktrace:
    undefined

Finished in 1.373 seconds
393 tests, 671 assertions, 5 failures

[[string0]]
.F....

Failures:

escapeHtml plugin

  1) should escape '&', '<' and newlines in doclet descriptions
  Message:
<br>        Replaces &lt;, &amp; and newlines' to equal 'Translate HTML tags in
descriptions into safe entities.<br>        Replaces &lt;, &amp; and newlines'.
  Stacktrace:
    undefined

Finished in 0.047 seconds
6 tests, 8 assertions, 1 failure
hegemonic commented 11 years ago

Wow, maybe the changes #204 sped up the test harness after all, at least on Windows.

The test failures are consistent with what I'm seeing. I'll add a note to #168.

matthewkastor commented 11 years ago

I don't know what it was exactly, but it does seem to finish a lot quicker. It could be the harness or it could be the elimination of color codes and other gibberish that windows doesn't know what to do with. :D Thanks for working on it, you keep making it closer and closer to doing what it was intended to do. :D