[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class DifferentialDiffTestCase extends ArcanistPhutilTestCase { 4 5 public function testDetectCopiedCode() { 6 $root = dirname(__FILE__).'/diff/'; 7 $parser = new ArcanistDiffParser(); 8 9 $diff = DifferentialDiff::newFromRawChanges( 10 PhabricatorUser::getOmnipotentUser(), 11 $parser->parseDiff(Filesystem::readFile($root.'lint_engine.diff'))); 12 $copies = idx(head($diff->getChangesets())->getMetadata(), 'copy:lines'); 13 14 $this->assertEqual( 15 array_combine(range(237, 252), range(167, 182)), 16 ipull($copies, 1)); 17 } 18 19 public function testDetectSlowCopiedCode() { 20 // This tests that the detector has a reasonable runtime when a diff 21 // contains a very large number of identical lines. See T5041. 22 23 $parser = new ArcanistDiffParser(); 24 25 $line = str_repeat('x', 60); 26 $oline = '-'.$line."\n"; 27 $nline = '+'.$line."\n"; 28 29 $n = 1000; 30 $oblock = str_repeat($oline, $n); 31 $nblock = str_repeat($nline, $n); 32 33 $raw_diff = <<<EODIFF 34 diff --git a/dst b/dst 35 new file mode 100644 36 index 0000000..1234567 37 --- /dev/null 38 +++ b/dst 39 @@ -0,0 +1,{$n} @@ 40 {$nblock} 41 diff --git a/src b/src 42 deleted file mode 100644 43 index 123457..0000000 44 --- a/src 45 +++ /dev/null 46 @@ -1,{$n} +0,0 @@ 47 {$oblock} 48 EODIFF; 49 50 $diff = DifferentialDiff::newFromRawChanges( 51 PhabricatorUser::getOmnipotentUser(), 52 $parser->parseDiff($raw_diff)); 53 54 $this->assertTrue(true); 55 } 56 57 58 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |