Git Product home page Git Product logo

Comments (5)

RealyUniqueName avatar RealyUniqueName commented on August 23, 2024

I agree this should work. The issue is not only the Timer implementation but also utest does not take thread safety into account at all.
As a temporary solution you could shadow haxe.Timer module with your own implementation, and maybe it would be enough for your case. But it's also possible you would face random test failures due to races.

from utest.

RealyUniqueName avatar RealyUniqueName commented on August 23, 2024

Another solution is to modify tests like this:

  function testBar(async: utest.Async) {
    var thread = Thread.current();
    veryComplexFunctionToBeTested(() -> {
      thread.events.run(() -> {
        utest.Assert.pass();
        async.done();
      });
    });
  }

from utest.

acarioni avatar acarioni commented on August 23, 2024

Thank you for your comments.
Currently I have resorted to a solution similar to that outlined in your last comment.
Regarding your first comment, how can I shadow a standard library class with my implementation?

from utest.

RealyUniqueName avatar RealyUniqueName commented on August 23, 2024

Just create a class with the same package and name in your project.

from utest.

ravendyne avatar ravendyne commented on August 23, 2024

Maybe not related to this, but also probably is, so I didn't want to open a new issue: async in setupClass blocks even after async.done() has been called, but only if it's been called from a Timer or Thread callback.

For example, running this test:

class TestSmoke extends utest.Test {

    function setupClass( async : utest.Async ) {
        trace('setup');

        sys.thread.Thread.current().events.run(()->{
            async.done();
            trace('delay done');
        });
        // haxe.Timer.delay(()->{
        //     async.done();
        //     trace('delay done');
        // },50);
    }

    function teardownClass() {
        trace('teardown');
    }

    function testSmoke() {
        utest.Assert.fail();
    }
}

will not fail as expected, instead it will just hang forever:

src/test/TestSmoke.hx:12: setup
src/test/TestSmoke.hx:25: teardown
src/test/TestSmoke.hx:16: delay done

Thread.current.events and Timer.delay give the same result (test execution hangs) on macro, neko and hl targets (haven't tried others).

from utest.

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.