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

Windows support when running local copy under node_modules #63

Closed
Iristyle opened this issue Sep 28, 2012 · 7 comments
Closed

Windows support when running local copy under node_modules #63

Iristyle opened this issue Sep 28, 2012 · 7 comments

Comments

@Iristyle
Copy link
Contributor

I'm having two separate issues it would appear...Windows 7 x64, Node 0.8.11.

  • On 0.2.0, Chrome Canary launches process + UI just fine, but the appended ?id=1 doesn't serve up any content.
  • On 0.3..7, Chrome Canary launches the process, but it's running headless somehow. I verified this multiple times just to make sure I wasn't seeing things (including reboots, etc)

I can launch a new browser instance, and plug in the id for the url that it was launched with and I get nothing. No content is served.

Note that I've configured testacular to use both PhantomJS and Canary

So if I take the id that's supposed to be used by PhantomJS and I plug that into the browser -- everything loads up. I can see in my shell that Testacular starts serving everything properly (I'm running with LOG_DEBUG)

I'm not going to worry about 0.2.0 .. and I'll focus on 0.3.7. So to recap on those issues

  • It seems that the id that's generated for Canary isn't hooked up to what it needs to be in the serving process..
  • The UI is not firing up anymore.

I should hopefully be able to figure out why chrome.exe is spawnd without a UI ... was wondering if anyone had encountered the other issue with bad Ids?

@vojtajina
Copy link
Contributor

This is Chrome issue on Windows.
Can you please star the issue on http://code.google.com/p/chromium/issues/detail?id=151836 ?

It worked fine in previous versions of Testacular, because we were using child_process.exec, which executes a command in a shell. However, that has troubles, that you can't kill it (on Window/Linux), so now all browsers are started using spawn and killing works fine on all major platforms.


I'm curious about "not serving the url with id". The web server should ignore anything after ?, so even urls like http://localhost:9876/?whatever should work and capture the browser. Just tried on Windows VM (win7) and yep, the UI is invisible, but the browser is captured and everything works fine.

@Iristyle
Copy link
Contributor Author

Yeah.. sorry, I should have given a few more details here. I was in the midst of copying some captured info out of my VM, when the machine powered off (having hardware issues with my laptop at the moment).

In any event, let me give you some debug output to make it a bit more clear. But what I'm saying is that I can do two things to verify I'm not being served the scripts (passed to the files config option).

For the sake of argument, let's say Canary is served the ?id=123 and PhantomJS is served ?id=124.

If I create a new Canary instance, and point it at ?=123 (which would be the same address that the hidden Chrome is pointing at), Socket IO connects, a Testacular runner page with just the top green banner shows, the standard Testacular files load up, etc. However, I do not get anything passed to files -- that is, none of my application, test files, the mocha adapter, etc.

I verify this in two ways

  • There is no corresponding LOG_DEBUG output in my shell like serving spec.js
  • I can watch the network traffic / resources in the dev tools in Chrome. I see I don't get any of the expected files.

I have tried to do a refresh with F5 and Ctrl+F5 to try to reload this url. Same result.

Now if I instead point the browser at ?id=124 -- the address that PhantomJS is pointed at -- voila. The shell outputs all the info on files that it is serving, and I can see in the traffic / resources, all the files load as expected.

Does that clear things up (until I can get you some real console output just to prove I'm not crazy ;0)

@vojtajina
Copy link
Contributor

This is weird. Really testacular does not care about the ?... part of the url, it serves completely the same content to all browsers.

I tried this on Windows7 VM:

  • start testacular with --browsers PhantomJS,Chrome
    -> capture both browsers (Chrome is invisible) and executes all the tests, no problem
  • open another Chrome and point it to http://localhost:9876/?id= (it's a a random number now)
    -> no problem, third browser captured, all tests executed
  • open another Chrome and point it to ?id=
    -> again, no problem, captured and tests executed

Can you double check the console if there is any error ?

@Iristyle
Copy link
Contributor Author

Ok -- I've figured out what the problem is.. I still think this is a bug, but maybe you have a good reason for this behavior.

The basic problem is that if not all of the specified browsers can be contacted, then the content won't be served / tests won't run. My PhantomJS was in a different spot on disk than where you expect it to be (something that should probably be configurable)... but I wasn't too worried about that, because I didn't think it would be a factor here.

As it turns out, it would seem that Testacular is expecting all the configured browsers to connect before it does anything. So by manually hitting the url that was intended for PhantomJS, I'm manually confirming that the browsers are responding.

IMHO, I think you should either

  • totally blow up Testacular if you can't find all the configured browsers - i.e. fail fast (note that I am running in watchmode)
  • not require all browsers to have communicated before serving the content (I don't know enough about the internals here to know if this is feasible)

Here's the longer story with all the details... which led me to the above conclusion.

I'm launching testacular from a Grunt build...

child = fork(path.join(__dirname, 'spec','server.js'), [JSON.stringify(options)])

Here is the server.js used to launch Testacular

util = require('util');
util.log('Starting testacular with arguments:' + util.inspect(process.argv[2]));

require('testacular').server.start(JSON.parse(process.argv[2]));

And here is the output on first run...

Waiting...30 Sep 01:30:27 - Starting testacular with arguments:'{"basePath":"..","files":["C:\\\\source\\\\AngularCoffeeLessDemo\\\\node_modules\\\\testacular\\\\adapter\\\\lib\\\\mocha.js","C:\\\\source\\\\AngularCoffeeLessDemo\\\\node_modules\\\\testacular\\\\adapter\\\\mocha.js","generated/lib/mocha.js","generated/test/mocha-shim.js","generated/lib/require.js","generated/app.js","generated/specs.js"],"reporter":"dots","browsers":["ChromeCanary","PhantomJS"],"autoWatch":true,"singleRun":false,"configFile":"C:\\\\source\\\\AngularCoffeeLessDemo\\\\config\\\\testacular.conf.js","adapter":"mocha","logLevel":4,"reportSlowerThan":500}'
warn (config): "reporter" is deprecated, use "reporters" instead
info: Testacular server started at http://localhost:9876/
debug (launcher): Creating temp dir at C:\Users\EPS\AppData\Local\Temp\testacular-77528555
info (launcher): Starting  browser "ChromeCanary"
debug (launcher): C:\Users\EPS\AppData\Local\Google\Chrome SxS\Application\chrome.exe --user-data-dir=C:\Users\EPS\AppData\Local\Temp\testacular-77528555
--no-default-browser-check --no-first-run --disable-default-apps http://localhost:9876/?id=77528555 --js-flags="--nocrankshaft --noopt"
debug (launcher): Creating temp dir at C:\Users\EPS\AppData\Local\Temp\testacular-32117180
info (launcher): Starting  browser "PhantomJS"
debug (launcher): C:\Program Files (x86)\PhantomJS\phantomjs.exe C:\Users\EPS\AppData\Local\Temp\testacular-32117180/capture.js
error (launcher): Cannot start PhantomJS
        CreateProcessW: The system cannot find the path specified.

debug (launcher): Cleaning C:\Users\EPS\AppData\Local\Temp\testacular-32117180
debug (watcher): Resolved files:
        C:/source/AngularCoffeeLessDemo/node_modules/testacular/adapter/lib/mocha.js
        C:/source/AngularCoffeeLessDemo/node_modules/testacular/adapter/mocha.js
        C:/source/AngularCoffeeLessDemo/generated/lib/mocha.js
        C:/source/AngularCoffeeLessDemo/generated/test/mocha-shim.js
        C:/source/AngularCoffeeLessDemo/generated/lib/require.js
        C:/source/AngularCoffeeLessDemo/generated/app.js
        C:/source/AngularCoffeeLessDemo/generated/specs.js
info (watcher): Watching "C:/source/AngularCoffeeLessDemo/node_modules/testacular/adapter/lib/mocha.js"
info (watcher): Watching "C:/source/AngularCoffeeLessDemo/node_modules/testacular/adapter/mocha.js"
info (watcher): Watching "C:/source/AngularCoffeeLessDemo/generated/lib/mocha.js"
info (watcher): Watching "C:/source/AngularCoffeeLessDemo/generated/test/mocha-shim.js"
info (watcher): Watching "C:/source/AngularCoffeeLessDemo/generated/lib/require.js"
info (watcher): Watching "C:/source/AngularCoffeeLessDemo/generated/app.js"
info (watcher): Watching "C:/source/AngularCoffeeLessDemo/generated/specs.js"
debug (watcher): Add file "C:/source/AngularCoffeeLessDemo/generated/app.js" ignored. Already in the list.
debug (watcher): Add file "C:/source/AngularCoffeeLessDemo/generated/specs.js" ignored. Already in the list.
debug (watcher): Add file "C:/source/AngularCoffeeLessDemo/generated/lib/mocha.js" ignored. Already in the list.
debug (watcher): Add file "C:/source/AngularCoffeeLessDemo/generated/test/mocha-shim.js" ignored. Already in the list.
debug (watcher): Add file "C:/source/AngularCoffeeLessDemo/generated/lib/require.js" ignored. Already in the list.
debug (watcher): Add file "C:/source/AngularCoffeeLessDemo/node_modules/testacular/adapter/mocha.js" ignored. Already in the list.
debug (watcher): Add file "C:/source/AngularCoffeeLessDemo/node_modules/testacular/adapter/lib/mocha.js" ignored. Already in the list.
debug (web server): serving: C:/source/AngularCoffeeLessDemo/node_modules/testacular/static/client.html
debug (web server): serving: C:/source/AngularCoffeeLessDemo/node_modules/testacular/static/testacular.js
debug: New browser has connected on socket aE5Sv5fKV_V3FG5Op3mc
info (Chrome 24.0): Connected on socket id aE5Sv5fKV_V3FG5Op3mc

You can see that it found the files just fine... but not that it's not serving everything that it should. It hasn't found PhantomJS. My assumption would be that just PhantomJS fails to run, but that's not the case.

If I point canary at http://localhost:9876/?id=77528555 - this is the url Canary is launched with:

debug (web server): serving: C:/source/AngularCoffeeLessDemo/node_modules/testacular/static/client.html
debug (web server): serving: C:/source/AngularCoffeeLessDemo/node_modules/testacular/static/testacular.js
debug: New browser has connected on socket pcOf-LTtMqSOtBmmp3md
info (Chrome 24.0): Connected on socket id pcOf-LTtMqSOtBmmp3md

If I refresh the page:

debug (web server): serving: C:/source/AngularCoffeeLessDemo/node_modules/testacular/static/client.html
warn (Chrome 24.0): Disconnected
debug (web server): serving: C:/source/AngularCoffeeLessDemo/node_modules/testacular/static/testacular.js
debug: New browser has connected on socket AdXY7Rx-Zavm_kGjp3mg
info (Chrome 24.0): Connected on socket id AdXY7Rx-Zavm_kGjp3mg

Now here's where it gets interesting... if I point the browser at http://localhost:9876/?id=32117180, the URL given to PhantomJS... this is what I end up with -- the files are served.

Obviously I've got some issues in the tests themselves, but to be able to figure that part out, I need them to run first! ;0

debug (web server): serving: C:/source/AngularCoffeeLessDemo/node_modules/testacular/static/client.html
warn (Chrome 24.0): Disconnected
debug (web server): serving: C:/source/AngularCoffeeLessDemo/node_modules/testacular/static/testacular.js
debug: New browser has connected on socket VdMFtnvyuDXjk--6p3mh
info (Chrome 24.0): Connected on socket id VdMFtnvyuDXjk--6p3mh
debug: All browsers are ready, executing
debug (web server): serving: C:/source/AngularCoffeeLessDemo/node_modules/testacular/static/context.html
debug (web server): serving: C:/source/AngularCoffeeLessDemo/node_modules/testacular/adapter/lib/mocha.js
debug (web server): serving: C:/source/AngularCoffeeLessDemo/node_modules/testacular/adapter/mocha.js
debug (web server): serving: C:/source/AngularCoffeeLessDemo/generated/lib/mocha.js
debug (web server): serving: C:/source/AngularCoffeeLessDemo/generated/test/mocha-shim.js
debug (web server): serving: C:/source/AngularCoffeeLessDemo/generated/lib/require.js
debug (web server): serving: C:/source/AngularCoffeeLessDemo/generated/app.js
debug (web server): serving: C:/source/AngularCoffeeLessDemo/generated/specs.js
debug (web server): serving: C:/source/AngularCoffeeLessDemo/node_modules/testacular/static/context.html
debug (web server): serving: C:/source/AngularCoffeeLessDemo/node_modules/testacular/adapter/lib/mocha.js
Chrome 24.0 ERROR
        Uncaught TypeError: undefined is not a function
        at http://localhost:9876/adapter/lib/mocha.js?1348868138000:4492
Chrome 24.0: Executed 0 of 0
Chrome 24.0: Executed 0 of 0 ERROR (1.369 secs / 0 secs)
debug (web server): serving: C:/source/AngularCoffeeLessDemo/node_modules/testacular/adapter/mocha.js
debug (web server): serving: C:/source/AngularCoffeeLessDemo/generated/lib/mocha.js
debug (web server): serving: C:/source/AngularCoffeeLessDemo/generated/test/mocha-shim.js
debug (web server): serving: C:/source/AngularCoffeeLessDemo/generated/lib/require.js
Chrome 24.0 ERROR
        Uncaught TypeError: undefined is not a function
        at http://localhost:9876/adapter/lib/mocha.js?1348868138000:4492
Chrome 24.0: Executed 0 of 0 ERROR (2.224 secs / 0 secs)
Chrome 24.0: Executed 0 of 0 ERROR (1.369 secs / 0 secs)
TOTAL: 0 SUCCESS

Thanks for taking a look -- sorry to have initially given you a red herring.

@Iristyle
Copy link
Contributor Author

Iristyle commented Oct 1, 2012

Note that even when PhantomJS is configured properly, it can take some time for it to fire up (on the first run)... might be useful to dump this to the output, as otherwise it can look like nothing is happening.

@vojtajina
Copy link
Contributor

Yep, currently Testacular waits for all the browsers to get captured, before running (in single run mode). There is an issue to change that #57.

It's not true, that the content is not served. Unless there is any windows specific issue, Testacular's web server does not care about any captured browser or whatsoever. It just serves all the time.

WATCHING MODE
If browser fails to get captured, Testacular does not care about it. Whenever you change a file, it executes in all captured browsers (only waits for previous execution to finish).

SINGLE RUN MODE
If browser fails to start (eg. the binary does not exists), it immediately fails (exit 1). Since 0.3.8 there is also timeout (--capture-timeout) and if any browser fails to capture in given timeout, it kills it and whole build immediately fails (exit 1).


To summarize this, I see only one issue - don't wait for all browsers to run. And there is already an issue for it #57.
So, I'm closing this issue. Feel free to re-open, if you think I'm missing something here.

@Iristyle
Copy link
Contributor Author

Iristyle commented Oct 3, 2012

Nope, that's accurate... aside from the configuring the path to PhantomJS part. I'll open up a separate issue for that.

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