Skip to content

Commit

Permalink
Use userspace differ
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Christiansen committed Jul 31, 2015
1 parent d6ee9bf commit bd48763
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"symfony/console": "^2.7",
"psr/log": "^1.0",
"sebastian/version": "^1.0",
"phpunit/php-timer": "^1.0"
"phpunit/php-timer": "^1.0",
"sebastian/diff": "^1.3"
},
"require-dev": {
"phpunit/phpunit": "^4.7"
Expand Down
11 changes: 4 additions & 7 deletions src/DBDiffer/CLI/DBDCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\ProgressBar;
use SebastianBergmann\Diff\Differ;

class DBDCommand extends Command
{
Expand Down Expand Up @@ -46,6 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$remoteDbTableFetcher = new \jach\DBDiffer\SQLTableFetcher\DatabaseSQLTableFetcher($dbRemote);

$sqlDiffer = new \jach\DBDiffer\SQLDiffer();
$differ = new Differ("--- File\n+++ Database\n", false);

$errors = [];
foreach ($dir as $fileinfo) {
Expand Down Expand Up @@ -89,15 +91,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
$res1 = trim($res1);
$res2 = trim($res2);

$sqlDiff = $differ->diff($res1, $res2);
if (!$sqlDiffer->diff($res1, $res2)) {
$errors[] = "{$tableName} is not equal";
$tmpName1 = tempnam("/tmp", "FOO");
$tmpName2 = tempnam("/tmp", "FOO");
file_put_contents($tmpName1, $res1);
file_put_contents($tmpName2, $res2);
$errors[] = shell_exec("diff -u {$tmpName1} {$tmpName2}");
unlink($tmpName1);
unlink($tmpName2);
$errors[] = $sqlDiff;
}
$progress->advance();
}
Expand Down

0 comments on commit bd48763

Please sign in to comment.