Skip to content

Proposal for a stability fix for the PhantomJS driver #24

Description

@halfer

I'm using Spiderling and PHPUnit Spiderling to offer a library that spins up an arbitrary number of web servers for the purposes of component/functional testing. I use a PHPUnit listener to spin up these servers based on custom namespace/classname matches, so that servers are only started when they are needed.

I think it is as a result of using process forking that means that when PhantomJS starts inside Spiderling, it instantiates a number of instances of the class even though they point to the same executable instance. This works fine when running and testing, but it means the destructor is run more than once.

The destructor tries to send a stop() to the instance, but only one of these will succeed. Since we're just in closing down mode, I propose that we trap the failure exception and let it fail silently, so any other test close-down happens in an orderly manner.

The code is presently:

    if ($this->_connection AND $this->_connection->is_started())
    {
        $this->_connection->stop();
    }

I have solved this here, what do you think? If you like this approach, and think it would work for the driver generally, I'd be happy to move this try-catch approach upstream to you, via a PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions