0

私の.cabalファイルには、次の hspec 構成が含まれています。

-- The name of the package.
name:                MyModule

version:             0.1.0.0

cabal-version:       >=1.10
...
test-suite my-tests
  ghc-options:         -Wall -Werror
  cpp-options:         -DTEST
  default-extensions:  OverloadedStrings
  type:                exitcode-stdio-1.0
  main-is:             HSpecTests.hs
  hs-source-dirs:      tests
  build-depends:       MyModule, base >= 4.8 && < 4.9, containers >= 0.5 && <0.6, split >= 0.2 && < 0.3, hspec
  default-language:    Haskell2010

私のディレクトリ構造は次のとおりです。

MyProject
     | - src
          | - Main.hs
          | - Other.hs
          | - tests
             | -HSpecTests.hs
     | - dist
     | - MyProj.cabal

を実行するcabal buildと、ソースが正常に実行可能ファイルにビルドされます./dist/build/myproj/myproj

cabal build次に失敗します:

cabal: can't find source for HSpecTests in
dist/build/my-tests/my-tests-tmp, tests

buildディレクトリを調べると、ディレクトリmy-testsが見つからないことがわかります。

を に変更すると、次のhs-source-dirsようになりsrc/tests ます。

cabal: can't find source for HSpecTests in 
dist/build/my-tests/my-tests-tmp, src/tests

すべてのテストをルート/テストの下の最上位に移動し、.cabalファイルを次のように変更すると、次のようになりますhs-source-dirs: tests

<command line>: cannot satisfy -package-id MyModule-0.1.0.0-inplace
    (use -v for more information)

これをどのように誤って構成しましたか?

4

2 に答える 2

0

次の 2 つの問題がありました。

1)(ファイル構造を軌道に乗せてくれた@Zetaに感謝します)、テストはルートレベルのtestsディレクトリにある必要がありました

2) ここに記載されているように:テスト スイートの作成中にエラーが発生しました: 「-package-id を満たすことができません」私のテストは実行可能ファイルに依存できず、ライブラリの作成が必要でした

于 2016-01-16T10:16:22.660 に答える