10

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

Community
  • 1
  • 1
Arnon
  • 2,237
  • 15
  • 23
  • how did you compile? (ghc directly - what options? or cabal - show the .cabal file) – d8d0d65b3f7cf42 Sep 04 '14 at 08:50
  • I have a fairly complicated compiling scheme. I actually just [wrote it down in another question](http://stackoverflow.com/questions/25424615/how-to-link-custom-object-file-with-haskell-library/25660388#25660388). – Arnon Sep 04 '14 at 09:19

1 Answers1

1

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.

Arnon
  • 2,237
  • 15
  • 23