@@ -3479,7 +3479,7 @@ sub new
3479
3479
{
3480
3480
my $class = shift ;
3481
3481
my $self = [{}, # linemap
3482
- {}, # filemap
3482
+ {}, # filemap: new_filename->old_filename
3483
3483
{}, # baseline: filename -> baseline lineno -> text
3484
3484
undef , # diff filename
3485
3485
[{}, {}], # def location
@@ -3497,10 +3497,11 @@ sub load
3497
3497
my ($self , $path , $info , $buildDirs ) = @_ ;
3498
3498
$self -> _read_udiff($path );
3499
3499
3500
+ # find list of soft links in [buildDirs] which may point to files in $info
3501
+ # we need to keep all the aliases as there may be files in baseline
3502
+ # which are not in current
3500
3503
if (@$buildDirs ) {
3501
- # find list of soft links in [buildDirs] which point to files in $info
3502
3504
my @stack = @$buildDirs ;
3503
- my %alias ;
3504
3505
while (@stack ) {
3505
3506
my $dir = pop (@stack );
3506
3507
die (" unexpected non-directory '$dir '" ) unless -d $dir ;
@@ -3515,7 +3516,10 @@ sub load
3515
3516
push (@stack , $path );
3516
3517
} elsif (-l $path ) {
3517
3518
my $l = Cwd::realpath($path );
3518
- $alias {$path } = $l if (-f $l );
3519
+ next if (!-e $l || TraceFile::skipCurrentFile($l ));
3520
+ # may need to turn $l into relative path??
3521
+ $self -> [ALIASES]-> {$path } = $l if (-f $l );
3522
+ # lcovutil::info("add alias '$path' -> '$l'\n");
3519
3523
# really, this should be a file...
3520
3524
die (" unexpected soft link $path to directory" )
3521
3525
unless -f $l ;
@@ -3524,17 +3528,6 @@ sub load
3524
3528
}
3525
3529
closedir ($dh );
3526
3530
}
3527
- # now look through list of filenames in the current .info file, and see
3528
- # if any match the soft links found above
3529
- foreach my $f ($info -> files()) {
3530
- my $path = $f ;
3531
- $path = File::Spec-> catfile($main::cwd , $f )
3532
- unless File::Spec-> file_name_is_absolute($f );
3533
- if (exists ($alias {$path })) {
3534
- # lcovutil::info("found alias $alias{$path} of $f\n");
3535
- $self -> [ALIASES]-> {$path } = $alias {$path };
3536
- }
3537
- }
3538
3531
}
3539
3532
return $self ;
3540
3533
}
@@ -3772,20 +3765,23 @@ sub check_path_consistency
3772
3765
# That is: files whose version differs should appear in the diff data
3773
3766
$self -> check_version_match($baseline , $current );
3774
3767
3775
- my %diffMap ;
3776
- my %diffBaseMap ;
3768
+ my %diffMap ; # current_filename -> where_used
3769
+ my %diffBaseMap ; # current_directory -> []
3770
+ # for every 'current' filename in the udiff file
3777
3771
foreach my $f ($self -> files()) {
3778
- $diffMap {$f } = 0;
3772
+ $diffMap {$f } = 0; # this file not used in baseline or current (yet)
3779
3773
my $b = File::Basename::basename($f );
3780
3774
$diffBaseMap {$b } = [[], {}]
3781
3775
unless exists ($diffBaseMap {$b });
3782
3776
push (@{$diffBaseMap {$b }-> [0]}, $f );
3783
3777
}
3778
+ # foreach unchanged file in udiff data
3784
3779
foreach my $f (keys %{$self -> [UNCHANGED]}) {
3785
3780
# unchanged in baseline and current
3786
3781
$diffMap {$f } = 3;
3787
3782
}
3788
3783
my %missed ;
3784
+ # for each file in 'current' info:
3789
3785
foreach my $curr ($current -> files()) {
3790
3786
my $b = File::Basename::basename($curr );
3791
3787
if ($self -> containsFile($curr )) {
@@ -3796,10 +3792,12 @@ sub check_path_consistency
3796
3792
$diffBaseMap {$b }-> [1]-> {$alias } = 0
3797
3793
unless exists ($diffBaseMap {$b }-> [1]-> {$alias });
3798
3794
++$diffBaseMap {$b }-> [1]-> {$alias };
3799
- } else {
3795
+ } elsif (! exists ( $self -> [UNCHANGED] -> { $self -> findName( $curr )})) {
3800
3796
$missed {$curr } = 1; # in current but not in diff
3797
+ # lcovutil::info("missed curr: $curr\n");
3801
3798
}
3802
3799
}
3800
+ # for each file in 'baseline' info:
3803
3801
foreach my $base ($baseline -> files()) {
3804
3802
my $b = File::Basename::basename($base );
3805
3803
if ($self -> containsFile($base )) {
@@ -3810,8 +3808,9 @@ sub check_path_consistency
3810
3808
$diffBaseMap {$b }-> [1]-> {$alias } = 0
3811
3809
unless exists ($diffBaseMap {$b }-> [1]-> {$alias });
3812
3810
++$diffBaseMap {$b }-> [1]-> {$alias };
3813
- } else {
3811
+ } elsif (! exists ( $self -> [UNCHANGED] -> { $self -> findName( $base )})) {
3814
3812
# in baseline but not in diff
3813
+ # lcovutil::info("missed base: $base\n");
3815
3814
if (exists ($missed {$base })) {
3816
3815
$missed {$base } |= 2;
3817
3816
} else {
@@ -3822,45 +3821,46 @@ sub check_path_consistency
3822
3821
my $ok = 1;
3823
3822
foreach my $f (sort keys (%missed )) {
3824
3823
my $b = File::Basename::basename($f );
3825
- if (exists ($diffBaseMap {$b })) {
3826
- # this basename is in the diff file and didn't match any other
3827
- # trace filename entry (i.e., same filename in more than one
3828
- # source code directory) - then warn about possible pathname issue
3829
- my ($diffFiles , $sourceFiles ) = @{$diffBaseMap {$b }};
3830
- # find the files which appear in the 'diff' list which have the
3831
- # same basename and were not matched - those might be candidates
3832
- my @unused ;
3833
- for my $d (@$diffFiles ) {
3834
- # my $location = $self->[DIFF_FILENAME] . ':' . $self->[LOCATION]->[NEW]->{$d};
3835
- push (@unused , $d )
3836
- unless exists ($sourceFiles -> {$d });
3837
- }
3838
- if (scalar (@unused )) {
3839
- my $type ;
3840
-
3841
- # my $baseData = $baseline->data($f);
3842
- # my $baseLocation = join(":", ${$baseData->location()});
3843
- # my $currData = $current->data($f);
3844
- # my $currLocation = join(":", ${$currData->location()});
3845
-
3846
- if (2 == $missed {$f }) {
3847
- $type = " baseline" ;
3848
- } elsif (1 == $missed {$f }) {
3849
- $type = " current" ;
3850
- } else {
3851
- $type = " both baseline and current" ;
3852
- }
3853
- my $single = 1 == scalar (@unused );
3854
- # @todo could print line numbers in baseline, current .info files and
3855
- # in diff file ..
3856
- if (lcovutil::warn_once($lcovutil::ERROR_MISMATCH , $f )) {
3857
- my $suffix =
3858
- $main::elide_path_mismatch ? ' (elided)' :
3859
- lcovutil::explain_once(
3860
- ' elide-path-mismatch' ,
3861
- ' Perhaps see "--elide-path-mismatch", "--substitute" and "--build-directory" options in \' man '
3862
- . $lcovutil::tool_name . ' \' ' );
3863
- lcovutil::ignorable_warning(
3824
+ next unless exists ($diffBaseMap {$b });
3825
+
3826
+ # this basename is in the diff file and didn't match any other
3827
+ # trace filename entry (i.e., same filename in more than one
3828
+ # source code directory) - then warn about possible pathname issue
3829
+ my ($diffFiles , $sourceFiles ) = @{$diffBaseMap {$b }};
3830
+ # find the files which appear in the 'diff' list which have the
3831
+ # same basename and were not matched - those might be candidates
3832
+ my @unused ;
3833
+ for my $d (@$diffFiles ) {
3834
+ # my $location = $self->[DIFF_FILENAME] . ':' . $self->[LOCATION]->[NEW]->{$d};
3835
+ push (@unused , $d )
3836
+ unless exists ($sourceFiles -> {$d });
3837
+ }
3838
+ next unless @unused ;
3839
+
3840
+ # my $baseData = $baseline->data($f);
3841
+ # my $baseLocation = join(":", ${$baseData->location()});
3842
+ # my $currData = $current->data($f);
3843
+ # my $currLocation = join(":", ${$currData->location()});
3844
+
3845
+ my $type ;
3846
+ if (2 == $missed {$f }) {
3847
+ $type = " baseline" ;
3848
+ } elsif (1 == $missed {$f }) {
3849
+ $type = " current" ;
3850
+ } else {
3851
+ $type = " both baseline and current" ;
3852
+ }
3853
+ my $single = 1 == scalar (@unused );
3854
+ # @todo could print line numbers in baseline, current .info files and
3855
+ # in diff file ..
3856
+ if (lcovutil::warn_once($lcovutil::ERROR_MISMATCH , $f )) {
3857
+ my $suffix =
3858
+ $main::elide_path_mismatch ? ' (elided)' :
3859
+ lcovutil::explain_once(
3860
+ ' elide-path-mismatch' ,
3861
+ ' Perhaps see "--elide-path-mismatch", "--substitute" and "--build-directory" options in \' man '
3862
+ . $lcovutil::tool_name . ' \' ' );
3863
+ lcovutil::ignorable_warning(
3864
3864
$lcovutil::ERROR_MISMATCH ,
3865
3865
" source file '$f ' (in $type .info file" .
3866
3866
($missed {$f } == 3 ? " s" : " " ) .
@@ -3874,16 +3874,14 @@ sub check_path_consistency
3874
3874
($single ? " " : " \n\t " ) .
3875
3875
' Possible pathname mismatch?' .
3876
3876
$suffix );
3877
- }
3878
- if ($main::elide_path_mismatch &&
3879
- $missed {$f } == 3 &&
3880
- $single ) {
3881
- $self -> [FILEMAP]-> {$f } = $f ;
3882
- $self -> [LINEMAP]-> {$f } = $self -> [LINEMAP]-> {$unused [0]};
3883
- } else {
3884
- $ok = 0;
3885
- }
3886
- }
3877
+ }
3878
+ if ($main::elide_path_mismatch &&
3879
+ $missed {$f } == 3 &&
3880
+ $single ) {
3881
+ $self -> [FILEMAP]-> {$f } = $f ;
3882
+ $self -> [LINEMAP]-> {$f } = $self -> [LINEMAP]-> {$unused [0]};
3883
+ } else {
3884
+ $ok = 0;
3887
3885
}
3888
3886
}
3889
3887
return $ok ;
0 commit comments