1
0
mirror of https://github.com/danog/amp.git synced 2024-12-02 17:37:50 +01:00
Commit Graph

384 Commits

Author SHA1 Message Date
Niklas Keller
5b4d019753 Allow tested calls to Amp\Promise\wait 2020-04-15 22:47:43 +02:00
Niklas Keller
feca077369
Provide useful exception trace in TimeoutCancellationToken (#303)
Without this, the exception trace is pretty useless, because it only includes Loop::run() and other internal loop calls, giving absolutely no indication which kind of thing had a timeout.

Use debug_backtrace instead of creating the exception early, because it helps with the changes to GC behavior such a change might introduce.

Co-authored-by: Aaron Piotrowski <aaron@trowski.com>
2020-04-04 17:05:26 +02:00
Niklas Keller
5a294f1381 Fix TracingDriver, add TracingDriverTest 2019-10-01 21:39:23 +02:00
Niklas Keller
4d849191e5
Fix build on Travis (#281) 2019-09-21 23:17:45 +02:00
Aaron Piotrowski
a726db92a5 Only create deferred for backpressure if necessary 2019-09-21 18:30:14 +02:00
Niklas Keller
558f1e9876 Catch also \Exception in clearLoopRethrows() 2019-05-31 11:38:02 -05:00
Niklas Keller
214443b8c6 Fix code style 2019-05-31 11:38:02 -05:00
Niklas Keller
c12828081f Fix exceptions bubbling from Coroutine::__destruct
This has been an edge case potentially hiding some exceptions. The tests have been refactored to error if the loop has watchers leaking from one test to another test.
2019-05-31 11:38:02 -05:00
Niklas Keller
aeb5de16d9 Add failing Coroutine test 2019-05-31 11:38:02 -05:00
Aaron Piotrowski
ef83723a79
Fix signal handler in NativeDriver when used with pcntl_async_signals
Fixes #264.
2019-02-25 18:05:47 -06:00
Bob Weinand
7075ef7d74 Fix #251 - 100% CPU usage in NativeDriver
Also use better bounds for timer - it must not execute before, but may execute a little later (on my system it were up to 7 ms actually)
2018-12-11 11:31:37 +01:00
Aaron Piotrowski
77a12c823b Add Loop::now() 2018-11-26 21:59:15 +01:00
Sascha-Oliver Prolic
96c2eeaa1f Add Promise\wrap (#234) 2018-11-26 19:36:46 +01:00
Sascha-Oliver Prolic
4a98cc4fde Add timeoutWithDefault function (#245) 2018-11-25 17:56:42 +01:00
Niklas Keller
b73e03bfe2 Rename Iterator\collect to Iterator\toArray 2018-11-25 17:09:50 +01:00
Niklas Keller
a60a8e1906 Add tests for Iterator\collect 2018-11-25 17:09:50 +01:00
Gabriel Caruso
6be5d4bfc5 Use dedicated PHPUnit assertions 2018-11-14 22:14:22 +01:00
Niklas Keller
fa3fe1d20b Apply PSR-2 2018-06-18 20:00:01 +02:00
Aaron Piotrowski
242d78a6ec Fix 212 and ignore unreference on invalid watchers (#216)
Fix #212 & Ignore unreference on invalid watchers
2018-04-12 09:46:52 +02:00
Niklas Keller
98cfaa63ca Remove unused variables 2017-12-05 08:48:56 +01:00
Markus Staab
34bf671f13 Automatically add \ for buitins (#186)
Fixes #185.
2017-11-29 13:36:50 +01:00
Niklas Keller
bd428ca31b Fix DriverTest::testBug163ConsecutiveDelayed to use assigned driver 2017-09-19 19:58:07 +02:00
Niklas Keller
7a04dc5c21 Fix EventDriver warnings and bugs
Fixes #163, #159.
2017-09-17 12:18:04 +02:00
Niklas Keller
36794da8e9 Fix code style 2017-07-09 14:17:47 +02:00
Bob Weinand
5e93318d85 Fix issue with the loop not terminating with only unreferenced watchers 2017-07-09 09:28:32 +02:00
Aaron Piotrowski
5f3e21a4a4 Add TimeoutCancellationToken 2017-06-13 12:41:47 -05:00
Niklas Keller
38ef4d9ffa Fix issues with interval = 0 repeat watchers, fixes #131 2017-05-23 19:46:23 +02:00
Niklas Keller
dbc853c3f1 Fix timers with interval = 0 in NativeDriver 2017-05-22 19:54:14 +02:00
Niklas Keller
e8e26d79e7 Revert "Drop max continuation depth"
This reverts commit cdf28fa938.

As streams always buffer before applying backpressure, these might
result in a stack overflow. Another example is file streaming with
the blocking driver, which always immediately succeeds.
2017-05-20 09:40:56 +02:00
Niklas Keller
a289e7e41d Increase testNestedLoopSignalDispatch timeouts 2017-05-19 16:47:55 +02:00
Niklas Keller
03d1630b69 Add further tests for cancellation 2017-05-16 21:56:52 +02:00
Niklas Keller
fdf18dedd7 Fix tabs → spaces 2017-05-16 20:08:27 +02:00
Aaron Piotrowski
be2a9f8c07 Merge pull request #130 from amphp/cancellation
Implement cancellation primitives, resolves #125
2017-05-16 11:32:42 -05:00
Bob Weinand
6e52f3e211 Fix potential issues when operating on destroyed uv handles in shutdown sequence 2017-05-16 18:17:12 +02:00
Niklas Keller
61a7596106 Implement cancellation primitives, resolves #125 2017-05-14 23:07:49 +02:00
Bob Weinand
f063a8311a Shutup "style" checker.... 2017-05-07 19:14:13 +02:00
Bob Weinand
6c03950abd Do not run uv tests separately in its own process 2017-05-07 19:02:22 +02:00
Bob Weinand
55de30c53d Properly run gc_collect_cycles() between tests
This avoids leaking file descriptors with Uv
2017-05-07 13:09:59 +02:00
Niklas Keller
5c81015ddb Increase repeat watcher to make test failure more unlikely 2017-05-03 22:21:57 +02:00
Niklas Keller
50b37b23ef Add asyncCall 2017-05-03 15:21:49 +02:00
Niklas Keller
def42c496a Fix code style 2017-05-02 22:09:11 +02:00
Niklas Keller
5471b17a67 Fix broken test 2017-05-02 21:57:00 +02:00
Niklas Keller
8d9219bf92 Increase timer delay and defer in testMultipleWatchersOnSameDescriptor 2017-05-02 21:51:52 +02:00
Niklas Keller
e00ab0db75 Wrap execution order test in extra defer
This should mitigate the EventDriverTest occassionally failing.

In case this doesn't help, increase the rep1 repeat timer interval.
2017-05-02 21:42:45 +02:00
Niklas Keller
ad08ffba1d Add missing test case in ProducerTraitTest 2017-05-02 19:13:53 +02:00
Niklas Keller
1419bd6c0c Remove unused imports 2017-05-02 19:04:25 +02:00
Niklas Keller
783fe8c4f4 Add asyncCoroutine and ReactPromise tests 2017-05-02 18:59:52 +02:00
Niklas Keller
141875b133 🔥 Kill pipe and capture
Use Amp\call instead.
2017-05-02 18:32:59 +02:00
Niklas Keller
14cea0cbf0 Added further Internal\Producer tests 2017-05-02 18:10:10 +02:00
Niklas Keller
b5770ba64a Rename missed Pause to Delayed 2017-05-02 07:22:53 +02:00
Aaron Piotrowski
835e617054 More stream → iterator
Hopefully that's all of them…
2017-05-02 07:07:43 +02:00
Aaron Piotrowski
da9b724f5b getIterator → iterate 2017-05-02 07:07:43 +02:00
Aaron Piotrowski
91c8da9fec Replace more occurrences of stream 2017-05-02 07:07:43 +02:00
Aaron Piotrowski
8ccb0643c1 Fail tests if exception is not thrown from advance() 2017-05-02 07:07:43 +02:00
Aaron Piotrowski
9a2a4966c6 Fix code style issues 2017-05-02 07:07:20 +02:00
Aaron Piotrowski
38d53304ae Stream → Iterator 2017-05-02 07:07:20 +02:00
Aaron Piotrowski
4992d3ebac Update stream tests 2017-05-02 07:06:20 +02:00
Niklas Keller
1286087c06 Rename Pause to Delayed
Pause doesn't cover the delayed value use case.
2017-05-02 07:02:02 +02:00
Niklas Keller
17224616aa Add more grace periods for timing dependent tests 2017-04-26 21:37:09 +02:00
Niklas Keller
37026dbaae Put memory leak tests into a group to enable skipping
Also fixes the missing directory on Travis.
2017-04-26 20:27:59 +02:00
Niklas Keller
136ccc7dad Run UV tests in a separate PHP instance 2017-04-26 20:20:08 +02:00
Aaron Piotrowski
8ca8009074 Remove note about yielding in finally
Yielding in finally will work as long as the generator is not force closed (for example, a yielded promise is never resolved and the coroutine object is subsequently destroyed).
2017-04-25 14:29:10 -05:00
Aaron Piotrowski
e1491b1925 Handle invalid yield like a failed promise 2017-04-24 13:08:30 -05:00
Aaron Piotrowski
34192ceca5 Drop Coroutine::dispose() 2017-04-24 11:10:05 -05:00
Niklas Keller
c3fc6659cd Revert to assertEquals where order might be different, remove strict rule 2017-04-24 16:28:56 +02:00
Niklas Keller
79ab41e5bf Update php-cs-fixer to version 2 and upgrade rules
This also fixes the code style according to the new rules.
2017-04-24 16:22:02 +02:00
Niklas Keller
0e376fbed9 Increase variation grace period in tests 2017-04-24 15:27:04 +02:00
Niklas Keller
e9d48a68d5 Rename createRunnable to asyncCoroutine and createCallable to coroutine 2017-04-24 15:27:04 +02:00
Niklas Keller
05670678e1 Fix tests regarding UnionTypeError 2017-04-24 15:27:04 +02:00
Niklas Keller
70e63a3748 Fix code style according to new rules 2017-04-24 15:27:04 +02:00
Niklas Keller
dfa40f5b00 Rename wrap to createRunnable and coroutine to createCallable 2017-04-24 15:27:04 +02:00
Niklas Keller
4577f92625 Remove unnecessary usages of Amp\wrap 2017-04-24 15:27:04 +02:00
Aaron Piotrowski
e75c62a5fd Do not depend on watcher execution order
Loop driver spec says order is not guaranteed.
2017-04-21 12:18:40 -05:00
Aaron Piotrowski
6375d0881d Use same FD for read and write 2017-04-21 10:08:58 -05:00
Aaron Piotrowski
ef51893b69 Test multiple watchers on same FD 2017-04-21 10:02:10 -05:00
Aaron Piotrowski
76e0913d9b Fix timer test comment
The concept of time continues to elude me…
2017-04-20 10:00:57 -05:00
Aaron Piotrowski
4792bf52fe Emulate "now" behavior of libuv/libev in NativeDriver and EventDriver
Timers created while not running when using NativeDriver and EventDriver will include the elapsed time before run() is called. This matches the behavior of EvDriver and UvDriver. Addresses #113.
2017-04-19 17:21:23 -05:00
Bob Weinand
61b88a780e Merge remote-tracking branch 'origin/kelunik-v2-review' 2017-04-15 00:42:07 +02:00
Aaron Piotrowski
38a6066e53 Remove Message 2017-04-14 09:23:47 -05:00
Niklas Keller
5e545301cd Rename Listener to StreamIterator 2017-04-13 18:20:46 +02:00
Niklas Keller
3e8b37f21f Remove Amp\Stream\interval and add delay option to fromIterable 2017-04-13 18:05:41 +02:00
Aaron Piotrowski
cdf28fa938 Drop max continuation depth
It seems unlikely a real-world application would run out of memory due to call stack depth for normal coroutine continuations (that is, where infinite recursion is not root problem). Hopefully time will not prove me wrong…
2017-03-30 23:45:54 -05:00
Aaron Piotrowski
2f7e9a0746 Run returned generator as coroutine from onResolve and onEmit callbacks 2017-03-27 18:37:55 -05:00
Aaron Piotrowski
173549ebba Halt recursive runs with each call to stop, addresses #84 2017-03-27 11:42:51 -05:00
Aaron Piotrowski
cb717952f1 Validate number of required promises 2017-03-27 11:42:11 -05:00
Aaron Piotrowski
67f9f4a569 Drop lift and Promise\map; add required param to Promise\some 2017-03-26 12:34:34 -05:00
Niklas Keller
995f6f1f6c Disable coverage by default, increase timeout for signal test 2017-03-25 21:47:30 +01:00
Niklas Keller
c838a0ae8f Only cache dist files on Travis and use --prefer-dist 2017-03-25 21:40:22 +01:00
Niklas Keller
ff5fef4b93 Fix UV executing multiple IO watchers in different ticks, fixes #85 2017-03-25 19:52:17 +01:00
Niklas Keller
2aa91a6c25 Rename Stream::listen to Stream::onEmit 2017-03-21 18:29:51 +01:00
Niklas Keller
ce269fa516 Rename Promise::when to Promise::onResolve, resolves #77 2017-03-21 17:23:37 +01:00
Aaron Piotrowski
a927b3cb06 Separate functions into Promise and Stream namespaces 2017-03-15 19:02:04 -05:00
Niklas Keller
ea67e113b2 Add test for loop accessor 2017-03-15 08:40:58 +01:00
Niklas Keller
5663f3a94e Add test for isSupported 2017-03-15 08:32:05 +01:00
Niklas Keller
c711c1c2d2 Remove test debugging leftovers 2017-03-15 07:34:25 +01:00
Niklas Keller
d61709db45 Re-enable generator test and fix it 2017-03-15 07:32:43 +01:00
Niklas Keller
5b52b94fe0 Test that loop drivers rethrow and run generators as coroutines 2017-03-15 00:34:37 +01:00
Aaron Piotrowski
a566ff0c99 Fix signal tests 2017-03-14 16:47:54 -05:00
Niklas Keller
45ea818883 Test Amp\capture for non-promise 2017-03-14 22:36:24 +01:00
Niklas Keller
dfab1d885f Add missing coroutine tests 2017-03-14 22:32:14 +01:00
Niklas Keller
179eb3d6f8 Add 1ms grace period for timing tests 2017-03-14 22:18:47 +01:00
Niklas Keller
d8f3810310 Add more tests for functions.php 2017-03-14 22:15:36 +01:00
Niklas Keller
4442f6cd33 Add test for Producer being already resolved 2017-03-14 22:05:45 +01:00
Aaron Piotrowski
6b9ec609c1 Add UnionTypeError 2017-03-14 13:15:31 -05:00
Niklas Keller
c13e8e3a66 Use Error instead of InvalidArgumentException, remove test file 2017-03-14 18:44:44 +01:00
Aaron Piotrowski
5bdfccde97 Update DriverTest 2017-03-14 11:50:24 -05:00
Aaron Piotrowski
fd7587b0fd Fix risky tests
Fixes #81.
2017-03-13 18:54:08 -05:00
Niklas Keller
20acaf123e Remove unsused code from InvalidWatcherException, add handle tests for drivers 2017-03-13 13:56:46 +01:00
Aaron Piotrowski
f187d4b31a Accept React promises in rethrow, wait, timeout, pipe, and capture
Fixes #75.
2017-03-13 07:17:06 +01:00
Aaron Piotrowski
8b7fb9ece3 Merge pull request #72 from amphp/issue-68
Implement yielding arrays as implicit all operator
2017-03-12 22:45:31 -05:00
Niklas Keller
77bd05b807 Fix tests and Producer React adaption 2017-03-12 22:09:19 +01:00
Niklas Keller
8f903b62db Add more tests for React promise adaption in various places 2017-03-12 21:02:26 +01:00
Niklas Keller
e8ea4e2ba9 Implement yielding arrays as implicit all operator, fixes #68 2017-03-12 19:42:25 +01:00
Aaron Piotrowski
cd4328ab48 Merge branch 'react-compatibility' 2017-03-12 11:38:48 -05:00
Pieter Hordijk
2db7bed1b6 Fixed typos an promise -> a promise 2017-03-12 17:36:07 +01:00
Niklas Keller
d748855a51 Fix some risky tests 2017-03-12 17:33:46 +01:00
Niklas Keller
766b3224d1 Rename drivers to have a Driver instead of Loop suffix 2017-03-12 11:21:44 +01:00
Aaron Piotrowski
7ad10f5d7d Add support for React promises 2017-03-11 09:17:43 -06:00
Niklas Keller
fe88413a17 Upgrade to PHPUnit 6
This commit removes Humbug, as it's no longer maintained and not
compatible with PHPUnit 6.
2017-03-11 14:57:03 +01:00
Niklas Keller
61d7f1b8d7 Remove remaining group use statements 2017-03-11 14:43:57 +01:00
Aaron Piotrowski
d505a13e18 Update promise test 2017-03-10 23:40:30 -06:00
Niklas Keller
be34c49a2d Fixup all remaining issues, tests pass locally 2017-03-10 22:20:28 +01:00
Niklas Keller
4f021220a2 Merge async-interop/promise-test into amphp/amp 2017-03-10 22:07:26 +01:00
Niklas Keller
0be9ae9ade Switch from AsyncInterop\Promise to Amp\Promise 2017-03-10 21:58:46 +01:00
Niklas Keller
e64bbfb9f5 Add Loop::set, auto-wrapping, fixup things 2017-03-10 21:31:57 +01:00
Niklas Keller
f4f9008ca0 Merge amphp/amp repository into amphp/amp 2017-03-10 18:26:17 +01:00
Niklas Keller
942cf801bd Merge async-interop/event-loop repository into amphp/amp 2017-03-10 18:07:13 +01:00
Aaron Piotrowski
72378e2b82 Add Amp\call() 2017-02-22 15:52:30 -06:00
Aaron Piotrowski
1369f5fd47 Assert callback count 2017-02-10 09:41:43 -06:00
Aaron Piotrowski
b72e504eab Ensure correct argument order in multi-argument lift 2017-02-09 22:34:24 -06:00
Aaron Piotrowski
5dade2443f Fix error in Message with empty stream 2017-01-31 17:30:05 -06:00
Aaron Piotrowski
5f284b2f70 Refactor Message, add Iterator 2017-01-31 17:09:38 -06:00
Aaron Piotrowski
0631560c65 Merge pull request #62 from amphp/drop-choose
Drop Amp\choose
2017-01-15 08:49:11 -06:00
Aaron Piotrowski
84917e7786 Add Message and Listener::getBuffered() 2017-01-13 18:46:32 -06:00
Aaron Piotrowski
df901a0305 Remove stream() method from Listener 2017-01-13 18:12:38 -06:00
Niklas Keller
36df722e95 Remove ChooseTest 2017-01-13 20:09:46 +01:00
Aaron Piotrowski
a643f9a260 Remove last consumed value from listener before drain 2017-01-11 20:13:12 -06:00
Niklas Keller
5a92c31197 Fix bootstrap test and execute it 2017-01-08 17:24:25 +01:00
Niklas Keller
30a6ac24ed Test bootstrap file 2017-01-08 17:12:04 +01:00
Aaron Piotrowski
4c48037295 Add reference/unreference methods to Pause 2017-01-08 01:15:57 -06:00
Aaron Piotrowski
ae28eae552 Lazy → LazyPromise 2017-01-08 01:02:11 -06:00
Aaron Piotrowski
0a79a063a6 Drop redundant tests
Covered by testInvalidYieldCatchingThrownException and testInvalidYieldCatchingThrownExceptionAndThrowing.
2017-01-08 00:34:41 -06:00
Aaron Piotrowski
5ad1fdb38b Add more Listener tests and kill another Humbug mutant 2017-01-08 00:22:07 -06:00
Niklas Keller
3b46c168a5 Improve tests and kill some Humbug mutants 2017-01-07 22:55:34 +01:00
Aaron Piotrowski
2976ebdbb5 Throw on consecutive calls to Listener::advance(); better property names 2017-01-07 12:31:36 -06:00
Aaron Piotrowski
cf5ebb1408 Better error message when emitting after resolve 2017-01-07 12:25:04 -06:00
Niklas Keller
bc110c4d63 Add test for callback combination in WhenQueue 2017-01-07 14:24:21 +01:00
Niklas Keller
ae69e92266 Update to promise 0.4.0 and event-loop 0.5.0, add humbug config 2017-01-07 13:47:45 +01:00
Niklas Keller
568183b261 Update to event-loop 0.5.0 2017-01-07 13:45:03 +01:00
Niklas Keller
559c64fdb8 Add test for invalid stream arguments 2017-01-06 23:16:06 +01:00