AdamNiederer / cov

An emacs extension for displaying coverage data on your code
GNU General Public License v3.0
76 stars 16 forks source link

Unable to find gcov files in /tmp folder. #54

Open citypilgrim opened 1 year ago

citypilgrim commented 1 year ago

To Replicate

  1. Write a hello world program main.C
  2. Build with coverage activated
    CC=g++ -g -01 -ftest-coverage -fprofile-arcs
    $CC -c main.C
    $CC main.o -o main.exe
  3. Generate coverage files
    ./main.exe
    gcov -b main.exe
  4. Move coverage files to /tmp
  5. Configure cov-coverage-file-paths
    (add-to-list 'cov-coverage-file-paths "/tmp")
    (add-to-list 'cov-coverage-file-paths
    #’(lambda (file-dir file-name)
        (let ((try (format "%s/%s%s"
                           "/tmp" file-name
                           ".gcov")))
          (and (file-exists-p try)
               (cons (file-truename try) ’gcov)))))
  6. Activate cov-mode inside of main.C

Output

In messages buffer

No coverage data found for /path/to/main.C
snogge commented 11 months ago

There was a problem in the file lookup that did not handle absolute paths in cov-coverage-file-paths correctly, I fixed that in #55. But one problem remains that I'm not sure we can or should fix in cov.el. The gcov file starts with the line

        -:    0:Source:main.C

cov uses that path to associate the coverage data with related source code files. This is very relevant for some other coverage formats that collect data for multiple source code files in a single coverage file. If you modify that path in main.C.gcov to be the absolute path to main.C (and apply fix #55) cov-modewill work.