Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getMixPath returns an incorrect path in some cases with cabal 1.22 / ghc 7.10 #44

Closed
killy971 opened this issue Feb 17, 2015 · 3 comments
Assignees
Labels
Milestone

Comments

@killy971
Copy link
Owner

Background analysis

Below is the current implementation of the getMixPath function, which computes a mix file path based on the hpc data directory, the test suite name, and the tix module:

getMixPath :: String -> String -> TixModule -> FilePath
getMixPath hpcDir testSuiteName tix = mixDir hpcDir ++ dirName ++ "/"
    where dirName = case span (/= '/') modName of
              (_, []) -> testSuiteName
              (packageId, _) -> packageId
          TixModule modName _ _ _ = tix

In some cases, this function doesn't return the correct path.
For a concrete example, see this build output: https://travis-ci.org/guillaume-nargeot/hpc-coveralls/jobs/50498362 (throw away test branch hpc-data-dir-troubleshooting)

As a result of this build, the partial directory tree of the dist/hpc/vanilla/ folder is:

├── mix
│   ├── hpc-coveralls
│   │   └── Trace.Hpc.Coveralls.Util.mix
│   └── hpc-coveralls-0.8.4
│       └── hpcco_IlD5BmmDkZU34g6Jd9zefP
│           └── Trace.Hpc.Coveralls.Util.mix
└── tix
    ├── hpc-coveralls-0.8.4
    │   └── hpc-coveralls-0.8.4.tix
    └── test-all
        └── test-all.tix

In both hpc-coveralls-0.8.4.tix and test-all.tix, the modName value for the TraceHpcCoveralls.Util module is hpcco_IlD5BmmDkZU34g6Jd9zefP/Trace.Hpc.Coveralls.Util.

When building the same package with cabal 1.20 and ghc 7.8 (instead of cabal 1.22 and ghc 7.10), the hpcco_IlD5BmmDkZU34g6Jd9zefP bit found in the module name and directory structure is hpc-coveralls-0.8.4, which seems to be more correct.

This strange looking string is the reason why the getMixPath function fails, as it will produce the following path, which doesn't exist:

dist/hpc/vanilla/mix/hpcco_IlD5BmmDkZU34g6Jd9zefP/

The correct path should instead be:

dist/hpc/vanilla/mix/hpc-coveralls-0.8.4/

The fact that the referenced mix file paths have this additional indirection (two times the package name) is yet to be understood.
A simpler package, such as this one, used for hpc-coveralls testing, doesn't seem to generate mix files in such a way (see this build), and therefore doesn't suffer from this issue.

Objective

Either find a way to better control hpc and where it outputs the tix/mix data files, or try to access the package name and pass it to the getMixPath function.

The package name can be parsed from the cabal file using Distribution.PackageDescription (distributed with cabal, so it should always be available).
A new command line option may have to be introduced in order to specify the cabal file, or it could be found by inspecting the current folder.

Feature branch: read-cabal-file

@killy971 killy971 added the bug label Feb 17, 2015
@zovt
Copy link

zovt commented Jul 2, 2015

I'm currently being affected by this issue. Has there been any progress?

killy971 referenced this issue in jtanguy/hmacaroons Jul 15, 2015
@killy971
Copy link
Owner Author

@zovt I'm working on it when I can find some time, and hope to fix it soon. Will keep you updated.

I've already implemented the module to read the package name-version.

@killy971
Copy link
Owner Author

TODO: 91924d1#commitcomment-12968500

@killy971 killy971 added this to the v1.0.0 milestone Sep 2, 2015
@killy971 killy971 self-assigned this Sep 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants