forked from AlDanial/cloc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
regression test for github issue AlDanial#82
- Loading branch information
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env perl | ||
use warnings; | ||
use strict; | ||
use Test::More; | ||
my @Tests = ( { | ||
'name' => 'exclude dir 1 (github issue #82)', | ||
'args' => '--exclude-dir cc ../tests/inputs/dd', | ||
'ref' => '../tests/outputs/exclude_dir_1.yaml', | ||
}, | ||
|
||
); | ||
|
||
my $Verbose = 0; | ||
|
||
my $results = 'results.yaml'; | ||
my $Run = "../cloc --quiet --yaml --out $results "; | ||
foreach my $t (@Tests) { | ||
print $Run . $t->{'args'} if $Verbose; | ||
system($Run . $t->{'args'}); | ||
ok(-e $results, $t->{'name'} . " created output"); | ||
my %ref = load_yaml($t->{'ref'}); | ||
my %this = load_yaml($results); | ||
is_deeply(\%ref, \%this, $t->{'name'} . " results match"); | ||
} | ||
done_testing(); | ||
|
||
sub load_yaml { | ||
my ($file, ) = @_; | ||
my %result = (); | ||
if (!-r $file) { | ||
warn "File not found: $file\n"; | ||
return %result; | ||
} | ||
open IN, $file or return %result; | ||
my $section = undef; | ||
while (<IN>) { | ||
next if /^\s*#/ or /^--/; | ||
if (/^(\w+)\s*:\s*$/) { | ||
$section = $1; | ||
next; | ||
} | ||
next unless defined $section; | ||
next if $section eq 'header'; | ||
chomp; | ||
s/\s+//g; | ||
my ($K, $V) = split(':'); | ||
$result{$section}{$K} = $V; | ||
} | ||
close IN; | ||
return %result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
# github.com/AlDanial/cloc | ||
header : | ||
cloc_url : github.com/AlDanial/cloc | ||
cloc_version : 1.67 | ||
elapsed_seconds : 0.0140111446380615 | ||
n_files : 2 | ||
n_lines : 374 | ||
files_per_second : 142.743512515527 | ||
lines_per_second : 26693.0368404036 | ||
report_file : ../tests/outputs/exclude_dir_1.yaml | ||
C++ : | ||
nFiles: 1 | ||
blank: 49 | ||
comment: 55 | ||
code: 182 | ||
C : | ||
nFiles: 1 | ||
blank: 22 | ||
comment: 22 | ||
code: 44 | ||
SUM: | ||
blank: 71 | ||
comment: 77 | ||
code: 226 | ||
nFiles: 2 |