-
Notifications
You must be signed in to change notification settings - Fork 691
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add exhaustive test suite for 'cabal path' cmd
We test that each query honours cabal.project files, cli parameters, and is composable with the other query flags. We extend the test output normalisers for ghc compiler location and cabal-install version, as the 'cabal path' command outputs the exact ghc and ghc-pkg location. In addition, the json output format is versioned on the cabal-install version. Currently, we query the cabal-install version on each test normalisation run. This might be unnecessary expensive, and could be avoided by introducing a 'cabalProgram' that specifies how the program version can be found. This way, we can cache the version query.
- Loading branch information
Showing
13 changed files
with
638 additions
and
13 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,27 @@ | ||
import Test.Cabal.Prelude | ||
import Data.List (subsequences) | ||
|
||
allOutputFormats = | ||
[ "json" | ||
, "key-value" | ||
] | ||
|
||
allFlags = | ||
[ "--compiler-info" | ||
, "--cache-dir" | ||
, "--logs-dir" | ||
, "--store-dir" | ||
, "--config-file" | ||
, "--installdir" | ||
] | ||
|
||
main = cabalTest $ do | ||
forM_ allOutputFormats $ \outputFormat -> do | ||
-- Order of flags should not matter, neither does any flag depend on the | ||
-- existence of any other flag. | ||
-- | ||
-- 'subsequences' generated "n over k" for k in (1 .. n) | ||
forM_ (subsequences allFlags) $ \flags -> do | ||
cabal "path" $ ["--output-format", outputFormat] <> flags | ||
|
||
|
||
main = cabalTest . void $ cabal "path" ["-z", "--output-format=key-value"] |
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,6 @@ | ||
# cabal path | ||
compiler-flavour: ghc | ||
compiler-id: ghc-<GHCVER> | ||
compiler-path: <GHCPATH> | ||
# cabal path | ||
{"cabal-install-version":"<CABAL_INSTALL_VER>","compiler":{"flavour":"ghc","id":"ghc-<GHCVER>","path":"<GHCPATH>"}} |
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,6 @@ | ||
import Test.Cabal.Prelude | ||
|
||
main = cabalTest $ do | ||
-- Basic output | ||
void $ cabal "path" ["-z", "--output-format=key-value", "--compiler-info"] | ||
void $ cabal "path" ["-z", "--output-format=json", "--compiler-info"] |
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,64 @@ | ||
# cabal path | ||
<ROOT>/cabal.dist/home/.cabal/packages | ||
# cabal path | ||
<ROOT>/cabal.dist/home/.cabal/logs | ||
# cabal path | ||
<ROOT>/cabal.dist/home/.cabal/store | ||
# cabal path | ||
<ROOT>/cabal.dist/home/.cabal/config | ||
# cabal path | ||
<ROOT>/cabal.dist/home/.cabal/bin | ||
# cabal path | ||
{"cabal-install-version":"<CABAL_INSTALL_VER>","cache-dir":"<ROOT>/cabal.dist/home/.cabal/packages"} | ||
# cabal path | ||
{"cabal-install-version":"<CABAL_INSTALL_VER>","logs-dir":"<ROOT>/cabal.dist/home/.cabal/logs"} | ||
# cabal path | ||
{"cabal-install-version":"<CABAL_INSTALL_VER>","store-dir":"<ROOT>/cabal.dist/home/.cabal/store"} | ||
# cabal path | ||
{"cabal-install-version":"<CABAL_INSTALL_VER>","config-file":"<ROOT>/cabal.dist/home/.cabal/config"} | ||
# cabal path | ||
{"cabal-install-version":"<CABAL_INSTALL_VER>","installdir":"<ROOT>/cabal.dist/home/.cabal/bin"} | ||
# cabal path | ||
test-dir | ||
# cabal path | ||
{"cabal-install-version":"<CABAL_INSTALL_VER>","store-dir":"test-dir"} | ||
# cabal path | ||
my-cache-dir | ||
# cabal path | ||
my-logs-dir | ||
# cabal path | ||
my-store-dir | ||
# cabal path | ||
fake-cabal.config | ||
# cabal path | ||
my-installdir | ||
# cabal path | ||
{"cabal-install-version":"<CABAL_INSTALL_VER>","cache-dir":"my-cache-dir"} | ||
# cabal path | ||
{"cabal-install-version":"<CABAL_INSTALL_VER>","logs-dir":"my-logs-dir"} | ||
# cabal path | ||
{"cabal-install-version":"<CABAL_INSTALL_VER>","store-dir":"my-store-dir"} | ||
# cabal path | ||
{"cabal-install-version":"<CABAL_INSTALL_VER>","config-file":"fake-cabal.config"} | ||
# cabal path | ||
{"cabal-install-version":"<CABAL_INSTALL_VER>","installdir":"my-installdir"} | ||
# cabal path | ||
my-cache-dir | ||
# cabal path | ||
my-logs-dir | ||
# cabal path | ||
my-store-dir | ||
# cabal path | ||
<ROOT>/cabal.dist/home/.cabal/config | ||
# cabal path | ||
my-installdir | ||
# cabal path | ||
{"cabal-install-version":"<CABAL_INSTALL_VER>","cache-dir":"my-cache-dir"} | ||
# cabal path | ||
{"cabal-install-version":"<CABAL_INSTALL_VER>","logs-dir":"my-logs-dir"} | ||
# cabal path | ||
{"cabal-install-version":"<CABAL_INSTALL_VER>","store-dir":"my-store-dir"} | ||
# cabal path | ||
{"cabal-install-version":"<CABAL_INSTALL_VER>","config-file":"<ROOT>/cabal.dist/home/.cabal/config"} | ||
# cabal path | ||
{"cabal-install-version":"<CABAL_INSTALL_VER>","installdir":"my-installdir"} |
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,43 @@ | ||
import Test.Cabal.Prelude | ||
|
||
main = cabalTest $ do | ||
-- Basic output | ||
void $ cabal "path" ["-z", "--output-format=key-value", "--cache-dir"] | ||
void $ cabal "path" ["-z", "--output-format=key-value", "--logs-dir"] | ||
void $ cabal "path" ["-z", "--output-format=key-value", "--store-dir"] | ||
void $ cabal "path" ["-z", "--output-format=key-value", "--config-file"] | ||
void $ cabal "path" ["-z", "--output-format=key-value", "--installdir"] | ||
-- Works for json, too | ||
void $ cabal "path" ["-z", "--output-format=json", "--cache-dir"] | ||
void $ cabal "path" ["-z", "--output-format=json", "--logs-dir"] | ||
void $ cabal "path" ["-z", "--output-format=json", "--store-dir"] | ||
void $ cabal "path" ["-z", "--output-format=json", "--config-file"] | ||
void $ cabal "path" ["-z", "--output-format=json", "--installdir"] | ||
-- Honours cli overwrites | ||
void $ cabalG ["--store-dir=test-dir"] "path" ["-z", "--output-format=key-value", "--store-dir"] | ||
void $ cabalG ["--store-dir=test-dir"] "path" ["-z", "--output-format=json", "--store-dir"] | ||
-- Honour config file overwrites: | ||
void $ cabalG ["--config-file=fake-cabal.config"] "path" ["-z", "--output-format=key-value", "--cache-dir"] | ||
void $ cabalG ["--config-file=fake-cabal.config"] "path" ["-z", "--output-format=key-value", "--logs-dir"] | ||
void $ cabalG ["--config-file=fake-cabal.config"] "path" ["-z", "--output-format=key-value", "--store-dir"] | ||
void $ cabalG ["--config-file=fake-cabal.config"] "path" ["-z", "--output-format=key-value", "--config-file"] | ||
void $ cabalG ["--config-file=fake-cabal.config"] "path" ["-z", "--output-format=key-value", "--installdir"] | ||
|
||
void $ cabalG ["--config-file=fake-cabal.config"] "path" ["-z", "--output-format=json", "--cache-dir"] | ||
void $ cabalG ["--config-file=fake-cabal.config"] "path" ["-z", "--output-format=json", "--logs-dir"] | ||
void $ cabalG ["--config-file=fake-cabal.config"] "path" ["-z", "--output-format=json", "--store-dir"] | ||
void $ cabalG ["--config-file=fake-cabal.config"] "path" ["-z", "--output-format=json", "--config-file"] | ||
void $ cabalG ["--config-file=fake-cabal.config"] "path" ["-z", "--output-format=json", "--installdir"] | ||
|
||
-- Honour cabal.project file | ||
void $ cabal "path" ["--project-file=fake.cabal.project", "--output-format=key-value", "--cache-dir"] | ||
void $ cabal "path" ["--project-file=fake.cabal.project", "--output-format=key-value", "--logs-dir"] | ||
void $ cabal "path" ["--project-file=fake.cabal.project", "--output-format=key-value", "--store-dir"] | ||
void $ cabal "path" ["--project-file=fake.cabal.project", "--output-format=key-value", "--config-file"] | ||
void $ cabal "path" ["--project-file=fake.cabal.project", "--output-format=key-value", "--installdir"] | ||
-- Works for json, too | ||
void $ cabal "path" ["--project-file=fake.cabal.project", "--output-format=json", "--cache-dir"] | ||
void $ cabal "path" ["--project-file=fake.cabal.project", "--output-format=json", "--logs-dir"] | ||
void $ cabal "path" ["--project-file=fake.cabal.project", "--output-format=json", "--store-dir"] | ||
void $ cabal "path" ["--project-file=fake.cabal.project", "--output-format=json", "--config-file"] | ||
void $ cabal "path" ["--project-file=fake.cabal.project", "--output-format=json", "--installdir"] |
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 @@ | ||
cabal-version: 3.0 | ||
name: config | ||
version: 0.1 | ||
|
||
library |
11 changes: 11 additions & 0 deletions
11
cabal-testsuite/PackageTests/Path/Config/fake-cabal.config
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,11 @@ | ||
-- this is a test file, dont use it | ||
repository hackage.haskell.org | ||
url: http://hackage.haskell.org/ | ||
-- secure: True | ||
-- root-keys: | ||
-- key-threshold: 3 | ||
|
||
logs-dir: my-logs-dir | ||
store-dir: my-store-dir | ||
remote-repo-cache: my-cache-dir | ||
installdir: my-installdir |
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,6 @@ | ||
packages: ./ | ||
|
||
logs-dir: my-logs-dir | ||
store-dir: my-store-dir | ||
remote-repo-cache: my-cache-dir | ||
installdir: my-installdir |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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