facebook / hhvm

A virtual machine for executing programs written in Hack.
https://hhvm.com
Other
18.19k stars 3k forks source link

PHPUnit's @runInSeparateProcess fails. #1584

Closed evert closed 10 years ago

evert commented 10 years ago

This can be tested with the following script:

<?php

class ProcessIsolationTest extends PHPUnit_Framework_TestCase {

    /**
     * @runInSeparateProcess
     */
    function testIsolation() {

        $this->assertTrue(true);

    }

}

Just run hhvm phpunit ProcessIsolationTest.php to trigger the error.

Effect on hhvm:

$ hhvm ~/bin/phpunit ProcessIsolationTest.php
PHPUnit 3.7.28 by Sebastian Bergmann.

E

Time: 157 ms, Memory: 1.67Mb

There was 1 error:

1) ProcessIsolationTest::testIsolation
PHPUnit_Framework_Exception: HipHop Notice: Nothing to do. Either pass a .php file to run, or use -m server

FAILURES!
Tests: 1, Assertions: 0, Errors: 1.

Effect on vanilla php:

$ ~/bin/phpunit ProcessIsolationTest.php
PHPUnit 3.7.28 by Sebastian Bergmann.

.

Time: 98 ms, Memory: 3.50Mb

OK (1 test, 1 assertion)
scannell commented 10 years ago

Thanks for reporting this. I suspect it has something to do with not supporting a particular commandline option. Feel free to submit a PR if you (or someone else reading this) gets to this before we do.

Maks3w commented 10 years ago

@evert The correct place for claim a issue about the product is the product itself. Follow this issue https://github.com/sebastianbergmann/phpunit/issues/1090

evert commented 10 years ago

@Maks3w that's only really correct if it's determined here if this is not to be fixed. hhvm aims for compatibility afaik.

sebastianbergmann commented 10 years ago

@scannell This is due to the fact that HHVM does not run code from STDIN:

➜  ~ php < test.php 
foo

➜  ~ hhvm < test.php 
HipHop Notice: Nothing to do. Either pass a .php file to run, or use -m server

I have opened issue #1590 to track this incompatibility.

jubianchi commented 10 years ago

We have the exact same problem with atoum where, to run test in isolated processes, we write code on STDIN. HHVM does not support that.

I actually made a workaround by writing code to a temporary file so I can pass its path to hhvm : https://github.com/jubianchi/atoum/commit/2c4bf9879c2ed54f46ac2f98f079d2ecbad2c497

It works but it could lead to performance loss : each test method being executed in its own process, for a suite like the atoum's one, we have to write something like 1600 temporary files.

scannell commented 10 years ago

@sebastianbergmann that makes sense, thanks for figuring out the root cause. I'll leave this open for the moment -- when this gets fixed it should close both issues though.

fredemmott commented 10 years ago

Running hhvm as 'php' (eg via a symlink) also works with the master version of PHPUnit.

fredemmott commented 10 years ago

You're also blocked by ini_get_all(), and get_included_files() being returned in the right order. These are both being worked on.