ndmitchell / hoogle

Haskell API search engine
http://hoogle.haskell.org/
Other
753 stars 137 forks source link

Hoogle test suite fails in container environment #43

Closed peti closed 10 years ago

peti commented 10 years ago

builds in NixOS are run in a virtualized container environment without network access to ensure that builds are reproducible. Unfortunately, this means that Hoogle's test suite fails in our builds:

running tests
Running 1 test suites...
Test suite hoogle-test: RUNNING...
WARNING: Could not find command line program wget.
curl: (6) Couldn't resolve host 'www.haskell.org'
hoogle: Failed to download: http://www.haskell.org/haskellwiki/Keywords
hoogle-test: Command: dist/build/hoogle/hoogle data
Failed with: ExitFailure 1
Test suite hoogle-test: FAIL
Test suite logged to: dist/test/hoogle-4.2.26-hoogle-test.log
0 of 1 test suites (0 of 1 test cases) passed.

To fix the build, I've disabled the test suite entirely.

Now, I reckon there are probably tests in that suite which don't need Internet access? Is there any way to still run those tests?

ndmitchell commented 10 years ago

There are ways to run the tests that don't need internet access. Unfortunately the cabal test support doesn't seem to be able to pass arguments to the executable, as far as I could tell? I guess I can add checking an environment variable to find out I am under a non-internet VM? Any suggestions?

peti commented 10 years ago

I believe that these options could be used to pass flags to the test executables during cabal test:

--test-options=TEMPLATES give extra options to test executables (name
                         templates can use $pkgid, $compiler, $os, $arch,
                         $test-suite)
--test-option=TEMPLATE   give extra option to test executables (no need to
                         quote options containing spaces, name template can
                         use $pkgid, $compiler, $os, $arch, $test-suite)

Alternatively, the test suite could be split into two (or more) executables, and then we run only those executables that don't need Internet access during cabal test. We've used that option with good success in the dns library.

ndmitchell commented 10 years ago

It seems like --test-option= is the best approach. Any suggestions on what is easy to integrate on your side?

Given that hoogle-test is really just a 3 line program that calls the real hoogle, and I'm somewhat bitter that I can't just declare my test suite to be hoogle test (e.g. the normal binary with a command line), I'd rather stay away from adding more test binaries.

peti commented 10 years ago

How about calling the test program with --no-net to disable net work access? I don't feel strongly about the name of tha flag, though. Any choice is fine.

ndmitchell commented 10 years ago

I'll add a --no-net flag. Given the spate of Hoogle releases to fix .cabal issues, and my plans for some real upcoming changes, I'll probably leave this a few weeks. Shout if you think it should be more important.

ndmitchell commented 10 years ago

I've added the feature with --no-net flag. I'll close the bug once it's released on Hackage.

peti commented 10 years ago

Thank you for your help!

ndmitchell commented 10 years ago

Fixed in 4.2.27 - let me know if you have any issues with it. I really appreciate the help, testing and notifications I get from the NixOS packagers (and all the packagers in general) - it helps ensure my packages are "right" in all the ways it's easy to forget when just releasing to Hackage.