How should I go about testing a monolithic executable package?

让人想犯罪 __ 提交于 2019-12-06 00:50:51

It's completely okay to move modules to library stanza (or internal library stanza if you don't want to expose those modules).

How should I go about testing it, beside shell scripts?

There's a common practice in Haskell world to move everything (even main function) into library so your Main.hs would look like this:

module Main where

import MyLib as Lib (main)

main :: IO ()
main = Lib.main

With this approach you can test completely everything via Haskell unit testing libraries.

However, I am not sure the maintainers will approve of such radical change. Is there a less invasive way?

Well, if maintainers care about their package, they should agree to this refactoring if they want better testing.

If moving the packages to a (perhaps internal) library is not an option, you could simply add all the sources of the executable to the hs-source-dirs of the test suite, and also add the dependencies of the executable to the build-depends of the test suite.

This has the disadvantage that you'll compile the same files twice: once for the executable and once for the test suite.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!