detectCopiesIn('lint_engine.diff'); $this->assertEqual( array_combine(range(237, 252), range(167, 182)), ipull($copies, 1)); } public function testDetectCopiedOverlaidCode() { $copies = $this->detectCopiesIn('copy_overlay.diff'); $this->assertEqual( array( 7 => 22, 8 => 23, 9 => 24, 10 => 25, 11 => 26, 12 => 27, ), ipull($copies, 1)); } private function detectCopiesIn($file) { $root = dirname(__FILE__).'/diff/'; $parser = new ArcanistDiffParser(); $diff = DifferentialDiff::newFromRawChanges( PhabricatorUser::getOmnipotentUser(), $parser->parseDiff(Filesystem::readFile($root.$file))); return idx(head($diff->getChangesets())->getMetadata(), 'copy:lines'); } public function testDetectSlowCopiedCode() { // This tests that the detector has a reasonable runtime when a diff // contains a very large number of identical lines. See T5041. $parser = new ArcanistDiffParser(); $line = str_repeat('x', 60); $oline = '-'.$line."\n"; $nline = '+'.$line."\n"; $n = 1000; $oblock = str_repeat($oline, $n); $nblock = str_repeat($nline, $n); $raw_diff = <<parseDiff($raw_diff)); $this->assertTrue(true); } }