Giter Club home page Giter Club logo

Comments (6)

kelunik avatar kelunik commented on May 18, 2024

Also, all signal tests are skipped for me right now.

from amp.

kelunik avatar kelunik commented on May 18, 2024

Signal tests have been fixed, all timer tests have a grace period of 1 millisecond now, but the UvDriverTest::testExecutionOrderGuarantees is still broken.

from amp.

KorvinSzanto avatar KorvinSzanto commented on May 18, 2024

So the issue with this is delaying from what I can tell. I've written a shorter test that's a little easier to follow and displays the issue more clearly:

    public function testExecutionOrder()
    {
        // Our expected output
        $this->expectOutputString('defer writable reenabled delay ');

        // Set up a closure to output
        $output = function(Driver $loop, string $output) {
            $called = false;
            // Return a function that tracks whether it has been called
            return function($id) use ($loop, $output, &$called) {
                if ($called) {
                    $this->fail('Watcher callback called too often');
                }

                $called = true;
                $loop->cancel($id);
                echo $output . ' ';
            };
        };

        // Begin a loop for testing
        $this->start(function (Driver $loop) use (&$ticks, $output) {
            // Lets start with the reenabled watcher
            $reenabled = $loop->onWritable(STDIN, $output($loop, 'reenabled'));
            $loop->disable($reenabled);

            // Lets defer something now
            $loop->defer($output($loop, 'defer'));

            // Move on to delay
            $loop->delay(0, $output($loop, 'delay'));

            // Writable
            $loop->onWritable(STDIN, $output($loop, 'writable'));

            // Reenable
            $loop->enable($reenabled);
        });

    }

Adding this to the DriverTest class will result in a failure for the UV driver looking like this:

1) Amp\Test\Loop\UvDriverTest::testExecutionOrder
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'defer writable reenabled delay '
+'defer delay writable reenabled '

Which tells me that UV's timer functionality is perhaps acting unexpectedly with low millisecond delays. I threw the whole of the handling code for delay in a $this->defer block, but that didn't really do much beyond move the delay to output after writable.

Is there a good spot where I could talk to someone who maybe knows more about this than I do?

from amp.

kelunik avatar kelunik commented on May 18, 2024

Actually, we do not guarantee timer and IO watcher order according to

* 3. Execute all due timer, pending signal and actionable stream callbacks, each only once per tick.
. I think we should just remove that test.

from amp.

KorvinSzanto avatar KorvinSzanto commented on May 18, 2024

Well, perhaps we should redo the test in a way that allows for that and makes it clear that that may happen. Let me see if I can come up with anything today and I'll submit a PR.

from amp.

kelunik avatar kelunik commented on May 18, 2024

The test totally needs a redo, it's horrible. Thanks for looking into that. 👍

from amp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.