Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

fix: Switched from launching phantomjs via node to ensuring that the .exe is always launched #33

Merged
merged 1 commit into from Apr 4, 2014

Conversation

ghost
Copy link

@ghost ghost commented Apr 3, 2014

No description provided.

@@ -48,12 +47,7 @@ var PhantomJSBrowser = function(baseBrowserDecorator, config, args) {
optionsCode.join('\n') + '\npage.open("' + url + '");\n';
fs.writeFileSync(captureFile, captureCode);

var isWin = /^win/.test(process.platform);
if (isWin) {
flags = flags.concat(win32PhantomJSPath(), captureFile);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The extra flag added here caused the command to be

> node path/to/phantomjs /path/to/capture.js

But when PHANTOMJS_BIN was set, it resulted in a command similar to:

> global/path/to/phantomjs.exe path/to/phantomjs /path/to/capture.js

Which caused phantomjs to hang.

@ghost
Copy link
Author

ghost commented Apr 3, 2014

This Pull Request provide an alternative approach to fixing the issues tackled in #32

This approach allows us to continue treating phantomjs as a browser executable and with one small extra bit of code to 'fix up' the cmd path to be the exe path on windows.

The approach I'd rather see is the cleanup code doing a recursive process kill on the process it launched, but I don't have the node expertise, code familiarity, or cross platform knowledge to pull that off.

@ghost
Copy link
Author

ghost commented Apr 3, 2014

@vojtajina, @sylvain-hamel We're being forced to fix / work around this issue because even though our package.json is locked at "karma": "0.10.10", that in turn depends on "karma-phantomjs-launcher": "~0.1.0" which I guess includes 0.1.3, which for us contained a breaking change.

I've no problem contributing back and I'm happy to try and help, but it was I was a bit shocked to see our CI builds fail, when we felt we had locked all our dependencies.

@sylvain-hamel
Copy link
Contributor

@chad-configit Thank a lot for your help! I like this alternative approach.
I'm very sorry for this impact this had (and still has) on you guys. I'll review this PR with @vojtajina asap.

@sylvain-hamel
Copy link
Contributor

@chad-configit does #32 have any drawbacks in your context or is this just a matter of choosing the cleanest solution?

@ghost
Copy link
Author

ghost commented Apr 3, 2014

does #32 have any drawbacks in your context or is this just a matter of choosing the cleanest solution?

A bit of both.

Because you can override the phantomjs_bin path using env, that meant if you did that it would try to run the phantomjs script thru phantomjs.exe, not node.exe. This was fixable but led to more codepaths and I prefered to par things back to a simpler solution.

Additionally after considering that, it seemed much nicer for phantomjs to be being called in the same way as chrome or any other 'normal browser', which seemed desirable from a code maintenance / understandability point of view.

@sylvain-hamel
Copy link
Contributor

@chad-configit would you please reword your commit message to something that reads well as a one-liner in a changelog using at the present tense. Something like this maybe?

fix : add support for phantomjs installed locally or with PHANTOMJS_BIN 
Fixes: #31

This will speed up the merge process.

@ghost
Copy link
Author

ghost commented Apr 3, 2014

@sylvain-hamel Done. I couldn't think of a better message 😄

I'm very sorry for this impact this had (and still has) on you guys

No worries, it's understandable. Package management can be a pain.

sylvain-hamel added a commit that referenced this pull request Apr 4, 2014
…in32-process-launching

fix : add support for phantomjs installed locally or with PHANTOMJS_BIN
@sylvain-hamel sylvain-hamel merged commit 26f19d5 into karma-runner:master Apr 4, 2014
@sylvain-hamel
Copy link
Contributor

@chad-configit I merged you PR. Thanks a lot!

@ghost ghost deleted the alternate-fix-for-phantom-win32-process-launching branch April 7, 2014 16:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant