Skip to content

Fail more gracefully when tests can't be run #2844

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

Conversation

enolan
Copy link
Contributor

@enolan enolan commented Sep 27, 2015

If cabal-install isn't built yet, we can't run it's tests yet. Prior to
this commit, if you tried running "./Setup test" on cabal-install without
having built cabal-install yet you got:

package-tests: dist/build/cabal: canonicalizePath: does not exist (No such file or directory)

Now you get:

package-tests: user error (The program 'cabal' is required but it could not be found.)

I moved the canonicalization logic into findProgramOnSearchPath. This is
a change to the semantics of the library, but shouldn't break anything.

@23Skidoo
Copy link
Member

Any ideas about what caused the build bot failure?

@enolan
Copy link
Contributor Author

enolan commented Sep 28, 2015

It's the AMP, I think. <$> got moved into Prelude. Needs some CPP to compile on <7.10. I'll fix it tonight.

@enolan
Copy link
Contributor Author

enolan commented Sep 28, 2015

Fixed now :)

@@ -109,7 +109,7 @@ findProgramOnSearchPath verbosity searchpath prog = do
findFirstExe (f:fs) = do
isExe <- doesExecutableExist f
if isExe
then return (Just f)
then Just `fmap` canonicalizePath f
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed, this function already returns an absolute path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It only returns absolute paths if all of the ProgramSearchPathDirs are absolute. That's the whole point. You'll notice my change is the only call to canonicalizePath in the function.

@23Skidoo
Copy link
Member

23Skidoo commented Oct 1, 2015

So the problem is that canonicalizePath exits with an error if the dist/build/cabal directory doesn't exist. I suggest adding a doesDirectoryExist check before the canonicalizePath path line if the goal is just to improve the error message.

@@ -60,8 +60,9 @@ main = do
distPref <- findDistPrefOrDefault NoFlag
-- Use the default builddir for all of the subsequent package tests
setEnv "CABAL_BUILDDIR" "dist"
buildDir <- canonicalizePath (distPref </> "build/cabal")
let programSearchPath = ProgramSearchPathDir buildDir : defaultProgramSearchPath
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can get the wrong cabal if dist/build/cabal exists but is empty.

@enolan
Copy link
Contributor Author

enolan commented Oct 11, 2015

The counterargument is that we already have a system for finding executables and throwing errors if they aren't there. It makes sense to me to use it. The diffstat for these changes is negative if you ignore comments.

@phadej
Copy link
Collaborator

phadej commented Oct 19, 2015

AFAICS the original issue is already fixed in master. Can @enolan confirm?

@enolan
Copy link
Contributor Author

enolan commented Oct 22, 2015

Bug is still there. On 3923101:

Test suite integration-tests: RUNNING...
integration-tests: dist/build/cabal: canonicalizePath: does not exist (No such file or directory)

If cabal-install isn't built yet, we can't run it's tests yet. Prior to
this commit, if you tried running "./Setup test" on cabal-install
without having built cabal-install yet you got:

package-tests: dist/build/cabal: canonicalizePath: does not exist (No
such file or directory)

Now you get:

package-tests: user error (The program 'cabal' is required but it could
not be found.)

I moved the canonicalization logic into findProgramOnSearchPath. This is
a change to the semantics of the library, but shouldn't break anything.
@enolan enolan force-pushed the better-error-when-testing-before-building-cabal-install branch from 05b8579 to e7b7a35 Compare November 4, 2015 20:24
@enolan
Copy link
Contributor Author

enolan commented Nov 4, 2015

Updated to work with the newer IntegrationTests suite. Don't pull yet, still need to handle #2910

@quasicomputational
Copy link
Contributor

Is this still relevant? The test-suite's gone through some significant changes in the past few years and cabal-install/tests/IntegrationTests.hs doesn't even exist any more. 40846f0 suggests that this PR isn't relevant since the integration tests don't use the cabal binary any more, and cabal-testsuite has stuff for test with and without a cabal binary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants