Changeset View
Changeset View
Standalone View
Standalone View
src/parser/__tests__/ArcanistBundleTestCase.php
<?php | <?php | ||||
final class ArcanistBundleTestCase extends PhutilTestCase { | final class ArcanistBundleTestCase extends PhutilTestCase { | ||||
private function loadResource($name) { | private function loadResource($name) { | ||||
return Filesystem::readFile($this->getResourcePath($name)); | return Filesystem::readFile($this->getResourcePath($name)); | ||||
} | } | ||||
private function getResourcePath($name) { | private function getResourcePath($name) { | ||||
return dirname(__FILE__).'/bundle/'.$name; | return __DIR__.'/bundle/'.$name; | ||||
} | } | ||||
private function loadDiff($old, $new) { | private function loadDiff($old, $new) { | ||||
list($err, $stdout) = exec_manual( | list($err, $stdout) = exec_manual( | ||||
'diff --unified=65535 --label %s --label %s -- %s %s', | 'diff --unified=65535 --label %s --label %s -- %s %s', | ||||
'file 9999-99-99', | 'file 9999-99-99', | ||||
'file 9999-99-99', | 'file 9999-99-99', | ||||
$this->getResourcePath($old), | $this->getResourcePath($old), | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | EODIFF; | ||||
* "arc patch", verifying that the resulting tree hash is identical to the | * "arc patch", verifying that the resulting tree hash is identical to the | ||||
* tree hash produced by the real commit. | * tree hash produced by the real commit. | ||||
*/ | */ | ||||
public function testGitRepository() { | public function testGitRepository() { | ||||
if (phutil_is_windows()) { | if (phutil_is_windows()) { | ||||
$this->assertSkipped(pht('This test is not supported under Windows.')); | $this->assertSkipped(pht('This test is not supported under Windows.')); | ||||
} | } | ||||
$archive = dirname(__FILE__).'/bundle.git.tgz'; | $archive = __DIR__.'/bundle.git.tgz'; | ||||
$fixture = PhutilDirectoryFixture::newFromArchive($archive); | $fixture = PhutilDirectoryFixture::newFromArchive($archive); | ||||
$old_dir = getcwd(); | $old_dir = getcwd(); | ||||
chdir($fixture->getPath()); | chdir($fixture->getPath()); | ||||
$caught = null; | $caught = null; | ||||
try { | try { | ||||
$this->runGitRepositoryTests($fixture); | $this->runGitRepositoryTests($fixture); | ||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
$caught = $ex; | $caught = $ex; | ||||
} | } | ||||
chdir($old_dir); | chdir($old_dir); | ||||
if ($caught) { | if ($caught) { | ||||
throw $ex; | throw $ex; | ||||
} | } | ||||
} | } | ||||
private function runGitRepositoryTests(PhutilDirectoryFixture $fixture) { | private function runGitRepositoryTests(PhutilDirectoryFixture $fixture) { | ||||
$patches = dirname(__FILE__).'/patches/'; | $patches = __DIR__.'/patches/'; | ||||
list($commits) = execx( | list($commits) = execx( | ||||
'git log --format=%s', | 'git log --format=%s', | ||||
'%H %T %s'); | '%H %T %s'); | ||||
$commits = explode("\n", trim($commits)); | $commits = explode("\n", trim($commits)); | ||||
// The very first commit doesn't have a meaningful parent, so don't examine | // The very first commit doesn't have a meaningful parent, so don't examine | ||||
// it. | // it. | ||||
▲ Show 20 Lines • Show All 568 Lines • ▼ Show 20 Lines | public function testEncodeBase85() { | ||||
$data = ''; | $data = ''; | ||||
for ($ii = 0; $ii <= 255; $ii++) { | for ($ii = 0; $ii <= 255; $ii++) { | ||||
$data .= chr($ii); | $data .= chr($ii); | ||||
} | } | ||||
for ($ii = 255; $ii >= 0; $ii--) { | for ($ii = 255; $ii >= 0; $ii--) { | ||||
$data .= chr($ii); | $data .= chr($ii); | ||||
} | } | ||||
$expect = Filesystem::readFile(dirname(__FILE__).'/base85/expect1.txt'); | $expect = Filesystem::readFile(__DIR__.'/base85/expect1.txt'); | ||||
$this->assertBase85($expect, $data, pht('Byte Sequences')); | $this->assertBase85($expect, $data, pht('Byte Sequences')); | ||||
// This is just a large block of random binary data, it has no special | // This is just a large block of random binary data, it has no special | ||||
// significance. | // significance. | ||||
$data = | $data = | ||||
"\x56\x4c\xb3\x63\xe5\x4a\x9f\x03\xa3\x4c\xdd\x5d\x85\x86\x10". | "\x56\x4c\xb3\x63\xe5\x4a\x9f\x03\xa3\x4c\xdd\x5d\x85\x86\x10". | ||||
"\x30\x3f\xc1\x28\x51\xd8\xb2\x1a\xc3\x79\x15\x85\x31\x66\xf9". | "\x30\x3f\xc1\x28\x51\xd8\xb2\x1a\xc3\x79\x15\x85\x31\x66\xf9". | ||||
▲ Show 20 Lines • Show All 264 Lines • ▼ Show 20 Lines | $data = | ||||
"\xb7\x8f\x12\xb0\x99\xbc\x93\x20\xb8\x95\x8d\xca\xc7\xa7\xd9". | "\xb7\x8f\x12\xb0\x99\xbc\x93\x20\xb8\x95\x8d\xca\xc7\xa7\xd9". | ||||
"\x2e\x19\xac\x06\xb9\x4e\x56\x8e\x74\xef\x2a\x04\xd8\x75\x04". | "\x2e\x19\xac\x06\xb9\x4e\x56\x8e\x74\xef\x2a\x04\xd8\x75\x04". | ||||
"\x38\x2a\xc7\xa0\xa4\x89\xf3\xa4\x8a\xd4\x2c\x2c\x58\x6f\x00". | "\x38\x2a\xc7\xa0\xa4\x89\xf3\xa4\x8a\xd4\x2c\x2c\x58\x6f\x00". | ||||
"\x03\x23\xb8\xaf\x02\x48\x7d\x50\x46\x6f\x5a\x08\x41\xe3\x56". | "\x03\x23\xb8\xaf\x02\x48\x7d\x50\x46\x6f\x5a\x08\x41\xe3\x56". | ||||
"\x6d\xcb\xe2\x4f\xea\x8e\xab\x74\xcd\xf9\xef\xcf\xf9\x1e\xf1". | "\x6d\xcb\xe2\x4f\xea\x8e\xab\x74\xcd\xf9\xef\xcf\xf9\x1e\xf1". | ||||
"\xf8\xb9\x6c\xaa\x3b\x37\xd1\x21\x42\x67\xec\xd6\x44\x55\x33". | "\xf8\xb9\x6c\xaa\x3b\x37\xd1\x21\x42\x67\xec\xd6\x44\x55\x33". | ||||
"\xe8\x1d\xa4\x18\xf3\x73\x82\xb4\x50\x59\xc2\x34\x36\x05\xeb"; | "\xe8\x1d\xa4\x18\xf3\x73\x82\xb4\x50\x59\xc2\x34\x36\x05\xeb"; | ||||
$expect = Filesystem::readFile(dirname(__FILE__).'/base85/expect2.txt'); | $expect = Filesystem::readFile(__DIR__.'/base85/expect2.txt'); | ||||
$this->assertBase85($expect, $data, pht('Random Data')); | $this->assertBase85($expect, $data, pht('Random Data')); | ||||
} | } | ||||
private function assertBase85($expect, $data, $label) { | private function assertBase85($expect, $data, $label) { | ||||
$modes = array( | $modes = array( | ||||
'32bit', | '32bit', | ||||
); | ); | ||||
Show All 16 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0