Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell Coverage - HPC can not find Main

I have a program that is built up of many C++ and Haskell files. I compile all of the Haskell with -fhpc flag so that I may run coverage tests on it.

After compiling is finished, I run the program and several .tix files are generated.

The problem: I attempt to run hpc markup build/Server --srcdir=. for instance. It will then generate some files, but fail prematurely:

Writing: file1.hs.html
Writing: file2.hs.html
Writing: file3.hs.html
hpc: can not find Main in ["./.hpc"]

The directory .hpc exists, and it does contain a file called Main.mix alongside other .mix files.

I've noticed some people reporting the same issues on IRC chat logs, but nowhere have I found a solution for this. Does anyone have this experience with hpc?

Edit: How I compile I have a fairly complicated compiling scheme. I actually just wrote it down in another question.

I use a very specific package library which I specify explicitly by using --no-user-package-db and --package-db=/usr/local/ghc-7.6.3-200814. That directory's listings is available here

like image 301
Arnon Avatar asked Aug 26 '14 12:08

Arnon


1 Answers

I finally got it running today. I changed my compilation to have no optimizations at all. I ran my server from the base project directory by running ./build/Server ...

I generated a list of all my modules to be included using sed inside Make.

(My directory structure is the same as the module names. For example, the filename haskell/Database/Module/Server/Server.lhs will become Database.Module.Server.Server.)

includify = $(foreach pkg,$(1), --include=$(pkg))
MODULES = $(shell find haskell -name "*.lhs" | sed -e "s/\.lhs\$$//g" | sed -e "s/^haskell\///g" | sed -e "s/\//\./g")
INCLUDES = $(call includify,$(MODULES))

and then created the target (inside Make again)

@echo "WRITING coverage/result.xml"
@hpc report Server srcdir=build $(INCLUDES) --xml-output > build/coverage/result.xml
@echo "WRITING coverage HTML FILES"
@hpc markup Server srcdir=build $(INCLUDES) --destdir=build/coverage

And this is how I solved my issues.

like image 195
Arnon Avatar answered Oct 10 '22 12:10

Arnon