App-ccdiff
view release on metacpan or search on metacpan
t/01-no-color.t view on Meta::CPAN
#!/usr/bin/env perl
use 5.014000;
use warnings;
use Test::More;
use Capture::Tiny "capture";
binmode STDOUT, ":encoding(utf-8)";
binmode STDERR, ":encoding(utf-8)";
binmode DATA, ":encoding(utf-8)";
# localtime will differ on other machines
my %stamp = map { s{^Files/}{}r => "$_ ".localtime ((stat)[9]) } glob "Files/*";
local $/ = "** EOT **\n";
while (<DATA>) {
chomp;
my ($dsc, $f1, $f2, $opt, $exp) = split m/\n/, $_, 5;
$exp =~ s/STAMP:1/$stamp{$f1}/g;
$exp =~ s/STAMP:2/$stamp{$f2}/g;
#diag "Description: $dsc";
#diag "Options: $opt";
my @cmd = ($^X, "ccdiff", "--utf-8", "--no-color", "Files/$f1", "Files/$f2");
$opt and push @cmd, split m/ / => $opt;
#diag "@cmd";
my ($out, $err, $exit) = capture { system @cmd; };
is ($out, $exp, $dsc);
is ($err, "", "No error");
is ($exit, 0, "Success");
}
done_testing;
__END__
No options
01_1.txt
01_2.txt
< STAMP:1
> STAMP:2
3,3c3,3
< usu. Ad duo posse theophrastus, vim in accumsan
---
> usu. Ad duo posse theophrastus. Vim in accumsan
** EOT **
Unified with header
01_1.txt
01_2.txt
-u0
--- STAMP:1
+++ STAMP:2
3,3c3,3
-usu. Ad duo posse theophrastus, vim in accumsan
+usu. Ad duo posse theophrastus. Vim in accumsan
** EOT **
No header
01_1.txt
01_2.txt
--no-header
3,3c3,3
< usu. Ad duo posse theophrastus, vim in accumsan
---
> usu. Ad duo posse theophrastus. Vim in accumsan
** EOT **
Unified with header
01_1.txt
01_2.txt
-u0
--- STAMP:1
+++ STAMP:2
3,3c3,3
-usu. Ad duo posse theophrastus, vim in accumsan
+usu. Ad duo posse theophrastus. Vim in accumsan
** EOT **
Unified without header
01_1.txt
01_2.txt
-u0 --no-header
3,3c3,3
-usu. Ad duo posse theophrastus, vim in accumsan
+usu. Ad duo posse theophrastus. Vim in accumsan
** EOT **
Unified with ascii markers
01_1.txt
( run in 1.921 second using v1.01-cache-2.11-cpan-39bf76dae61 )