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

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

Closed
grayjay opened this issue Mar 12, 2018 · 1 comment · Fixed by #5219
Closed

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

grayjay opened this issue Mar 12, 2018 · 1 comment · Fixed by #5219

Comments

@grayjay
Copy link
Collaborator

grayjay commented Mar 12, 2018

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.

@grayjay
Copy link
Collaborator Author

grayjay commented Mar 12, 2018

I was able to run most of the hackage-repo-tool tests on AppVeyor with this commit: grayjay@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

grayjay added a commit to grayjay/cabal that referenced this issue Mar 18, 2018
…haskell#5204).

appveyor.yml currently downloads hackage-security from Github, since the changes
that allow building on Windows haven't been released yet.

I disabled one test that still fails on Windows:
PackageTests/NewBuild/CustomSetup/RemotePackageWithCustomSetup/build-package-from-repo-with-custom-setup.test.hs
grayjay added a commit to grayjay/cabal that referenced this issue Mar 25, 2018
…haskell#5204).

I disabled one test that still fails on Windows:
PackageTests/NewBuild/CustomSetup/RemotePackageWithCustomSetup/build-package-from-repo-with-custom-setup.test.hs
grayjay added a commit to grayjay/cabal that referenced this issue Mar 29, 2018
…haskell#5204).

I disabled one test that still fails on Windows:
PackageTests/NewBuild/CustomSetup/RemotePackageWithCustomSetup/build-package-from-repo-with-custom-setup.test.hs
grayjay added a commit to grayjay/cabal that referenced this issue Mar 31, 2018
…haskell#5204).

I disabled one test that still fails on Windows:
PackageTests/NewBuild/CustomSetup/RemotePackageWithCustomSetup/build-package-from-repo-with-custom-setup.test.hs
grayjay added a commit to grayjay/cabal that referenced this issue Mar 31, 2018
…haskell#5204).

I disabled one test that still fails on Windows:
PackageTests/NewBuild/CustomSetup/RemotePackageWithCustomSetup/build-package-from-repo-with-custom-setup.test.hs
grayjay added a commit to grayjay/cabal that referenced this issue Apr 29, 2018
…haskell#5204).

I disabled one test that still fails on Windows:
PackageTests/NewBuild/CustomSetup/RemotePackageWithCustomSetup/build-package-from-repo-with-custom-setup.test.hs
grayjay added a commit to grayjay/cabal that referenced this issue May 3, 2018
…haskell#5204).

I disabled one test that still fails on Windows:
PackageTests/NewBuild/CustomSetup/RemotePackageWithCustomSetup/build-package-from-repo-with-custom-setup.test.hs
23Skidoo pushed a commit that referenced this issue May 9, 2018
…#5204).

I disabled one test that still fails on Windows:
PackageTests/NewBuild/CustomSetup/RemotePackageWithCustomSetup/build-package-from-repo-with-custom-setup.test.hs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant