Comments (5)
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.
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.
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.
Just create a class with the same package and name in your project.
from utest.
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)
- Null safety
- Class name pattern
- Multiple async calls HOT 4
- Simple way to print out running tests
- Assert.sameAs failure
- Release a new version for Haxe 4.1.0 HOT 2
- UTest.run(cases, callback): callback not called
- Attempt to call a nil value error on Lua HOT 3
- Assert is not compatible with null safety
- Haxe < 4.1 compatibility HOT 2
- Make Sys.exit() after completion optional HOT 3
- Add method Assert.raisesMessage HOT 1
- 4.2 issue? Unmatched patterns: OpSpread HOT 2
- Deprecated Assert.is method in the documentation HOT 2
- Haxe 4.2.3: Doesnt work HOT 4
- php target is broken HOT 1
- async setupClass hangs (never displays results)
- Feature request: parametrizing tests HOT 2
- Partial object matching
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from utest.