2011-12-27 62 views
8

我想我的第一個包上傳到Hackage(耶!),我得到這個錯誤:哈斯克爾:測試包對基地的多個版本Hackage

The dependency 'build-depends: base' does not specify an upper bound on the version number. Each major release of the 'base' package changes the API in various ways and most packages will need some changes to compile with it. The recommended practise is to specify an upper bound on the version of the 'base' package. This ensures your package will continue to build when a new major version of the 'base' package is released. If you are not sure what upper bound to use then use the next major version. For example if you have tested your package with 'base' version 2 and 3 then use 'build-depends: base >= 2 && < 4'.

這似乎是一個完全可以接受的有理由拒絕我的包裹。

是否有一個很好的工具來測試我的包與各種版本的base,所以我可以看到什麼是邊界(而不是隻是猜測)?我能想到的最好的方法是使用一些shell腳本來做類似的事情:

% for v in $BASE_VERSIONS 
do 
    cabal install base-$v &&\ 
    cabal configure --enable-tests &&\ 
    cabal build &&\ 
    cabal test && echo "$v ok" || echo "$v fail" 
done 

但是我覺得應該有更好的東西。

回答

9

這是一個非常糟糕的主意!您必須而不是升級基地或any other packages that come with GHC(在標籤欄中有-),否則一切都會崩潰。

使用較舊版本的基礎測試的唯一方法是安裝一個較舊的GHC並使用該版本進行測試。我建議在7.0.4和7.2.2上試試;支持舊版本可能是浪費時間。

如果不成功,只需指定base >= VERSION && < 5,其中VERSION是GHC的版本。或base == 4.*,並希望最好的:)

在所有嚴肅的情況下,基地的API並沒有真正改變那麼多,所以你不可能遇到很多問題。

爲了測試你的程序與各種版本的軟件包一般都不會干擾你的主要~/.cabal存儲庫,我強烈建議cabal-dev;像

$ cabal-dev install 'pkg==VERSION' 
$ cabal-dev install 
$ cabal-dev test 

應該這樣做。

順便說一句,你可以做cabal check在上傳你的包到Hackage之前得到警告。