Changeset View
Changeset View
Standalone View
Standalone View
src/future/exec/__tests__/ExecFutureTestCase.php
| Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | list($stdout) = $this->newCat() | ||||
| ->write($data) | ->write($data) | ||||
| ->resolvex(); | ->resolvex(); | ||||
| $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 | ||||
| // ExecFuture timeout, which are similar but not identical. | // resolution timeout, which are somewhat similar but not identical. | ||||
| $future = $this->newSleep(32000)->start(); | $future = $this->newSleep(32000)->start(); | ||||
| $future->setTimeout(32000); | $future->setTimeout(32000); | ||||
| // We expect this to return in 0.01s. | // We expect this to return in 0.01s. | ||||
| $result = $future->resolve(0.01); | $iterator = (new FutureIterator(array($future))) | ||||
| ->setUpdateInterval(0.01); | |||||
| foreach ($iterator as $resolved_result) { | |||||
| $result = $resolved_result; | |||||
| 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(); | $future->resolve(); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||