diff --git a/cabal-testsuite/PackageTests/BuildToolDependsExternal/cabal.project b/cabal-testsuite/PackageTests/BuildToolDependsExternal/cabal.project new file mode 100644 index 00000000000..359fdc811bd --- /dev/null +++ b/cabal-testsuite/PackageTests/BuildToolDependsExternal/cabal.project @@ -0,0 +1,2 @@ +packages: client +optional-packages: pre-proc diff --git a/cabal-testsuite/PackageTests/BuildToolDependsExternal/client/Hello.x b/cabal-testsuite/PackageTests/BuildToolDependsExternal/client/Hello.x new file mode 100644 index 00000000000..28f179506bf --- /dev/null +++ b/cabal-testsuite/PackageTests/BuildToolDependsExternal/client/Hello.x @@ -0,0 +1,3 @@ +module Main where + +main = print 0 diff --git a/cabal-testsuite/PackageTests/BuildToolDependsExternal/client/client.cabal b/cabal-testsuite/PackageTests/BuildToolDependsExternal/client/client.cabal new file mode 100644 index 00000000000..a13e99b682a --- /dev/null +++ b/cabal-testsuite/PackageTests/BuildToolDependsExternal/client/client.cabal @@ -0,0 +1,13 @@ +name: client +version: 0.1.0.0 +synopsis: Checks build-tool-depends are put in PATH +license: BSD3 +category: Testing +build-type: Simple +cabal-version: >=1.10 + +executable hello-world + main-is: Hello.hs + build-depends: base + build-tool-depends: pre-proc:alex + default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/BuildToolDependsExternal/pre-proc/MyCustomPreprocessor.hs b/cabal-testsuite/PackageTests/BuildToolDependsExternal/pre-proc/MyCustomPreprocessor.hs new file mode 100644 index 00000000000..bcc4af46d1c --- /dev/null +++ b/cabal-testsuite/PackageTests/BuildToolDependsExternal/pre-proc/MyCustomPreprocessor.hs @@ -0,0 +1,13 @@ +module Main where + +import System.Environment +import System.IO + +-- This is a "fake" version of alex, so it should take the command line arguments +-- as alex. +main :: IO () +main = do + (_:"-o":target:source:_) <- getArgs + let f '0' = '1' + f c = c + writeFile target . map f =<< readFile source diff --git a/cabal-testsuite/PackageTests/BuildToolDependsExternal/pre-proc/pre-proc.cabal b/cabal-testsuite/PackageTests/BuildToolDependsExternal/pre-proc/pre-proc.cabal new file mode 100644 index 00000000000..5724eb58296 --- /dev/null +++ b/cabal-testsuite/PackageTests/BuildToolDependsExternal/pre-proc/pre-proc.cabal @@ -0,0 +1,17 @@ +name: pre-proc +version: 999.999.999 +synopsis: Checks build-tool-depends are put in PATH +license: BSD3 +category: Testing +build-type: Simple +cabal-version: >=1.10 + +executable alex + main-is: MyCustomPreprocessor.hs + build-depends: base, directory + default-language: Haskell2010 + +executable bad-do-not-build-me + main-is: MyMissingPreprocessor.hs + build-depends: base, directory + default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/BuildToolDependsExternal/scripts/alex b/cabal-testsuite/PackageTests/BuildToolDependsExternal/scripts/alex new file mode 100755 index 00000000000..27bdc4e880d --- /dev/null +++ b/cabal-testsuite/PackageTests/BuildToolDependsExternal/scripts/alex @@ -0,0 +1,4 @@ +#! /usr/bin/env bash + +echo "I am not the alex you are looking for" +exit 1 diff --git a/cabal-testsuite/PackageTests/BuildToolDependsExternal/setup.out b/cabal-testsuite/PackageTests/BuildToolDependsExternal/setup.out new file mode 100644 index 00000000000..0600824409d --- /dev/null +++ b/cabal-testsuite/PackageTests/BuildToolDependsExternal/setup.out @@ -0,0 +1,14 @@ +# cabal v2-build +Configuration is affected by the following files: +- cabal.project +Resolving dependencies... +Build profile: -w ghc- -O1 +In order, the following will be built: + - pre-proc-999.999.999 (exe:alex) (first run) + - client-0.1.0.0 (exe:hello-world) (first run) +Configuring executable 'alex' for pre-proc-999.999.999... +Preprocessing executable 'alex' for pre-proc-999.999.999... +Building executable 'alex' for pre-proc-999.999.999... +Configuring executable 'hello-world' for client-0.1.0.0... +Preprocessing executable 'hello-world' for client-0.1.0.0... +Building executable 'hello-world' for client-0.1.0.0... diff --git a/cabal-testsuite/PackageTests/BuildToolDependsExternal/setup.test.hs b/cabal-testsuite/PackageTests/BuildToolDependsExternal/setup.test.hs new file mode 100644 index 00000000000..6575b355838 --- /dev/null +++ b/cabal-testsuite/PackageTests/BuildToolDependsExternal/setup.test.hs @@ -0,0 +1,5 @@ +import Test.Cabal.Prelude +-- Test build-tool-depends isn't influenced by PATH +main = cabalTest $ do + env <- getTestEnv + addToPath (testTmpDir env "scripts/") $ cabal "v2-build" ["client"]