[MDEV-25915] dgcov --generate error Created: 2021-06-14  Updated: 2021-06-21  Resolved: 2021-06-21

Status: Closed
Project: MariaDB Server
Component/s: Scripts & Clients
Affects Version/s: 10.2
Fix Version/s: 10.5.11

Type: Bug Priority: Major
Reporter: Anel Husakovic Assignee: Anel Husakovic
Resolution: Not a Bug Votes: 0
Labels: dgcov

Issue Links:
Relates
relates to MDEV-20787 Script dgcov.pl does not work Closed
relates to MDEV-25914 gcda data files are not created when ... Closed

 Description   

Based on documentation:

Usage:
            $0 \[options\] \[git diff arguments\]

The dgcov program runs gcov for code coverage analysis, and reports missing
coverage only for those lines that are changed by the specified commit(s).
Commits are specified in the format of git diff arguments. For example:
 * All unpushed commits:        $0 \@{u} HEAD
 * All uncommitted changes:     $0 HEAD
 * Specific commit:             $0 <commit>^ <commit>
 
If no arguments are specified, it prints the coverage for all uncommitted
changes, if any, otherwise for the last commit.

Meaning if no changes and args in usage of dgcov than changes from last commit should be presented.
If we debug: dgcov --generate>file and no git diff in our tree, we see that command that is invoked for printing:
git diff --no-prefix --ignore-space-change HEAD and it results in empty result in a file.
It should show changes from the last commit.

serg can you please confirm above?



 Comments   
Comment by Sergei Golubchik [ 2021-06-17 ]

Nope. Works fine for me. Check the code. It has

if (@ARGV) {
  print_gcov_for_diff(@ARGV);
} else {
  print_gcov_for_diff('HEAD') or print_gcov_for_diff('HEAD^');
}

obvisouly, it means either a diff for HEAD and if it's empty, a diff for HEAD^. Meaning, print_gcov_for_diff() should return whether a diff is empty. It does

  while (<PIPE>) {
    if (/^diff --git (.*) \1\n/) {
      print $acc if $printme;
      $fname=$1;
      ...
  return defined($fname);
}

so it returns true if there was at least one diff --git line.

Now run

git diff --no-prefix --ignore-space-change HEAD

manually and see what it returns for you. When it's empty, dgcov.pl correctly tries HEAD^ for me, as expected.

Comment by Anel Husakovic [ 2021-06-21 ]

Ahh I was confused with last commit in help. Expected to see git show somewhere missed git diff HEAD^ what is the actually git show without commit message.
Thanks Serg.

Generated at Thu Feb 08 09:41:22 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.