Skip to content

Commit

Permalink
Add package test for --project-dir
Browse files Browse the repository at this point in the history
  • Loading branch information
cydparser committed Jan 30, 2023
1 parent 6f8f10f commit 9e726f1
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cabal-testsuite/PackageTests/ProjectDir/app/App.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Main where

main :: IO ()
main = pure ()
7 changes: 7 additions & 0 deletions cabal-testsuite/PackageTests/ProjectDir/app/app.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cabal-version: 3.6
name: app
version: 0.1

executable app
main-is: App.hs
build-depends: base
23 changes: 23 additions & 0 deletions cabal-testsuite/PackageTests/ProjectDir/cabal.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Test.Cabal.Prelude

main :: IO ()
main = cabalTest $ recordMode DoNotRecord $ do
env <- getTestEnv

let cwd = testCurrentDir env

-- Relative directory
cabal "v2-build" [ "--project-dir=proj", "all" ]

-- Absolute directory
cabal "v2-build" [ "--project-dir", (cwd </> "proj"), "all" ]

cabal "v2-clean" [ "--project-dir=proj" ]

withProjectFile "nix/cabal.project" $ do
cabal "v2-build" [ "--project-dir=proj", "extra" ]

cabal "v2-clean" [ "--project-dir=proj" ]

-- App with no cabal.project
void $ cabal_raw' [ "run", "--project-dir=app", "app" ] Nothing
4 changes: 4 additions & 0 deletions cabal-testsuite/PackageTests/ProjectDir/proj/App.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Main where

main :: IO ()
main = pure ()
4 changes: 4 additions & 0 deletions cabal-testsuite/PackageTests/ProjectDir/proj/Lib.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Lib where

x :: ()
x = ()
2 changes: 2 additions & 0 deletions cabal-testsuite/PackageTests/ProjectDir/proj/cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages: .

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages: .

package proj
flags: +extra
17 changes: 17 additions & 0 deletions cabal-testsuite/PackageTests/ProjectDir/proj/proj.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cabal-version: 3.8
name: proj
version: 0.1

flag extra
default: False
manual: True

library
build-depends: base
exposed-modules: Lib

executable extra
build-depends: base
main-is: App.hs
if !flag(extra)
buildable: False

0 comments on commit 9e726f1

Please sign in to comment.