Skip to content

Tests requiring hackage-repo-tool don't run on Windows. #5204

Closed

Description

@sebright

I tried to run the tests that depend on hackage-repo-tool on AppVeyor, but I ran into several issues:

  1. cabal-tests uses tar to create the repository, but tar misinterprets the colon in the drive letter, as in https://stackoverflow.com/questions/12823499/windows-command-line-tar-cannot-connect-to-d-resolve-failed-with-chef-knife/37996249. I was able to fix this issue by adding --force-local to the arguments in

    tar ["-czf", dst, "-C", src_parent, src_dir]

  2. cabal-testsuite tests can access the Hackage package index on Windows #5187 prevents the tests from reading the repository settings from the test config file. Setting CABAL_CONFIG for each test seemed to work.

  3. The repository url field in the config file generated by cabal-tests cannot be parsed as a URI. cabal-tests generates the config file here:

    , " url: file:" ++ testRepoDir env

    That produces a string with backslashes, such as file:C:\projects\cabal\cabal-testsuite\PackageTests\NewBuild\CustomSetup\LocalPackageWithCustomSetup\build-local-package-with-custom-setup.dist\repo. cabal parses the field as a URI in
    remoteRepoFields =
    [ simpleField "url"
    (text . show) (parseTokenQ >>= parseURI')
    remoteRepoURI (\x repo -> repo { remoteRepoURI = x })

  4. cabal treats the file URI path as a file path when initializing the repository with hackage-security:

    withRepo _ callback | uriScheme remoteRepoURI == "file:" = do
    dir <- Sec.makeAbsolute $ Sec.fromFilePath (uriPath remoteRepoURI)

    fromFilePath seems to expect a platform-specific path:
    https://github.com/haskell/hackage-security/blob/21519f4f572b9547485285ebe44c152e1230fd76/hackage-security/src/Hackage/Security/Util/Path.hs#L277-L281
    It converts the String to a FsPath, which contains a Path, which stores the path as a Posix-style path string: https://github.com/haskell/hackage-security/blob/21519f4f572b9547485285ebe44c152e1230fd76/hackage-security/src/Hackage/Security/Util/Path.hs#L121

    Later, hackage-security fails to find root.json, because it calls toAbsoluteFilePath on the invalid path:
    https://github.com/haskell/hackage-security/blob/21519f4f572b9547485285ebe44c152e1230fd76/hackage-security/src/Hackage/Security/Util/Path.hs#L322-L325 . toAbsoluteFilePath tries to convert the Absolute path back to the platform-specific format:
    https://github.com/haskell/hackage-security/blob/21519f4f572b9547485285ebe44c152e1230fd76/hackage-security/src/Hackage/Security/Util/Path.hs#L257-L258
    After I worked around (3), I saw that cabal/hackage-security converted the path of type Path Absolute, C:/projects/cabal/cabal-testsuite/PackageTests/NewBuild/CustomSetup/LocalPackageWithCustomSetup/build-local-package-with-custom-setup.dist/repo/root.json, to C:projects\cabal\cabal-testsuite\PackageTests\NewBuild\CustomSetup\LocalPackageWithCustomSetup\build-local-package-with-custom-setup.dist\repo\root.json. The result is invalid because it is missing a backslash after the drive letter.

  5. After I worked around the previous issues, I saw new warnings about mirrors in the output, though I didn't look into them further.

     # cabal update
    +Warning: Caught exception during _mirrors lookup:user error (DnsQuery_A failed with 9003)
    +Warning: No mirrors found for file:///C:/projects/cabal/cabal-testsuite/PackageTests/NewBuild/CustomSetup/LocalPackageWithCustomSetup/build-local-package-with-custom-setup.dist/repo
     Downloading the latest package list from test-local-repo
    

EDIT: I think (5) was only caused by the changes I made to work around the other issues.

Activity

  1. sebright commented on Mar 12, 2018

    @sebright
    CollaboratorAuthor

    I was able to run most of the hackage-repo-tool tests on AppVeyor with this commit: sebright@d547107 I temporarily worked around the repo path issues by using a relative path, though I think that caused three of the new-freeze tests to fail.

    Log: https://ci.appveyor.com/project/grayjay/cabal/build/1.0.507

    There was one other test failure, PackageTests/NewBuild/CustomSetup/RemotePackageWithCustomSetup/build-package-from-repo-with-custom-setup.test.hs: https://ci.appveyor.com/project/grayjay/cabal/build/1.0.507#L1450

  2. added a commit that references this issue on Mar 18, 2018
    39bed2f
  3. added 4 commits that reference this issue on Mar 25, 2018
    dbd5676
    82bd99e
    1a8c711
    1911c73
  4. added 2 commits that reference this issue on Apr 29, 2018
    a629cc0
    1826980
  5. added a commit that references this issue on May 9, 2018
    3c339d2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions