forked from haskell/cabal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test to check that build-tool-depends are used (haskell#10692)
The testcase is not so easy to write because * The bug only surfaces when the build-tool you are depending on is known (ie alex, happy etc) * But then it is tricky to write a test, as we can't depend on the known tools or bundle the source for them. * So we create a fake "alex", which cabal then invokes on a fake ".x" file. This is maybe a bit fragile if the way cabal invokes alex changes in future, but then the test can be modified as well. Ticket haskell#10692
- Loading branch information
1 parent
fafcb55
commit bb4ae8b
Showing
8 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
cabal-testsuite/PackageTests/BuildToolDependsExternal/cabal.project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
packages: client | ||
optional-packages: pre-proc |
3 changes: 3 additions & 0 deletions
3
cabal-testsuite/PackageTests/BuildToolDependsExternal/client/Hello.x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module Main where | ||
|
||
main = print 0 |
13 changes: 13 additions & 0 deletions
13
cabal-testsuite/PackageTests/BuildToolDependsExternal/client/client.cabal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
13 changes: 13 additions & 0 deletions
13
cabal-testsuite/PackageTests/BuildToolDependsExternal/pre-proc/MyCustomPreprocessor.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
17 changes: 17 additions & 0 deletions
17
cabal-testsuite/PackageTests/BuildToolDependsExternal/pre-proc/pre-proc.cabal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
4 changes: 4 additions & 0 deletions
4
cabal-testsuite/PackageTests/BuildToolDependsExternal/scripts/alex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#! /usr/bin/env bash | ||
|
||
echo "I am not the alex you are looking for" | ||
exit 1 |
14 changes: 14 additions & 0 deletions
14
cabal-testsuite/PackageTests/BuildToolDependsExternal/setup.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# cabal v2-build | ||
Configuration is affected by the following files: | ||
- cabal.project | ||
Resolving dependencies... | ||
Build profile: -w ghc-<GHCVER> -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... |
5 changes: 5 additions & 0 deletions
5
cabal-testsuite/PackageTests/BuildToolDependsExternal/setup.test.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] |