I'm developing a software project with source code spread across different directories, some parts being project-specific, other parts are shared across projects.
I want to measure the test coverage for all source code in question, however, I fail to use the directory parameters for lcov correctly.
example:
the following files exist:
$HOME/dev/common/src/tools.cpp
$HOME/dev/project/src/project.cpp
the test executable is stored in $HOME/dev/project/src/bin/unittest
The makefile is executed from $HOME/dev/project/src
I invoke lcov as
lcov --base-directory ../../ --directory ../../ --zerocounters -q
${MAKE} test
lcov --base-directory ../../ --directory ../../ -c -o $(BINDIR)/unittests.info
I'd expect lcov to store the data as /home/$USER/project/src/common/tools.cpp
But then, I see output like
SF:/home/$USER/project/tools.cpp
Therefore, genhtml fails to find the sources, and cannot produce any output.
All *.gcda and *.gcno are stored next to the cpp files.
I'd rather not change directories before executing commands, as all of this is executed in a makefile
What am I missing?
Cheers,
Michael
Related
I'm trying to use mercurial file sets to add all the files in a directory tree, excluding very large files and any binary files. Cribbing from the mercurial documentation, this command should do it:
hg init
hg add 'set: size("<1M") and not binary()'
However this returns a status code of 0, and hasn't added anything to my new, empty repo. I've tried just 'set: not binary()' and that didn't work either.
The frustrating thing is that although I can google for mercurial file sets, and find lots of examples, I can't find anything to help troubleshoot when it doesn't work!
I don't have a .hgignore file, and it's a fresh empty repo. Mercurial 4.2.2.
The directory where I'm testing this has a couple of artificially created files for the purpose of testing. In my real use case, I inherit a multi-gigbyte tarball of assorted sources and binaries from a client, and I want to get all the sources into mercurial before I start hacking to fix their problems, hence the need to exclude the binaries and large files that otherwise choke mercurial.
Here's my little test script:
#!/bin/sh -ex
dd if=/dev/urandom of=binary_1k bs=1 count=1024
dd if=/dev/urandom of=binary_2M bs=1 count=2097152
echo "This. Is, a SMALL text file." > text_small
hexdump binary_1k > text_1k
hexdump binary_2M > text_2M
ls -lh
file binary_1k
file binary_2M
file text_1k
file text_2M
hg init
hg add 'set: size("<1M") and not binary()'
hg status -a
hg add 'set: not binary()'
hg status -a
hg add 'set: size("<1M")'
hg status -a
At the end of this, each status command reports no files in the repo, and the add commands report no errors.
The problem is that file sets do a query of Mercurial's repository data base, which knows only about files that are part of the repository or have been added.
One solution is to add all, and then to get rid of the files that you don't like, e.g.:
hg forget 'set:size(">1M") or binary()'
This works, because the query also requires recently added files, even if they haven't been committed yet.
I want to add a hook to my repository. I can't work out where i need to put the hook file. The hgrc file is as follows:
[hooks]
precommit.test = precommithook
Location is C:\Code\RepoTest.hg\hgrc
Hook file is:
echo "hello world"
Location is C:\Code\RepoTest.hg\precommithook
When i run
hg commit -m"test"
from the command line i get
running hook precommit.test: precommithook
'precommithook' is not recognized as an internal or external command,
operable program or batch file.
abort: precommit.test hook exited with status 1
I've tried various paths but nothing works.
Most of the examples i googled with regards to Mercurial hooks are Unix based.
Is it possible to write hooks in a powershell?
According to Hooks doc, hook must be executable in given environment program, it haven't predefined location, but have to be found by OS.
Thus:
For pure Windows, hook must be named precommithook.bat
It must be placed into dir in $PATH or full path used in hook definition
As result, with
precommit.test = z:\precommit.bat in hgrc
#echo off
echo Hello World in z:\precommit.bat
I have on commit attempt
>hg commit -m "Edits"
Hello World
I've been using Zsh as a Bash replacement for a while now. One thing that doesn't work as well anymore is the completion for branch and uncommitted file names for mercurial.
If previously (bash) I had the following hg tracked folder:
repo/
.hg/
file1.txt
file2.txt <-- modified
Then doing this in Bash:
% hg commit -m "changed file2.txt" <TAB>
automagically completed file2.txt.
Same with branches — assuming I had default, dev and crazy branches, Bash knew how to complete branch names:
% hg update cr<TAB>
completed the branch name to crazy.
Basically what I'm asking is how to restore this functionality — which file/s take care of that and so on.
zsh uses its internal system for advanced completion, while bash uses a separate bash-completion software for that. Their configuration is incompatible so if you want some function to work you need to find a 3rd party zsh completion module for it or write it yourself. mercurial contains a sample zsh completion function, it is installed on my system as /usr/share/doc/mercurial/examples/zsh_completion.gz.
I successfully compile alsa-lib when I run ./configure and subsequently make from the sources extracted from the original .tar.gz
Since I versioned with mercurial and then try to hg clone the full source tree, the ./configure and make doesn't work anymore.
I compared the .tar.gz extracted sources with the hg cloned sources using kdiff3 and they're exactly the same (except for the .hg folder).
What I notice is that running make from the extracted .tar.gz it simply compiles; running the same from the hg cloned sources instead, before compiling, calls
alsa-lib-1.0.24.1/missing --run aclocal-1.11 -I m4
....
then there's again a list of configuration commands before starting the compilation that fails.
deleting all the content of the file named "missing" I can have a successful compilation also from the hg cloned sources but this solution seems to me ugly, does anybody know what's happening here?
I have a local repository, let's call it ONE. ONE is the actual program. It's an android program, in case it matters for some reason.
I have a remote repository, let's call it EXT. EXT is somewhat a library, used by ONE.
ONE has a complex directory structure, mandated by android. The main sources are in src/bla/bla/ONE. Since ONE uses EXT, to do it I had to create another directory next to that one, that is src/bla/bla/EXT.
I think would like to keep them separated in two repositories, but I need for them to actually be in this same directory structure to compile ONE.
At the moment I just created a symlink to do it, but I wonder if there is a better way of doing that, that uses some hg feature.
Subrepositories are great for this. Take a look at this related SO question: (how do I add a subrepo to an existing repo in mercurial.
I'm no expert on this, but I don't think sub-repositories work in this case.
You have 2 projects with the same deeply nested directory structure:
Project "ONE":
ONE
/src
/bla
/bla
/ONE
Project "EXT"
EXT
/src
/bla
/bla
/EXT
When you compile these projects you want the following structure:
Compile Project
/src
/bla
/bla
/ONE
/EXT
Or something similar - essentially both source trees combined under a single "src".
Since you can't checkout part of a repository, wherever you create a sub-repository you'll get the full "EXT" directory. So, if you make a subrepo next to "ONE" you'll end up with:
Combined Project
/src
/bla
/bla
/ONE
/src
/bla
/bla
/EXT
What you are after is a "Partial Clone", which doesn't exist yet.
https://www.mercurial-scm.org/wiki/PartialClone
I think OS links are the way to go.
Hope this helps.
Use hg subrepos. For example:
$ git init ONE-proj
$ cd ONE-proj
$ mkdir -p src/bla/bla/ONE
$ ... # commit your initial project files for ONE
$ echo src/bla/bla/EXT = /path/to/hg/repository/EXT > .hgsub
$ hg add .hgsub
$ hg clone /path/to/hg/repository/EXT src/bla/bla/EXT
$ hg commit