-
Notifications
You must be signed in to change notification settings - Fork 703
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
Fix #4270: make detailed-0.9 test suites work with dynamic exes #4274
Conversation
@bennofs, thanks for your PR! By analyzing the history of the files in this pull request, we identified @Ericson2314, @ttuegel and @ezyang to be potential reviewers. |
Do we need to do the same thing for |
@ttuegel I believe not since a normal executable component will not build any shared library that needs to be linked against |
@bennofs What if it links against the package's library component? |
From AppVeyor failure, test needs to be disabled on platforms that don't support dynamic linking e.g. Windows. Use |
else return shellEnv | ||
print shellEnv' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you wanted to keep this
@@ -94,8 +94,10 @@ runTest pkg_descr lbi clbi flags suite = do | |||
let (Platform _ os) = LBI.hostPlatform lbi | |||
paths <- LBI.depLibraryPaths | |||
True False lbi clbi | |||
return (addLibraryPath os paths shellEnv) | |||
cpath <- canonicalizePath $ LBI.componentBuildDir lbi clbi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure you want canonicalizePath and not makeAbsolute?
@ttuegel That is already handled correctly, since we do add the library dirs for all dependencies. The I (hopefully) addressed the remaining review comments (thanks for that!). Tell me if you'd like me to squash the commits. |
Should |
@bennofs You're right! So I guess we also need a "has Cabal shared library" parameter. Unfortunately, I don't actually know how to test for this... maybe do a |
This PR actually seems to be a duplicate of #3527 |
@ezyang I was looking at the test code, and found a function called hasCabalGorGhc in Prelude.hs. What's that function for? |
hasCabalForGhc is a different function, related to what we do when we test the Cabal library, passing |
The detailed-0.9 test suite type compiles the test module into a shared library, so for running the tests, we need to include the directory where the shared library is stored in LD_LIBRARY_PATH.
I squashed some of the commits, travis build should be fine now. |
-- An example where this is needed is if you want to dynamically link | ||
-- detailed-0.9 test suites, since those depend on the Cabal library unde rtest. | ||
hasCabalShared :: TestM Bool | ||
hasCabalShared = do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting implementation of hasCabalShared
. At the very least, I would add a note that it is a relatively expensive check, because it involves banging on GHC, so you really only want to call this once, if at all possible.
Assuming that this is the best way to go about doing this, I have some comments:
-
First, are you sure that
runProgramM ghcProgram
isn't enough to invoke GHC? I believe that GHC should already be configured intestProgramDb
; the configuration was done inTest/Cabal/Monad.hs
so I don't think we should have to do it again. If this doesn't work, there is probably a different bug somewhere. Is the problem thatrunM
callsrequireSuccess
whereas you need to get a boolean out instead? Maybe we can refactor those functions so you get a version that raises exceptions, and one that doesn't. This is related to cabal-testsuite: check return code ofrunghc Setup.hs
#4292 where we wanted to handlefails
more systematically. -
Second, the invocation of GHC doesn't attempt to control what packages are in scope, which means that you could end up in a situation where there are two
Cabal
packages in scope. I guess GHC is preferring the latest version so it's working correctly in this case, but it would be more robust to explicitly specify which Cabal library we want to use, and the test would stop working the moment someone uses a GHC that comes with a newer version of Cabal.
Is this check the way we want to go about it? I'll admit, I can't think of very many other good choices. One possibility is to look at the LocalBuildInfo
when we mkScriptEnv
and check if dynamic compilation was enabled (adding a new field to ScriptEnv
saying if we were building with dynamic or not.) This seems a lot simpler and efficient!
Sorry about the yak shaving on |
Using the |
Windows build failure is due to #4005 |
@ezyang using the LocalBuildInfo was a really good idea, there's now much less code. |
@bennofs Good! I restarted the Windows build, if it passes let's ship it! |
Failing -Werror; import changes need to be undone. |
@ezyang fixed that and squashed the changes into the add-regression-test commit. |
Good work! |
The detailed-0.9 test suite type compiles the test module into a shared library,
so for running the tests, we need to include the directory where the shared
library is stored in LD_LIBRARY_PATH.