How to add LCOV_EXCL_LINE marker for code coverage in C or C++ code? - lcov

I tried two ways to add LCOV_EXCL_LINE in my code.
I add it as comment, compile and generate lcov report but lcov binary takes it as a comment and showing the coverage of excluded line.
Image showing coverage of excluded line:
After compilation and execution I add LCOV_EXCL_LINE before running lcov and genhtml binaries but it results in misalignment after first exclusion.
Image showing misalignment coverage:

You add the comment in the line you want excluded. Not in the line before that you want excluded.

As 1737973 said, you should do something like:
printf("* ") // LCOV_EXCL_LINE
printf("\n") // LCOV_EXCL_LINE

Related

What does "#" mean in LCOV report?

I thought I had covered both cases for the while loop, but brcov doesn't show 100% due to that "#" alert:
hash symbol
From the genhtml man page:
--branch-coverage
--no-branch-coverage
Specify whether to display branch coverage data in HTML output.
Use --branch-coverage to enable branch coverage display or
--no-branch-coverage to disable it. Branch coverage data display
is enabled by default
When branch coverage display is enabled, each overview page will
contain the number of branches found and hit per file or direc‐
tory, together with the resulting coverage rate. In addition,
each source code view will contain an extra column which lists
all branches of a line with indications of whether the branch
was taken or not. Branches are shown in the following format:
' + ': Branch was taken at least once
' - ': Branch was not taken
' # ': The basic block containing the branch was never executed
Note that it might not always be possible to relate branches to
the corresponding source code statements: during compilation,
GCC might shuffle branches around or eliminate some of them to
generate better code.
This option can also be configured permanently using the config‐
uration file option genhtml_branch_coverage.

Function to open a file and navigate to a specified line number

I have the output of recursive grep (actually ag) in a buffer, which is of the form filename:linenumber: ... [match] ..., and I want to be able to go to the occurrence (file and line number) currently under the cursor. This told me that I could execute normal-mode movements, so after extracting the file:line portion, I wrote this function:
function OpenFileNewTab(name)
let l:pair=split(a:name, ":")
execute "tabnew" get(l:pair, 0)
execute "normal!" get(l:pair, 1) . "G"
endfunction
It is supposed to open the specified file in a tab and then do <lineno>G, like I am able to do manually, to go to the specified line number. However, the cursor just stays on line 1. What am I doing wrong?
This question, by title alone, would be an exact duplicate, but it talks locating symbols in other files, while I already have the locations at hand.
Edit: My mappings for grep / ag are as follows:
nnoremap <Leader>ag :execute "new \| read !ag --literal -w" "<C-r><C-w>" g:repo \| :set filetype=c<CR>
nnoremap <Leader>gf ^v2t:"zy :execute OpenFileNewTab("<C-r>z")<CR>
To get my grep / ag results, I put the cursor on the word I want to search and enter <leader>ag, then, in the new buffer, I put the cursor on a line and enter <leader>gf - it selects from the start up to the second colon and calls OpenFileNewTab.
Edit 2: I'm on Cygwin, if it is of any importance - I doubt it.
Why don't you set &grepprg to call ag ?
" according to man ag
set grepprg=ag\ --vimgrep\ $*
set grepformat=%f:%l:%c:%m
" And then (not tested)
nnoremap <Leader>ag :grep -w <c-r><c-w><cr>
As others have said in the comments, you are just trying to emulate what the quickfix windows already provides. And, we are lucky vim can call grep, and it has a variation point to let us specify which grep program we wish to use: 'grepprg'.
Use file-line plugin. Pressing Enter on a line in the quicklist will normally open that file; file-line will make any filename of the form file:line:column (and several other formats) to open file and position to line and column.
I only found this (old) thread after I posted the exact same question on vi.stackexchange: https://vi.stackexchange.com/q/39557/44764. To help anyone who comes looking, I post the best answer to my question below as an alternative to the answers already given.
The gF command, like gf, opens the file in a new tab but additionally it also positions the cursor on the line after the colon. (I note the OP defines <leader>gf so maybe vim/neovim didn't auto-define gf or gF at the time this thread was originally created.)

How to set empty file description using AutoItWrapper?

When I add this wrapper directive it changes the description field of my executable. But when I leave it empty (or omit the directive) its value defaults to Aut2Exe.
#AutoIt3Wrapper_Res_Description=
How can I change this behavior? Is there a parameter for AutoIt3Wrapper.exe that leaves it empty? This is the compile command executed by SciTE:
"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /in "C:\...\myscript.au3" /console
Looking at the AutoIt3Wrapper source code, which is provided in the installation, the following line (line 2326 in my installation) reads:
If $INP_Description = "" Then $INP_Description = FileGetVersion($AutoItBin, "FileDescription")
I believe that to be the source of the Aut2Exe description.
How to force the description to be blank is a bit trickier. The quick and easy hack is to have a script that runs after compilation that removes the description, I usually have reshacker somewhere to hand for tasks like this.
Long term, I will put the issue to the developer, as it seems strange to set a description when the user has explicitly left it blank.

Mercurial - List out the modified lines of code in a file with line number

I'm new to mercurial, i have a certain revision with me and i would like to switch to that particular revision and save the change-set of a particular file with line number. Thank You
I don't know a simple way to do this. Mercurial has a method where it calculates the diff between changesets and then it applies a formatter to this to print the data.
But your requirement is more complex than it looks. Imagine you have two changes in a file. In version 2, a couple of lines at the beginning have been deleted and then a line near the end has been changed.
Questions:
How do you plan to assign line numbers to the deleted lines? Omit them or use the original line numbers from version 1?
How about the lines after the deleted lines? Do you want to show the new line numbers or the original ones?
Which line numbers are you going to show for the changes near the end?
Of course, you could show both but that would need a lot of parsing in your head.
Some HTML-based changeset viewers use this approach: https://bitbucket.org/digulla/ts-html/commits/62fc23841ff7e7cce95eefa85244a2b821f92ba2
But I haven't see something similar for the command line since it would waste 15-20 columns of text.

Using mxmlc to compile as files with more than one src paths

I am using mxmlc.exe to compile my Flash project but I have two separated source files.
I noticed that I can specify more than one -compiler.library-path but it seems not OK to specify more than one -compiler.source-path parameters.
For some reasons I have to keep the src files in different folders. Is there any way I can still compile?
Thanks!
The desired command-line parameters:
mxmlc.exe src/Editor.as
-output=Editor.swf
-compiler.source-path=src1 -compiler.source-path=../src2
-compiler.library-path=libs -compiler.library-path=../libs
The += operator will append the second path to compiler.library-path, whereas the = operator will replace the value with a new one.
try this instead:
mxmlc.exe src/Editor.as
-output=Editor.swf
-compiler.source-path=src1 -compiler.source-path=../src2
-compiler.library-path+=libs -compiler.library-path=../libs
You might have to play a bit with the spacing before and after the += to get it working exactly right.