Changeset View
Changeset View
Standalone View
Standalone View
src/future/exec/__tests__/ExecFutureTestCase.php
| Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | public function testBufferLimit() { | ||||
| $this->assertEqual(substr($data, 0, 1024), $stdout); | $this->assertEqual(substr($data, 0, 1024), $stdout); | ||||
| } | } | ||||
| public function testResolveTimeoutTestShouldRunLessThan1Sec() { | public function testResolveTimeoutTestShouldRunLessThan1Sec() { | ||||
| // NOTE: This tests interactions between the resolve() timeout and the | // NOTE: This tests interactions between the resolve() timeout and the | ||||
| // resolution timeout, which are somewhat similar but not identical. | // resolution timeout, which are somewhat similar but not identical. | ||||
| $future = $this->newSleep(32000)->start(); | $future = $this->newSleep(32000); | ||||
| $future->setTimeout(32000); | $future->setTimeout(32000); | ||||
| // We expect this to return in 0.01s. | // We expect this to return in 0.01s. | ||||
| $iterator = (new FutureIterator(array($future))) | $iterator = (new FutureIterator(array($future))) | ||||
| ->setUpdateInterval(0.01); | ->setUpdateInterval(0.01); | ||||
| foreach ($iterator as $resolved_result) { | foreach ($iterator as $resolved_result) { | ||||
| $result = $resolved_result; | $result = $resolved_result; | ||||
| break; | break; | ||||
| } | } | ||||
| $this->assertEqual($result, null); | $this->assertEqual($result, null); | ||||
| // We expect this to now force the time out / kill immediately. If we don't | // We expect this to now force the time out / kill immediately. If we don't | ||||
| // do this, we'll hang when exiting until our subprocess exits (32000 | // do this, we'll hang when exiting until our subprocess exits (32000 | ||||
| // seconds!) | // seconds!) | ||||
| $future->setTimeout(0.01); | $future->setTimeout(0.01); | ||||
| $future->resolve(); | $iterator->resolveAll(); | ||||
| } | } | ||||
| public function testTerminateWithoutStart() { | public function testTerminateWithoutStart() { | ||||
| // We never start this future, but it should be fine to kill a future from | // We never start this future, but it should be fine to kill a future from | ||||
| // any state. | // any state. | ||||
| $future = $this->newSleep(1); | $future = $this->newSleep(1); | ||||
| $future->resolveKill(); | $future->resolveKill(); | ||||
| ▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines | |||||