Changeset View
Changeset View
Standalone View
Standalone View
src/filesystem/__tests__/PhutilDeferredLogTestCase.php
| Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | try { | ||||
| new PhutilDeferredLog('/derp/derp/derp/derp/derp', 'derp'); | new PhutilDeferredLog('/derp/derp/derp/derp/derp', 'derp'); | ||||
| } | } | ||||
| } catch (Exception $ex) { | } catch (Exception $ex) { | ||||
| $caught = $ex; | $caught = $ex; | ||||
| } | } | ||||
| $this->assertTrue($caught instanceof Exception); | $this->assertTrue($caught instanceof Exception); | ||||
| } | } | ||||
| public function testManyWriters() { | |||||
| $root = phutil_get_library_root('arcanist').'/../'; | |||||
| $bin = $root.'scripts/test/deferred_log.php'; | |||||
| $n_writers = 3; | |||||
| $n_lines = 8; | |||||
| $tmp = new TempFile(); | |||||
| $futures = array(); | |||||
| for ($ii = 0; $ii < $n_writers; $ii++) { | |||||
| $futures[] = new ExecFuture('%s %d %s', $bin, $n_lines, (string)$tmp); | |||||
| } | |||||
| id(new FutureIterator($futures)) | |||||
| ->resolveAll(); | |||||
| $this->assertEqual( | |||||
| str_repeat("abcdefghijklmnopqrstuvwxyz\n", $n_writers * $n_lines), | |||||
| Filesystem::readFile($tmp)); | |||||
| } | |||||
| public function testNoWrite() { | public function testNoWrite() { | ||||
| $tmp = new TempFile(); | $tmp = new TempFile(); | ||||
| $log = new PhutilDeferredLog($tmp, 'xyz'); | $log = new PhutilDeferredLog($tmp, 'xyz'); | ||||
| $log->setFile(null); | $log->setFile(null); | ||||
| unset($log); | unset($log); | ||||
| $this->assertEqual('', Filesystem::readFile($tmp), pht('No Write')); | $this->assertEqual('', Filesystem::readFile($tmp), pht('No Write')); | ||||
| ▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines | |||||