diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1596006990..f02a53e996 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,7 +5,7 @@ "args": { "GHC_VERSION": "9.10.3", // "SUBTAG": "int-native", - "HLS_VERSION": "2.13.0.0", + "HLS_VERSION": "2.14.0.0", "USE_ZSH_FOR_ROOT": "unset-to-use-ash", "LANG": "C.UTF-8", "TZ": "" diff --git a/.devcontainer/ghc-9.12.3/devcontainer.json b/.devcontainer/ghc-9.12.4/devcontainer.json similarity index 94% rename from .devcontainer/ghc-9.12.3/devcontainer.json rename to .devcontainer/ghc-9.12.4/devcontainer.json index 4ba56636e9..67bbf5bc44 100644 --- a/.devcontainer/ghc-9.12.3/devcontainer.json +++ b/.devcontainer/ghc-9.12.4/devcontainer.json @@ -1,10 +1,10 @@ { - "name": "GHC 9.12.3 (experimental)", + "name": "GHC 9.12.4 (experimental)", "build": { "dockerfile": "../GHC.Dockerfile", "context": "..", "args": { - "GHC_VERSION": "9.12.3", + "GHC_VERSION": "9.12.4", // "SUBTAG": "int-native", "USE_ZSH_FOR_ROOT": "unset-to-use-ash", "LANG": "C.UTF-8", diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index ebbd2e38ae..daf617389d 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -5,7 +5,7 @@ about: Report a bug in Stack Please follow the steps below for reporting a bug in Stack: -Make sure that you are using the latest release (currently Stack 3.9.1). See the +Make sure that you are using the latest release (currently Stack 3.9.3). See the [upgrade instructions](http://docs.haskellstack.org/en/stable/install_and_upgrade/#upgrade) to upgrade. @@ -45,7 +45,7 @@ stack --verbose ~~~text stack --version -Version 3.9.1, Git revision 49377548db1244e55d577b2e4107cf8f8579e060 x86_64 hpack-0.39.1 +Version 3.9.3, Git revision c7eb8487a82d5c3e0b88d56f8b8a98be23223eb5 x86_64 hpack-0.39.1 ~~~ ### Method of installation diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 04d58b4dd1..699675f815 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -3,7 +3,7 @@ name: Feature Request about: Request a feature be added to Stack, or discuss such a feature --- -Make sure that you are using the latest release (currently Stack 3.9.1). See the +Make sure that you are using the latest release (currently Stack 3.9.3). See the [upgrade instructions](http://docs.haskellstack.org/en/stable/install_and_upgrade/#upgrade) to upgrade. diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md index 5b4aba2a2c..90e340d705 100644 --- a/.github/ISSUE_TEMPLATE/question.md +++ b/.github/ISSUE_TEMPLATE/question.md @@ -16,7 +16,7 @@ the [stack-templates](https://github.com/commercialhaskell/stack-templates) repository instead. If you still want to ask the question here instead, please make sure that you -are using the latest release (currently Stack 3.7.1). See the +are using the latest release (currently Stack 3.9.3). See the [upgrade instructions](http://docs.haskellstack.org/en/stable/install_and_upgrade/#upgrade) to upgrade. @@ -24,7 +24,7 @@ to upgrade. ~~~text stack --version -Version 3.9.1, Git revision 49377548db1244e55d577b2e4107cf8f8579e060 x86_64 hpack-0.39.1 +Version 3.9.3, Git revision c7eb8487a82d5c3e0b88d56f8b8a98be23223eb5 x86_64 hpack-0.39.1 ~~~ ### Method of installation diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 216721db97..cb05fa44f8 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -16,10 +16,13 @@ on: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# As of 2026-01-30, ubuntu-latest and windows-latest come with Stack 3.9.1 and -# GHC 9.14.1. However, macos-15-intel and macos-latest do not come with Haskell -# tools. windows-latest no longer comes with NSIS 3.10, for which the default -# value of the 'Unicode' installer attribute is 'true'. However, that is not the +# As of 2026-03-01: +# * ubuntu-latest comes with Stack 3.9.3 and GHC 9.14.1; and +# * windows-latest comes with Stack 3.9.1 and GHC 9.14.1. +# However, macos-15-intel and macos-latest do not come with Haskell tools. +# +# windows-latest no longer comes with NSIS 3.10, for which the default value of +# the 'Unicode' installer attribute is 'true'. However, that is not the # 'large strings' build of NSIS and creates installers that corrupt the PATH # environment variable if the default string length of 1024 characters is # exceeded. @@ -40,7 +43,7 @@ jobs: # Stack's project-level configuration (stack.yaml) specifies the # multi-architecture (including Linux/Aarch64) Docker image published # by Oliver Benz (@benz0li, on GitHub). That image comes with - # Stack 3.9.1. (Note that the online documentation for + # Stack 3.9.3. (Note that the online documentation for # '--docker-stack-exe image' specifies that the host Stack and image # Stack must have the same version number.) release-args: "--alpine --stack-args --docker-stack-exe=image" @@ -73,22 +76,23 @@ jobs: ~\AppData\Roaming\stack ~\AppData\Local\Programs\stack key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('stack.yaml') }}-${{ matrix.cache-bust }} - - name: Install NSIS 3.10 on Windows + - name: Install NSIS 3.12 on Windows if: startsWith(runner.os, 'Windows') - uses: repolevedavaj/install-nsis@v1.0.3 + uses: xavier2k6/install-nsis@nsis_envvarplugin_fix + # repolevedavaj/install-nsis@v1.2.0 with: - nsis-version: '3.10' + nsis-version: '3.12' # Upgrades to a 'large strings' build of NSIS 3.10 tool. See # https://nsis.sourceforge.io/Special_Builds. - - name: Upgrade NSIS 3.10 on Windows + - name: Upgrade NSIS 3.12 on Windows if: startsWith(runner.os, 'Windows') shell: bash run: | # wget is not available but the Stack-supplied MSYS2 will provide it - stack exec -- wget -O nsis-3.10-strlen_8192.zip https://downloads.sourceforge.net/nsis/NSIS%203/3.10/nsis-3.10-strlen_8192.zip - 7z x -aoa -o"/c/Program Files (x86)/NSIS" nsis-3.10-strlen_8192.zip + stack exec -- wget -O nsis-3.12-strlen_8192.zip https://downloads.sourceforge.net/nsis/NSIS%203/3.12/nsis-3.12-strlen_8192.zip + 7z x -aoa -o"/c/Program Files (x86)/NSIS" nsis-3.12-strlen_8192.zip # Clean up - rm nsis-3.10-strlen_8192.zip + rm nsis-3.12-strlen_8192.zip makensis -VERSION && echo # Should include defined symbol NSIS_MAX_STRLEN=8192 makensis -HDRINFO @@ -99,11 +103,21 @@ jobs: if [[ "${{ matrix.os }}" == "ubuntu-24.04-arm" || "${{ matrix.os }}" == "macos-15-intel" || "${{ matrix.os }}" == "macos-latest" ]] then - # ubuntu-24.04-arm, macos-15-intel and macos-latest do not include - # Haskell tools as at 2026-01-30. + # As at 2026-03-01: + # + # * ubuntu-24.04-arm, macos-15-intel and macos-latest do not include + # Haskell tools. curl -sSL https://get.haskellstack.org/ | sh fi + if [[ "${{ matrix.os }}" == "windows-latest" ]] + then + # As at 2026-03-01: + # + # * windows-latest does not include Stack 3.9.3. + stack upgrade + fi + if [[ "${{ matrix.os }}" == "ubuntu-latest" ]] then # Install a faster linker (lld) than Ubuntu's default. @@ -123,10 +137,10 @@ jobs: # Enter the Nix environment... . ~/.nix-profile/etc/profile.d/nix.sh # Add a channel named 'nixpkgs' to the list of subscribed channels... - nix-channel --add https://nixos.org/channels/nixos-23.05 nixpkgs + nix-channel --add https://nixos.org/channels/nixos-25.11 nixpkgs # Download the Nix expressions for all subscribed channels... # - # As at 2023-08-21, nixos-23.05 provides GHC 9.2.8. + # As at 2026-03-01, nixos-25.11 provides GHC 9.10.2. nix-channel --update # The NIX_PATH environment variable sets a list of directories used to # look up the location of Nix expressions using paths enclosed in @@ -151,14 +165,6 @@ jobs: EOF fi - # A temporary fix, due to Docker 29.0.0 and later producing an error - # message in a format not recognised by Stack 3.9.1 or earlier. See - # https://github.com/commercialhaskell/stack/issues/6848 - if [[ "${{ matrix.release-args }}" == "--alpine" ]] - then - docker pull quay.io/benz0li/ghc-musl:9.10.3 - fi - # In case GHCup hooks have been created, remove them if [ -d $(stack path --stack-root)/hooks ] then @@ -184,6 +190,7 @@ jobs: - name: Build bindist shell: bash run: | + git status stack etc/scripts/release.hs build ${{ matrix.release-args }} - name: Upload bindist diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 3abd28e94c..fd955780a5 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -9,8 +9,10 @@ on: - rc/** workflow_dispatch: -# As of 2026-01-30, ubuntu-latest and windows-latest come with Stack 3.9.1 -# and GHC 9.14.1. However, macos-latest does not come with Haskell tools. +# As of 2026-03-01: +# * ubuntu-latest comes with Stack 3.9.3 and GHC 9.14.1; and +# * windows-latest comes with Stack 3.9.1 and GHC 9.14.1. +# However, macos-15-intel and macos-latest do not come with Haskell tools. jobs: pedantic: @@ -76,10 +78,20 @@ jobs: if [[ "${{ matrix.os }}" == "macos-latest" ]] then - # macos-latest does not include Haskell tools as at 2026-01-30. + # As at 2026-03-01: + # + # * macos-latest does not include Haskell tools. curl -sSL https://get.haskellstack.org/ | sh fi + if [[ "${{ matrix.os }}" == "windows-latest" ]] + then + # As at 2026-03-01: + # + # * windows-latest does not include Stack 3.9.3. + stack upgrade + fi + if [[ "${{ matrix.extra-suffix }}" == "alpine" ]] then mkdir -p ~/.stack @@ -93,14 +105,6 @@ jobs: EOF fi - # A temporary fix, due to Docker 29.0.0 and later producing an error - # message in a format not recognised by Stack 3.9.1 or earlier. See - # https://github.com/commercialhaskell/stack/issues/6848 - if [[ "${{ matrix.extra-suffix }}" == "alpine" ]] - then - docker pull quay.io/benz0li/ghc-musl:9.10.3 - fi - stack test ${{ matrix.stack-args }} --haddock --no-haddock-deps --ghc-options="-Werror -O0" --copy-bins --local-bin-path bin # Get output about whether the exe is dynamically linked diff --git a/.stan.toml b/.stan.toml index 586019edb7..299b627745 100644 --- a/.stan.toml +++ b/.stan.toml @@ -67,57 +67,57 @@ # Infinite: base/isSuffixOf # Usage of the 'isSuffixOf' function that hangs on infinite lists [[ignore]] - id = "OBS-STAN-0102-luLR/n-533:30" + id = "OBS-STAN-0102-luLR/n-540:30" # ✦ Category: #Infinite #List # ✦ File: src\Stack\New.hs # -# 532 ┃ -# 533 ┃ let isPkgSpec f = ".cabal" `L.isSuffixOf` f || "package.yaml" `L.isSuffixOf` f -# 534 ┃ ^^^^^^^^^^^^^^ +# 539 ┃ +# 540 ┃ let isPkgSpec f = ".cabal" `L.isSuffixOf` f || "package.yaml" `L.isSuffixOf` f +# 541 ┃ ^^^^^^^^^^^^^^ # Infinite: base/isSuffixOf # Usage of the 'isSuffixOf' function that hangs on infinite lists [[ignore]] - id = "OBS-STAN-0102-luLR/n-533:65" + id = "OBS-STAN-0102-luLR/n-540:65" # ✦ Category: #Infinite #List # ✦ File: src\Stack\New.hs # -# 532 ┃ -# 533 ┃ let isPkgSpec f = ".cabal" `L.isSuffixOf` f || "package.yaml" `L.isSuffixOf` f -# 534 ┃ ^^^^^^^^^^^^^^ +# 539 ┃ +# 540 ┃ let isPkgSpec f = ".cabal" `L.isSuffixOf` f || "package.yaml" `L.isSuffixOf` f +# 541 ┃ ^^^^^^^^^^^^^^ # Infinite: ghc-internal/isSuffixOf # Usage of the 'isSuffixOf' function that hangs on infinite lists [[ignore]] - id = "OBS-STAN-0102-8cspI6-400:41" + id = "OBS-STAN-0102-8cspI6-404:41" # ✦ Category: #Infinite #List # ✦ File: src\Stack\Coverage.hs # -# 399 ┃ -# 400 ┃ pure (filter ((".tix" `L.isSuffixOf`) . toFilePath) files) -# 401 ┃ ^^^^^^^^^^^^^^ +# 403 ┃ +# 404 ┃ pure (filter ((".tix" `L.isSuffixOf`) . toFilePath) files) +# 405 ┃ ^^^^^^^^^^^^^^ # Infinite: ghc-internal/isSuffixOf # Usage of the 'isSuffixOf' function that hangs on infinite lists [[ignore]] - id = "OBS-STAN-0102-8cspI6-433:31" + id = "OBS-STAN-0102-8cspI6-437:31" # ✦ Category: #Infinite #List # ✦ File: src\Stack\Coverage.hs # -# 432 ┃ -# 433 ┃ pure (filter ((".tix" `L.isSuffixOf`) . toFilePath) files) -# 434 ┃ ^^^^^^^^^^^^^^ +# 436 ┃ +# 437 ┃ pure (filter ((".tix" `L.isSuffixOf`) . toFilePath) files) +# 438 ┃ ^^^^^^^^^^^^^^ # Infinite: ghc-internal/isSuffixOf # Usage of the 'isSuffixOf' function that hangs on infinite lists [[ignore]] - id = "OBS-STAN-0102-8cspI6-664:30" + id = "OBS-STAN-0102-8cspI6-668:30" # ✦ Category: #Infinite #List # ✦ File: src\Stack\Coverage.hs # -# 663 ┃ -# 664 ┃ pure (filter ((".tix" `L.isSuffixOf`) . toFilePath) files) -# 665 ┃ ^^^^^^^^^^^^^^ +# 667 ┃ +# 668 ┃ pure (filter ((".tix" `L.isSuffixOf`) . toFilePath) files) +# 669 ┃ ^^^^^^^^^^^^^^ # Infinite: ghc-internal/isSuffixOf # Usage of the 'isSuffixOf' function that hangs on infinite lists @@ -140,25 +140,25 @@ # Anti-pattern: Data.ByteString.Char8.pack [[ignore]] - id = "OBS-STAN-0203-erw24B-1043:3" + id = "OBS-STAN-0203-erw24B-1138:3" # ✦ Description: Usage of 'pack' function that doesn't handle Unicode characters # ✦ Category: #AntiPattern # ✦ File: src\Stack\Build\ExecuteEnv.hs # -# 1042 ┃ -# 1043 ┃ S8.pack . formatTime defaultTimeLocale "%Y-%m-%dT%H:%M:%S%6Q" -# 1044 ┃ ^^^^^^^ +# 1137 ┃ +# 1138 ┃ S8.pack . formatTime defaultTimeLocale "%Y-%m-%dT%H:%M:%S%6Q" +# 1139 ┃ ^^^^^^^ # Anti-pattern: Data.ByteString.Char8.pack [[ignore]] - id = "OBS-STAN-0203-tuE+RG-249:24" + id = "OBS-STAN-0203-tuE+RG-252:24" # ✦ Description: Usage of 'pack' function that doesn't handle Unicode characters # ✦ Category: #AntiPattern # ✦ File: src\Stack\Build\ExecutePackage.hs # -# 248 ┃ -# 249 ┃ newConfigFileRoot <- S8.pack . toFilePath <$> view configFileRootL -# 250 ┃ ^^^^^^^ +# 251 ┃ +# 252 ┃ newConfigFileRoot <- S8.pack . toFilePath <$> view configFileRootL +# 253 ┃ ^^^^^^^ # Anti-pattern: Data.ByteString.Char8.pack [[ignore]] @@ -258,36 +258,36 @@ # Anti-pattern: unsafe functions [[ignore]] - id = "OBS-STAN-0212-FNS1cF-67:17" + id = "OBS-STAN-0212-FNS1cF-68:17" # ✦ Description: Usage of unsafe functions breaks referential transparency # ✦ Category: #Unsafe #AntiPattern # ✦ File: src\Stack\BuildOpts.hs # -# 66 ┃ -# 67 ┃ buildMonoid = undefined :: BuildOptsMonoid -# 68 ┃ ^^^^^^^^^ +# 67 ┃ +# 68 ┃ buildMonoid = undefined :: BuildOptsMonoid +# 69 ┃ ^^^^^^^^^ # Anti-pattern: unsafe functions [[ignore]] - id = "OBS-STAN-0212-FNS1cF-79:14" + id = "OBS-STAN-0212-FNS1cF-81:14" # ✦ Description: Usage of unsafe functions breaks referential transparency # ✦ Category: #Unsafe #AntiPattern # ✦ File: src\Stack\BuildOpts.hs # -# 78 ┃ -# 79 ┃ toMonoid = undefined :: TestOptsMonoid -# 80 ┃ ^^^^^^^^^ +# 79 ┃ +# 80 ┃ toMonoid = undefined :: TestOptsMonoid +# 81 ┃ ^^^^^^^^^ # Anti-pattern: unsafe functions [[ignore]] - id = "OBS-STAN-0212-FNS1cF-90:15" + id = "OBS-STAN-0212-FNS1cF-92:15" # ✦ Description: Usage of unsafe functions breaks referential transparency # ✦ Category: #Unsafe #AntiPattern # ✦ File: src/Stack/BuildOpts.hs # -# 89 ┃ -# 90 ┃ beoMonoid = undefined :: BenchmarkOptsMonoid -# 91 ┃ ^^^^^^^^^ +# 90 ┃ +# 91 ┃ beoMonoid = undefined :: BenchmarkOptsMonoid +# 92 ┃ ^^^^^^^^^ # Anti-pattern: Pattern matching on '_' # Pattern matching on '_' for sum types can create maintainability issues diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2b6c3147df..b343ccabe6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -351,10 +351,11 @@ compatibility with a range of versions of GHC that a library package (such as Stack aims to depend on well-known packages. The specific versions on which it depends at any time are specified by `package.yaml` and `stack.yaml`. It does not aim to be compatible with more than one version of the `Cabal` package at -any time. At the time of writing (January 2026) the package versions are -primarily ones in Stackage snapshot LTS Haskell 24.24 (for GHC 9.10.3), the -latest version of `Cabal` released on Hackage (`Cabal-3.16.0.0`), -`pantry-0.11.2`, and `persistent-2.18.0.0`. +any time. At the time of writing (May 2026) the package versions are +primarily ones in Stackage snapshot LTS Haskell 24.43 (for GHC 9.10.3), the +latest version of `Cabal` released on Hackage (`Cabal-3.16.1.0`), +`pantry-0.11.2`, `persistent-2.18.1.0` and the latest version of packages in +the `tls` family (which reduce dependencies on unmaintained packages). A Stack executable makes use of Cabal (the library) through a small 'Setup' executable that it compiles from Haskell source code. The executable compiles diff --git a/ChangeLog.md b/ChangeLog.md index 814ce8a845..06e321580f 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,98 @@ # Changelog +## Unreleased changes + +Release notes: + +**Changes since v3.11.1:** + +Major changes: + +* On 64-bit Windows, the default `msys-environment` configuration option is now + `CLANG64`, rather than `MINGW64` (which remains an option). The MSYS2 project + deprecated the latter environment on 15 March 2026. The GHC project has used + the former toolchain from GHC 9.4.1. No default is provided for 32-bit + Windows, rather than `MINGW32` (which remains an option). The MSYS2 project + ceased to actively support it on 17 May 2020. 32-bit Windows is not supported + by the GHC project from GHC 8.12. + +Behavior changes: + +Other enhancements: + +Bug fixes: + +* On Windows, Stack's `build` command now accepts a build directory that is a + long path. + +## v3.11.1 - 2026-05-30 + +**Changes since v3.9.3:** + +Behavior changes: + +* Stack's default Nix integration now includes the `cacert` Nix package, in + order to support Stack's use of `crypton-x509-system >= 1.6.8`. +* Following a change to the Stackage project's server API, the default value of + the `urls` key includes + `recent-snapshots: https://stackage.org/api/v1/snapshots`. +* The `--[no-]keep-ghc-rts` flag of Stack's `config env` command is now enabled + by default, consistent with Stack's `exec` command. +* On Windows, in the Stack environment, the MSYS2 `usr/local/bin` directory (if + it exists) is now searched before the MSYS2 `usr/bin` directory, rather than + after. + +Other enhancements: + +* Bump to Hpack 0.39.5. +* Experimental: Add flag `--[no-]semaphore` (default: disabled) to Stack's + `build` command, to allow GHC to use a system semaphore to perform compilation + in parallel when possible. Supported, by default, by GHC 9.10.1 or later. The + option is considered experiemental because, on Linux only, musl and non-musl + semaphores are incompatible. +* Add option `--reach ` to Stack's `dot` and `ls dependencies` + commands, to prune packages that cannot reach any of the specified packages in + the dependency graph. +* Add option `--test-suite-timeout-grace=SECONDS` to Stack's `build` command to + request termination of a timed-out test suite process and, after the specified + grace period, force termination. Used together with the existing + `--test-suite-timeout=SECONDS` option. +* In YAML configuration files, the `recent-snapshots` key is introduced (under + the `urls` key), to specify the URL used by Stack's `ls snapshots remote` + command. +* In YAML configuration files (`stack.yaml` and `config.yaml`), an + `!include ` directive is now supported. This allows common + configuration to be shared across multiple files. For example, a project that + maintains multiple project-level configuration files for testing against + different snapshots can use `!include` to avoid duplicating shared settings. +* Stack's `config set` command raises an error if the target configuration file + excludes the key being set and includes an `!include` directive. +* Stack's `config set snapshot` command now works with other snapshot values + in addition to snapshot synonymns. +* Add Stack's `config compiler-tools` command to create (when applicable) the + compiler tools directory for the specified compiler version (implies Stack's + `config build-files` command). + +Bug fixes: + +* Stack's `dot` and `ls dependencies` commands no longer prune a package with + dependencies only because all its direct dependencies are to be pruned. +* After March 2026, Hackage requires Stack's user agent to be set when applying + digest authentication to a request. Stack's `upload` command now does that, + re-establishing authentication by Hackage username and password. +* Stack 3.9.3 and earlier fail to construct a build plan if project package A + depends on project package B and package B's executables (only) depend on + package A and the name of A is before that of B, alphabetically. That bug is + fixed. +* Stack's `config set` commands will recreate the `global-project` directory + contents, if Stack needs to consult its project-level configuration file and + there is no file. +* The output of Stack's `path --bin-path` command is now consistent with the + Stack environment in Stack's `exec` command and includes the `bin` directory + of Stack's local install root directory. +* Stack now builds packages that depend directly on packages with the same name + as a sublibrary or foreign library of the package. + ## v3.9.3 - 2026-02-19 Release notes: @@ -128,7 +221,7 @@ Other enhancements: documentation. * `stack sdist` and `stack upload` report the version of Cabal (the library) being used to check packages. -* Add the `stack config build-files` command to generate (when applicable) a +* Add Stack's `config build-files` command to generate (when applicable) a Cabal file from a package description in the Hpack format and/or a lock file for Stack's project-level configuration, without taking any other build steps. diff --git a/cabal.config b/cabal.config index f98d194646..65dce650f1 100644 --- a/cabal.config +++ b/cabal.config @@ -1,42 +1,41 @@ constraints: - , Cabal ==3.16.0.0 - , Cabal-syntax ==3.16.0.0 + , Cabal ==3.16.1.0 + , Cabal-syntax ==3.16.1.0 , Glob ==0.10.2 - , OneTuple ==0.4.2 + , OneTuple ==0.4.3 , QuickCheck ==2.15.0.1 , StateVar ==1.2.2 , Win32 ==2.14.1.0 - , aeson ==2.2.3.0 + , aeson ==2.2.5.0 , aeson-warning-parser ==0.1.1 - , alex ==3.5.4.0 + , alex ==3.5.4.2 , annotated-wl-pprint ==0.7.0 - , ansi-terminal ==1.1.4 + , ansi-terminal ==1.1.5 , ansi-terminal-types ==1.1.3 , appar ==0.1.8 , array ==0.5.8.0 - , asn1-encoding ==0.9.6 - , asn1-parse ==0.9.5 - , asn1-types ==0.3.4 , assoc ==1.1.1 - , async ==2.2.5 + , async ==2.2.6 , atomic-counter ==0.1.2.4 , attoparsec ==0.14.4 , attoparsec-aeson ==2.2.2.0 , auto-update ==0.2.6 , base ==4.20.2.0 - , base-orphans ==0.9.3 + , base-orphans ==0.9.4 + , base16 ==1.0 , base16-bytestring ==1.0.2.0 + , base64 ==1.0 , base64-bytestring ==1.2.1.0 , basement ==0.0.16 - , bifunctors ==5.6.2 + , bifunctors ==5.6.3 , binary ==0.8.9.3 - , bitvec ==1.1.5.0 + , bitvec ==1.1.6.0 , blaze-builder ==0.4.4.1 , blaze-html ==0.9.2.0 , blaze-markup ==0.8.3.0 , byteorder ==1.0.4 , bytestring ==0.12.2.0 - , casa-client ==0.0.3 + , casa-client ==0.0.4 , casa-types ==0.0.3 , case-insensitive ==1.2.1.0 , cborg ==0.2.10.0 @@ -44,46 +43,50 @@ constraints: , character-ps ==0.1 , clock ==0.8.4 , cmdargs ==0.10.22 - , colour ==2.3.6 - , comonad ==5.0.9 + , colour ==2.3.7 + , comonad ==5.0.10 , companion ==0.1.0 , conduit ==1.3.6.1 , conduit-combinators ==1.3.0 , conduit-extra ==1.3.8 , containers ==0.7 - , contravariant ==1.5.5 + , contravariant ==1.5.6 , cookie ==0.5.1 , cryptohash-sha256 ==0.11.102.1 - , crypton ==1.0.4 + , crypton ==1.0.6 + , crypton-asn1-encoding ==0.10.0 + , crypton-asn1-parse ==0.10.0 + , crypton-asn1-types ==0.4.1 , crypton-conduit ==0.2.3 , crypton-connection ==0.4.5 + , crypton-pem ==0.3.0 , crypton-socks ==0.6.2 - , crypton-x509 ==1.7.7 - , crypton-x509-store ==1.6.12 - , crypton-x509-system ==1.6.7 - , crypton-x509-validation ==1.6.14 - , data-default ==0.8.0.1 + , crypton-x509 ==1.8.0 + , crypton-x509-store ==1.8.0 + , crypton-x509-system ==1.8.0 + , crypton-x509-validation ==1.8.0 + , data-default ==0.8.0.2 , data-default-class ==0.2.0.0 , data-fix ==0.3.4 , deepseq ==1.5.0.0 , digest ==0.0.2.1 , directory ==1.3.8.5 , directory-ospath-streaming ==0.2.2 - , distributive ==0.6.2.1 + , distributive ==0.6.3 , dlist ==1.0 , easy-file ==0.2.5 + , ech-config ==0.0.1 , echo ==0.1.4 , ed25519 ==0.0.5.0 , exceptions ==0.10.9 , extra ==1.8.1 , fast-logger ==3.2.6 , file-embed ==0.0.16.0 - , file-io ==0.1.5 - , filelock ==0.1.1.8 + , file-io ==0.1.6 + , filelock ==0.1.1.9 , filepath ==1.5.4.0 , fsnotify ==0.4.4.0 - , generic-deriving ==1.14.6 - , generically ==0.1.1 + , generic-deriving ==1.14.7 , ghc-bignum ==1.3 , ghc-boot ==9.10.3 , ghc-boot-th ==9.10.3 @@ -95,25 +98,25 @@ constraints: , half ==0.3.3 , happy ==2.1.7 , happy-lib ==2.1.7 - , hashable ==1.5.0.0 + , hashable ==1.5.1.0 , haskell-src-exts ==1.23.1 , haskell-src-meta ==0.8.15 , hi-file-parser ==0.1.8.0 - , hourglass ==0.2.12 - , hpack ==0.39.1 + , hpack ==0.39.5 , hpc ==0.7.0.2 - , http-api-data ==0.6.2 + , hpke ==0.0.0 + , http-api-data ==0.6.3 , http-client ==0.7.19 , http-client-tls ==0.3.6.4 , http-conduit ==2.3.9.1 , http-download ==0.2.1.0 , http-types ==0.12.4 - , indexed-traversable ==0.1.4 - , indexed-traversable-instances ==0.1.2 + , indexed-traversable ==0.1.5 + , indexed-traversable-instances ==0.1.2.1 , infer-license ==0.2.0 , integer-conversion ==0.1.1 , integer-gmp ==1.1 - , integer-logarithms ==1.0.4 + , integer-logarithms ==1.0.5 , iproute ==1.7.15 , libyaml ==0.1.4 , libyaml-clib ==0.2.5 @@ -124,7 +127,7 @@ constraints: , microlens ==0.4.14.0 , microlens-mtl ==0.2.1.0 , microlens-th ==0.4.3.17 - , mime-types ==0.1.2.0 + , mime-types ==0.1.2.2 , mintty ==0.1.4 , monad-control ==1.0.3.1 , monad-logger ==0.3.42 @@ -135,26 +138,26 @@ constraints: , mustache ==2.4.3.1 , neat-interpolation ==0.5.1.4 , network ==3.2.8.0 + , network-byte-order ==0.1.8 , network-uri ==2.6.4.2 , old-locale ==1.0.0.7 - , old-time ==1.1.0.4 + , old-time ==1.1.1.0 , open-browser ==0.4.0.0 , optparse-applicative ==0.18.1.0 , optparse-simple ==0.1.1.4 , os-string ==2.0.7 , pantry ==0.11.2 , parsec ==3.1.18.0 - , parser-combinators ==1.3.0 + , parser-combinators ==1.3.1 , path ==0.9.6 , path-io ==1.8.2 , path-pieces ==0.2.1 - , pem ==0.2.4 - , persistent ==2.18.0.0 + , persistent ==2.18.1.0 , persistent-sqlite ==2.13.3.1 , persistent-template ==2.12.0.0 , pretty ==1.1.3.6 - , prettyprinter ==1.7.1 - , prettyprinter-ansi-terminal ==1.1.3 + , prettyprinter ==1.7.2 + , prettyprinter-ansi-terminal ==1.1.4 , primitive ==0.9.1.0 , process ==1.6.26.1 , project-template ==0.2.1.0 @@ -165,21 +168,22 @@ constraints: , retry ==0.9.3.1 , rio ==0.1.24.0 , rio-orphans ==0.1.2.0 - , rio-prettyprint ==0.1.8.0 + , rio-prettyprint ==0.1.9.0 , rts ==1.0.2 , safe ==0.3.21 , safe-exceptions ==0.1.7.4 - , scientific ==0.3.8.0 - , semialign ==1.3.1 - , semigroupoids ==6.0.1 + , scientific ==0.3.8.1 + , semaphore-compat ==1.0.0 + , semialign ==1.3.1.1 + , semigroupoids ==6.0.2 , serialise ==0.2.6.1 , silently ==1.2.5.4 , split ==0.2.5 - , splitmix ==0.1.3.1 - , stack ==3.9.4 + , splitmix ==0.1.3.2 + , stack ==3.12.0 , static-bytes ==0.1.1 , stm ==2.5.3.1 - , stm-chans ==3.0.0.9 + , stm-chans ==3.0.0.11 , streaming-commons ==0.2.3.1 , strict ==0.5.1 , string-interpolate ==0.3.4.0 @@ -187,27 +191,28 @@ constraints: , tagged ==0.8.9 , tar ==0.6.4.0 , tar-conduit ==0.4.1 - , tasty ==1.5.3 + , tasty ==1.5.4 , template-haskell ==2.22.0.0 , temporary ==1.3 , text ==2.1.3 , text-conversions ==0.3.1.1 - , text-iso8601 ==0.1.1 + , text-iso8601 ==0.1.1.1 , text-metrics ==0.3.3 - , text-short ==0.1.6 - , th-abstraction ==0.7.1.0 - , th-compat ==0.1.6 + , text-short ==0.1.6.1 + , th-abstraction ==0.7.2.0 + , th-compat ==0.1.7 , th-expand-syns ==0.4.12.0 - , th-lift ==0.8.6 + , th-lift ==0.8.7 , th-lift-instances ==0.1.20 - , th-orphans ==0.13.16 + , th-orphans ==0.13.17 , th-reify-many ==0.1.10 , these ==1.2.1 , time ==1.12.2 - , time-compat ==1.9.8 - , tls ==2.1.8 + , time-compat ==1.9.9 + , time-hourglass ==0.3.0 + , tls ==2.2.2 , transformers ==0.6.1.1 - , transformers-base ==0.4.6 + , transformers-base ==0.4.6.1 , transformers-compat ==0.7.2 , typed-process ==0.2.13.0 , unix ==2.8.6.0 @@ -217,8 +222,8 @@ constraints: , unliftio-core ==0.2.1.0 , unordered-containers ==0.2.20.1 , utf8-string ==1.0.2 - , uuid-types ==1.0.6 - , vault ==0.3.1.5 + , uuid-types ==1.0.6.1 + , vault ==0.3.1.6 , vector ==0.13.2.0 , vector-algorithms ==0.9.1.0 , vector-stream ==0.1.0.1 @@ -226,4 +231,4 @@ constraints: , yaml ==0.11.11.2 , zip-archive ==0.4.3.2 , zlib ==0.7.1.1 - , zlib-clib ==1.3.1 + , zlib-clib ==1.3.2 diff --git a/cabal.project b/cabal.project index 6b8e022627..bff0e92d82 100644 --- a/cabal.project +++ b/cabal.project @@ -33,7 +33,7 @@ -- specified by the snapshot specifed in Stack's project-level YAML -- configuration file (`stack.yaml`). The relevant version of GHC can be -- confirmed by reviewing the snapshot on Stackage. For example, at: --- https://www.stackage.org/lts-24.24/cabal.config. +-- https://www.stackage.org/lts-24.43/cabal.config. -- with-compiler: ghc-9.10.3 import: cabal.config diff --git a/doc/commands/bench_command.md b/doc/commands/bench_command.md index 52ff529810..e4b014b39e 100644 --- a/doc/commands/bench_command.md +++ b/doc/commands/bench_command.md @@ -16,12 +16,13 @@ stack bench [TARGET] [--dry-run] [--pedantic] [--fast] [--ghc-options OPTIONS] [--[no-]copy-bins] [--[no-]copy-compiler-tool] [--[no-]prefetch] [--[no-]keep-going] [--[no-]keep-tmp-files] [--[no-]force-dirty] [--[no-]test] [--[no-]rerun-tests] [--ta|--test-arguments TEST_ARGS] - [--coverage] [--[no-]run-tests] [--test-suite-timeout ARG] - [--[no-]tests-allow-stdin] [--[no-]bench] - [--ba|--benchmark-arguments BENCH_ARGS] [--[no-]run-benchmarks] - [--[no-]reconfigure] [--cabal-verbosity VERBOSITY | - --[no-]cabal-verbose] [--[no-]split-objs] [--skip ARG] - [--[no-]interleaved-output] [--ddump-dir ARG] + [--coverage] [--[no-]run-tests] [--test-suite-timeout SECONDS] + [--test-suite-timeout-grace SECONDS] [--[no-]tests-allow-stdin] + [--[no-]bench] [--ba|--benchmark-arguments BENCH_ARGS] + [--[no-]run-benchmarks] [--[no-]reconfigure] + [--cabal-verbosity VERBOSITY | --[no-]cabal-verbose] + [--[no-]split-objs] [--skip ARG] [--[no-]interleaved-output] + [--ddump-dir ARG] ~~~ `stack bench` is a synonym for `stack build --bench`. For further information, diff --git a/doc/commands/build_command.md b/doc/commands/build_command.md index 8d1e7571dc..5eaf19a5c0 100644 --- a/doc/commands/build_command.md +++ b/doc/commands/build_command.md @@ -7,21 +7,23 @@ stack build [TARGET] [--dry-run] [--pedantic] [--fast] [--ghc-options OPTIONS] [--flag PACKAGE:[-]FLAG] [--dependencies-only | --only-snapshot | --only-dependencies | --only-locals] [--file-watch | --file-watch-poll] [--watch-all] [--exec COMMAND [ARGUMENT(S)]] - [--only-configure] [--trace] [--profile] [--no-strip] - [--[no-]library-profiling] [--[no-]executable-profiling] - [--[no-]library-stripping] [--[no-]executable-stripping] - [--[no-]haddock] [--haddock-arguments HADDOCK_ARGS] - [--[no-]open] [--[no-]haddock-deps] [--[no-]haddock-internal] + [--only-configure] [--[no-]semaphore] [--trace] [--profile] + [--no-strip] [--[no-]library-profiling] + [--[no-]executable-profiling] [--[no-]library-stripping] + [--[no-]executable-stripping] [--[no-]haddock] + [--haddock-arguments HADDOCK_ARGS] [--[no-]open] + [--[no-]haddock-deps] [--[no-]haddock-internal] [--[no-]haddock-hyperlink-source] [--[no-]haddock-for-hackage] [--[no-]copy-bins] [--[no-]copy-compiler-tool] [--[no-]prefetch] [--[no-]keep-going] [--[no-]keep-tmp-files] [--[no-]force-dirty] [--[no-]test] [--[no-]rerun-tests] [--ta|--test-arguments TEST_ARGS] - [--coverage] [--[no-]run-tests] [--test-suite-timeout ARG] - [--[no-]tests-allow-stdin] [--[no-]bench] - [--ba|--benchmark-arguments BENCH_ARGS] [--[no-]run-benchmarks] - [--[no-]reconfigure] [--cabal-verbosity VERBOSITY | - --[no-]cabal-verbose] [--[no-]split-objs] [--skip ARG] - [--[no-]interleaved-output] [--ddump-dir ARG] + [--coverage] [--[no-]run-tests] [--test-suite-timeout SECONDS] + [--test-suite-timeout-grace SECONDS] [--[no-]tests-allow-stdin] + [--[no-]bench] [--ba|--benchmark-arguments BENCH_ARGS] + [--[no-]run-benchmarks] [--[no-]reconfigure] + [--cabal-verbosity VERBOSITY | --[no-]cabal-verbose] + [--[no-]split-objs] [--skip ARG] [--[no-]interleaved-output] + [--ddump-dir ARG] ~~~ `stack build` and its synonyms (`stack test`, `stack bench`, `stack haddock` and @@ -826,6 +828,24 @@ suite in a timeout so that the test suite fails if no result is available within the specified number of seconds. The option is ignored if the number of seconds is not positive. +!!! note + + The `--test-suite-timeout` option, in isolation, is not guaranteed to + terminate a timed-out test suite process. In that regard, see the + [`--test-suite-timeout-grace`](#-test-suite-timeout-option). + +### `--test-suite-timeout-grace` option + +Default: None + +`stack build --test --test-suite-timeout= --test-suite-timeout-grace=` +uses staged timeout termination for each running test suite: if +[`--test-suite-timeout`](#-test-suite-timeout-option) causes the test suite to +fail, Stack requests the termination of the test suite process and waits the +specified number of seconds as a grace period before termination of the +process is forced. The option is ignored if the number of seconds is not +positive. + ## Flags affecting GHC's behaviour ### `--[no-]executable-profiling` flag @@ -926,6 +946,32 @@ expressions, and generate a profiling report in tests or benchmarks. The flag affects the location of the local project installation directory. See the [`stack path --local-install-root`](path_command.md) command. +### `--[no]-semaphore` flag + +:octicons-beaker-24: Experimental + +:octicons-tag-24: UNRELEASED + +Default: Disabled + +This flag allows GHC to use a system semaphore to perform compilation in +parallel when possible. + +!!! info + + GHC 9.8.1 and later can act as a jobserver client, which enables two or more + GHC processes running at once to share system resources with each other, + communicating via a system semaphore. This GHC feature is supported by + Cabal 3.12.0.0 (a boot package of GHC 9.10.1) and later. The flag is ignored + with a warning when the feature is unsupported. + +!!! warning + + On Linux, musl and non-musl system semaphores are incompatible. That means + that a Stack executable built on Alpine Linux (such as the official Stack + for Linux) creates system semaphores that cannot be used by a GHC executable + built on non-musl Linux distributions. + ### `--[no-]split-objs` flag :octicons-beaker-24: Experimental @@ -1152,7 +1198,7 @@ where the test suite takes the form of an executable and the executable takes nothing on the standard input stream (`stdin`). Pass this flag to override that specification and allow the executable to receive input on that stream. If you pass `--no-tests-allow-stdin` and the executable seeks input on the standard -input stream, an exception will be thown. +input stream, an exception will be thrown. ## Examples diff --git a/doc/commands/config_command.md b/doc/commands/config_command.md index 86782f7433..8d8102a839 100644 --- a/doc/commands/config_command.md +++ b/doc/commands/config_command.md @@ -9,6 +9,9 @@ Available commands: build-files Generate (when applicable) a Cabal file from a package description in the Hpack format and/or a lock file for Stack's project-level configuration. + compiler-tools-bin Create (when applicable) the compiler tools + directory for the specified compiler version (implies + 'config build-files'). env Print environment variables for use in a shell. set Set a key in a configuration file to value. ~~~ @@ -32,6 +35,19 @@ stack config build-files without taking any other build steps. +## The `stack config compiler-tools` command + +:octicons-tag-24: UNRELEASED + +~~~text +stack config compiler-tools +~~~ + +`stack config compiler-tools` creates (when applicable) the +[compiler tools directory](../topics/stack_root.md#compiler-tools-directory-optional) +for the specified compiler version. Implies Stack's +[`config build-files` command](#the-stack-config-build-files-command). + ## The `stack config env` command ~~~text @@ -51,7 +67,7 @@ script that is output: or not * `--[no-]locale-utf8` (disabled by default) set the `GHC_CHARENC` environment variable to `UTF-8` or not -* `--[no-]keep-ghc-rts` (disabled by default) keep/discard any `GHCRTS` +* `--[no-]keep-ghc-rts` (enabled by default) keep/discard any `GHCRTS` environment variable The command also accepts flags and options of the @@ -88,6 +104,14 @@ to be set. See `stack config set` for the available keys. The `config set` commands support an existing key only in the form `key: value` on a single line. +!!! warning + + The `config set` commands cannot add a new key to a configuration file that + uses [`!include`](../configure/yaml/include.md) directives. Stack will report + an error if it detects `!include` directives in the target configuration file + and the key being set is not already present. Existing keys can be modified + even in files that use `!include`. + ## The `stack config set install-ghc` command ~~~text @@ -172,6 +196,9 @@ A snapshot of `lts` or `nightly` will be translated into the most recent available. A snapshot of `lts-22` will be translated into the most recent available in the `lts-22` sequence. +Snapshot values that are compiler versions, a URL or a local file path are also +accepted. + If a (deprecated) `resolver` key is present, it will be replaced by a `snapshot` key. diff --git a/doc/commands/dot_command.md b/doc/commands/dot_command.md index d45dff19c6..83975ff71a 100644 --- a/doc/commands/dot_command.md +++ b/doc/commands/dot_command.md @@ -4,8 +4,8 @@ ~~~text stack dot [--[no-]external] [--[no-]include-base] [--depth DEPTH] - [--prune PACKAGES] [TARGET] [--flag PACKAGE:[-]FLAG] - [--test] [--bench] [--global-hints] + [--prune PACKAGES] [--reach PACKAGES] [TARGET] + [--flag PACKAGE:[-]FLAG] [--test] [--bench] [--global-hints] ~~~ A package and its dependencies and the direct dependency relationships between @@ -28,9 +28,10 @@ By default: `--depth ` option to limit the depth; * all relevant packages are included in the output. Pass the `--prune ` option to exclude the specified packages (including - project packages), where `` is a list of package names separated - by commas. A package with dependencies is pruned if all of its direct - dependencies are pruned; + project packages). Pass the `--reach ` option to exclude packages + (including project packages) that cannot reach any of the specified packages + in the dependency graph. In both cases, `` is a list of package + names separated by commas; * for all relevant project packages, relevant dependencies are included in the output. However, each project package for which dependencies are included can be specified as a target argument. The argument uses the same format as @@ -114,3 +115,12 @@ output in the form of a SVG file named `wreq-example*.svg`. ~~~ [![wreq-example6.svg](https://cdn.jsdelivr.net/gh/commercialhaskell/stack@master/doc/img/dot_command/wreq-example6.svg)](https://cdn.jsdelivr.net/gh/commercialhaskell/stack@master/doc/img/dot_command/wreq-example6.svg) + +* Include external dependencies and prune packages that cannot reach any of + `memory` and `basement` in the dependency graph: + + ~~~text + stack dot --external --reach memory,basement | dot -Tsvg -o wreq-example7.svg + ~~~ + + [![wreq-example7.svg](https://cdn.jsdelivr.net/gh/commercialhaskell/stack@master/doc/img/dot_command/wreq-example7.svg)](https://cdn.jsdelivr.net/gh/commercialhaskell/stack@master/doc/img/dot_command/wreq-example7.svg) diff --git a/doc/commands/haddock_command.md b/doc/commands/haddock_command.md index e1c5bff14a..519fa5a933 100644 --- a/doc/commands/haddock_command.md +++ b/doc/commands/haddock_command.md @@ -17,7 +17,8 @@ stack haddock [TARGET] [--dry-run] [--pedantic] [--fast] [--ghc-options OPTIONS] [--[no-]keep-going] [--[no-]keep-tmp-files] [--[no-]force-dirty] [--[no-]test] [--[no-]rerun-tests] [--ta|--test-arguments TEST_ARGS] [--coverage] [--[no-]run-tests] - [--test-suite-timeout ARG] [--[no-]tests-allow-stdin] + [--test-suite-timeout SECONDS] + [--test-suite-timeout-grace SECONDS] [--[no-]tests-allow-stdin] [--[no-]bench] [--ba|--benchmark-arguments BENCH_ARGS] [--[no-]run-benchmarks] [--[no-]reconfigure] [--cabal-verbosity VERBOSITY | --[no-]cabal-verbose] diff --git a/doc/commands/install_command.md b/doc/commands/install_command.md index 653981a2d4..6e73f574ae 100644 --- a/doc/commands/install_command.md +++ b/doc/commands/install_command.md @@ -17,7 +17,8 @@ stack install [TARGET] [--dry-run] [--pedantic] [--fast] [--ghc-options OPTIONS] [--[no-]keep-going] [--[no-]keep-tmp-files] [--[no-]force-dirty] [--[no-]test] [--[no-]rerun-tests] [--ta|--test-arguments TEST_ARGS] [--coverage] [--[no-]run-tests] - [--test-suite-timeout ARG] [--[no-]tests-allow-stdin] + [--test-suite-timeout SECONDS] + [--test-suite-timeout-grace SECONDS] [--[no-]tests-allow-stdin] [--[no-]bench] [--ba|--benchmark-arguments BENCH_ARGS] [--[no-]run-benchmarks] [--[no-]reconfigure] [--cabal-verbosity VERBOSITY | --[no-]cabal-verbose] diff --git a/doc/commands/list_command.md b/doc/commands/list_command.md index 627678987a..454bab3907 100644 --- a/doc/commands/list_command.md +++ b/doc/commands/list_command.md @@ -45,17 +45,17 @@ Error: [S-4926] tasty, retry, path, pretty, pasty, xattr, alloy, para, pappy and alure. -stack --snapshot lts-24.24 list base unix Win32 acme-missiles pantry +stack --snapshot lts-24.43 list base unix Win32 acme-missiles pantry Error: [S-4926] * Package does not appear in snapshot (directly or indirectly): acme-missiles. -stack --snapshot lts-24.24 list base unix Win32 pantry +stack --snapshot lts-24.43 list base unix Win32 pantry base-4.20.2.0 unix-2.8.7.0 Win32-2.14.1.0 pantry-0.10.1 -stack --snapshot lts-24.24 list +stack --snapshot lts-24.43 list AC-Angle-1.0 ALUT-2.4.0.3 ... diff --git a/doc/commands/ls_command.md b/doc/commands/ls_command.md index 98aae35878..9485b849d1 100644 --- a/doc/commands/ls_command.md +++ b/doc/commands/ls_command.md @@ -69,9 +69,10 @@ By default: `--depth ` option to limit the depth; * all relevant packages are included in the output. Pass the `--prune ` option to exclude the specified packages (including - project packages), where `` is a list of package names separated - by commas. A package with dependencies is pruned if all of its direct - dependencies are pruned; + project packages). Pass the `--reach ` option to exclude packages + (including project packages) that cannot reach any of the specified packages + in the dependency graph. In both cases, `` is a list of package + names separated by commas; * for all relevant project packages, relevant dependencies are included in the output. However, each project package for which dependencies are included can be specified as a target argument. The argument uses the same format as diff --git a/doc/commands/script_command.md b/doc/commands/script_command.md index 98092ff472..42ee05187a 100644 --- a/doc/commands/script_command.md +++ b/doc/commands/script_command.md @@ -49,7 +49,7 @@ A snapshot must be specified on the command line, using the `--snapshot` option. For example: ~~~text -stack script --snapshot lts-24.24 MyScript.hs +stack script --snapshot lts-24.43 MyScript.hs ~~~ An immutable extra-dep can be added to the snapshot on the command line with the @@ -211,7 +211,7 @@ main = do can be compiled and run, with arguments, with: ~~~text -stack --snapshot lts-24.24 script --package acme-missiles --compile MyScript.hs -- "Don't panic!" "Duck and cover!" +stack --snapshot lts-24.43 script --package acme-missiles --compile MyScript.hs -- "Don't panic!" "Duck and cover!" ~~~ `acme-missiles-0.3` (the most recent version in the package index) will be used. @@ -231,7 +231,7 @@ snapshot as an extra-dep. The `stack script` command is specified using Stack's ~~~haskell {- stack script - -- snapshot lts-24.24 + -- snapshot lts-24.43 -- extra-dep acme-missiles-0.2 -- package acme-missiles -} @@ -333,7 +333,7 @@ A Haskell source file `MyScript.hs`, as follows: ~~~haskell {- stack script - --snapshot lts-24.24 + --snapshot lts-24.43 -} {-# LANGUAGE OverloadedStrings #-} diff --git a/doc/commands/test_command.md b/doc/commands/test_command.md index cb0f2cb9c9..12f37f5544 100644 --- a/doc/commands/test_command.md +++ b/doc/commands/test_command.md @@ -16,12 +16,13 @@ stack test [TARGET] [--dry-run] [--pedantic] [--fast] [--ghc-options OPTIONS] [--[no-]copy-bins] [--[no-]copy-compiler-tool] [--[no-]prefetch] [--[no-]keep-going] [--[no-]keep-tmp-files] [--[no-]force-dirty] [--[no-]test] [--[no-]rerun-tests] [--ta|--test-arguments TEST_ARGS] - [--coverage] [--[no-]run-tests] [--test-suite-timeout ARG] - [--[no-]tests-allow-stdin] [--[no-]bench] - [--ba|--benchmark-arguments BENCH_ARGS] [--[no-]run-benchmarks] - [--[no-]reconfigure] [--cabal-verbosity VERBOSITY | - --[no-]cabal-verbose] [--[no-]split-objs] [--skip ARG] - [--[no-]interleaved-output] [--ddump-dir ARG] + [--coverage] [--[no-]run-tests] [--test-suite-timeout SECONDS] + [--test-suite-timeout-grace SECONDS] [--[no-]tests-allow-stdin] + [--[no-]bench] [--ba|--benchmark-arguments BENCH_ARGS] + [--[no-]run-benchmarks] [--[no-]reconfigure] + [--cabal-verbosity VERBOSITY | --[no-]cabal-verbose] + [--[no-]split-objs] [--skip ARG] [--[no-]interleaved-output] + [--ddump-dir ARG] ~~~ `stack test` is a synonym for `stack build --test`. For further information, diff --git a/doc/commands/upload_command.md b/doc/commands/upload_command.md index fe3ff5ab0b..f9ab6d2a40 100644 --- a/doc/commands/upload_command.md +++ b/doc/commands/upload_command.md @@ -89,15 +89,6 @@ are ignored. [:octicons-tag-24: 2.3.1](https://github.com/commercialhaskell/stack/releases/tag/v2.3.1) -!!! warning - - After March 2026, Hackage requires Stack to add its user agent when applying - digest authentication to a request. Stack 3.9.3 and earlier do not do this. - Consequently, Stack's `upload` command is unable to submit digest - credentials and encounters an authentication failure when uploading to the - server. A work around is to use the - [`HACKAGE_KEY` environment variable](#the-hackage_key-environment-variable). - `stack upload` will request a Hackage username and password to authenticate. This can be avoided by setting the `HACKAGE_USERNAME` and `HACKAGE_PASSWORD` environment variables. For diff --git a/doc/configure/yaml/include.md b/doc/configure/yaml/include.md new file mode 100644 index 0000000000..3f9411e340 --- /dev/null +++ b/doc/configure/yaml/include.md @@ -0,0 +1,117 @@ +
+ +# The `!include` directive + +Stack's configuration files are in the [YAML](https://yaml.org/) format. Stack +also supports the use of an `!include` local tag together with scalar content +that represents an absolute or relative path to another file. This provides a +directive that allows the content of one YAML file to be included in another. + +The directive can be used in both +[project-level and global](index.md#project-level-and-global-configuration-files) +configuration files. + +!!! note + + An included relative file path is relative to the directory containing the + file with the `!include` directive. + +!!! warning + + The [`stack config set`](../../commands/config_command.md#the-stack-config-set-commands) + commands cannot modify a configuration file that excludes the relevant key + and uses `!include` directives. + +## Including a value + +A value for a key can be provided by an included file. For example, given a file +`snapshot.yaml` in the project directory with the content: + +~~~yaml +lts-24.43 +~~~ + +the following project-level configuration file would use `lts-24.43` as the +snapshot: + +~~~yaml +snapshot: !include snapshot.yaml +~~~ + +The included file replaces the `!include` directive with its content, so this is +equivalent to: + +~~~yaml +snapshot: lts-24.43 +~~~ + +## Including a sequence + +The value provided by an included file is not limited to scalar content. It can +be a YAML sequence. For example, given a file `extra-deps.yaml` in the project +directory with the content: + +~~~yaml +- acme-missiles-0.3 +- text-short-0.1.6 +~~~ + +the following project-level configuration file would use those as extra-deps: + +~~~yaml +snapshot: lts-24.43 +extra-deps: !include extra-deps.yaml +~~~ + +## Merging mappings + +YAML's merge key (`<<`) is used to indicate that all of the keys of one or more +specified mappings should be inserted into the current mapping. + +YAML's merge key can be combined with an `!include` directive to merge the +content of an included file into the current mapping. For example, given a file +`shared-config.yaml` in the project directory with the content: + +~~~yaml +ghc-options: + "$everything": -Wall +flags: + my-package: + my-flag: true +~~~ + +the following project-level configuration file would merge those options: + +~~~yaml +snapshot: lts-24.43 +<<: !include shared-config.yaml +~~~ + +This is equivalent to: + +~~~yaml +snapshot: lts-24.43 +ghc-options: + "$everything": -Wall +flags: + my-package: + my-flag: true +~~~ + +The `!include` directive can also be placed on the line after the merge key: + +~~~yaml +snapshot: lts-24.43 +<<: + !include shared-config.yaml +~~~ + +## Nested includes + +Included files can themselves contain `!include` directives, allowing for nested +composition of configuration. + +!!! note + + A file cannot include itself or a file that has already included the file. + Stack detects and raises an error for cyclic includes. diff --git a/doc/configure/yaml/index.md b/doc/configure/yaml/index.md index 293bbd9492..0f9fae07b0 100644 --- a/doc/configure/yaml/index.md +++ b/doc/configure/yaml/index.md @@ -6,7 +6,8 @@ title: Configuration files # Configuration files Stack is configured by the content of files in the [YAML](https://yaml.org/) -format. +format. Stack also supports an [`!include` directive](include.md) that allows a +configuration file to include the contents of another file. ## Project-specific and non-project specific options diff --git a/doc/configure/yaml/non-project.md b/doc/configure/yaml/non-project.md index b6fee40611..315a4589e5 100644 --- a/doc/configure/yaml/non-project.md +++ b/doc/configure/yaml/non-project.md @@ -165,6 +165,11 @@ Default: ~~~yaml build: + # Experimental. Since Stack UNRELEASED. Supported by GHC 9.8.1 or later with + # Cabal 3.12.0.0 (a boot package of GHC 9.10.1) or later. Ignored with a + # warning when unsupported. + semaphore: false + library-profiling: false executable-profiling: false library-stripping: true @@ -219,6 +224,8 @@ build: no-run-tests: false # The option is ignored if the specified number of seconds is not positive: test-suite-timeout: 0 + # The option is ignored if the specified number of seconds is not positive: + test-suite-timeout-grace: 0 bench: false benchmark-opts: @@ -310,7 +317,7 @@ can be used to override the compiler (and, implicitly, its boot packages) for a Stackage snapshot, like this: ~~~yaml -snapshot: lts-24.24 +snapshot: lts-24.43 compiler: ghc-9.10.2 compiler-check: match-exact ~~~ @@ -947,7 +954,9 @@ modify-code-page: false Restrictions: Windows systems only. -Default: `MINGW64` (64-bit Windows) or `MINGW32` (32-bit Windows) +Default: +([:octicons-tag-24: 3.11.1](https://github.com/commercialhaskell/stack/releases/tag/v3.11.1)) +`CLANG64` (64-bit Windows) The name of the MSYS2 environment (case-sensitive) used in the Stack environment. Valid environments are `CLANG32`, `CLANG64`, `CLANGARM64`, @@ -1587,18 +1596,29 @@ Default: ~~~yaml urls: latest-snapshot: https://stackage-haddock.haskell.org/snapshots.json + recent-snapshots: https://www.stackage.org/api/v1/snapshots ~~~ -Customize the URLs where Stack looks for snapshot build plans. +Customize the URLs where Stack looks for information about available snapshots, +either +([:octicons-tag-24: 1.1.0](https://github.com/commercialhaskell/stack/releases/tag/v1.1.0)) +the latest LTS and Nightly snapshots (`latest-snapshots`) or +(:octicons-tag-24: UNRELEASED) recently-published snapshots (`recent-snapshots`). !!! note - The default for Stack 1.3.0 to 2.15.3 was + The default for `latest-snapshots` for Stack 1.3.0 to 2.15.3 was https://s3.amazonaws.com/haddock.stackage.org/snapshots.json. Following the handover of the Stackage project to the Haskell Foundation in early 2024, the file at that URL may not be up to date. Users of those versions of Stack should configure the URL to be the default above. +!!! note + + The default for `recent-snapshots` for Stack 1.7.1 to 3.9.3 was + https://www.stackage.org/snapshots. The Stackage server API may cease to use + that end point in the future. + ## with-gcc Command line equivalent (takes precedence): `--with-gcc` option diff --git a/doc/configure/yaml/project.md b/doc/configure/yaml/project.md index 82dc880970..4593d2b247 100644 --- a/doc/configure/yaml/project.md +++ b/doc/configure/yaml/project.md @@ -39,13 +39,13 @@ snapshot defines a GHC version, the package version of packages available for installation, and various settings like build flags. For example: ~~~yaml -snapshot: lts-24-30 # A Stackage LTS Haskell snapshot +snapshot: lts-24.43 # A Stackage LTS Haskell snapshot ~~~ or ~~~yaml -snapshot: nightly-2026-02-09 # A Stackage Nightly snapshot +snapshot: nightly-2026-05-29 # A Stackage Nightly snapshot ~~~ For further information about how to specify the location of a snapshot, see the diff --git a/doc/img/dot_command/wreq-example7.svg b/doc/img/dot_command/wreq-example7.svg new file mode 100644 index 0000000000..d78d538314 --- /dev/null +++ b/doc/img/dot_command/wreq-example7.svg @@ -0,0 +1,457 @@ + + + + + + +deps + + + +wreq + +wreq + + + +memory + +memory + + + +wreq->memory + + + + + +authenticate-oauth + +authenticate-oauth + + + +wreq->authenticate-oauth + + + + + +crypton + +crypton + + + +wreq->crypton + + + + + +http-client-tls + +http-client-tls + + + +wreq->http-client-tls + + + + + +wreq-examples + +wreq-examples + + + +wreq-examples->wreq + + + + + +basement + +basement + + + +RSA + +RSA + + + +crypto-pubkey-types + +crypto-pubkey-types + + + +RSA->crypto-pubkey-types + + + + + +asn1-encoding + +asn1-encoding + + + +crypto-pubkey-types->asn1-encoding + + + + + +asn1-types + +asn1-types + + + +crypto-pubkey-types->asn1-types + + + + + +asn1-encoding->asn1-types + + + + + +asn1-types->memory + + + + + +asn1-parse + +asn1-parse + + + +asn1-parse->asn1-encoding + + + + + +asn1-parse->asn1-types + + + + + +memory->basement + + + + + +authenticate-oauth->RSA + + + + + +authenticate-oauth->crypto-pubkey-types + + + + + +crypton->basement + + + + + +crypton->memory + + + + + +crypton-connection + +crypton-connection + + + +crypton-x509-store + +crypton-x509-store + + + +crypton-connection->crypton-x509-store + + + + + +crypton-x509-system + +crypton-x509-system + + + +crypton-connection->crypton-x509-system + + + + + +tls + +tls + + + +crypton-connection->tls + + + + + +crypton-x509-store->asn1-encoding + + + + + +crypton-x509-store->asn1-types + + + + + +crypton-x509-store->crypton + + + + + +crypton-x509 + +crypton-x509 + + + +crypton-x509-store->crypton-x509 + + + + + +pem + +pem + + + +crypton-x509-store->pem + + + + + +crypton-x509-system->asn1-encoding + + + + + +crypton-x509-system->crypton-x509-store + + + + + +crypton-x509-system->crypton-x509 + + + + + +crypton-x509-system->pem + + + + + +tls->asn1-encoding + + + + + +tls->asn1-types + + + + + +tls->memory + + + + + +tls->crypton + + + + + +tls->crypton-x509-store + + + + + +tls->crypton-x509 + + + + + +crypton-x509-validation + +crypton-x509-validation + + + +tls->crypton-x509-validation + + + + + +crypton-x509->asn1-encoding + + + + + +crypton-x509->asn1-types + + + + + +crypton-x509->asn1-parse + + + + + +crypton-x509->memory + + + + + +crypton-x509->crypton + + + + + +crypton-x509->pem + + + + + +pem->basement + + + + + +pem->memory + + + + + +crypton-x509-validation->asn1-encoding + + + + + +crypton-x509-validation->asn1-types + + + + + +crypton-x509-validation->memory + + + + + +crypton-x509-validation->crypton + + + + + +crypton-x509-validation->crypton-x509-store + + + + + +crypton-x509-validation->crypton-x509 + + + + + +crypton-x509-validation->pem + + + + + +http-client-tls->memory + + + + + +http-client-tls->crypton + + + + + +http-client-tls->crypton-connection + + + + + +http-client-tls->tls + + + + + diff --git a/doc/maintainers/stack_errors.md b/doc/maintainers/stack_errors.md index e24a902b13..ac3086639c 100644 --- a/doc/maintainers/stack_errors.md +++ b/doc/maintainers/stack_errors.md @@ -5,7 +5,7 @@ In connection with considering Stack's support of the [Haskell Error Index](https://errors.haskell.org/) initiative, this page seeks to take stock of the errors that Stack itself can raise, by reference to the -`master` branch of the Stack repository. Last updated: 2025-08-16. +`master` branch of the Stack repository. Last updated: 2026-04-24. * `Stack.main`: catches exceptions from action `commandLineHandler`. @@ -78,18 +78,19 @@ to take stock of the errors that Stack itself can raise, by reference to the [S-8575] = SnapshotNotSupportedException (Maybe Project) (Maybe AbstractSnapshot) ~~~ - - `Stack.Config.Nix.ConfigNixException` + - `Stack.Config.Nix.ConfigNixPrettyException` ~~~haskell - [S-2726] = NixCannotUseShellFileAndPackagesException + [S-2726] = NixCannotUseShellFileAndPackagesException FilePath [Text] [S-9317] | GHCMajorVersionUnspecified [S-8605] | OnlyGHCSupported ~~~ - - `Stack.ConfigCmd.ConfigCmdException` + - `Stack.ConfigCmd.ConfigCmdPrettyException` ~~~haskell [S-3136] = NoProjectConfigAvailable + [S-6088] | ConfigFileContainsIncludes (Path Abs File) ~~~ - `Stack.Constants.ConstantsException` @@ -190,10 +191,11 @@ to take stock of the errors that Stack itself can raise, by reference to the [S-1353] = WritingLockFileError (Path Abs File) Locked ~~~ - - `Stack.Ls.LsException` * + - `Stack.Ls.LsPrettyException` ~~~haskell [S-3421] = ParseFailure [Value] + [S-9131] | ParseRecentSnapshotsUrlFailed HttpException ~~~ - `Stack.New.NewPrettyException` @@ -208,7 +210,7 @@ to take stock of the errors that Stack itself can raise, by reference to the [S-3113] | AttemptedOverwrites [Path Abs File] ~~~ - - `Stack.Nix.NixException` + - `Stack.Nix.NixPrettyException` ~~~haskell [S-7384] = CannotDetermineProjectRoot @@ -349,8 +351,6 @@ to take stock of the errors that Stack itself can raise, by reference to the [S-5797] | LocalPackageDoesn'tMatchTarget PackageName Version Version [S-3118] | NoSetupHsFound (Path Abs Dir) [S-4925] | InvalidGhcOptionsSpecification [PackageName] - [S-7987] | TestSuiteExeMissing Bool String String String - [S-8027] | CabalCopyFailed Bool String [S-5510] | LocalPackagesPresent [PackageIdentifier] [S-7168] | CouldNotLockDistDir (Path Abs File) [S-7868] | TaskCycleBug PackageIdentifier @@ -377,6 +377,8 @@ to take stock of the errors that Stack itself can raise, by reference to the [S-1727] | NotOnlyLocal [PackageName] [Text] [S-6362] | CompilerVersionMismatch (Maybe (ActualCompiler, Arch)) (WantedCompiler, Arch) GHCVariant CompilerBuild VersionCheck WantedCompilerSetter Text [S-4660] | ActionNotFilteredBug StyleDoc + [S-7987] | TestSuiteExeMissing Bool String PackageName StackUnqualCompName + [S-8027] | CabalCopyFailed Bool BuildPrettyException ~~~ - `Stack.Types.Compiler.CompilerException` diff --git a/doc/topics/GHC_from_source.md b/doc/topics/GHC_from_source.md index 2c66e07f81..c693e48166 100644 --- a/doc/topics/GHC_from_source.md +++ b/doc/topics/GHC_from_source.md @@ -167,25 +167,25 @@ Stack will build and install `happy` and `alex`, if not already on the PATH. ~~~pwsh stack exec -- pacman --sync --refresh # Synchronize MSYS2 package databases - stack exec -- pacman --sync mingw-w64-x86_64-python-pip + stack exec -- pacman --sync mingw-w64-clang-x86_64-python-pip # The PyPA recommended tool (pip) for installing Python packages. Also # installs Python as a dependency. GHC uses a Python script named `boot`. - # The package must be the one from the `mingw64` MSYS2 repository, as Python + # The package must be the one from the `clang64` MSYS2 repository, as Python # from the `msys` repository cannot interpret Windows file paths correctly. - stack exec -- pacman --sync mingw-w64-x86_64-autotools + stack exec -- pacman --sync mingw-w64-clang-x86_64-autotools # The GNU autotools build system, including `autoreconf`, `aclocal` # and `make`. GHC uses a sh script named `configure` which is itself created # from a file named `configure.ac`. stack exec -- pacman --sync patch # A utility to apply patch files to original sources. - stack exec -- pacman --sync texinfo + stack exec -- pacman --sync mingw-w64-clang-x86_64-texinfo # Utilities to work with and produce manuals, ASCII text, and on-line # documentation from a single source file, including `makeinfo`. - stack exec -- pacman --sync mingw-w64-x86_64-ca-certificates + stack exec -- pacman --sync mingw-w64-clang-x86_64-ca-certificates # Common CA (certificate authority) certificates. - stack exec -- pacman -sync mingw-w64-x86_64-python-sphinx + stack exec -- pacman -sync mingw-w64-clang-x86_64-python-sphinx # Sphinx is the Python documentation generator. - stack exec -- pacman -sync mingw-w64-x86_64-texlive-full + stack exec -- pacman -sync mingw-w64-clang-x86_64-texlive-full # The TeX Live distribution. ~~~ diff --git a/doc/topics/Stack_and_VS_Code.md b/doc/topics/Stack_and_VS_Code.md index 8a18445914..cc50c5fa9a 100644 --- a/doc/topics/Stack_and_VS_Code.md +++ b/doc/topics/Stack_and_VS_Code.md @@ -150,7 +150,7 @@ VS Code with the 'Haskell' extension can be configured in a number of ways: Each time that a snapshot is used that references a different version of GHC, then GHCup must be used to install it (if GHCup has not already - installed that version). For example, to use `snapshot: lts-24.24` + installed that version). For example, to use `snapshot: lts-24.43` (GHC 9.10.3), the command `ghcup install ghc 9.10.3` must have been used to install GHC 9.10.3. That may be a minor inconvenience for some people, as one the primary benefits of Stack over other tools for building diff --git a/doc/topics/custom_snapshot.md b/doc/topics/custom_snapshot.md index 03dd173944..cd6e2958e4 100644 --- a/doc/topics/custom_snapshot.md +++ b/doc/topics/custom_snapshot.md @@ -29,7 +29,7 @@ available in snapshots to ensure reproducibility. ~~~yaml # Inherits a specific GHC version and, implicitly, its boot packages and # specific versions of a set of other packages: -snapshot: lts-24.24 +snapshot: lts-24.43 # Overwrites the version of GHC (and, implicitly, its boot packages) specified # in the snapshot (optional): compiler: ghc-9.10.2 @@ -75,36 +75,36 @@ custom snapshot, due to Stack sharing snapshot packages whenever possible. ### Overriding the compiler -The following snapshot specification will be identical to `lts-24.24`, but +The following snapshot specification will be identical to `lts-24.43`, but instead use `ghc-9.10.2` and its boot packages instead of `ghc-9.10.3` and its boot packages: ~~~yaml -snapshot: lts-24.24 # GHC 9.10.3 +snapshot: lts-24.43 # GHC 9.10.3 compiler: ghc-9.10.2 ~~~ ### Dropping packages -The following snapshot specification will be identical to `lts-24.24`, but +The following snapshot specification will be identical to `lts-24.43`, but without the `text` package in our snapshot. Removing this package will cause all the packages that depend on `text` to be unbuildable, but they will still be present in the snapshot. ~~~yaml -snapshot: lts-24.24 +snapshot: lts-24.43 drop-packages: - text ~~~ ### Hiding packages -The following snapshot specification will be identical to `lts-24.24`, but the +The following snapshot specification will be identical to `lts-24.43`, but the `text` package will be hidden when registering. This will affect, for example, the import parser in the script command. ~~~yaml -snapshot: lts-24.24 +snapshot: lts-24.43 hidden: - text ~~~ @@ -115,11 +115,11 @@ In order to specify GHC options for a package, you use the same syntax as the [ghc-options](../configure/yaml/non-project.md#ghc-options) key for build configuration. -The following snapshot specification will be identical to `lts-24.24`, but +The following snapshot specification will be identical to `lts-24.43`, but provides `-O1` as a ghc-option for `text`: ~~~yaml -snapshot: lts-24.24 +snapshot: lts-24.43 packages: - text-2.1.2 ghc-options: @@ -138,11 +138,11 @@ packages in the `packages` list, rather than all packages in the snapshot. In order to specify Cabal flags for a package, you use the same syntax as the [flags](../configure/yaml/project.md#flags) key for build configuration. The -following snapshot specification will be identical to `lts-24.24`, but +following snapshot specification will be identical to `lts-24.43`, but it enables the `developer` Cabal flag: ~~~yaml -snapshot: lts-24.24 +snapshot: lts-24.43 packages: - text-2.1.2 flags: diff --git a/doc/topics/developing_on_windows.md b/doc/topics/developing_on_windows.md index b3756fb6e0..b71ca19dd4 100644 --- a/doc/topics/developing_on_windows.md +++ b/doc/topics/developing_on_windows.md @@ -3,11 +3,11 @@ # Developing on Windows # On Windows, Stack comes with an installation of [MSYS2](https://www.msys2.org/). -An environment of MSYS2 (by default, `MINGW64` on 64-bit Windows or `MINGW32` on -32-bit Windows) will be used by Stack to provide a Unix-like shell and -environment for Stack. This may be necessary for installing some Haskell -packages, such as those which use `configure` scripts, or if your project needs -some additional tools during the build phase. +An environment of MSYS2 (by default, `CLANG64` on 64-bit Windows) will be used +by Stack to provide a Unix-like shell and environment for Stack. This may be +necessary for installing some Haskell packages, such as those which use +`configure` scripts, or if your project needs some additional tools during the +build phase. No matter which terminal software you choose (Windows Terminal, Console Windows Host, Command Prompt, PowerShell, Git bash or any other) you can use this @@ -26,22 +26,22 @@ example, help about the operation `--sync` (or `-S`) can be obtained with `stack exec -- pacman --sync --help` or, equivalently, `stack exec -- pacman -Sh`. -Command `stack path --bin-path` to see the PATH in the Stack environment. If the -relevant MSYS2 environment is `MINGW64`, on Windows, it includes the -`\mingw64\bin`, `\usr\bin` and `\usr\local\bin` directories of the -Stack-supplied MSYS2. (It includes the corresponding directory if the relevant -MSYS2 environment is other than `MINGW64`.) If your executable depends on files -(for example, dynamic-link libraries) in those directories and you want to run -it outside of the Stack environment, you will need to ensure copies of those -files are on the PATH. +Command `stack path --bin-path` to see the PATH in the +[Stack environment](stack_environment.md). If the relevant MSYS2 environment is +`CLANG64`, on Windows, it includes the `\clang64\bin`, `\usr\local\bin` and +`\usr\bin` directories of the Stack-supplied MSYS2. (It includes the +corresponding directory if the relevant MSYS2 environment is other than +`CLANG64`.) If your executable depends on files (for example, dynamic-link +libraries) in those directories and you want to run it outside of the Stack +environment, you will need to ensure copies of those files are on the PATH. Command `stack path --extra-include-dirs` and `stack path --extra-library-dirs` to see the extra directories searched for C header files or system libraries -files in the Stack environment. If the relevant MSYS2 environment is `MINGW64`, -on Windows, it includes the `\mingw64\include` (include) and the `\mingw64\lib` -and `\mingw64\bin` directories (library) of the Stack-supplied MSYS2. (It +files in the Stack environment. If the relevant MSYS2 environment is `CLANG64`, +on Windows, it includes the `\clang64\include` (include) and the `\clang64\lib` +and `\clang64\bin` directories (library) of the Stack-supplied MSYS2. (It includes the corresponding directories if the relevant MSYS2 environment is -other than `MINGW64`.) +other than `CLANG64`.) For further information about configuring the relevant MSYS2 environment, see Stack's [`msys-environment`](../configure/yaml/non-project.md#msys-environment) @@ -72,7 +72,7 @@ common Haskell packages on Windows. Feel free to submit additional entries via a pull request. * For [text-icu](https://hackage.haskell.org/package/text-icu) install - `mingw64/mingw-w64-x86_64-icu`. + `mingw-w64-clang-x86_64-icu`. * For [zlib >= 0.7](https://hackage.haskell.org/package/zlib) the default Cabal flag `pkg-config` is `true` and requires executable `pkg-config` on @@ -83,27 +83,3 @@ pull request. stack exec -- pacman -S pkgconf Alternatively, build with `--flag zlib:-pkg-config`. - -## CMake ## - -CMake has trouble finding other tools even if they are available on the PATH. -Likely this is not a CMake problem but one of the environment not fully -integrating. For example GHC comes with a copy of GCC which is not installed by -MSYS2 itself. If you want to use this GCC you can provide a full path to it, or -find it first with `System.Directory.findExecutable` if you want to launch GCC -from a Haskell file such as `Setup.hs`. - -Experience tells that the `mingw-w64` versions of Make and CMake are most -likely to work. Though there are other versions available through `pacman`, so -have a look to see what works for you. Both tools can be installed with the -commands: - - stack exec -- pacman -S mingw-w64-x86_64-make - stack exec -- pacman -S mingw-w64-x86_64-cmake - -Even though Make and CMake are then both installed into the same environment, -CMake still seems to have trouble to find Make. To help CMake find GCC and Make -supply the following flags: - - -DCMAKE_C_COMPILER=path - -DCMAKE_MAKE_PROGRAM=path diff --git a/doc/topics/haskell_and_c_code.md b/doc/topics/haskell_and_c_code.md index 7524a0b50e..3aba0a5895 100644 --- a/doc/topics/haskell_and_c_code.md +++ b/doc/topics/haskell_and_c_code.md @@ -83,7 +83,7 @@ executables: The project's `stack.yaml` file only needs to identify a snapshot: ~~~yaml -snapshot: lts-24.24 # GHC 9.10.3 +snapshot: lts-24.43 # GHC 9.10.3 ~~~ This example project can be built with Stack in the normal way (`stack build`), @@ -221,7 +221,7 @@ The `include-dirs` key will cause the specified directory (again, The project's `stack.yaml` file only needs to identify a snapshot: ~~~yaml -snapshot: lts-24.24 # GHC 9.10.3 +snapshot: lts-24.43 # GHC 9.10.3 ~~~ This example project can be built with Stack in the normal way (`stack build`), diff --git a/doc/topics/lock_files.md b/doc/topics/lock_files.md index 2bfb41d974..c5f26e5ca2 100644 --- a/doc/topics/lock_files.md +++ b/doc/topics/lock_files.md @@ -49,9 +49,7 @@ Relevant to this discussion, Stack's project-level configuration file Some of this information can be incomplete. Consider this `stack.yaml` file: ~~~yaml -snapshot: lts-19.22 -packages: -- . +snapshot: lts-24.43 extra-deps: - acme-missiles-0.3 ~~~ @@ -68,15 +66,15 @@ extra-deps: sha256: 614bc0cca76937507ea0a5ccc17a504c997ce458d7f2f9e43b15a10c8eaeb033 ~~~ -The `lts-19.22` information is also incomplete. While we assume in general that +The `lts-24.43` information is also incomplete. While we assume in general that Haskell LTS snapshots never change, there is nothing that prohibits that from happening. Instead, the complete version of that key is: ~~~yaml -snapshot: -- url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/22.yaml - size: 619399 - sha256: 5098594e71bdefe0c13e9e6236f12e3414ef91a2b89b029fd30e8fc8087f3a07 +snapshots: +- url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/24/43.yaml + size: 729011 + sha256: 3c412a7c13dba6d3d808455a458e0776c58b6cf99b8a7961a2f5e55589d6f1d6 ~~~ Users do not particularly feel like writing all of that. Therefore, it is common @@ -84,9 +82,9 @@ to see _incomplete_ information in a `stack.yaml` file. ## Recursive snapshot layers -Snapshot files can be _recursive_, where `stack.yaml` refers to `foo.yaml`, -which refers to `bar.yaml`, which refers to `baz.yaml`. A local snapshot file -can refer to a remote snapshot file (available via an HTTP(S) URL). +Snapshot files can be _recursive_, where `stack.yaml` refers to +`mySnapshotA.yaml`, which refers to `mySnapshotB.yaml`, which refers to a remote +snapshot file (available via an HTTP(S) URL). We need to encode information from _all_ of these snapshot layers and the `stack.yaml` file in the lock file, to ensure that we can detect if anything @@ -116,35 +114,27 @@ The lock file contains the following information: It looks like the following: ~~~yaml -# Lock file, some message about the file being auto-generated -snapshots: - # Starts with the snapshot specified in stack.yaml, - # then continues with the snapshot specified in each - # subsequent snapshot file - - original: - foo.yaml # raw content specified in a snapshot file - completed: - file: foo.yaml - sha256: XXXX - size: XXXX - - original: - lts-13.9 - completed: - size: 496662 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/13/9.yaml - sha256: 83de9017d911cf7795f19353dba4d04bd24cd40622b7567ff61fc3f7223aa3ea +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/topics/lock_files packages: -- original: https://hackage.haskell.org/package/acme-missiles-0.3.tar.gz - completed: - size: 1442 - url: https://hackage.haskell.org/package/acme-missiles-0.3.tar.gz - name: acme-missiles - version: '0.3' - sha256: e563d8b524017a06b32768c4db8eff1f822f3fb22a90320b7e414402647b735b +# Listed in the order that they are encountered in the layers of snapshots, +# starting at the lowest layer: +- completed: + hackage: acme-missiles-0.3@sha256:2ba66a092a32593880a87fb00f3213762d7bca65a687d45965778deb8694c5d1,613 pantry-tree: - size: 226 sha256: 614bc0cca76937507ea0a5ccc17a504c997ce458d7f2f9e43b15a10c8eaeb033 + size: 226 + original: + hackage: acme-missiles-0.3 +snapshots: +- completed: + sha256: 3c412a7c13dba6d3d808455a458e0776c58b6cf99b8a7961a2f5e55589d6f1d6 + size: 729011 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/24/43.yaml + original: lts-24.43 ~~~ ## Creation procedure diff --git a/doc/topics/nix_integration.md b/doc/topics/nix_integration.md index 6896e5af6e..7720033893 100644 --- a/doc/topics/nix_integration.md +++ b/doc/topics/nix_integration.md @@ -37,8 +37,9 @@ environment: 1. provide a list of [Nix packages][nix-search-packages]. To these, Stack will add Nix packages for the GHC compiler, `git` (the distributed version control - system), `gcc` (the GNU compiler collection) and `gmp` (the GNU multiple - precision arithmetic library); and + system), `gcc` (the GNU compiler collection), `gmp` (the GNU multiple + precision arithmetic library) and `cacert` (a bundle of X.509 certificates of + public Certificate Authorities); and 2. provide a `shell.nix` file that gives you more control over the libraries and tools available inside the shell. diff --git a/doc/topics/scripts.md b/doc/topics/scripts.md index 5b7ef645b0..86a070f2f1 100644 --- a/doc/topics/scripts.md +++ b/doc/topics/scripts.md @@ -19,7 +19,7 @@ An example will be easiest to understand. Consider the Haskell source file ~~~haskell #!/usr/bin/env stack --- stack script --snapshot lts-24.24 --package turtle +-- stack script --snapshot lts-24.43 --package turtle {-# LANGUAGE OverloadedStrings #-} import Turtle (echo) main = echo "Hello World!" @@ -78,11 +78,11 @@ able to reuse everything already built). The second line of the source code is the Stack interpreter options comment. In this example, it specifies the [`stack script`](../commands/script_command.md) -command with the options of a LTS Haskell 24.24 snapshot -(`--snapshot lts-24.24`) and ensuring the +command with the options of a LTS Haskell 24.43 snapshot +(`--snapshot lts-24.43`) and ensuring the [`turtle`](https://hackage.haskell.org/package/turtle) package is available (`--package turtle`). The version of the package will be that in the specified -snapshot (`lts-24.24` provides `turtle-1.6.2`). +snapshot (`lts-24.43` provides `turtle-1.6.2`). ## Arguments and interpreter options and arguments @@ -117,7 +117,7 @@ For example, the command `stack MyScript.hs arg1 arg2` with `MyScript.hs`: ~~~haskell #!/usr/bin/env stack {- stack script - --snapshot lts-24.24 + --snapshot lts-24.43 -- +RTS -s -RTS -} @@ -133,7 +133,7 @@ main = do is equivalent to the following command at the command line: ~~~text -stack script --snapshot lts-24.24 -- MyScript.hs arg1 arg2 +RTS -s -RTS +stack script --snapshot lts-24.43 -- MyScript.hs arg1 arg2 +RTS -s -RTS ~~~ where `+RTS -s -RTS` are some of GHC's @@ -164,7 +164,7 @@ options, or by providing a comma or space separated list. For example: ~~~haskell #!/usr/bin/env stack {- stack script - --snapshot lts-24.24 + --snapshot lts-24.43 --package turtle --package "stm async" --package http-client,http-conduit @@ -180,7 +180,7 @@ each. For example: ~~~haskell #!/usr/bin/env stack {- stack script - --snapshot lts-24.24 + --snapshot lts-24.43 --extra-dep acme-missiles-0.3@rev:0 --extra-dep "{git: git@github.com:yesodweb/wai, commit: '2f8a8e1b771829f4a8a77c0111352ce45a14c30f', subdirs: [auto-update, wai]}" -} @@ -227,7 +227,7 @@ which makes use of the joke package ~~~haskell {- stack script - --snapshot lts-24.24 + --snapshot lts-24.43 --package acme-missiles -} import Acme.Missiles (launchMissiles) @@ -238,7 +238,7 @@ main = launchMissiles The command `stack --script-no-run-compile Script.hs` then behaves as if the command -`stack script --snapshot lts-24.24 --package acme-missiles --no-run --compile -- Script.hs` +`stack script --snapshot lts-24.43 --package acme-missiles --no-run --compile -- Script.hs` had been given. `Script.hs` is compiled (without optimisation) and the resulting executable is not run: no missiles are launched in the process! @@ -280,7 +280,7 @@ those curious, here is an example with {- stack runghc --install-ghc - --snapshot lts-24.24 + --snapshot lts-24.43 --package base --package turtle -- @@ -304,7 +304,7 @@ it. Here is an example: {- stack exec ghci --install-ghc - --snapshot lts-24.24 + --snapshot lts-24.43 --package turtle -} ~~~ diff --git a/doc/topics/snapshot_location.md b/doc/topics/snapshot_location.md index f2b337d935..e0b1718f67 100644 --- a/doc/topics/snapshot_location.md +++ b/doc/topics/snapshot_location.md @@ -32,7 +32,7 @@ There are four ways to specify a snapshot location: * **Stackage LTS Haskell snapshots**, for example: ~~~yaml - snapshot: lts-24.30 + snapshot: lts-24.43 ~~~ ??? info "Expansion of `lts-X.Y`" @@ -52,7 +52,7 @@ There are four ways to specify a snapshot location: * **Stackage Nightly snapshots**, for example: ~~~yaml - snapshot: nightly-2026-02-09 + snapshot: nightly-2026-05-29 ~~~ ??? info "Expansion of `nightly-YYYY-MM-DD`" @@ -95,7 +95,7 @@ There are four ways to specify a snapshot location: 3. Via a **URL** pointing to a snapshot configuration file, for example: ~~~yaml - snapshot: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2025/8/17.yaml` + snapshot: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2026/5/29.yaml` ~~~ For safer, more reproducible builds, you can optionally specify a URL @@ -103,9 +103,9 @@ There are four ways to specify a snapshot location: ~~~yaml snapshot: - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/12/0.yaml - size: 499143 - sha256: 781ea577595dff08b9c8794761ba1321020e3e1ec3297fb833fe951cce1bee11 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/24/43.yaml + size: 729011 + sha256: 3c412a7c13dba6d3d808455a458e0776c58b6cf99b8a7961a2f5e55589d6f1d6 ~~~ `size` is the number of bytes in the file and `sha256` is the file's SHA256 diff --git a/doc/topics/stack_environment.md b/doc/topics/stack_environment.md index 625047de92..d95eaaa79e 100644 --- a/doc/topics/stack_environment.md +++ b/doc/topics/stack_environment.md @@ -4,12 +4,8 @@ Command [`stack config env`](../commands/config_command.md#the-stack-config-env-command) -to see how the PATH is defined in the Stack environment. - -Alternatively, command -[`stack path --bin-path`](../commands/path_command.md) to see the PATH -excluding the project Stack work directory's `bin` directory (see further -below). +or [`stack path --bin-path`](../commands/path_command.md) to see how the PATH is +defined in the Stack environment. In that environment, Stack adds certain directories to the start of the PATH. The directories added are set out below, in order of search priority. @@ -45,7 +41,7 @@ root directory. ## The compiler tools directory -When the directory is required, Stack creates, in the +When the directory is required or requested, Stack creates, in the [Stack root](stack_root.md#compiler-tools-directory-optional), a compiler tools directory for the specified compiler version. Command [`stack path --compiler-tools-bin`](../commands/path_command.md) to see that @@ -66,7 +62,9 @@ directory. compiler's executable file, put a copy of the alternative tool (or a link to it) in the [compiler tools directory](stack_root.md#compiler-tools-directory-optional) - for the specified compiler version. + for the specified compiler version. If that directory does not exist, it can + be created with Stack's + [`config compiler-tools` command](../commands/config_command.md#the-stack-config-compiler-tools-command). ## The compiler binary's directory @@ -84,14 +82,14 @@ The GHC-supplied MinGW `bin` directory. The `bin` directory for the specified MSYS2 environment of the [Stack-supplied MSYS2](developing_on_windows.md). -## Stack-supplied MSYS2 `usr\bin` directory (Windows only) +## Stack-supplied MSYS2 `usr\local\bin` directory (Windows only) -The `usr\bin` directory for the +The `usr\local\bin` directory for the [Stack-supplied MSYS2](developing_on_windows.md). -## Stack-supplied MSYS2 `usr\local\bin` directory (Windows only) +## Stack-supplied MSYS2 `usr\bin` directory (Windows only) -The `usr\local\bin` directory for the +The `usr\bin` directory for the [Stack-supplied MSYS2](developing_on_windows.md). ## Specified extra paths diff --git a/doc/topics/stack_root.md b/doc/topics/stack_root.md index 56eaae3987..3192fa24d2 100644 --- a/doc/topics/stack_root.md +++ b/doc/topics/stack_root.md @@ -199,7 +199,9 @@ that, in turn, contains a `bin` directory (the compiler tools directory for that compiler version). If the compiler tools directory for a specified compiler version does not exist, -and Stack needs that directory, then Stack will create it. +and Stack needs that directory, then Stack will create it. The directory can +also be created using Stack's +[`config compiler-tools` command](../commands/config_command.md#the-stack-config-compiler-tools-command) In the [Stack environment](stack_environment.md#the-compiler-tools-directory), the compiler tools directory for the specified compiler version is on the PATH. @@ -207,8 +209,7 @@ the compiler tools directory for the specified compiler version is on the PATH. For further information see: * The [Stack environment](stack_environment.md#the-compiler-tools-directory); -* Stack's [`path --compiler-tools-bin` command](../commands/path_command.md); - and +* Stack's [`path --compiler-tools-bin` command](../commands/path_command.md); and * Stack's [`build --copy-compiler-tool` command](../commands/build_command.md#-no-copy-compiler-tool-flag). diff --git a/doc/topics/stack_yaml_vs_cabal_package_file.md b/doc/topics/stack_yaml_vs_cabal_package_file.md index cc83764349..8d3b435d37 100644 --- a/doc/topics/stack_yaml_vs_cabal_package_file.md +++ b/doc/topics/stack_yaml_vs_cabal_package_file.md @@ -64,8 +64,8 @@ requires that you have chosen a specific version for each package available. The most common means by which this set of packages is defined is via a snapshot provided by Stackage. For example, if you go to the page -, you will see a list of 3,415 packages at -specific version numbers. When you then specify `snapshot: lts-24.24` you are +, you will see a list of 3,427 packages at +specific version numbers. When you then specify `snapshot: lts-24.43` you are telling Stack to use those package versions in resolving dependencies down to specific versions of packages. diff --git a/doc/tutorial/building_your_project.md b/doc/tutorial/building_your_project.md index 0d8ddc23aa..fa90eca480 100644 --- a/doc/tutorial/building_your_project.md +++ b/doc/tutorial/building_your_project.md @@ -249,7 +249,7 @@ With that out of the way, let us dig a little bit more into these snapshots. We mentioned the LTS snapshots, and you can get information about it at [https://www.stackage.org/lts](https://www.stackage.org/lts), including: -* The appropriate value (`lts-24.24`, as is currently the latest LTS) +* The appropriate value (`lts-24.43`, as is currently the latest LTS) * The GHC version used * A full list of all packages versions available in this snapshot * The ability to perform a Hoogle search on the packages in this snapshot diff --git a/doc/tutorial/executing_commands.md b/doc/tutorial/executing_commands.md index a0a9553ee4..56454e60f2 100644 --- a/doc/tutorial/executing_commands.md +++ b/doc/tutorial/executing_commands.md @@ -34,7 +34,7 @@ yields output like: Writing the configuration file for the implicit global project to: .../global-project/stack.yaml. Note: You can change the snapshot via the snapshot key there. -Using the latest snapshot lts-24.24. +Using the latest snapshot lts-24.43. I installed the stm package via --package stm ~~~ diff --git a/doc/tutorial/hello_world_example.md b/doc/tutorial/hello_world_example.md index b720c0f562..62f34b7a24 100644 --- a/doc/tutorial/hello_world_example.md +++ b/doc/tutorial/hello_world_example.md @@ -59,7 +59,7 @@ creating manually a Stack project-level configuration file named `stack.yaml` in `my-project`, with the contents: ~~~yaml -snapshot: lts-24.24 +snapshot: lts-24.43 ~~~ By adding those two files (one to describe a package, the other to configure the @@ -324,7 +324,7 @@ environment. !!! info On Windows, the [Stack environment](../topics/stack_environment.md) includes - the `\mingw64\bin`, `\usr\bin` and `\usr\local\bin` directories of the + the `\clang64\bin`, `\usr\bin` and `\usr\local\bin` directories of the Stack-supplied MSYS2. If your executable depends on files (for example, dynamic-link libraries) in those directories and you want ro run it outside of the Stack environment, you will need to ensure copies of those files are diff --git a/doc/tutorial/multi-package_projects.md b/doc/tutorial/multi-package_projects.md index dc0ddd9735..31c47a358a 100644 --- a/doc/tutorial/multi-package_projects.md +++ b/doc/tutorial/multi-package_projects.md @@ -37,10 +37,10 @@ Using the Cabal packages: Selecting the best among 14 snapshots... -Note: Matches https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/24/25.yaml +Note: Matches https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/24/43.yaml -Selected the snapshot https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/24/25.yaml. -Initialising Stack's project-level configuration file using snapshot https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/24/25.yaml. +Selected the snapshot https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/24/43.yaml. +Initialising Stack's project-level configuration file using snapshot https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/24/43.yaml. Considered 2 user packages. Writing configuration to stack.yaml. Stack's project-level configuration file has been initialised. @@ -51,7 +51,7 @@ should be something like this: ~~~yaml snapshot: - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/24/25.yaml + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/24/43.yaml packages: - packageA diff --git a/doc/tutorial/project_configuration.md b/doc/tutorial/project_configuration.md index 5b6e5bb598..a8af000d03 100644 --- a/doc/tutorial/project_configuration.md +++ b/doc/tutorial/project_configuration.md @@ -35,7 +35,7 @@ those comments, the contents will look something like this: ~~~yaml snapshot: - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/24/9.yaml + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/24/43.yaml packages: - . ~~~ @@ -44,7 +44,7 @@ The key [`snapshot`](../configure/yaml/project.md#snapshot) is a project-specific configuration option. Its value tells Stack *how* to build your package: which version of GHC (and, implicitly, its boot packages) to use; which versions of other package dependencies to use, and so on. Our value here says to -use [LTS Haskell 24.24](https://www.stackage.org/lts-24.24), which implies +use [LTS Haskell 24.43](https://www.stackage.org/lts-24.43), which implies GHC 9.10.3 (which is why `stack build` installs that version of GHC if it is not already available to Stack). There are a number of values you can use for `snapshot`, which we will cover later. diff --git a/etc/scripts/build-stack-installer.hs b/etc/scripts/build-stack-installer.hs index 97dac34b82..010b81ba79 100644 --- a/etc/scripts/build-stack-installer.hs +++ b/etc/scripts/build-stack-installer.hs @@ -1,5 +1,5 @@ {- stack script - --snapshot lts-24.24 + --snapshot lts-24.43 --package nsis -} {-# LANGUAGE OverloadedStrings #-} diff --git a/etc/scripts/release-linux-aarch64.hs b/etc/scripts/release-linux-aarch64.hs index fa12f28656..06f95c8d20 100644 --- a/etc/scripts/release-linux-aarch64.hs +++ b/etc/scripts/release-linux-aarch64.hs @@ -1,5 +1,5 @@ {- stack script - --snapshot lts-24.24 + --snapshot lts-24.43 --ghc-options -Wall -} @@ -7,7 +7,7 @@ -- interpreter options comment, Stack deduces the required packages from the -- module imports, being: Cabal, base, bytestring, directory, extra, process, -- shake, tar, zip-archive and zlib. These are either GHC boot packages or in --- the snapshot. Stackage LTS Haskell 24.24 does not include boot packages +-- the snapshot. Stackage LTS Haskell 24.43 does not include boot packages -- directly. As GHC 9.10.3 boot packages Cabal and Cabal-syntax expose modules -- with the same names, the language extension PackageImports is required. diff --git a/etc/scripts/release.hs b/etc/scripts/release.hs index 081e960497..0f17e7898d 100644 --- a/etc/scripts/release.hs +++ b/etc/scripts/release.hs @@ -1,5 +1,5 @@ {- stack script - --snapshot lts-24.24 + --snapshot lts-24.43 --ghc-options -Wall -} @@ -7,7 +7,7 @@ -- interpreter options comment, Stack deduces the required packages from the -- module imports, being: Cabal, base, bytestring, directory, extra, process, -- shake, tar, zip-archive and zlib. These are either GHC boot packages or in --- the snapshot. Stackage LTS Haskell 24.24 does not include boot packages +-- the snapshot. Stackage LTS Haskell 24.43 does not include boot packages -- directly. As GHC 9.10.3 boot packages Cabal and Cabal-syntax expose modules -- with the same names, the language extension PackageImports is required. diff --git a/etc/scripts/stack.yaml b/etc/scripts/stack.yaml index c5f61065a2..94d7af0974 100644 --- a/etc/scripts/stack.yaml +++ b/etc/scripts/stack.yaml @@ -6,4 +6,4 @@ # build-stack-installer.hs. The work around is to build the package required for # that script using the same Stack configuration as used by the script. -snapshot: lts-24.24 +snapshot: lts-24.43 diff --git a/mkdocs.yml b/mkdocs.yml index ae90c97ac0..7b35baaf22 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -100,6 +100,7 @@ nav: - configure/yaml/index.md - Project-specific configuration: configure/yaml/project.md - Non-project specific configuration: configure/yaml/non-project.md + - The !include directive: configure/yaml/include.md - Global flags and options: configure/global_flags.md - Customisation scripts: configure/customisation_scripts.md - Topics: diff --git a/package.yaml b/package.yaml index ddcadad022..47d3055feb 100644 --- a/package.yaml +++ b/package.yaml @@ -2,7 +2,7 @@ spec-version: 0.35.0 name: stack -version: '3.9.4' +version: '3.12.0' synopsis: A program for developing Haskell projects description: | Stack (the Haskell Tool Stack) is a program for developing Haskell projects. @@ -120,6 +120,7 @@ dependencies: - random - rio >= 0.1.22.0 && ( < 0.1.23.0 || > 0.1.23.0 ) - rio-prettyprint >= 0.1.8.0 +- semaphore-compat - split - stm - tar >= 0.6.2.0 @@ -303,6 +304,7 @@ library: - Stack.Types.Component - Stack.Types.ComponentUtils - Stack.Types.Config + - Stack.Types.ConfigExtra - Stack.Types.Config.Exception - Stack.Types.ConfigMonoid - Stack.Types.ConfigSetOpts diff --git a/src/Network/HTTP/StackClient.hs b/src/Network/HTTP/StackClient.hs index fb894d2e96..2a6bc48b90 100644 --- a/src/Network/HTTP/StackClient.hs +++ b/src/Network/HTTP/StackClient.hs @@ -80,16 +80,16 @@ import qualified Data.Text as T import Data.Time.Clock ( NominalDiffTime, diffUTCTime, getCurrentTime ) import Network.HTTP.Client - ( HttpException (..), HttpExceptionContent (..), Request - , RequestBody (..), Response (..), checkResponse, getUri - , method, parseRequest, parseUrlThrow, path, requestBody + ( HttpException (..), HttpExceptionContent (..), Manager + , Request, RequestBody (..), Response (..), checkResponse + , getUri, method, parseRequest, parseUrlThrow, path + , requestBody ) import Network.HTTP.Client.MultipartFormData ( formDataBody, partBS, partFileRequestBody, partLBS ) import Network.HTTP.Client.TLS - ( applyDigestAuth, displayDigestAuthException - , getGlobalManager - ) + ( displayDigestAuthException, getGlobalManager ) +import qualified Network.HTTP.Client.TLS ( applyDigestAuth ) import Network.HTTP.Conduit ( requestHeaders ) import Network.HTTP.Download ( CheckHexDigest (..), DownloadRequest, HashCheck (..) @@ -306,3 +306,15 @@ chunksOverTime diff = do then put (currentTime, mempty) >> yield acc' else put (lastTime, acc') go + +-- | Like 'Network.HTTP.Client.TLS.applyDigestAuth' but sets the User-Agent +-- request header. +applyDigestAuth :: + (MonadIO m, MonadThrow n) + => Strict.ByteString + -> Strict.ByteString + -> Request + -> Manager + -> m (n Request) +applyDigestAuth user pass = + Network.HTTP.Client.TLS.applyDigestAuth user pass . setUserAgent diff --git a/src/Stack/Build.hs b/src/Stack/Build.hs index 06e754eca5..fb70273576 100644 --- a/src/Stack/Build.hs +++ b/src/Stack/Build.hs @@ -41,6 +41,7 @@ import Stack.Package ( buildableExes, resolvePackage ) import Stack.Prelude hiding ( loadPackage ) import Stack.Runners ( ShouldReexec (..), withConfig, withEnvConfig ) import Stack.Setup ( withNewLocalBuildTargets ) +import Stack.Types.Build.ConstructPlan ( PackageLoader ) import Stack.Types.Build.Exception ( BuildException (..), BuildPrettyException (..) ) import Stack.Types.BuildConfig ( HasBuildConfig, configFileL ) @@ -408,13 +409,7 @@ mkBaseConfigOpts buildOptsCLI = do } -- | Provide a function for loading package information from the package index -loadPackage :: - (HasBuildConfig env, HasSourceMap env) - => PackageLocationImmutable - -> Map FlagName Bool - -> [Text] -- ^ GHC options - -> [Text] -- ^ Cabal configure options - -> RIO env Package +loadPackage :: (HasBuildConfig env, HasSourceMap env) => PackageLoader (RIO env) loadPackage loc flags ghcOptions cabalConfigOpts = do compilerVersion <- view actualCompilerVersionL platform <- view platformL diff --git a/src/Stack/Build/Cache.hs b/src/Stack/Build/Cache.hs index 2f5aca0d3e..366ae18b39 100644 --- a/src/Stack/Build/Cache.hs +++ b/src/Stack/Build/Cache.hs @@ -79,9 +79,7 @@ import Stack.Types.EnvConfig ) import Stack.Types.GhcPkgId ( ghcPkgIdString ) import Stack.Types.Installed - ( InstallLocation (..), Installed (..) - , InstalledLibraryInfo (..), foldOnGhcPkgId' - ) + ( InstallLocation (..), Installed (..), foldOnGhcPkgId' ) import Stack.Types.NamedComponent ( NamedComponent (..), componentCachePath ) import Stack.Types.SourceMap ( smRelDir ) @@ -301,12 +299,9 @@ deleteCaches dir = flagCacheKey :: (HasEnvConfig env) => Installed -> RIO env ConfigCacheKey flagCacheKey installed = do installationRoot <- installationRootLocal - case installed of - Library _ installedInfo -> do - let gid = installedInfo.ghcPkgId - pure $ configCacheKey installationRoot (ConfigCacheTypeFlagLibrary gid) - Executable ident -> pure $ - configCacheKey installationRoot (ConfigCacheTypeFlagExecutable ident) + pure $ configCacheKey installationRoot $ case installed of + Library ident _ -> ConfigCacheTypeFlagLibrary ident + Executable ident -> ConfigCacheTypeFlagExecutable ident -- | Loads the Cabal flag cache for the given installed extra-deps. tryGetFlagCache :: diff --git a/src/Stack/Build/ConstructPlan.hs b/src/Stack/Build/ConstructPlan.hs index 8a625945a1..ddb92bed59 100644 --- a/src/Stack/Build/ConstructPlan.hs +++ b/src/Stack/Build/ConstructPlan.hs @@ -46,10 +46,10 @@ import Stack.Package import Stack.Prelude hiding ( loadPackage ) import Stack.SourceMap ( getPLIVersion, mkProjectPackage ) import Stack.Types.Build.ConstructPlan - ( AddDepRes (..), CombinedMap, Ctx (..), M - , MissingPresentDeps (..), PackageInfo (..), ToolWarning(..) - , UnregisterState (..), W (..), adrHasLibrary, adrVersion - , isAdrToInstall, toTask + ( AddDepRes (..), CombinedMap, Ctx (..), LibraryMap, M + , MissingPresentDeps (..), PackageInfo (..), PackageLoader + , ToolWarning(..), UnregisterState (..), W (..) + , adrHasLibrary, adrVersion, isAdrToInstall, toTask ) import Stack.Types.Build.Exception ( BadDependency (..), BuildException (..) @@ -121,16 +121,11 @@ import System.Environment ( lookupEnv ) constructPlan :: forall env. HasEnvConfig env => BaseConfigOpts - -> [DumpPackage] -- ^ locally registered - -> ( PackageLocationImmutable - -> Map FlagName Bool - -> [Text] - -- ^ GHC options - -> [Text] - -- ^ Cabal configure options - -> RIO EnvConfig Package - ) - -- ^ load upstream package + -> [DumpPackage] + -- ^ Locally registered. + -> PackageLoader (RIO EnvConfig) + -- ^ Function to load a 'Package' given the location of a package assumed + -- to be immutable. -> SourceMap -> InstalledMap -> Bool @@ -195,14 +190,22 @@ constructPlan let ctx = mkCtx econfig globalCabalVersion sources curator pathEnvVar targetPackageNames = Map.keys sourceMap.targets.targets -- Ignore the result of 'getCachedDepOrAddDep'. - onTarget = void . getCachedDepOrAddDep + onTarget pkgName = do + logDebugPlanS "constructPlan" $ + "Constructing for target " + <> fromPackageName pkgName + void $ getCachedDepOrAddDep pkgName + inner :: M () inner = mapM_ onTarget targetPackageNames - (((), W efinals installExes dirtyReason warnings parents), m) <- - liftIO $ runRIO ctx (runStateT (runWriterT inner) Map.empty) + action :: RIO Ctx (((), W), LibraryMap) + action = runStateT (runWriterT inner) Map.empty + (((), output), libraryMap) <- liftIO $ runRIO ctx action + let W efinals installExes dirtyReason warnings parents = output -- Report any warnings mapM_ prettyWarn (warnings []) -- Separate out errors - let (errlibs, adrs) = partitionEithers $ map toEither $ Map.toList m + let (errlibs, adrs) = + partitionEithers $ map toEither $ Map.toList libraryMap (errfinals, finals) = partitionEithers $ map toEither $ Map.toList efinals errs = errlibs ++ errfinals @@ -239,18 +242,30 @@ constructPlan hasBaseInDeps = Map.member (mkPackageName "base") sourceDeps - mkCtx ctxEnvConfig globalCabalVersion sources curator pathEnvVar = Ctx - { baseConfigOpts = baseConfigOpts0 - , loadPackage = \w x y z -> runRIO ctxEnvConfig $ - applyForceCustomBuild globalCabalVersion <$> loadPackage0 w x y z - , combinedMap = combineMap sources installedMap - , ctxEnvConfig - , callStack = [] - , wanted = Map.keysSet sourceMap.targets.targets - , localNames = Map.keysSet sourceProject - , curator - , pathEnvVar - } + mkCtx :: + EnvConfig + -> Version + -> Map PackageName PackageSource + -> Maybe Curator + -> Text + -> Ctx + mkCtx ctxEnvConfig globalCabalVersion sources curator pathEnvVar = + let loadPackage loc flags ghcOptions cabalConfigOpts = do + let action = do + package <- loadPackage0 loc flags ghcOptions cabalConfigOpts + pure $ applyForceCustomBuild globalCabalVersion package + runRIO ctxEnvConfig action + in Ctx + { baseConfigOpts = baseConfigOpts0 + , loadPackage + , combinedMap = combineMap sources installedMap + , ctxEnvConfig + , callStack = [] + , wanted = Map.keysSet sourceMap.targets.targets + , localNames = Map.keysSet sourceProject + , curator + , pathEnvVar + } toEither :: (k, Either e v) -> Either e (k, v) toEither (_, Left e) = Left e @@ -467,7 +482,10 @@ addFinal :: -- ^ Should Haddock documentation be built? -> M () addFinal lp package allInOne buildHaddocks = do - res <- addPackageDeps package >>= \case + let name = package.name + logDebugPlanS "addFinal" "Clearing the call stack." + res <- local (\ctx' -> ctx' { callStack = [] }) $ + addPackageDeps package >>= \case Left e -> pure $ Left e Right (MissingPresentDeps missing present _minLoc) -> do let pkgConfigOpts = packageConfigureOptsFromPackage package @@ -489,24 +507,30 @@ addFinal lp package allInOne buildHaddocks = do , cachePkgSrc = CacheSrcLocal (toFilePath (parent lp.cabalFP)) , buildTypeConfig = packageBuildTypeConfig package } - tell mempty { wFinals = Map.singleton package.name res } + ctx <- ask + logDebugPlanS "addFinal" $ + "Restoring the call stack: " + <> fromString (show $ map packageNameString ctx.callStack) + logDebugPlanS "addFinal" $ + "Adding to construction output " + <> fromPackageName name + <> summariseResult res + tell mempty { wFinals = Map.singleton name res } -- | Given a 'PackageName', adds all of the build tasks to build the package, if -- needed. First checks if the package name is in the library map. -- --- 'constructPlan' invokes this on all the target packages, setting --- @treatAsDep'@ to False, because those packages are direct build targets. +-- 'constructPlan' invokes this on all the target packages. +-- -- 'addPackageDeps' invokes this while recursing into the dependencies of a --- package. As such, it sets @treatAsDep'@ to True, forcing this package to be --- marked as a dependency, even if it is directly wanted. This makes sense - if --- we left out packages that are deps, it would break the --only-dependencies --- build plan. +-- package, even if it is directly wanted. This makes sense - if we left out +-- packages that are deps, it would break the --only-dependencies build plan. getCachedDepOrAddDep :: PackageName -> M (Either ConstructPlanException AddDepRes) getCachedDepOrAddDep name = do - libMap <- get - case Map.lookup name libMap of + libraryMap <- get + case Map.lookup name libraryMap of Just res -> do logDebugPlanS "getCachedDepOrAddDep" $ "Using cached result for " @@ -542,10 +566,19 @@ checkCallStackAndAddDep name = do <> fromPackageName name <> "." pure $ Left $ UnknownPackage compiler name - Just packageInfo -> + Just packageInfo -> do + logDebugPlanS "checkCallStackAndAddDep" $ + "Pushing " + <> fromPackageName name + <> " on to the call stack." -- Add the current package name to the head of the call stack. - local (\ctx' -> ctx' { callStack = name : ctx'.callStack }) $ + res <- local (\ctx' -> ctx' { callStack = name : ctx'.callStack }) $ addDep name packageInfo + logDebugPlanS "checkCallStackAndAddDep" $ + "Popped " + <> fromPackageName name + <> " from the call stack." + pure res updateLibMap name res pure res @@ -679,15 +712,16 @@ installPackage name ps minstalled = do resolveDepsAndInstall True lp.buildHaddocks ps lp.package minstalled Just tb -> do + -- Preserve the current library map. + libMap <- get -- Attempt to find a plan which performs an all-in-one build. Ignore -- the writer action + reset the state if it fails. - libMap <- get res <- pass $ do res <- addPackageDeps tb - let writerFunc w = case res of - Left _ -> mempty - _ -> w - pure (res, writerFunc) + let modifyOutput = case res of + Left _ -> const mempty + _ -> id + pure (res, modifyOutput) case res of Right deps -> do logDebugPlanS "installPackage" $ @@ -759,8 +793,14 @@ installPackageGivenDeps :: -> Maybe Installed -> MissingPresentDeps -> M AddDepRes -installPackageGivenDeps allInOne buildHaddocks ps package minstalled - (MissingPresentDeps missing present minMutable) = do +installPackageGivenDeps + allInOne + buildHaddocks + ps + package + minstalled + (MissingPresentDeps missing present minMutable) + = do let name = package.name mRightVersionInstalled <- case minstalled of Just installed -> if Set.null missing @@ -813,10 +853,15 @@ packageBuildTypeConfig pkg = pkg.buildType == Configure -- Update response in the library map. If it is an error, and there's already an -- error about cyclic dependencies, prefer the cyclic error. updateLibMap :: PackageName -> Either ConstructPlanException AddDepRes -> M () -updateLibMap name val = modify $ \mp -> - case (Map.lookup name mp, val) of - (Just (Left DependencyCycleDetected{}), Left _) -> mp - _ -> Map.insert name val mp +updateLibMap name res = do + logDebugPlanS "updateLibMap" $ + "Updating for: " + <> fromPackageName name + <> summariseResult res + modify $ \mp -> + case (Map.lookup name mp, res) of + (Just (Left DependencyCycleDetected{}), Left _) -> mp + _ -> Map.insert name res mp addEllipsis :: Text -> Text addEllipsis t @@ -1036,7 +1081,7 @@ checkDirtiness :: PackageSource -> Installed -> Package - -> Map PackageIdentifier GhcPkgId + -> Map MungedPackageId GhcPkgId -> Bool -- ^ Is Haddock documentation being built? -> M Bool @@ -1264,6 +1309,12 @@ logDebugPlanS s msg = do debugPlan <- view $ globalOptsL . to (.planInLog) when debugPlan $ logDebugS s msg +-- | A function to summarise a result. Assumes that 'Left' is an error and +-- 'Right' is not. Intended to be used to annotate, so includes an initial space +-- character. +summariseResult :: Either a b -> Utf8Builder +summariseResult res = " (" <> either (const "error") (const "ok") res <> ")" + -- | A function to yield a 'PackageInfo' value from: (1) a 'PackageSource' -- value; and (2) a pair of an 'InstallLocation' value and an 'Installed' value. -- Checks that the version of the 'PackageSource' value and the version of the diff --git a/src/Stack/Build/ExecuteEnv.hs b/src/Stack/Build/ExecuteEnv.hs index 11f4837b88..5ae611b9bb 100644 --- a/src/Stack/Build/ExecuteEnv.hs +++ b/src/Stack/Build/ExecuteEnv.hs @@ -54,6 +54,7 @@ import qualified Distribution.Simple.Build.Macros as C import Distribution.System ( OS (..), Platform (..) ) import Distribution.Types.PackageName ( mkPackageName ) import Distribution.Verbosity ( showForCabal ) +import Distribution.Version ( mkVersion ) import Path ( PathException, (), parent, parseRelDir, parseRelFile ) import Path.Extra ( forgivingResolveFile, toFilePathNoTrailingSep ) @@ -78,7 +79,7 @@ import Stack.Prelude import Stack.Types.ApplyGhcOptions ( ApplyGhcOptions (..) ) import Stack.Types.Build ( ConvertPathsToAbsolute (..), ExcludeTHLoading (..) - , KeepOutputOpen (..) + , KeepOutputOpen (..), RunCabalWithArgs ) import Stack.Types.Build.Exception ( BuildException (..), BuildPrettyException (..) ) @@ -86,7 +87,9 @@ import Stack.Types.BuildOpts ( BuildOpts (..) ) import Stack.Types.BuildOptsCLI ( BuildOptsCLI (..) ) import Stack.Types.BuildOptsMonoid ( CabalVerbosity (..) ) import Stack.Types.Compiler - ( WhichCompiler (..), compilerVersionString, whichCompilerL ) + ( WhichCompiler (..), compilerVersionString + , getGhcVersion, whichCompilerL + ) import Stack.Types.CompilerPaths ( CompilerPaths (..), HasCompiler (..), cabalVersionL , getCompilerPath @@ -94,7 +97,8 @@ import Stack.Types.CompilerPaths import Stack.Types.Config ( Config (..), HasConfig (..), stackRootL ) import Stack.Types.ConfigureOpts ( BaseConfigOpts (..) ) -import Stack.Types.Dependency ( DepValue(..) ) +import Stack.Types.Dependency + ( DepLibrary (..), DepType (..), DepValue (..) ) import Stack.Types.DumpLogs ( DumpLogs (..) ) import Stack.Types.DumpPackage ( DumpPackage (..) ) import Stack.Types.EnvConfig @@ -105,7 +109,9 @@ import Stack.Types.EnvSettings ( EnvSettings (..) ) import Stack.Types.GhcPkgId ( GhcPkgId, ghcPkgIdString ) import Stack.Types.Installed ( InstallLocation (..), Installed (..) ) import Stack.Types.Package - ( LocalPackage (..), Package (..), packageIdentifier ) + ( LocalPackage (..), Package (..), packageIdentifier + , toCabalMungedPackageName + ) import Stack.Types.Plan ( TaskType (..), taskTypeLocation, taskTypePackageIdentifier ) @@ -115,6 +121,8 @@ import qualified System.Directory as D import System.Environment ( lookupEnv ) import System.FileLock ( SharedExclusive (..), withFileLock, withTryFileLock ) +import System.Semaphore + ( Semaphore, destroySemaphore, freshSemaphore ) -- | Type representing environments in which the @Setup.hs@ commands of Cabal -- (the library) can be executed. @@ -147,6 +155,8 @@ data ExecuteEnv = ExecuteEnv -- ^ For nicer interleaved output: track the largest package name size , pathEnvVar :: !Text -- ^ Value of the PATH environment variable + , semaphore :: !(Maybe Semaphore) + -- ^ The semaphore that is used for job control, if --semaphore is given } -- | Type representing setup executable circumstances. @@ -256,6 +266,9 @@ getSetupExe setupHs setupShimHs tmpdir = do renameFile tmpExePath exePath pure $ Just exePath +semaphorePrefix :: String +semaphorePrefix = "stack" + -- | Execute a function that takes an t'ExecuteEnv'. withExecuteEnv :: forall env a. HasEnvConfig env @@ -320,6 +333,8 @@ withExecuteEnv ignoringAbsence (removeFile setupO) ignoringAbsence (removeFile setupShimHi) ignoringAbsence (removeFile setupShimO) + compilerVersion <- view actualCompilerVersionL + let ghcVersion = getGhcVersion compilerVersion cabalPkgVer <- view cabalVersionL globalDB <- view $ compilerPathsL . to (.globalDB) let globalDumpPkgs = toDumpPackagesByGhcPkgId globalPackages @@ -330,6 +345,27 @@ withExecuteEnv logFiles <- liftIO $ atomically newTChan let totalWanted = length $ filter (.wanted) locals pathEnvVar <- liftIO $ maybe mempty T.pack <$> lookupEnv "PATH" + jobs <- view $ configL . to (.jobs) + let semaphoreSupported = + (cabalPkgVer >= mkVersion [3, 12, 0, 0]) + && (ghcVersion >= mkVersion [9, 8, 1]) + semaphoreUnsupportedWarning = + prettyWarnL + [ "The" + , style Shell "--semaphore" + , flow "flag was specified, which is supported by GHC 9.8.1 or \ + \later with Cabal 3.12.0.0 (a boot package of GHC 9.10.1) \ + \or later. GHC version" + , fromString (versionString ghcVersion) + , flow "and Cabal version" + , fromString (versionString cabalPkgVer) + , flow "was found. The flag will be ignored." + ] + semaphore <- if not buildOpts.semaphore + then pure Nothing + else if semaphoreSupported + then Just <$> liftIO (freshSemaphore semaphorePrefix jobs) + else semaphoreUnsupportedWarning >> pure Nothing inner ExecuteEnv { buildOpts , buildOptsCLI @@ -355,7 +391,10 @@ withExecuteEnv , customBuilt , largestPackageName , pathEnvVar - } `finally` dumpLogs logFiles totalWanted + , semaphore + } `finally` do + liftIO (whenJust semaphore destroySemaphore) + dumpLogs logFiles totalWanted where toDumpPackagesByGhcPkgId = Map.fromList . map (\dp -> (dp.ghcPkgId, dp)) @@ -560,21 +599,25 @@ withSingleContext :: => ActionContext -> ExecuteEnv -> TaskType - -> Map PackageIdentifier GhcPkgId - -- ^ All dependencies' package ids to provide to Setup.hs. + -> Map MungedPackageId GhcPkgId + -- ^ Ids of Installed packages that are assumed to be available to build a + -- package's custom @Setup.hs@, given its dependencies specified in its + -- @custom-setup@ stanza of its Cabal file. -> Maybe String + -- ^ An optional suffix for the build log's file name. -> ( Package -- Package info -> Path Abs File -- Cabal file path -> Path Abs Dir -- Package root directory file path -- Note that the `Path Abs Dir` argument is redundant with the -- `Path Abs File` argument, but we provide both to avoid recalculating -- `parent` of the `File`. - -> (KeepOutputOpen -> ExcludeTHLoading -> [String] -> RIO env ()) - -- Function to run Cabal with args + -> RunCabalWithArgs env + -- Function to run Cabal (the library) with arguments. -> (Utf8Builder -> RIO env ()) -- An plain 'announce' function, for different build phases -> OutputType - -> RIO env a) + -> RIO env a + ) -> RIO env a withSingleContext ac @@ -672,7 +715,8 @@ withSingleContext Package -> Path Abs Dir -> OutputType - -> ( (KeepOutputOpen -> ExcludeTHLoading -> [String] -> RIO env ()) + -> ( RunCabalWithArgs env + -- Function to run Cabal (the library) with arguments. -> RIO env a ) -> RIO env a @@ -688,7 +732,7 @@ withSingleContext , keepGhcRts = False } menv <- liftIO $ config.processContextSettings envSettings - distRelativeDir' <- distRelativeDir + distDir' <- distDirFromDir pkgDir setupexehs <- -- Avoid broken Setup.hs files causing problems for simple build -- types, see: @@ -759,25 +803,57 @@ withSingleContext pure cabalPackageArg matchedDeps <- forM (Map.toList customSetupDeps) $ \(name, depValue) -> do - let matches (PackageIdentifier name' version) = - name == name' + let mungedPkgNames = depToMungedPkgNames name depValue + countMungedPkgNames = Set.size mungedPkgNames + matches (MungedPackageId mungedPkgName version) _ = + mungedPkgName `Set.member` mungedPkgNames && version `withinRange` depValue.versionRange - case filter (matches . fst) (Map.toList allDeps) of - x:xs -> do - unless (null xs) $ - prettyWarnL - [ flow "Found multiple installed packages for \ - \custom-setup dep:" - , style Current (fromPackageName name) <> "." - ] - pure ("-package-id=" ++ ghcPkgIdString (snd x), Just (fst x)) - [] -> do + case Map.filterWithKey matches allDeps of + matchedDeps | Map.null matchedDeps -> do prettyWarnL [ flow "Could not find custom-setup dep:" , style Current (fromPackageName name) <> "." ] - pure ("-package=" ++ packageNameString name, Nothing) - let depsArgs = map fst matchedDeps + pure (["-package=" <> packageNameString name], Nothing) + matchedDeps -> do + let groupMatchedByVersion = + Map.foldlWithKey' + ( \acc k v -> + let p = mungedVersion k + innerMap = Map.singleton k v + in Map.insertWith Map.union p innerMap acc + ) + Map.empty + matchedDeps + countMatchedDeps = Map.size matchedDeps + if Map.size groupMatchedByVersion == 1 + then do + when (countMatchedDeps < countMungedPkgNames) $ + prettyWarnL + [ flow "Found insufficent installed packages \ + \for custom-setup dep:" + , style Current (fromPackageName name) <> "." + ] + else do + prettyWarnL + [ flow "Found installed packages with multiple \ + \versions for custom-setup dep:" + , style Current (fromPackageName name) <> "." + ] + let packageIdOpt ghcPkgId = + "-package-id=" <> ghcPkgIdString ghcPkgId + -- The previous algorithm (arbitrarily?) selected + -- the first relevant item yielded by Map.toList + -- (which is Map.toAscList), so we select the + -- minimum: + selectedGroup = Map.findMin groupMatchedByVersion + selectedVersion = fst selectedGroup + packageIdOpts = + map packageIdOpt $ Map.elems $ snd selectedGroup + selectedPkgId = + PackageIdentifier name selectedVersion + pure (packageIdOpts, Just selectedPkgId) + let depsArgs = L.concatMap fst matchedDeps -- Generate setup_macros.h and provide it to ghc let macroDeps = mapMaybe snd matchedDeps cppMacrosFile = setupDir relFileSetupMacrosH @@ -837,7 +913,26 @@ withSingleContext <> cabalPackageArg setupArgs = - ("--builddir=" ++ toFilePathNoTrailingSep distRelativeDir') : args + ("--builddir=" ++ toFilePathNoTrailingSep distDir') : args + + depToMungedPkgNames :: + PackageName + -- ^ The name of the Cabal package. + -> DepValue + -- ^ The dependency value for that package. + -> Set.Set MungedPackageName + depToMungedPkgNames pkgName depValue + | AsLibrary depLibrary <- depValue.depType = + let addMain = if depLibrary.main + then Set.insert mungedMainPkgName + else id + mungedMainPkgName = toCabalMungedPackageName pkgName Nothing + subLibSet = + Set.map + (toCabalMungedPackageName pkgName . Just) + depLibrary.subLib + in addMain subLibSet + | otherwise = Set.empty runExe :: Path Abs File -> [String] -> RIO env () runExe exeName fullArgs = do diff --git a/src/Stack/Build/ExecutePackage.hs b/src/Stack/Build/ExecutePackage.hs index 33d95f05d2..233a9a56b9 100644 --- a/src/Stack/Build/ExecutePackage.hs +++ b/src/Stack/Build/ExecutePackage.hs @@ -68,6 +68,8 @@ import Stack.Build.ExecuteEnv ( ExcludeTHLoading (..), ExecuteEnv (..), KeepOutputOpen (..) , OutputType (..), withSingleContext ) +import Stack.Build.TestSuiteTimeout + ( forceKill, prepareForEscalation, terminateGracefully ) import Stack.Build.Source ( addUnlistedToBuildCache ) import Stack.Config.ConfigureScript ( ensureConfigureScript ) import Stack.ConfigureOpts @@ -86,6 +88,7 @@ import Stack.Package ) import Stack.PackageDump ( conduitDumpPackage, ghcPkgDescribe ) import Stack.Prelude +import Stack.Types.Build ( RunCabalWithArgs ) import Stack.Types.Build.Exception ( BuildException (..), BuildPrettyException (..) ) import Stack.Types.BuildConfig @@ -127,7 +130,7 @@ import Stack.Types.GhcPkgId ( GhcPkgId, ghcPkgIdToText ) import Stack.Types.GlobalOpts ( GlobalOpts (..) ) import Stack.Types.Installed ( InstallLocation (..), Installed (..), InstalledMap - , InstalledLibraryInfo (..) + , InstalledLibraryInfo (..), simpleInstalledLib ) import Stack.Types.IsMutable ( IsMutable (..) ) import Stack.Types.NamedComponent @@ -136,8 +139,7 @@ import Stack.Types.NamedComponent ) import Stack.Types.Package ( LocalPackage (..), Package (..), installedPackageToGhcPkgId - , runMemoizedWith, simpleInstalledLib - , toCabalMungedPackageName + , runMemoizedWith, toCabalMungedPackageName ) import Stack.Types.PackageFile ( PackageWarning (..) ) import Stack.Types.Plan @@ -151,6 +153,7 @@ import System.IO.Error ( isDoesNotExistError ) import System.PosixCompat.Files ( createLink, getFileStatus, modificationTime ) import System.Random ( randomIO ) +import System.Semaphore ( Semaphore (..), SemaphoreName (..) ) -- | Generate the t'ConfigCache' value. getConfigCache :: @@ -160,7 +163,7 @@ getConfigCache :: -> InstalledMap -> Bool -> Bool - -> RIO env (Map PackageIdentifier GhcPkgId, ConfigCache) + -> RIO env (Map MungedPackageId GhcPkgId, ConfigCache) getConfigCache ee task installedMap enableTest enableBench = do let extra = -- We enable tests if the test suite dependencies are already @@ -195,11 +198,11 @@ getConfigCache ee task installedMap enableTest enableBench = do -- collision for the return here. But unifying things with configureOpts -- where it was the opposite resulted in this. It doesn't seem to make any -- difference anyway. - allDepsMap = Map.union missing' task.present + allDeps = Map.union missing' task.present configureOpts' = configureOptsFromBase cOpts.envConfig cOpts.baseConfigOpts - allDepsMap + allDeps cOpts.isLocalNonExtraDep cOpts.isMutable pcOpts @@ -218,7 +221,7 @@ getConfigCache ee task installedMap enableTest enableBench = do , pkgSrc = task.cachePkgSrc , pathEnvVar = ee.pathEnvVar } - pure (allDepsMap, cache) + pure (allDeps, cache) -- | Ensure that the configuration for the package matches what is given ensureConfig :: @@ -381,7 +384,7 @@ singleBuild installedMap isFinalBuild = do - (allDepsMap, cache) <- + (allDeps, cache) <- getConfigCache ee task installedMap enableTests enableBenchmarks let bcoSnapInstallRoot = ee.baseConfigOpts.snapInstallRoot mprecompiled <- getPrecompiled cache task.taskType bcoSnapInstallRoot @@ -399,7 +402,7 @@ singleBuild (isFinalBuild, buildingFinals) cache curator - allDepsMap + allDeps whenJust minstalled $ \installed -> do writeFlagCache installed cache liftIO $ atomically $ modifyTVar ee.ghcPkgIds $ Map.insert pkgId installed @@ -421,7 +424,10 @@ realConfigAndBuild :: -- ^ (isFinalBuild, buildingFinals) -> ConfigCache -> Maybe Curator - -> Map PackageIdentifier GhcPkgId + -> Map MungedPackageId GhcPkgId + -- ^ Ids of installed packages that are assumed to be available to build a + -- package's custom @Setup.hs@, given its dependencies specified in its + -- @custom-setup@ stanza of its Cabal file. -> RIO env (Maybe Installed) realConfigAndBuild ac @@ -432,8 +438,8 @@ realConfigAndBuild (isFinalBuild, buildingFinals) cache mcurator0 - allDepsMap - = withSingleContext ac ee task.taskType allDepsMap Nothing $ + allDeps + = withSingleContext ac ee task.taskType allDeps Nothing $ \package cabalFP pkgDir cabal0 announce _outputType -> do let cabal = cabal0 CloseOnException _neededConfig <- @@ -505,9 +511,10 @@ realConfigAndBuild realBuild :: Package -> Path Abs Dir - -> (KeepOutputOpen -> ExcludeTHLoading -> [String] -> RIO env ()) + -> RunCabalWithArgs env + -- ^ Function to run Cabal (the library) with arguments. -> (Utf8Builder -> RIO env ()) - -- ^ A plain 'announce' function + -- ^ A plain 'announce' function. -> RIO env Installed realBuild package pkgDir cabal0 announce = do let cabal = cabal0 CloseOnException @@ -569,7 +576,7 @@ realConfigAndBuild <> display actualCompiler ) config <- view configL - extraOpts <- extraBuildOptions wc ee.buildOpts + extraOpts <- extraBuildOptions wc ee.buildOpts ee.semaphore let stripTHLoading | config.hideTHLoading = ExcludeTHLoading | otherwise = KeepTHLoading @@ -641,9 +648,9 @@ realConfigAndBuild announce "copy/register" try (cabal KeepTHLoading $ "copy" : copyOpts) >>= \case Left err@CabalExitedUnsuccessfully{} -> - throwM $ CabalCopyFailed - (package.buildType == C.Simple) - (displayException err) + prettyThrowM $ CabalCopyFailed + (package.buildType == C.Simple) + err _ -> pure () when (hasLibrary || hasSubLibraries) $ cabal KeepTHLoading ["register"] @@ -718,27 +725,28 @@ fetchAndMarkInstalledPackage :: -> PackageIdentifier -> RIO env Installed fetchAndMarkInstalledPackage ee taskInstallLocation package pkgId = do - let ghcPkgIdLoader = fetchGhcPkgIdForLib ee taskInstallLocation package.name - -- Only pure the sub-libraries to cache them if we also cache the main - -- library (that is, if it exists) - if hasBuildableMainLibrary package + let hasMainLibrary = hasBuildableMainLibrary package + subLibs = package.subLibraries + if not hasMainLibrary && null subLibs then do - let foldSubLibToMap subLib mapInMonad = do - maybeGhcpkgId <- ghcPkgIdLoader (Just subLib.name) - mapInMonad <&> case maybeGhcpkgId of - Just v -> Map.insert subLib.name v - _ -> id - subLibsPkgIds <- foldComponentToAnotherCollection - package.subLibraries - foldSubLibToMap - mempty - ghcPkgIdLoader Nothing >>= \case - Nothing -> throwM $ Couldn'tFindPkgId package.name - Just ghcPkgId -> pure $ simpleInstalledLib pkgId ghcPkgId subLibsPkgIds - else do - markExeInstalled taskInstallLocation pkgId -- TODO unify somehow - -- with writeFlagCache? + markExeInstalled taskInstallLocation pkgId + -- TODO: Unify the above somehow with writeFlagCache? pure $ Executable pkgId + else do + ghcPkgId <- if hasMainLibrary + then ghcPkgIdLoader Nothing + else pure Nothing + subLibsPkgIds <- + foldComponentToAnotherCollection subLibs foldSubLibToMap mempty + pure $ simpleInstalledLib pkgId ghcPkgId subLibsPkgIds + where + ghcPkgIdLoader = fetchGhcPkgIdForLib ee taskInstallLocation package.name + + foldSubLibToMap subLib mapInMonad = do + maybeGhcpkgId <- ghcPkgIdLoader (Just subLib.name) + mapInMonad <&> case maybeGhcpkgId of + Just v -> Map.insert subLib.name v + _ -> id fetchGhcPkgIdForLib :: (HasTerm env, HasEnvConfig env) @@ -747,7 +755,7 @@ fetchGhcPkgIdForLib :: -> PackageName -> Maybe Component.StackUnqualCompName -> RIO env (Maybe GhcPkgId) -fetchGhcPkgIdForLib ee installLocation pkgName libName = do +fetchGhcPkgIdForLib ee installLocation pkgName mLibName = do let baseConfigOpts = ee.baseConfigOpts (installedPkgDb, installedDumpPkgsTVar) = case installLocation of @@ -758,11 +766,9 @@ fetchGhcPkgIdForLib ee installLocation pkgName libName = do ( baseConfigOpts.localDB , ee.localDumpPkgs ) let commonLoader = loadInstalledPkg [installedPkgDb] installedDumpPkgsTVar - case libName of - Nothing -> commonLoader pkgName - Just v -> do - let mungedName = encodeCompatPackageName $ toCabalMungedPackageName pkgName v - commonLoader mungedName + mungedPkgName = toCabalMungedPackageName pkgName mLibName + encodedPkgName = encodeCompatPackageName mungedPkgName + commonLoader encodedPkgName -- | Copy ddump-* files, if we are building finals and a non-empty ddump-dir -- has been specified. @@ -918,7 +924,7 @@ copyPreCompiled ee task pkgId (PrecompiledCache mlib subLibs exes) = do pure $ Just $ case mpkgid of Nothing -> assert False $ Executable pkgId - Just pkgid -> simpleInstalledLib pkgId pkgid mempty + _ -> simpleInstalledLib pkgId mpkgid mempty where bindir = ee.baseConfigOpts.snapInstallRoot bindirSuffix @@ -991,11 +997,11 @@ singleTest :: singleTest topts testsToRun ac ee task installedMap = do -- FIXME: Since this doesn't use cabal, we should be able to avoid using a -- full blown 'withSingleContext'. - (allDepsMap, _cache) <- getConfigCache ee task installedMap True False + (allDeps, _cache) <- getConfigCache ee task installedMap True False mcurator <- view $ buildConfigL . to (.curator) let pname = pkgName $ taskProvides task expectFailure = expectTestFailure pname mcurator - withSingleContext ac ee task.taskType allDepsMap (Just "test") $ + withSingleContext ac ee task.taskType allDeps (Just "test") $ \package _cabalfp pkgDir _cabal announce outputType -> do config <- view configL let needHpc = topts.coverage @@ -1059,8 +1065,8 @@ singleTest topts testsToRun ac ee task installedMap = do idMap <- liftIO $ readTVarIO ee.ghcPkgIds pure $ Map.lookup (taskProvides task) idMap let pkgGhcIdList = case installed of - Just (Library _ libInfo) -> [libInfo.ghcPkgId] - _ -> [] + Just (Library _ libInfo) -> maybeToList libInfo.mMainGhcPkgId + _ -> [] -- doctest relies on template-haskell in QuickCheck-based tests thGhcId <- case L.find ((== "template-haskell") . pkgName . (.packageIdent) . snd) @@ -1100,7 +1106,7 @@ singleTest topts testsToRun ac ee task installedMap = do <> display (ghcPkgIdToText ghcId) <> "\n" ) - (pkgGhcIdList ++ thGhcId:Map.elems allDepsMap) + (pkgGhcIdList ++ thGhcId : Map.elems allDeps) writeFileUtf8Builder fp ghcEnv menv <- liftIO $ setEnv fp =<< config.processContextSettings EnvSettings @@ -1155,13 +1161,47 @@ singleTest topts testsToRun ac ee task installedMap = do ) createSource OTLogFile _ h -> Nothing <$ useHandleOpen h - optionalTimeout action + runOutput p = + case (getStdout p, getStderr p) of + (Nothing, Nothing) -> pure () + (Just x, Just y) -> concurrently_ x y + (x, y) -> assert False $ + concurrently_ + (fromMaybe (pure ()) x) + (fromMaybe (pure ()) y) + timeoutWithGrace p maxSecs graceSecs = do + mExit <- timeout (maxSecs * 1000000) (waitExitCode p) + case mExit of + Just ec -> pure (Just ec) + Nothing -> do + terminateGracefully p + mGraceExit <- timeout (graceSecs * 1000000) + (waitExitCode p) + case mGraceExit of + Just _ -> pure Nothing + Nothing -> do + forceKill p + void $ waitExitCode p + pure Nothing + runWithTimeout pc + | Just maxSecs <- topts.maximumTimeSeconds, maxSecs > 0 + , Just graceSecs <- topts.timeoutGraceSeconds + , graceSecs > 0 = + withProcessWait (prepareForEscalation pc) $ \p -> do + (_, mec') <- concurrently + (runOutput p) + (timeoutWithGrace p maxSecs graceSecs) + pure mec' | Just maxSecs <- topts.maximumTimeSeconds, maxSecs > 0 = - timeout (maxSecs * 1000000) action - | otherwise = Just <$> action + timeout (maxSecs * 1000000) $ + withProcessWait pc $ \p -> do + runOutput p + waitExitCode p + | otherwise = + Just <$> withProcessWait pc (\p -> runOutput p *> waitExitCode p) mec <- withWorkingDir (toFilePath pkgDir) $ - optionalTimeout $ proc (toFilePath exePath) args $ \pc0 -> do + proc (toFilePath exePath) args $ \pc0 -> do changeStdin <- if isTestTypeLib then do @@ -1184,15 +1224,7 @@ singleTest topts testsToRun ac ee task installedMap = do $ setStdout output $ setStderr output pc0 - withProcessWait pc $ \p -> do - case (getStdout p, getStderr p) of - (Nothing, Nothing) -> pure () - (Just x, Just y) -> concurrently_ x y - (x, y) -> assert False $ - concurrently_ - (fromMaybe (pure ()) x) - (fromMaybe (pure ()) y) - waitExitCode p + runWithTimeout pc -- Add a trailing newline, incase the test -- output didn't finish with a newline. case outputType of @@ -1225,12 +1257,12 @@ singleTest topts testsToRun ac ee task installedMap = do else pure $ Map.singleton testName (Just ec) else do unless expectFailure $ - logError $ - displayShow $ TestSuiteExeMissing + prettyError $ + pretty $ TestSuiteExeMissing (package.buildType == C.Simple) exeName - (packageNameString package.name) - (unqualCompToString testName) + package.name + testName pure emptyResult when needHpc $ do @@ -1273,8 +1305,8 @@ singleBench :: -> InstalledMap -> RIO env () singleBench beopts benchesToRun ac ee task installedMap = do - (allDepsMap, _cache) <- getConfigCache ee task installedMap False True - withSingleContext ac ee task.taskType allDepsMap (Just "bench") $ + (allDeps, _cache) <- getConfigCache ee task installedMap False True + withSingleContext ac ee task.taskType allDeps (Just "bench") $ \_package _cabalfp _pkgDir cabal announce _outputType -> do let args = map unqualCompToString benchesToRun <> maybe [] ((:[]) . ("--benchmark-options=" <>)) @@ -1294,17 +1326,22 @@ extraBuildOptions :: (HasEnvConfig env, HasRunner env) => WhichCompiler -> BuildOpts + -> Maybe Semaphore -> RIO env [String] -extraBuildOptions wc bopts = do +extraBuildOptions wc bopts semaphore = do colorOpt <- appropriateGhcColorFlag let optsFlag = compilerOptionsCabalFlag wc + semaphoreFlag = maybe + [] + (("--semaphore":) . L.singleton . getSemaphoreName . semaphoreName) + semaphore baseOpts = maybe "" (" " ++) colorOpt if bopts.testOpts.coverage then do hpcIndexDir <- toFilePathNoTrailingSep <$> hpcRelativeDir - pure [optsFlag, "-hpcdir " ++ hpcIndexDir ++ baseOpts] + pure $ semaphoreFlag ++ [optsFlag, "-hpcdir " ++ hpcIndexDir ++ baseOpts] else - pure [optsFlag, baseOpts] + pure $ semaphoreFlag ++ [optsFlag, baseOpts] -- Library, sub-library, foreign library and executable build components. primaryComponentOptions :: LocalPackage -> [String] diff --git a/src/Stack/Build/Installed.hs b/src/Stack/Build/Installed.hs index 1e2d4d5b45..609175df4d 100644 --- a/src/Stack/Build/Installed.hs +++ b/src/Stack/Build/Installed.hs @@ -287,7 +287,7 @@ toLoadHelper compiler pkgDb dp = LoadHelper if name `Set.member` wiredInPackages compiler then [] else dp.depends - installedLibInfo = InstalledLibraryInfo ghcPkgId (Right <$> dp.license) mempty + installedLibInfo = InstalledLibraryInfo (Just ghcPkgId) mempty toInstallLocation :: PackageDbVariety -> InstallLocation toInstallLocation GlobalDb = Snap @@ -313,23 +313,26 @@ gatherAndTransformSubLoadHelper lh = (_, Library _ existingLibInfo) = ( pLoc , Library pn existingLibInfo - { subLib = Map.union - incomingLibInfo.subLib - existingLibInfo.subLib - , ghcPkgId = if isJust lh.subLibDump - then existingLibInfo.ghcPkgId - else incomingLibInfo.ghcPkgId + { subLib = Map.union incomingLibInfo.subLib existingLibInfo.subLib + , mMainGhcPkgId = + if isJust lh.subLibDump + then existingLibInfo.mMainGhcPkgId + else incomingLibInfo.mMainGhcPkgId } ) onPreviousLoadHelper newVal _oldVal = newVal (key, value) = case lh.subLibDump of Nothing -> (rawPackageName, rawValue) Just sd -> (sd.packageName, updateAsSublib sd <$> rawValue) + -- rawValue should always have a main library: see toLoadHelper. (rawPackageName, rawValue) = lh.pair updateAsSublib sd (Library (PackageIdentifier _sublibMungedPackageName version) libInfo) - = Library - (PackageIdentifier key version) - libInfo { subLib = Map.singleton sd.libraryName libInfo.ghcPkgId } + = case libInfo.mMainGhcPkgId of + Nothing -> + error "gatherAndTransformSubLoadHelper: the impossible happened!" + Just ghcPkgId' -> Library + (PackageIdentifier key version) + libInfo { subLib = Map.singleton sd.libraryName ghcPkgId' } updateAsSublib _ v = v diff --git a/src/Stack/BuildOpts.hs b/src/Stack/BuildOpts.hs index 86d27dd834..b843a5b4a8 100644 --- a/src/Stack/BuildOpts.hs +++ b/src/Stack/BuildOpts.hs @@ -62,6 +62,7 @@ defaultBuildOpts = BuildOpts , interleavedOutput = defaultFirstTrue buildMonoid.interleavedOutput , progressBar = CappedBar , ddumpDir = Nothing + , semaphore = defaultFirstFalse buildMonoid.semaphore } where buildMonoid = undefined :: BuildOptsMonoid @@ -73,6 +74,7 @@ defaultTestOpts = TestOpts , coverage = defaultFirstFalse toMonoid.coverage , runTests = defaultFirstTrue toMonoid.runTests , maximumTimeSeconds = Nothing + , timeoutGraceSeconds = Nothing , allowStdin = defaultFirstTrue toMonoid.allowStdin } where diff --git a/src/Stack/CLI.hs b/src/Stack/CLI.hs index 1d0a15e3b3..2fff57727e 100644 --- a/src/Stack/CLI.hs +++ b/src/Stack/CLI.hs @@ -33,8 +33,9 @@ import Stack.Build ( buildCmd ) import Stack.BuildInfo ( hpackVersion, versionString' ) import Stack.Clean ( CleanCommand (..), cleanCmd ) import Stack.ConfigCmd - ( cfgCmdBuildFiles, cfgCmdBuildFilesName, cfgCmdEnv - , cfgCmdEnvName, cfgCmdName, cfgCmdSet, cfgCmdSetName + ( cfgCmdBuildFiles, cfgCmdBuildFilesName, cfgCmdCompilerTools + , cfgCmdCompilerToolsName, cfgCmdEnv, cfgCmdEnvName + , cfgCmdName, cfgCmdSet, cfgCmdSetName ) import Stack.Constants ( globalFooter, osIsWindows, relFileStack, relFileStackDotExe @@ -257,6 +258,12 @@ commandLineHandler currentDir progName mExecutablePath isInterpreter = -- cfgCmdBuildFiles itself yields nothing of interest. (withConfig YesReexec . withBuildConfig . cfgCmdBuildFiles) (pure ()) + addCommand' + cfgCmdCompilerToolsName + "Create (when applicable) the compiler tools directory for the \ + \specified compiler version (implies 'config build-files')." + (withConfig YesReexec . withDefaultEnvConfig . cfgCmdCompilerTools) + (pure ()) ) docker = addSubCommands' diff --git a/src/Stack/Config.hs b/src/Stack/Config.hs index 0def9f8ca2..3e26f49674 100644 --- a/src/Stack/Config.hs +++ b/src/Stack/Config.hs @@ -33,6 +33,7 @@ module Stack.Config , defaultConfigYaml , getProjectConfig , withBuildConfig + , withConfigExtra , withNewLogFunc , determineStackRootAndOwnership ) where @@ -55,6 +56,7 @@ import Data.Monoid.Map ( MonoidMap (..) ) import qualified Data.Set as Set import qualified Data.Text as T import qualified Data.Yaml as Yaml +import qualified Data.Yaml.Include as YamlInclude import qualified Distribution.PackageDescription as PD import Distribution.System ( Arch (..), OS (..), Platform (..), buildPlatform ) @@ -125,6 +127,7 @@ import Stack.Types.Config.Exception ( ConfigException (..), ConfigPrettyException (..) , ParseAbsolutePathException (..) ) +import Stack.Types.ConfigExtra ( ConfigExtra (..) ) import Stack.Types.ConfigMonoid ( ConfigMonoid (..), parseConfigMonoid ) import Stack.Types.Casa ( CasaOptsMonoid (..) ) @@ -282,6 +285,9 @@ configFromConfigMonoid latestSnapshot = fromFirst "https://stackage-haddock.haskell.org/snapshots.json" configMonoid.latestSnapshot + recentSnapshots = fromFirst + "https://www.stackage.org/api/v1/snapshots" + configMonoid.recentSnapshots clConnectionCount = fromFirst 8 configMonoid.connectionCount hideTHLoading = fromFirstTrue configMonoid.hideTHLoading prefixTimestamps = fromFirst False configMonoid.prefixTimestamps @@ -300,10 +306,6 @@ configFromConfigMonoid installMsys = fromFirst installGHC configMonoid.installMsys skipGHCCheck = fromFirstFalse configMonoid.skipGHCCheck skipMsys = fromFirstFalse configMonoid.skipMsys - defMsysEnvironment = case platform of - Platform I386 Windows -> Just MINGW32 - Platform X86_64 Windows -> Just MINGW64 - _ -> Nothing extraIncludeDirs = configMonoid.extraIncludeDirs extraLibDirs = configMonoid.extraLibDirs customPreprocessorExts = configMonoid.customPreprocessorExts @@ -318,15 +320,19 @@ configFromConfigMonoid requireStackVersion = simplifyVersionRange configMonoid.requireStackVersion.intersectingVersionRange compilerCheck = fromFirst MatchMinor configMonoid.compilerCheck - msysEnvironment <- case defMsysEnvironment of - -- Ignore the configuration setting if there is no default for the - -- platform. + mMsysEnv = case platform of + Platform X86_64 Windows -> + -- Default CLANG64 on 64-bit Windows: + Just $ fromFirst CLANG64 configMonoid.msysEnvironment + Platform _ Windows -> + -- No default on unsupported 32-bit Windows: + getFirst configMonoid.msysEnvironment + _ -> Nothing + msysEnvironment <- case mMsysEnv of Nothing -> pure Nothing - Just defMsysEnv -> do - let msysEnv = fromFirst defMsysEnv configMonoid.msysEnvironment - if msysEnvArch msysEnv == arch - then pure $ Just msysEnv - else prettyThrowM $ BadMsysEnvironment msysEnv arch + Just msysEnv + | msysEnvArch msysEnv == arch -> pure $ Just msysEnv + | otherwise -> prettyThrowM $ BadMsysEnvironment msysEnv arch platformVariant <- liftIO $ maybe PlatformVariantNone PlatformVariant <$> lookupEnv platformVariantEnvVar let build = buildOptsFromMonoid configMonoid.buildOpts @@ -596,6 +602,7 @@ configFromConfigMonoid , ghcVariant , ghcBuild , latestSnapshot + , recentSnapshots , systemGHC , installGHC , installMsys @@ -781,32 +788,77 @@ loadConfig inner = do -- by @loadConfig@. values. withBuildConfig :: RIO BuildConfig a -> RIO Config a withBuildConfig inner = do - config <- ask + withConfigExtra True $ \configExtra -> do + -- The mcompiler is provided on the command line. + mcompiler <- view $ globalOptsL . to (.compiler) + let config = configExtra.config + project' = configExtra.project + configFile = configExtra.configFile + project :: Project + project = project' + { Project.compiler = mcompiler <|> project'.compiler + , Project.snapshot = fromMaybe project'.snapshot configExtra.mSnapshot + } + -- We are indifferent as to whether the configuration file is a + -- user-specific global or a project-level one. + eitherConfigFile = EE.fromEither configFile + extraPackageDBs <- mapM resolveDir' project.extraPackageDBs + + smWanted <- lockCachedWanted eitherConfigFile project.snapshot $ + fillProjectWanted eitherConfigFile config project + -- Unfortunately redoes getWorkDir, since we don't have a BuildConfig yet + workDir <- view workDirL + let projectStorageFile = + parent eitherConfigFile workDir relFileStorage + + initProjectStorage projectStorageFile $ \projectStorage -> do + let bc = BuildConfig + { config + , smWanted + , extraPackageDBs + , configFile + , curator = project.curator + , projectStorage + } + runRIO bc inner + +-- | Adds certain build-specific values to the configuration loaded by +-- @loadConfig@ values. +withConfigExtra :: + forall a env. (HasConfig env, HasTerm env) + => Bool + -- ^ Report user message in the project-level configuration file, if + -- a user message is present? + -> (ConfigExtra -> RIO env a) + -> RIO env a +withConfigExtra reportUserMessage inner = do + config <- view configL -- If provided, turn the AbstractSnapshot from the command line into a - -- snapshot that can be used below. + -- snapshot that can be used. - -- The snapshot and mcompiler are provided on the command line. In order - -- to properly deal with an AbstractSnapshot, we need a base directory (to - -- deal with custom snapshot relative paths). We consider the current working - -- directory to be the correct base. Let's calculate the mSnapshot first. + -- The snapshot is provided on the command line. In order to properly deal + -- with an AbstractSnapshot, we need a base directory (to deal with custom + -- snapshot relative paths). We consider the current working directory to be + -- the correct base. We calculate the mSnapshot first. mSnapshot <- forM config.snapshot $ \aSnapshot -> do logDebug $ - "Using snapshot: " - <> display aSnapshot - <> " specified on command line" + "Using snapshot: " + <> display aSnapshot + <> " specified on command line" makeConcreteSnapshot aSnapshot - (project', configFile) <- case config.project of + (project, configFile) <- case config.project of PCProject (project, fp) -> do - forM_ project.userMsg prettyUserMessage + when reportUserMessage $ + forM_ project.userMsg prettyUserMessage pure (project, Right fp) PCNoProject extraDeps -> do - p <- + project <- case mSnapshot of Nothing -> throwIO NoSnapshotWhenUsingNoProject Just _ -> getEmptyProject mSnapshot extraDeps - pure (p, Left config.userGlobalConfigFile) + pure (project, Left config.userGlobalConfigFile) PCGlobalProject -> do logDebug "Run from outside a project, using implicit global project config" destDir <- getImplicitGlobalProjectDir @@ -839,7 +891,7 @@ withBuildConfig inner = do , style Shell "snapshot" , flow "key there." ] - p <- getEmptyProject mSnapshot [] + project <- getEmptyProject mSnapshot [] liftIO $ do writeBinaryFileAtomic dest $ byteString $ S.concat [ "# This is the implicit global project's configuration file, which is only used\n" @@ -850,45 +902,24 @@ withBuildConfig inner = do , "# For more information about Stack's configuration, see\n" , "# http://docs.haskellstack.org/en/stable/configure/yaml/\n" , "#\n" - , Yaml.encode p] - writeBinaryFileAtomic (parent dest relFileReadmeTxt) $ - "This is the implicit global project, which is " <> - "used only when 'stack' is run\noutside of a " <> - "real project.\n" - pure (p, Right dest) - mcompiler <- view $ globalOptsL . to (.compiler) - let project :: Project - project = project' - { Project.compiler = mcompiler <|> project'.compiler - , Project.snapshot = fromMaybe project'.snapshot mSnapshot - } - -- We are indifferent as to whether the configuration file is a - -- user-specific global or a project-level one. - eitherConfigFile = EE.fromEither configFile - extraPackageDBs <- mapM resolveDir' project.extraPackageDBs - - smWanted <- lockCachedWanted eitherConfigFile project.snapshot $ - fillProjectWanted eitherConfigFile config project - - -- Unfortunately redoes getWorkDir, since we don't have a BuildConfig yet - workDir <- view workDirL - let projectStorageFile = parent eitherConfigFile workDir relFileStorage - - initProjectStorage projectStorageFile $ \projectStorage -> do - let bc = BuildConfig - { config - , smWanted - , extraPackageDBs - , configFile - , curator = project.curator - , projectStorage - } - runRIO bc inner + , Yaml.encode project + ] + writeBinaryFileAtomic (parent dest relFileReadmeTxt) $ mconcat + [ "This is the implicit global project, which is used only when 'stack' is run\n" + , "outside of a real project.\n" + ] + pure (project, Right dest) + inner $ ConfigExtra + { config + , mSnapshot + , project + , configFile + } where getEmptyProject :: Maybe RawSnapshotLocation -> [RawPackageLocationImmutable] - -> RIO Config Project + -> RIO env Project getEmptyProject mSnapshot extraDeps = do snapshot <- case mSnapshot of Just snapshot -> do @@ -916,7 +947,7 @@ withBuildConfig inner = do , curator = Nothing , dropPackages = mempty } - prettyUserMessage :: String -> RIO Config () + prettyUserMessage :: String -> RIO env () prettyUserMessage userMsg = do let userMsgs = map flow $ splitAtLineEnds userMsg warningDoc = mconcat $ intersperse blankLine userMsgs @@ -1212,7 +1243,7 @@ loadYaml :: -> Path Abs File -> RIO env (Either Yaml.ParseException a) loadYaml parser path = - liftIO (Yaml.decodeFileEither (toFilePath path)) >>= \case + liftIO (YamlInclude.decodeFileEither (toFilePath path)) >>= \case Left err -> pure (Left err) Right val -> case Yaml.parseEither parser val of diff --git a/src/Stack/Config/Build.hs b/src/Stack/Config/Build.hs index 8a43b8df21..3731527744 100644 --- a/src/Stack/Config/Build.hs +++ b/src/Stack/Config/Build.hs @@ -95,6 +95,7 @@ buildOptsFromMonoid buildMonoid = BuildOpts , interleavedOutput = fromFirstTrue buildMonoid.interleavedOutput , progressBar = fromFirst CappedBar buildMonoid.progressBar , ddumpDir = getFirst buildMonoid.ddumpDir + , semaphore = fromFirstFalse buildMonoid.semaphore } where isHaddockFromHackage = fromFirstFalse buildMonoid.haddockForHackage @@ -134,6 +135,10 @@ testOptsFromMonoid toMonoid madditional = defaultTestOpts fromFirst defaultTestOpts.maximumTimeSeconds toMonoid.maximumTimeSeconds + , TestOpts.timeoutGraceSeconds = + fromFirst + defaultTestOpts.timeoutGraceSeconds + toMonoid.timeoutGraceSeconds , TestOpts.allowStdin = fromFirstTrue toMonoid.allowStdin } diff --git a/src/Stack/Config/ConfigureScript.hs b/src/Stack/Config/ConfigureScript.hs index 62ef8beeb8..03ec7f6ca4 100644 --- a/src/Stack/Config/ConfigureScript.hs +++ b/src/Stack/Config/ConfigureScript.hs @@ -1,5 +1,6 @@ -{-# LANGUAGE NoImplicitPrelude #-} -{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE OverloadedRecordDot #-} +{-# LANGUAGE OverloadedStrings #-} {-| Module : Stack.Config.ConfigureScript @@ -12,15 +13,17 @@ module Stack.Config.ConfigureScript import Path ( () ) import Path.IO ( doesFileExist ) +import RIO.Process ( withWorkingDir ) import Stack.Constants ( osIsWindows, relFileConfigure ) import Stack.DefaultColorWhen ( defaultColorWhen ) import Stack.Prelude -import RIO.Process ( HasProcessContext, withWorkingDir ) +import Stack.Types.Config ( Config (..), HasConfig (..) ) +import Stack.Types.MsysEnvironment ( MsysEnvironment (..) ) -- | For the given directory, yields an action that trys to generate a -- @configure@ script with @autoreconf@, if one does not exist in the directory. ensureConfigureScript :: - (HasProcessContext env, HasTerm env) + HasConfig env => Path b Dir -> RIO env () ensureConfigureScript dir = do @@ -55,6 +58,7 @@ ensureConfigureScript dir = do <> blankLine <> string (displayException ex) when osIsWindows $ do + config <- view configL prettyInfo $ fillSep [ flow "Check that executable" @@ -79,22 +83,7 @@ ensureConfigureScript dir = do <> line <> indent 4 (style Shell $ flow "stack exec where.exe -- aclocal") <> blankLine - <> fillSep - [ "If" - , style File "perl" <> "," - , style File "autoreconf" - , "or" - , style File "aclocal" - , flow "is not on the path in the required location, add them \ - \with command (note that the relevant package name is" - , style File "autotools" - , "not" - , style File "autoreconf" <> "):" - ] - <> blankLine - <> indent 4 - (style Shell $ flow "stack exec pacman -- --sync --refresh mingw-w64-x86_64-autotools") - <> blankLine + <> maybe mempty advice config.msysEnvironment <> fillSep [ flow "Some versions of" , style File "perl" @@ -107,6 +96,33 @@ ensureConfigureScript dir = do , flow "in the required location is working, try command:" ] <> blankLine - <> indent 4 (style Shell $ flow "stack exec perl -- --version") + <> indent 4 (style Shell "stack exec perl -- --version") <> blankLine fixupOnWindows + where + advice :: MsysEnvironment -> StyleDoc + advice CLANG32 = mempty + advice MINGW32 = mempty + advice CLANG64 = adviceWith "mingw-w64-clang-x86_64-autotools" + advice CLANGARM64 = adviceWith "mingw-w64-clang-aarch64-autotools" + advice MINGW64 = adviceWith "mingw-w64-x86_64-autotools" + advice UCRT64 = adviceWith "mingw-w64-ucrt-x86_64-autotools" + + adviceWith :: StyleDoc -> StyleDoc + adviceWith msysPackage = + fillSep + [ "If" + , style File "perl" <> "," + , style File "autoreconf" + , "or" + , style File "aclocal" + , flow "is not on the path in the required location, add them \ + \with command (note that the relevant package name is" + , style File "autotools" + , "not" + , style File "autoreconf" <> "):" + ] + <> blankLine + <> indent 4 + (style Shell $ "stack exec pacman -- --sync --refresh " <> msysPackage) + <> blankLine diff --git a/src/Stack/Config/Nix.hs b/src/Stack/Config/Nix.hs index c80b866543..90a64d35f7 100644 --- a/src/Stack/Config/Nix.hs +++ b/src/Stack/Config/Nix.hs @@ -12,13 +12,13 @@ Nix configuration. -} module Stack.Config.Nix - ( ConfigNixException + ( ConfigNixPrettyException , nixCompiler , nixCompilerVersion , nixOptsFromMonoid ) where -import Control.Monad.Extra ( ifM ) +import Control.Monad.Extra ( ifM, whenJust ) import qualified Data.Text as T import qualified Data.Text.IO as TIO import Distribution.System ( OS (..) ) @@ -28,26 +28,47 @@ import Stack.Types.Runner ( HasRunner ) import Stack.Types.Nix ( NixOpts (..), NixOptsMonoid (..) ) import System.Directory ( doesFileExist ) --- | Type representing exceptions thrown by functions exported by the +-- | Type representing \'pretty\' exceptions thrown by functions exported by the -- "Stack.Config.Nix" module. -data ConfigNixException - = NixCannotUseShellFileAndPackagesException +data ConfigNixPrettyException + = NixCannotUseShellFileAndPackagesException !FilePath ![Text] -- ^ Nix can't be given packages and a shell file at the same time | GHCMajorVersionUnspecified | OnlyGHCSupported deriving Show -instance Exception ConfigNixException where - displayException NixCannotUseShellFileAndPackagesException = - "Error: [S-2726]\n" - ++ "You cannot have packages and a shell-file filled at the same time \ - \in your nix-shell configuration." - displayException GHCMajorVersionUnspecified = - "Error: [S-9317]\n" - ++ "GHC major version not specified." - displayException OnlyGHCSupported = - "Error: [S-8605]\n" - ++ "Only GHC is supported by 'stack --nix'." +instance Pretty ConfigNixPrettyException where + pretty (NixCannotUseShellFileAndPackagesException initFile packages) = + "[S-2726]" + <> line + <> flow "The configuration of Stack's Nix integration cannot specify both \ + \a Nix shell file and Nix packages. You have specified:" + <> blankLine + <> spacedBulletedList + [ fillSep + [ flow "Shell file:" + , style File (fromString initFile) <> ";" + , "and" + ] + , fillSep $ + flow "Nix packages:" + : mkNarrativeList (Just Shell) False prettyPackages + ] + where + prettyPackages :: [StyleDoc] + prettyPackages = map (fromString . T.unpack) packages + pretty GHCMajorVersionUnspecified = + "[S-9317]" + <> line + <> flow "Stack's Nix integration requires at least a major version of GHC \ + \to be specified. No major version is specified." + pretty OnlyGHCSupported = + "[S-8605]" + <> line + <> flow "Stack's Nix integration supports only GHC binary distributions as \ + \compiler." + +instance Exception ConfigNixPrettyException -- | Interprets NixOptsMonoid options. nixOptsFromMonoid :: @@ -79,8 +100,9 @@ nixOptsFromMonoid nixMonoid os = do pure False else pure nixEnable0 - when (not (null packages) && isJust initFile) $ - throwIO NixCannotUseShellFileAndPackagesException + unless (null packages) $ whenJust initFile $ \fp -> + prettyThrowIO $ NixCannotUseShellFileAndPackagesException fp packages + pure NixOpts { enable , pureShell @@ -93,7 +115,7 @@ nixOptsFromMonoid nixMonoid os = do prefixAll p (x:xs) = p : x : prefixAll p xs prefixAll _ _ = [] -nixCompiler :: WantedCompiler -> Either ConfigNixException T.Text +nixCompiler :: WantedCompiler -> Either ConfigNixPrettyException T.Text nixCompiler compilerVersion = case compilerVersion of WCGhc version -> @@ -119,7 +141,7 @@ nixCompiler compilerVersion = WCGhcjs{} -> Left OnlyGHCSupported WCGhcGit{} -> Left OnlyGHCSupported -nixCompilerVersion :: WantedCompiler -> Either ConfigNixException T.Text +nixCompilerVersion :: WantedCompiler -> Either ConfigNixPrettyException T.Text nixCompilerVersion compilerVersion = case compilerVersion of WCGhc version -> diff --git a/src/Stack/ConfigCmd.hs b/src/Stack/ConfigCmd.hs index 1861d482da..95f824237f 100644 --- a/src/Stack/ConfigCmd.hs +++ b/src/Stack/ConfigCmd.hs @@ -18,7 +18,10 @@ module Stack.ConfigCmd , cfgCmdEnvName , cfgCmdBuildFiles , cfgCmdBuildFilesName + , cfgCmdCompilerTools + , cfgCmdCompilerToolsName , cfgCmdName + , yamlContainsInclude ) where import qualified Data.Aeson.Key as Key @@ -31,63 +34,71 @@ import qualified Data.Map.Merge.Strict as Map import qualified Data.Text as T import qualified Data.Yaml as Yaml import Pantry ( loadSnapshot ) -import Path ( (), parent ) +import Path ( parent ) +import Path.IO ( ensureDir ) import qualified RIO.Map as Map import RIO.NonEmpty ( nonEmpty ) import qualified RIO.NonEmpty as NE import RIO.Process ( envVarsL ) -import Stack.Config - ( makeConcreteSnapshot, getProjectConfig - , getImplicitGlobalProjectDir - ) -import Stack.Constants ( stackDotYaml ) +import Stack.Config ( makeConcreteSnapshot, withConfigExtra ) import Stack.Prelude import Stack.Types.BuildConfig ( BuildConfig ) import Stack.Types.Config ( Config (..), HasConfig (..) ) +import Stack.Types.ConfigExtra ( ConfigExtra (..) ) import Stack.Types.ConfigMonoid - ( configMonoidInstallGHCName - , configMonoidInstallMsysName + ( configMonoidInstallGHCName, configMonoidInstallMsysName , configMonoidRecommendStackUpgradeName , configMonoidSystemGHCName ) import Stack.Types.ConfigSetOpts ( CommandScope (..), ConfigCmdSet (..) ,configCmdSetScope ) -import Stack.Types.EnvConfig ( EnvConfig ) +import Stack.Types.EnvConfig ( EnvConfig, bindirCompilerTools ) import Stack.Types.EnvSettings ( EnvSettings (..) ) import Stack.Types.GHCVariant ( HasGHCVariant ) -import Stack.Types.GlobalOpts ( GlobalOpts (..) ) -import Stack.Types.ProjectConfig ( ProjectConfig (..) ) -import Stack.Types.Runner ( globalOptsL ) import Stack.Types.Snapshot ( AbstractSnapshot ) import System.Environment ( getEnvironment ) --- | Type repesenting exceptions thrown by functions exported by the +-- | Type repesenting \'pretty\' exceptions thrown by functions exported by the -- "Stack.ConfigCmd" module. -data ConfigCmdException +data ConfigCmdPrettyException = NoProjectConfigAvailable + | ConfigFileContainsIncludes !(Path Abs File) deriving Show -instance Exception ConfigCmdException where - displayException NoProjectConfigAvailable = - "Error: [S-3136]\n" - ++ "'config' command used when no project configuration available." +instance Pretty ConfigCmdPrettyException where + pretty NoProjectConfigAvailable = + "[S-3136]" + <> line + <> fillSep + [ style Shell "config" + , flow "command used when no project configuration available." + ] + pretty (ConfigFileContainsIncludes configFile) = + "[S-6088]" + <> line + <> fillSep + [ "The" + , style Shell "config set" + , flow "command cannot add a new key to a configuration file that uses" + , style Shell "!include" + , "directives:" + , pretty configFile + ] + +instance Exception ConfigCmdPrettyException -- | Function underlying Stack's @config set@ command. cfgCmdSet :: (HasConfig env, HasGHCVariant env) => ConfigCmdSet -> RIO env () -cfgCmdSet cmd = do - conf <- view configL - configFilePath <- - case configCmdSetScope cmd of - CommandScopeProject -> do - mstackYamlOption <- view $ globalOptsL . to (.stackYaml) - mstackYaml <- getProjectConfig mstackYamlOption - case mstackYaml of - PCProject stackYaml -> pure stackYaml - PCGlobalProject -> getImplicitGlobalProjectDir <&> ( stackDotYaml) - PCNoProject _extraDeps -> throwIO NoProjectConfigAvailable - -- maybe modify the ~/.stack/config.yaml file instead? +-- We ignore any user message in the project-level configuration file: +cfgCmdSet cmd = withConfigExtra False $ \configExtra -> do + let conf = configExtra.config + configFilePath <- case configCmdSetScope cmd of + CommandScopeProject -> case configExtra.configFile of + Left _ -> prettyThrowIO NoProjectConfigAvailable + -- Maybe modify the global configuration file (config.yaml) instead? + Right fp -> pure fp CommandScopeGlobal -> pure conf.userGlobalConfigFile rawConfig <- liftIO (readFileUtf8 (toFilePath configFilePath)) config <- either throwM pure (Yaml.decodeEither' $ encodeUtf8 rawConfig) @@ -101,6 +112,8 @@ cfgCmdSet cmd = do primaryCmdKey = NE.last $ NE.head cmdKeys newYamlLines <- case hits of [] -> do + when (yamlContainsInclude rawConfig) $ + prettyThrowIO (ConfigFileContainsIncludes configFilePath) prettyInfoL [ pretty configFilePath , flow "has been extended." @@ -267,7 +280,20 @@ snapshotValue root snapshot = do concreteSnapshot <- makeConcreteSnapshot snapshot' -- Check that the snapshot actually exists void $ loadSnapshot =<< completeSnapshotLocation concreteSnapshot - pure (Yaml.toJSON concreteSnapshot) + rslValue concreteSnapshot + +rslValue :: HasConfig env => RawSnapshotLocation -> RIO env Yaml.Value +rslValue (RSLCompiler compiler) = pure $ Yaml.toJSON compiler +rslValue (RSLUrl url Nothing) = pure $ Yaml.toJSON url +rslValue (RSLUrl url _) = do + -- I can't see how this would ever arise, but it is added for completeness: + prettyWarnL + [ flow "The specified snapshot value is a URL. The associated SHA256 hash \ + \and file size will be ignored." + ] + pure $ Yaml.toJSON url +rslValue (RSLFilePath rp) = pure $ Yaml.toJSON $ resolvedRelative rp +rslValue rsl = pure $ Yaml.toJSON rsl cfgCmdSetKeys :: ConfigCmdSet -> NonEmpty (NonEmpty Text) cfgCmdSetKeys (ConfigCmdSetSnapshot _) = [["snapshot"], ["resolver"]] @@ -280,6 +306,24 @@ cfgCmdSetKeys (ConfigCmdSetRecommendStackUpgrade _ _) = cfgCmdSetKeys (ConfigCmdSetDownloadPrefix _ _) = [["package-index", "download-prefix"]] +-- | Check if YAML content contains a @!include@ directive in value position. +-- This covers both inline values (e.g. @key: !include path@) and values on +-- the next line after indentation. Stack config keys do not contain spaces or +-- colons, so the first @:@ is always the value separator. +yamlContainsInclude :: Text -> Bool +yamlContainsInclude = + let lineContainsInclude yamlLine = + let stripped = T.stripStart yamlLine + in includeAsValue stripped || includeOnOwnLine stripped + + includeAsValue strippedLine = + let (_key, rest) = T.breakOn ":" strippedLine + in "!include" `T.isPrefixOf` T.stripStart (T.drop 1 rest) + + includeOnOwnLine strippedLine = + "!include" `T.isPrefixOf` strippedLine + in any lineContainsInclude . T.lines + -- | The name of Stack's @config@ command. cfgCmdName :: String cfgCmdName = "config" @@ -296,6 +340,10 @@ cfgCmdEnvName = "env" cfgCmdBuildFilesName :: String cfgCmdBuildFilesName = "build-files" +-- | The name of Stack's @config@ command's @compiler-tools-bin@ subcommand. +cfgCmdCompilerToolsName :: String +cfgCmdCompilerToolsName = "compiler-tools" + data EnvVarAction = EVASet !Text | EVAUnset deriving Show @@ -329,3 +377,7 @@ cfgCmdEnv es = do -- 'Stack.Config.withBuildConfig' that yields the desired actions. cfgCmdBuildFiles :: () -> RIO BuildConfig () cfgCmdBuildFiles () = pure () + +-- | This function takes no settings. +cfgCmdCompilerTools :: () -> RIO EnvConfig () +cfgCmdCompilerTools () = bindirCompilerTools >>= ensureDir diff --git a/src/Stack/ConfigureOpts.hs b/src/Stack/ConfigureOpts.hs index 539d12ddcc..6a31ed3740 100644 --- a/src/Stack/ConfigureOpts.hs +++ b/src/Stack/ConfigureOpts.hs @@ -18,8 +18,6 @@ module Stack.ConfigureOpts import qualified Data.Map as Map import qualified Data.Text as T import Database.Persist ( Entity, entityVal ) -import Distribution.Types.MungedPackageName - ( decodeCompatPackageName ) import Distribution.Types.PackageName ( unPackageName ) import Distribution.Types.UnqualComponentName ( unUnqualComponentName ) @@ -70,7 +68,7 @@ configureOptsFromDb x y = ConfigureOpts configureOptsFromBase :: EnvConfig -> BaseConfigOpts - -> Map PackageIdentifier GhcPkgId -- ^ dependencies + -> Map MungedPackageId GhcPkgId -- ^ dependencies -> Bool -- ^ local non-extra-dep? -> IsMutable -> PackageConfigureOpts @@ -119,7 +117,7 @@ configureOptsPathRelated bco isMutable pkgOpts = concat configureOptsNonPathRelated :: EnvConfig -> BaseConfigOpts - -> Map PackageIdentifier GhcPkgId -- ^ Dependencies. + -> Map MungedPackageId GhcPkgId -- ^ Dependencies. -> Bool -- ^ Is this a local, non-extra-dep? -> PackageConfigureOpts -> [String] @@ -197,18 +195,18 @@ configureOptsNonPathRelated econfig bco deps isLocal package = concat depOptions = mapAndAppend toDepOption [] deps - toDepOption (PackageIdentifier name _) gid = concat + toDepOption (MungedPackageId name _) gid = concat [ "--dependency=" , depOptionKey , "=" , ghcPkgIdString gid ] where - MungedPackageName subPkgName lib = decodeCompatPackageName name - depOptionKey = case lib of - LMainLibName -> unPackageName name - LSubLibName cn -> - unPackageName subPkgName <> ":" <> unUnqualComponentName cn + MungedPackageName pkgName libName = name + pkgName' = unPackageName pkgName + depOptionKey = case libName of + LMainLibName -> pkgName' + LSubLibName cn -> pkgName' <> ":" <> unUnqualComponentName cn -- | Render configure options as a single list of options. renderConfigureOpts :: ConfigureOpts -> [String] diff --git a/src/Stack/DependencyGraph.hs b/src/Stack/DependencyGraph.hs index c95be77ed9..b5a484d572 100644 --- a/src/Stack/DependencyGraph.hs +++ b/src/Stack/DependencyGraph.hs @@ -117,9 +117,12 @@ createPrunedDependencyGraph dotOpts = withDotConfig dotOpts $ do localNames <- view $ buildConfigL . to (Map.keysSet . (.smWanted.project)) logDebug "Creating dependency graph" (compiler, resultGraph) <- createDependencyGraph dotOpts - let pkgsToPrune = if dotOpts.includeBase - then dotOpts.prune - else Set.insert "base" dotOpts.prune + let pkgsToPrune = Set.union + ( if dotOpts.includeBase + then dotOpts.prune + else Set.insert "base" dotOpts.prune + ) + (nonParentDependencies resultGraph dotOpts.reach) prunedGraph = pruneGraph localNames pkgsToPrune resultGraph logDebug "Returning pruned dependency graph" pure (compiler, localNames, prunedGraph) @@ -394,9 +397,7 @@ pruneGraph dontPrune names = if pkg `F.elem` names then Nothing else let filtered = Set.filter (`F.notElem` names) pkgDeps - in if Set.null filtered && not (Set.null pkgDeps) - then Nothing - else Just (filtered, x)) + in Just (filtered, x)) -- | Make sure that all unreachable nodes (orphans) are pruned pruneUnreachable :: @@ -413,5 +414,36 @@ pruneUnreachable dontPrune = fixpoint prune reachable k = k `F.elem` dontPrune || k `Set.member` reachables reachables = F.fold (fst <$> graph') +nonParentDependencies :: + F.Foldable f + => Map PackageName (Set PackageName, a) + -> f PackageName + -> Set PackageName +nonParentDependencies graph names + | F.null names = Set.empty + | otherwise = + Set.difference (Map.keysSet graph) (backwardReachable names graph) + +backwardReachable :: + F.Foldable f + => f PackageName + -> Map PackageName (Set PackageName, a) + -> Set PackageName +backwardReachable names graph = go Set.empty (F.toList names) + where + reverseGraph = + Map.fromListWith Set.union + [ (dep, Set.singleton name) + | (name, (deps, _)) <- Map.toList graph + , dep <- Set.toList deps + ] + + go seen [] = seen + go seen (x : xs) + | x `Set.member` seen = go seen xs + | otherwise = + let parents = Map.findWithDefault Set.empty x reverseGraph + in go (Set.insert x seen) (Set.toList parents <> xs) + localPackageToPackage :: LocalPackage -> Package localPackageToPackage lp = fromMaybe lp.package lp.testBench diff --git a/src/Stack/Ghci.hs b/src/Stack/Ghci.hs index 4ae118ee59..8db0e71196 100644 --- a/src/Stack/Ghci.hs +++ b/src/Stack/Ghci.hs @@ -916,32 +916,37 @@ makeGhciPkgInfo :: -> RIO env GhciPkgInfo makeGhciPkgInfo installMap installedMap locals addPkgs mfileTargets pkgDesc = do bopts <- view buildOptsL - let pkg = pkgDesc.package + let package = pkgDesc.package cabalFP = pkgDesc.cabalFP target = pkgDesc.target - name = pkg.name - (mods, files, opts) <- - getPackageOpts pkg installMap installedMap locals addPkgs cabalFP - let filteredOpts = filterWanted opts + name = package.name + dir = parent cabalFP + targetFiles = mfileTargets >>= M.lookup name + (mods, files, allOpts) <- + getPackageOpts package installMap installedMap locals addPkgs cabalFP + let opts = M.toList $ filterWanted allOpts filterWanted :: Map NamedComponent a -> Map NamedComponent a filterWanted = M.filterWithKey (\k _ -> k `S.member` allWanted) - allWanted = wantedPackageComponents bopts target pkg - pure GhciPkgInfo - { name - , opts = M.toList filteredOpts - , dir = parent cabalFP - , modules = unionModuleMaps $ + allWanted = wantedPackageComponents bopts target package + modules = unionModuleMaps $ map ( \(comp, mp) -> M.map - (\fp -> M.singleton fp (S.singleton (pkg.name, comp))) + (\fp -> M.singleton fp (S.singleton (name, comp))) mp ) (M.toList (filterWanted mods)) - , mainIs = M.map (mapMaybe dotCabalMainPath) files - , cFiles = mconcat + mainIs = M.map (mapMaybe dotCabalMainPath) files + cFiles = mconcat (M.elems (filterWanted (M.map (mapMaybe dotCabalCFilePath) files))) - , targetFiles = mfileTargets >>= M.lookup name - , package = pkg + pure GhciPkgInfo + { name + , opts + , dir + , modules + , mainIs + , cFiles + , targetFiles + , package } -- NOTE: this should make the same choices as the components code in diff --git a/src/Stack/Init.hs b/src/Stack/Init.hs index 7b84d64b23..f156cc390c 100644 --- a/src/Stack/Init.hs +++ b/src/Stack/Init.hs @@ -437,8 +437,8 @@ renderStackYaml p ignoredPackages dupPackages = , "A snapshot dictates the compiler version and the set of packages" , "to be used for project dependencies. For example:" , "" - , "snapshot: lts-24.24" - , "snapshot: nightly-2025-12-20" + , "snapshot: lts-24.43" + , "snapshot: nightly-2026-05-29" , "snapshot: ghc-9.10.3" , "" , "The location of a snapshot can be provided as a file or url. Stack assumes" diff --git a/src/Stack/Ls.hs b/src/Stack/Ls.hs index de8f3c03e9..1e978441ad 100644 --- a/src/Stack/Ls.hs +++ b/src/Stack/Ls.hs @@ -31,8 +31,8 @@ import qualified Data.Text as T import qualified Data.Text.IO as T import qualified Data.Vector as V import Network.HTTP.StackClient - ( addRequestHeader, hAccept, httpJSON, getResponseBody - , parseRequest + ( HttpException (..), addRequestHeader, getResponseBody + , hAccept, httpJSON, parseUrlThrow ) import Path ( parent ) import RIO.List ( sort ) @@ -48,7 +48,8 @@ import Stack.Setup.Installed import Stack.SourceMap ( globalsFromHints ) import Stack.Types.BuildConfig ( BuildConfig (..), HasBuildConfig (..) ) -import Stack.Types.Config ( Config (..), HasConfig (..) ) +import Stack.Types.Config + ( Config (..), HasConfig (..), askRecentSnapshotsUrl ) import Stack.Types.DependencyTree ( DependencyGraph, DependencyTree (..), DotPayload (..) , licenseText, versionText @@ -63,7 +64,7 @@ import Stack.Types.LsOpts , ListStylesOpts (..), ListToolsOpts (..), LsView (..) , SnapshotOpts (..) ) -import Stack.Types.Runner ( HasRunner, Runner, terminalL ) +import Stack.Types.Runner ( Runner, terminalL ) import Stack.Types.SourceMap ( SMWanted (..) ) import System.Console.ANSI.Codes ( SGR (Reset), setSGRCode, sgrToCode ) @@ -71,17 +72,34 @@ import System.Process.Pager ( pageText ) import System.Directory ( listDirectory ) import System.IO ( putStrLn ) --- | Type representing exceptions thrown by functions exported by the "Stack.Ls" --- module. -newtype LsException - = ParseFailure [Value] - deriving Show - -instance Exception LsException where - displayException (ParseFailure val) = - "Error: [S-3421]\n" - ++ "Failure to parse values as a snapshot: " - ++ show val +-- | Type representing \'pretty\' exceptions thrown by functions exported by the +-- "Stack.Ls" module. +data LsPrettyException + = ParseFailure ![Value] + | ParseRecentSnapshotsUrlFailed !HttpException + +deriving instance Show LsPrettyException + +instance Pretty LsPrettyException where + pretty (ParseFailure val) = + "[S-3421]" + <> line + <> fillSep + [ flow "Failure to parse values as a snapshot:" + , string (show val) + ] + pretty (ParseRecentSnapshotsUrlFailed err) = + "[S-9131]" + <> line + <> fillSep + [ flow "While trying to parse the" + , style Shell "recent-snapshots" + , flow "URL, Stack encountered the following error:" + ] + <> blankLine + <> fromString (displayException err) + +instance Exception LsPrettyException -- | Type representing Stackage snapshot types. data SnapshotType @@ -120,7 +138,7 @@ toSnapshot [String snapId, String title, String time] = , title , time } -toSnapshot val = impureThrow $ ParseFailure val +toSnapshot val = prettyImpureThrow $ ParseFailure val parseSnapshot :: Value -> A.Parser Snapshot parseSnapshot = A.withArray "array of snapshot" (pure . toSnapshot . V.toList) @@ -199,9 +217,12 @@ handleLocal lsOpts = do LsStyles _ -> pure () LsTools _ -> pure () -handleRemote :: HasRunner env => LsCmdOpts -> RIO env () +handleRemote :: HasConfig env => LsCmdOpts -> RIO env () handleRemote lsOpts = do - req <- liftIO $ parseRequest urlInfo + urlInfoText <- askRecentSnapshotsUrl + req <- catch + (parseUrlThrow $ T.unpack urlInfoText) + (prettyThrowM . ParseRecentSnapshotsUrlFailed) isStdoutTerminal <- view terminalL let req' = addRequestHeader hAccept "application/json" req result <- httpJSON req' @@ -222,8 +243,6 @@ handleRemote lsOpts = do LsDependencies _ -> pure () LsStyles _ -> pure () LsTools _ -> pure () - where - urlInfo = "https://www.stackage.org/snapshots" -- | Function underlying the @stack ls@ command. lsCmd :: LsCmdOpts -> RIO Runner () @@ -232,7 +251,7 @@ lsCmd lsOpts = LsSnapshot sopt -> case sopt.viewType of Local -> handleLocal lsOpts - Remote -> handleRemote lsOpts + Remote -> withConfig NoReexec $ handleRemote lsOpts LsGlobals globalsOpts -> withConfig NoReexec $ listGlobalsCmd globalsOpts LsDependencies depOpts -> listDependencies depOpts LsStyles stylesOpts -> withConfig NoReexec $ listStylesCmd stylesOpts diff --git a/src/Stack/Nix.hs b/src/Stack/Nix.hs index d25d678a19..666280052e 100644 --- a/src/Stack/Nix.hs +++ b/src/Stack/Nix.hs @@ -36,17 +36,20 @@ import Stack.Types.Version ( showStackVersion ) import System.Environment ( getArgs, lookupEnv ) import qualified System.FilePath as F --- | Type representing exceptions thrown by functions exported by the --- "Stack.Nix" module. -data NixException +-- | Type representing \'pretty\' exceptions thrown by functions exported by +-- the "Stack.Nix" module. +data NixPrettyException = CannotDetermineProjectRoot -- ^ Can't determine the project root (location of the shell file if any). deriving Show -instance Exception NixException where - displayException CannotDetermineProjectRoot = - "Error: [S-7384]\n" - ++ "Cannot determine project root directory." +instance Pretty NixPrettyException where + pretty CannotDetermineProjectRoot = + "[S-7384]" + <> line + <> flow "Cannot determine project root directory." + +instance Exception NixPrettyException -- | Execute @nix-shell@, replacing the current process. runShellAndExit :: RIO Config void @@ -77,10 +80,12 @@ runShellAndExit = do -- (thus the void return type) compilerVersion <- withBuildConfig $ view wantedCompilerVersionL - ghc <- either throwIO pure $ nixCompiler compilerVersion - ghcVersion <- either throwIO pure $ nixCompilerVersion compilerVersion + ghc <- either prettyThrowIO pure $ nixCompiler compilerVersion + ghcVersion <- either prettyThrowIO pure $ nixCompilerVersion compilerVersion let pkgsInConfig = config.nix.packages - pkgs = pkgsInConfig ++ [ghc, "git", "gcc", "gmp"] + -- It appears that cacert needs to be specified in order for + -- crypton-x509-system >= 1.6.8 to work with Stack's Nix integration: + pkgs = pkgsInConfig ++ [ghc, "git", "gcc", "gmp", "cacert"] pkgsStr = "[" <> T.intercalate " " pkgs <> "]" pureShell = config.nix.pureShell addGCRoots = config.nix.addGCRoots diff --git a/src/Stack/Options/BuildMonoidParser.hs b/src/Stack/Options/BuildMonoidParser.hs index 640836e7c1..7de4eeaa78 100644 --- a/src/Stack/Options/BuildMonoidParser.hs +++ b/src/Stack/Options/BuildMonoidParser.hs @@ -36,7 +36,8 @@ import Stack.Types.ComponentUtils ( unqualCompFromString ) -- | Parse command line arguments for build configuration. buildOptsMonoidParser :: GlobalOptsContext -> Parser BuildOptsMonoid buildOptsMonoidParser hide0 = BuildOptsMonoid - <$> trace' + <$> semaphore + <*> trace' <*> profile <*> noStrip <*> libProfiling @@ -244,6 +245,11 @@ buildOptsMonoidParser hide0 = BuildOptsMonoid <> help "Specify output directory for ddump-files." <> hide )) + semaphore = firstBoolFlagsFalse + "semaphore" + "the use of a system semaphore to perform compilation in parallel when \ + \possible. Supported, by default, by GHC 9.10.1 or later." + hide -- | Parser for Cabal verbosity options cabalVerbosityOptsParser :: Bool -> Parser (First CabalVerbosity) diff --git a/src/Stack/Options/ConfigEnvParser.hs b/src/Stack/Options/ConfigEnvParser.hs index 9a03506e3e..80d3c1cd31 100644 --- a/src/Stack/Options/ConfigEnvParser.hs +++ b/src/Stack/Options/ConfigEnvParser.hs @@ -1,4 +1,5 @@ -{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE OverloadedRecordDot #-} {-| Module : Stack.Options.ConfigEnvParser @@ -14,16 +15,34 @@ module Stack.Options.ConfigEnvParser import qualified Options.Applicative as OA import Options.Applicative.Builder.Extra ( boolFlags ) import Stack.Prelude -import Stack.Types.EnvSettings ( EnvSettings (..) ) +import Stack.Types.EnvSettings + ( EnvSettings (..), defaultEnvSettings ) -- | Parse command line arguments for Stack's @config env@ command. configCmdEnvParser :: OA.Parser EnvSettings configCmdEnvParser = EnvSettings - <$> boolFlags True "locals" "include information about local packages" mempty - <*> boolFlags True - "ghc-package-path" "set GHC_PACKAGE_PATH environment variable" mempty - <*> boolFlags True "stack-exe" "set STACK_EXE environment variable" mempty - <*> boolFlags False - "locale-utf8" "set the GHC_CHARENC environment variable to UTF-8" mempty - <*> boolFlags False - "keep-ghc-rts" "keep any GHCRTS environment variable" mempty + <$> boolFlags + defaultEnvSettings.includeLocals + "locals" + "include information about local packages" + mempty + <*> boolFlags + defaultEnvSettings.includeGhcPackagePath + "ghc-package-path" + "set GHC_PACKAGE_PATH environment variable" + mempty + <*> boolFlags + defaultEnvSettings.stackExe + "stack-exe" + "set STACK_EXE environment variable" + mempty + <*> boolFlags + defaultEnvSettings.localeUtf8 + "locale-utf8" + "set the GHC_CHARENC environment variable to UTF-8" + mempty + <*> boolFlags + defaultEnvSettings.keepGhcRts + "keep-ghc-rts" + "keep any GHCRTS environment variable" + mempty diff --git a/src/Stack/Options/ConfigSetParser.hs b/src/Stack/Options/ConfigSetParser.hs index efe64f3929..776fefe793 100644 --- a/src/Stack/Options/ConfigSetParser.hs +++ b/src/Stack/Options/ConfigSetParser.hs @@ -36,7 +36,7 @@ configCmdSetParser = <$> OA.argument readAbstractSnapshot ( OA.metavar "SNAPSHOT" - <> OA.help "E.g. \"nightly\" or \"lts-24.24\"" )) + <> OA.help "E.g. \"nightly\" or \"lts-24.43\"" )) ( OA.progDesc "Change the snapshot of the current project." )) , OA.command "resolver" @@ -45,7 +45,7 @@ configCmdSetParser = <$> OA.argument readAbstractSnapshot ( OA.metavar "SNAPSHOT" - <> OA.help "E.g. \"nightly\" or \"lts-24.24\"" )) + <> OA.help "E.g. \"nightly\" or \"lts-24.43\"" )) ( OA.progDesc "Change the snapshot of the current project, using the \ \(deprecated) resolver key." )) diff --git a/src/Stack/Options/DotParser.hs b/src/Stack/Options/DotParser.hs index 56dc22c592..3572c50464 100644 --- a/src/Stack/Options/DotParser.hs +++ b/src/Stack/Options/DotParser.hs @@ -34,6 +34,7 @@ dotOptsParser externalDefault = DotOpts <*> includeBase <*> depthLimit <*> fmap (maybe Set.empty $ Set.fromList . splitNames) prunedPkgs + <*> fmap (maybe Set.empty $ Set.fromList . splitNames) reachPkgs <*> targetsParser <*> flagsParser <*> testTargets @@ -59,6 +60,13 @@ dotOptsParser externalDefault = DotOpts <> help "Prune specified package(s). PACKAGES is a comma-separated list of \ \package names." )) + reachPkgs = optional (strOption + ( long "reach" + <> metavar "PACKAGES" + <> help "Prune packages that cannot reach any of the specified package(s) \ + \in the dependency graph. PACKAGES is a comma-separated list of \ + \package names." + )) targetsParser :: Parser [Text] targetsParser = diff --git a/src/Stack/Options/ExecParser.hs b/src/Stack/Options/ExecParser.hs index 227b7b7419..1ad5d8eb3a 100644 --- a/src/Stack/Options/ExecParser.hs +++ b/src/Stack/Options/ExecParser.hs @@ -1,4 +1,5 @@ -{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE OverloadedRecordDot #-} {-| Module : Stack.Options.ExecParser @@ -23,7 +24,8 @@ import Stack.Exec ( ExecOpts (..), ExecOptsExtra (..), SpecialExecCmd (..) ) import Stack.Options.Completion ( projectExeCompleter ) import Stack.Prelude -import Stack.Types.EnvSettings ( EnvSettings (..) ) +import Stack.Types.EnvSettings + ( EnvSettings (..), defaultEnvSettings ) -- | Parse command line arguments for Stack's @exec@, @ghc@, @run@, -- @runghc@ and @runhaskell@ commands. @@ -57,18 +59,18 @@ execOptsExtraParser = ExecOptsExtra <*> eoCwdParser where eoEnvSettingsParser :: Parser EnvSettings - eoEnvSettingsParser = EnvSettings True - <$> boolFlags True + eoEnvSettingsParser = EnvSettings defaultEnvSettings.includeLocals + <$> boolFlags defaultEnvSettings.includeGhcPackagePath "ghc-package-path" "setting the GHC_PACKAGE_PATH variable for the subprocess." idm - <*> boolFlags True + <*> boolFlags defaultEnvSettings.stackExe "stack-exe" "setting the STACK_EXE environment variable to the path for the \ \stack executable." idm - <*> pure False - <*> pure True + <*> pure defaultEnvSettings.localeUtf8 + <*> pure defaultEnvSettings.keepGhcRts eoPackagesParser :: Parser [String] eoPackagesParser = many (strOption diff --git a/src/Stack/Options/TestParser.hs b/src/Stack/Options/TestParser.hs index 1a708e9ca6..4571d55c6c 100644 --- a/src/Stack/Options/TestParser.hs +++ b/src/Stack/Options/TestParser.hs @@ -44,7 +44,15 @@ testOptsParser hide0 = TestOptsMonoid hide <*> optionalFirst (option (fmap Just auto) ( long "test-suite-timeout" - <> help "Maximum test suite run time in seconds." + <> metavar "SECONDS" + <> help "For each test suite, maximum run time before it fails." + <> hide + )) + <*> optionalFirst (option (fmap Just auto) + ( long "test-suite-timeout-grace" + <> metavar "SECONDS" + <> help "Request termination of timed-out test suite process. Grace \ + \period after timeout before termination is forced." <> hide )) <*> firstBoolFlagsTrue diff --git a/src/Stack/Package.hs b/src/Stack/Package.hs index a30ea47146..3701b11f5f 100644 --- a/src/Stack/Package.hs +++ b/src/Stack/Package.hs @@ -38,12 +38,10 @@ module Stack.Package import qualified Data.Map.Strict as M import qualified Data.Set as S -import qualified Data.Text as T import Distribution.CabalSpecVersion ( cabalSpecToVersionDigits ) import Distribution.Compiler ( CompilerFlavor (..), PerCompilerFlavor (..) ) import Distribution.ModuleName ( ModuleName ) -import Distribution.Package ( mkPackageName ) import Distribution.PackageDescription ( Benchmark (..), BuildInfo (..), BuildType (..) , CondTree (..), Condition (..), ConfVar (..) @@ -87,7 +85,6 @@ import Stack.Types.BuildConfig ( HasBuildConfig (..), getWorkDir ) import Stack.Types.CompCollection ( CompCollection, collectionLookup, foldAndMakeCollection , foldComponentToAnotherCollection, getBuildableSet - , getBuildableSetText ) import Stack.Types.Compiler ( ActualCompiler (..) ) import Stack.Types.CompilerPaths ( cabalVersionL ) @@ -574,6 +571,7 @@ buildLogPath :: (MonadReader env m, HasBuildConfig env, MonadThrow m) => Package -> Maybe String + -- ^ An optional suffix for the log's file name. -> m (Path Abs File) buildLogPath package' msuffix = do env <- ask @@ -625,7 +623,8 @@ mkDepPackage pl = do -- | Force a package to be treated as a custom build type, see -- applyForceCustomBuild :: - Version -- ^ global Cabal version + Version + -- ^ Global Cabal version. -> Package -> Package applyForceCustomBuild cabalVersion package @@ -695,115 +694,118 @@ processPackageComponent :: -> m a -- ^ Initial value. -> m a -processPackageComponent pkg componentFn = do - let componentKindProcessor :: - forall component. HasComponentInfo component - => (Package -> CompCollection component) - -> m a - -> m a - componentKindProcessor target = - foldComponentToAnotherCollection - (target pkg) - componentFn - processMainLib = maybe id componentFn pkg.library - processAllComp = - ( if pkg.benchmarkEnabled - then componentKindProcessor (.benchmarks) - else id - ) - . ( if pkg.testEnabled - then componentKindProcessor (.testSuites) - else id - ) - . componentKindProcessor (.foreignLibraries) - . componentKindProcessor (.executables) - . componentKindProcessor (.subLibraries) - . processMainLib - processAllComp +processPackageComponent pkg componentFn = + processBenchmarks + . processTestSuites + . componentKindProcessor (.foreignLibraries) + . componentKindProcessor (.executables) + . componentKindProcessor (.subLibraries) + . processMainLib + where + processMainLib = maybe id componentFn pkg.library + + componentKindProcessor :: + forall component. HasComponentInfo component + => (Package -> CompCollection component) + -- ^ Accessor. + -> m a + -- ^ Initial value. + -> m a + componentKindProcessor target = + foldComponentToAnotherCollection (target pkg) componentFn + + processTestSuites = if pkg.testEnabled + then componentKindProcessor (.testSuites) + else id + + processBenchmarks = if pkg.benchmarkEnabled + then componentKindProcessor (.benchmarks) + else id -- | This is a function to iterate in a monad over all of a package's --- dependencies, and yield a collection of results (used with list and set). +-- dependencies (including any custom-setup ones), and yield a collection of +-- results (used with list and set). processPackageMapDeps :: (Monad m) => Package -> (Map PackageName DepValue -> m a -> m a) + -- ^ Processing function. -> m a + -- ^ Initial value. -> m a -processPackageMapDeps pkg fn = do - let packageSetupDepsProcessor resAction = case pkg.setupDeps of - Nothing -> resAction - Just v -> fn v resAction - processAllComp = processPackageComponent pkg (fn . componentDependencyMap) - . packageSetupDepsProcessor - processAllComp - --- | This is a function to iterate in a monad over all of a package component's --- dependencies, and yield a collection of results. +processPackageMapDeps pkg fn = + packageDepsProcessor . packageSetupDepsProcessor + where + packageSetupDepsProcessor action = + maybe action (`fn` action) pkg.setupDeps + + packageDepsProcessor = + processPackageComponent pkg (fn . componentDependencyMap) + +-- | This is a function to iterate in a monad over all of a package's +-- dependencies (including any custom-setup ones), and yield a collection of +-- results. processPackageDeps :: - (Monad m) + forall a b m. Monad m => Package - -> (smallResT -> resT -> resT) - -> (PackageName -> DepValue -> m smallResT) - -> m resT - -> m resT -processPackageDeps pkg combineResults fn = do - let - asPackageNameSet :: - (Package -> CompCollection component) - -> Set PackageName - asPackageNameSet accessor = - S.map (mkPackageName . T.unpack) $ getBuildableSetText $ accessor pkg - (!subLibNames, !foreignLibNames) = - ( asPackageNameSet (.subLibraries) - , asPackageNameSet (.foreignLibraries) - ) - shouldIgnoreDep (packageNameV :: PackageName) - | packageNameV == pkg.name = True - | packageNameV `S.member` subLibNames = True - | packageNameV `S.member` foreignLibNames = True - | otherwise = False - innerIterator packageName depValue resListInMonad - | shouldIgnoreDep packageName = resListInMonad - | otherwise = do - resList <- resListInMonad - newResElement <- fn packageName depValue - pure $ combineResults newResElement resList - processPackageMapDeps pkg (flip (M.foldrWithKey' innerIterator)) - --- | Iterate/fold on all the package dependencies, components, setup deps and --- all. + -> (b -> a -> a) + -- ^ Combining function. + -> (PackageName -> DepValue -> m b) + -- ^ Processing function for a dependency. + -> m a + -- ^ Intial value. + -> m a +processPackageDeps pkg combineResults fn = + processPackageMapDeps pkg (flip (M.foldrWithKey' iterator)) + where + iterator :: PackageName -> DepValue -> m a -> m a + iterator depPackageName depValue acc + -- If the name of the dependency package is the same as the package, we + -- ignore the former. It is possible for a dependency package to have the + -- same name as a named sublibrary or a named foreign library. + | depPackageName == pkg.name = acc + | otherwise = combineResults <$> fn depPackageName depValue <*> acc + +-- | This is a function to iterate in a monad over all of a package's +-- dependencies (including any custom-setup ones), and yield a list of +-- results. processPackageDepsToList :: Monad m => Package - -> (PackageName -> DepValue -> m resT) - -> m [resT] + -> (PackageName -> DepValue -> m b) + -- ^ Processing function for a dependency. + -> m [b] processPackageDepsToList pkg fn = processPackageDeps pkg (:) fn (pure []) --- | Iterate/fold on all the package dependencies, components, setup deps and --- all. +-- | This is a function to iterate in a monad over all of a package's +-- dependencies (including any custom-setup ones), and yield a collection of +-- the results. processPackageDepsEither :: (Monad m, Monoid a, Monoid b) => Package -> (PackageName -> DepValue -> m (Either a b)) + -- ^ Processing function for dependency. -> m (Either a b) processPackageDepsEither pkg fn = - processPackageDeps pkg combineRes fn (pure (Right mempty)) + processPackageDeps pkg combineResults fn (pure (Right mempty)) where - combineRes (Left err) (Left errs) = Left (errs <> err) - combineRes _ (Left b) = Left b - combineRes (Left err) _ = Left err - combineRes (Right a) (Right b) = Right $ a <> b + combineResults (Left a) (Left b) = Left (a <> b) + combineResults _ (Left b) = Left b + combineResults (Left a) _ = Left a + combineResults (Right a) (Right b) = Right (a <> b) --- | List all package's dependencies in a "free" context through the identity +-- | List the names of all of a package's dependencies (including any +-- custom-setup ones) in a "free" context through the 'Data.Functor.Identity' -- monad. listOfPackageDeps :: Package -> [PackageName] -listOfPackageDeps pkg = - runIdentity $ processPackageDepsToList pkg (\pn _ -> pure pn) +listOfPackageDeps pkg = runIdentity $ + processPackageDepsToList pkg (\pn _ -> pure pn) --- | The set of package's dependencies. +-- | Yield a set of the names of all a package's dependencies (including any +-- custom-setup ones) through the 'Data.Functor.Identity' monad. setOfPackageDeps :: Package -> Set PackageName -setOfPackageDeps pkg = - runIdentity $ processPackageDeps pkg S.insert (\pn _ -> pure pn) (pure mempty) +setOfPackageDeps pkg = runIdentity $ + processPackageDeps pkg S.insert (\pn _ -> pure pn) (pure mempty) -- | This implements a topological sort on all targeted components for the build -- and their dependencies. It's only targeting internal dependencies, so it's diff --git a/src/Stack/Path.hs b/src/Stack/Path.hs index eef69b6aa7..6dcee45fbe 100644 --- a/src/Stack/Path.hs +++ b/src/Stack/Path.hs @@ -53,6 +53,7 @@ import Stack.Types.EnvConfig , packageDatabaseLocal ) import qualified Stack.Types.EnvConfig as EnvConfig +import Stack.Types.EnvSettings ( defaultEnvSettings ) import Stack.Types.GHCVariant ( HasGHCVariant (..) ) import Stack.Types.GlobalOpts ( GlobalOpts (..), globalOptsBuildOptsMonoidL ) @@ -123,7 +124,13 @@ printKeys extractors single info = do T.putStrLn $ prefix <> extractPath info runHaddockWithEnvConfig :: Bool -> RIO EnvConfig () -> RIO Runner () -runHaddockWithEnvConfig x action = runHaddock x (withDefaultEnvConfig action) +runHaddockWithEnvConfig x action = runHaddock x $ + withDefaultEnvConfig $ do + config <- view configL + menv <- liftIO $ config.processContextSettings defaultEnvSettings + -- Required, as otherwise (due to withDefaultEnvConfig) the environment is + -- based on Stack.Type.EnvSettings.minimalEnvSettings. + withProcessContext menv action runHaddockWithConfig :: RIO Config () -> RIO Runner () runHaddockWithConfig = runHaddock False @@ -140,11 +147,6 @@ fillEnvConfigPathInfo = do -- We must use a BuildConfig from an EnvConfig to ensure that it contains the -- full environment info including GHC paths etc. buildConfig <- view $ envConfigL . buildConfigL - -- This is the modified 'bin-path', - -- including the local GHC or MSYS if not configured to operate on - -- global GHC. - -- It was set up in 'withBuildConfigAndLock -> withBuildConfigExt -> setupEnv'. - -- So it's not the *minimal* override path. snapDb <- packageDatabaseDeps localDb <- packageDatabaseLocal extraDbs <- packageDatabaseExtra @@ -297,7 +299,7 @@ pathsFromEnvConfig = , "compiler-bin" , WithoutHaddocks $ T.pack . toFilePathNoTrailingSep . parent . (.compiler) ) - , ( "Directory containing binaries specific to a particular compiler" + , ( "The compiler tools directory for the specified compiler version." , "compiler-tools-bin" , WithoutHaddocks $ T.pack . toFilePathNoTrailingSep . (.toolsDir) ) diff --git a/src/Stack/Prelude.hs b/src/Stack/Prelude.hs index b0976e669d..e7c5856b26 100644 --- a/src/Stack/Prelude.hs +++ b/src/Stack/Prelude.hs @@ -38,6 +38,7 @@ module Stack.Prelude , ppException , prettyThrowIO , prettyThrowM + , prettyImpureThrow , mcons , MungedPackageId (..) , MungedPackageName (..) @@ -133,8 +134,8 @@ import RIO.PrettyPrint ) import RIO.PrettyPrint.DefaultStyles (defaultStyles) import RIO.PrettyPrint.PrettyException - ( PrettyException (..), ppException, prettyThrowIO - , prettyThrowM + ( PrettyException (..), ppException, prettyImpureThrow + , prettyThrowIO, prettyThrowM ) import RIO.PrettyPrint.StylesUpdate ( StylesUpdate (..), parseStylesUpdateFromString ) diff --git a/src/Stack/SDist.hs b/src/Stack/SDist.hs index a27f117ad6..e018b39def 100644 --- a/src/Stack/SDist.hs +++ b/src/Stack/SDist.hs @@ -81,12 +81,11 @@ import Stack.Types.EnvConfig ( EnvConfig (..), HasEnvConfig (..), actualCompilerVersionL ) import Stack.Types.GhcPkgId ( GhcPkgId ) import Stack.Types.Installed - ( InstallMap, Installed (..), InstalledMap - , InstalledLibraryInfo (..), installedVersion + ( InstallMap, InstalledMap, installedVersion ) import Stack.Types.Package ( LocalPackage (..), Package (..), PackageConfig (..) - , packageIdentifier + , installedPackageToGhcPkgId', packageIdentifier ) import Stack.Types.Plan ( TaskType (..) ) import Stack.Types.Platform ( HasPlatform (..) ) @@ -204,8 +203,7 @@ getSDistTarball :: -- ^ Filename, tarball contents, and option Cabal file revision to upload getSDistTarball mpvpBounds pkgDir = do config <- view configL - let PvpBounds pvpBounds asRevision = - fromMaybe config.pvpBounds mpvpBounds + let PvpBounds pvpBounds asRevision = fromMaybe config.pvpBounds mpvpBounds tweakCabal = pvpBounds /= PvpBoundsNone pkgFp = toFilePath pkgDir lp <- readLocalPackage pkgDir @@ -226,14 +224,13 @@ getSDistTarball mpvpBounds pkgDir = do installMap <- toInstallMap sourceMap (installedMap, _globalDumpPkgs, _snapshotDumpPkgs, _localDumpPkgs) <- getInstalled installMap - let deps = Map.fromList - [ (pid, libInfo.ghcPkgId) - | (_, Library pid libInfo) <- Map.elems installedMap] + let allDeps = + Map.unions $ Map.map (installedPackageToGhcPkgId' . snd) installedMap prettyInfoL [ flow "Getting the file list for" , style File (fromString pkgFp) <> "." ] - (fileList, cabalFP) <- getSDistFileList lp deps + (fileList, cabalFP) <- getSDistFileList lp allDeps prettyInfoL [ flow "Building a compressed archive file in the sdist format for" , style File (fromString pkgFp) <> "." @@ -477,19 +474,22 @@ readLocalPackage pkgDir = do getSDistFileList :: HasEnvConfig env => LocalPackage - -> Map PackageIdentifier GhcPkgId + -> Map MungedPackageId GhcPkgId + -- ^ Ids of installed packages that are assumed to be available to build a + -- package's custom @Setup.hs@, given its dependencies specified in its + -- @custom-setup@ stanza of its Cabal file. -> RIO env (String, Path Abs File) -getSDistFileList lp deps = +getSDistFileList lp allDeps = withSystemTempDir (stackProgName <> "-sdist") $ \tmpdir -> do let bopts = defaultBuildOpts let boptsCli = defaultBuildOptsCLI baseConfigOpts <- mkBaseConfigOpts boptsCli locals <- projectLocalPackages - withExecuteEnv bopts boptsCli baseConfigOpts locals - [] [] [] Nothing -- provide empty list of globals. This is a hack around - -- custom Setup.hs files + -- We provide three empty lists of dumped installed packages. This is a hack + -- around custom Setup.hs files: + withExecuteEnv bopts boptsCli baseConfigOpts locals [] [] [] Nothing $ \ee -> - withSingleContext ac ee taskType deps (Just "sdist") $ + withSingleContext ac ee taskType allDeps (Just "sdist") $ \_package cabalFP _pkgDir cabal _announce _outputType -> do let outFile = toFilePath tmpdir FP. "source-files-list" cabal diff --git a/src/Stack/Setup/Installed.hs b/src/Stack/Setup/Installed.hs index b2c7f81652..137747d99c 100644 --- a/src/Stack/Setup/Installed.hs +++ b/src/Stack/Setup/Installed.hs @@ -160,8 +160,10 @@ toolExtraDirs tool = do pure mempty { bins = [ dir relDirMsysEnvPrefix relDirBin - , dir relDirUsr relDirBin + -- Stack follows the Unix-like convention that usr/local/bin + -- should have search priority over usr/bin. , dir relDirUsr relDirLocal relDirBin + , dir relDirUsr relDirBin ] , includes = [ dir relDirMsysEnvPrefix relDirInclude diff --git a/src/Stack/Types/Build.hs b/src/Stack/Types/Build.hs index ea64c0fe0b..9bae8b5265 100644 --- a/src/Stack/Types/Build.hs +++ b/src/Stack/Types/Build.hs @@ -9,13 +9,19 @@ Build-specific types. -} module Stack.Types.Build - ( ExcludeTHLoading (..) + ( RunCabalWithArgs + , ExcludeTHLoading (..) , ConvertPathsToAbsolute (..) , KeepOutputOpen (..) ) where import Stack.Prelude +-- | Type synonym that represents functions that run Cabal (the library) with +-- arguments. +type RunCabalWithArgs env = + KeepOutputOpen -> ExcludeTHLoading -> [String] -> RIO env () + -- | Type representing treatments of GHC's informational messages during -- compilation when it evaluates Template Haskell code. data ExcludeTHLoading diff --git a/src/Stack/Types/Build/ConstructPlan.hs b/src/Stack/Types/Build/ConstructPlan.hs index 1f94cfbcbb..3f06cda318 100644 --- a/src/Stack/Types/Build/ConstructPlan.hs +++ b/src/Stack/Types/Build/ConstructPlan.hs @@ -15,12 +15,14 @@ module Stack.Types.Build.ConstructPlan , CombinedMap , M , W (..) + , LibraryMap , AddDepRes (..) , toTask , adrVersion , adrHasLibrary , isAdrToInstall , Ctx (..) + , PackageLoader , UnregisterState (..) , ToolWarning (..) , MissingPresentDeps (..) @@ -82,15 +84,7 @@ type CombinedMap = Map PackageName PackageInfo -- | Type synonym representing values used during the construction of a build -- plan. The type is an instance of 'Monad', hence its name. -type M = - WriterT - W - -- ^ The output to be collected - ( StateT - (Map PackageName (Either ConstructPlanException AddDepRes)) - -- ^ Library map - (RIO Ctx) - ) +type M = WriterT W (StateT LibraryMap (RIO Ctx)) -- | Type representing values used as the output to be collected during the -- construction of a build plan. @@ -121,6 +115,11 @@ instance Monoid W where mempty = memptydefault mappend = (<>) +-- | A type synonym representing dictionaries of package names, and either an +-- exception encountered during the construction of the build plan or the +-- 'Stack.Build.ConstructPlan.addDep' result. +type LibraryMap = Map PackageName (Either ConstructPlanException AddDepRes) + -- | Type representing results of 'Stack.Build.ConstructPlan.addDep'. data AddDepRes = ADRToInstall Task @@ -155,7 +154,7 @@ adrHasLibrary (ADRFound _ Executable{}) = False data MissingPresentDeps = MissingPresentDeps { missingPackages :: !(Set PackageIdentifier) - , presentPackages :: !(Map PackageIdentifier GhcPkgId) + , presentPackages :: !(Map MungedPackageId GhcPkgId) , isMutable :: !IsMutable } deriving Show @@ -175,14 +174,9 @@ instance Monoid MissingPresentDeps where data Ctx = Ctx { baseConfigOpts :: !BaseConfigOpts -- ^ Basic information used to determine configure options - , loadPackage :: !( PackageLocationImmutable - -> Map FlagName Bool - -> [Text] - -- ^ GHC options. - -> [Text] - -- ^ Cabal configure options. - -> M Package - ) + , loadPackage :: !(PackageLoader M) + -- ^ A function to load a `Package` given the location of a package assumed + -- to be immutable. , combinedMap :: !CombinedMap -- ^ A dictionary of package names, and combined information about the -- package in respect of whether or not it is already installed and, unless @@ -197,6 +191,20 @@ data Ctx = Ctx , pathEnvVar :: !Text } +-- | A type synonym representing functions that yield a 'Package' given the +-- location of a package assumed to be immutable, parameterised by the relevant +-- monad. +type PackageLoader m = + PackageLocationImmutable + -- ^ Location of a package that is assumed to be immutable. + -> Map FlagName Bool + -- ^ Cabal flags. + -> [Text] + -- ^ GHC options. + -> [Text] + -- ^ Cabal configure options. + -> m Package + instance HasPlatform Ctx where platformL = configL . platformL {-# INLINE platformL #-} diff --git a/src/Stack/Types/Build/Exception.hs b/src/Stack/Types/Build/Exception.hs index e5f375aecf..86414bc52f 100644 --- a/src/Stack/Types/Build/Exception.hs +++ b/src/Stack/Types/Build/Exception.hs @@ -70,8 +70,6 @@ data BuildException Version -- version specified on command line | NoSetupHsFound (Path Abs Dir) | InvalidGhcOptionsSpecification [PackageName] - | TestSuiteExeMissing Bool String String String - | CabalCopyFailed Bool String | LocalPackagesPresent [PackageIdentifier] | CouldNotLockDistDir !(Path Abs File) | TaskCycleBug PackageIdentifier @@ -178,23 +176,6 @@ instance Exception BuildException where , packageNameString name , "' not found" ] - displayException (TestSuiteExeMissing isSimpleBuildType exeName pkgName' testName) = - missingExeError "[S-7987]" - isSimpleBuildType $ concat - [ "Test suite executable \"" - , exeName - , " not found for " - , pkgName' - , ":test:" - , testName - ] - displayException (CabalCopyFailed isSimpleBuildType innerMsg) = - missingExeError "[S-8027]" - isSimpleBuildType $ concat - [ "'cabal copy' failed. Error message:\n" - , innerMsg - , "\n" - ] displayException (LocalPackagesPresent locals) = unlines $ "Error: [S-5510]" : "Local packages are not allowed when using the 'script' command. \ @@ -266,6 +247,8 @@ data BuildPrettyException WantedCompilerSetter -- Way that the wanted compiler is set StyleDoc -- recommended resolution | ActionNotFilteredBug StyleDoc + | TestSuiteExeMissing !Bool !String !PackageName !StackUnqualCompName + | CabalCopyFailed !Bool !BuildPrettyException deriving Show instance Pretty BuildPrettyException where @@ -461,6 +444,29 @@ instance Pretty BuildPrettyException where , flow "is seeking to run an action that should have been filtered from \ \the list of actions." ] + pretty (TestSuiteExeMissing isSimpleBuildType exeName pkgName testName) = + missingExeError "[S-7987]" isSimpleBuildType $ + fillSep + [ flow "Test suite executable" + , style Shell (fromString exeName) + , flow "not found for" + , style PkgComponent pkgComponent <> "." + ] + <> line + where + pkgComponent = + fromString (packageNameString pkgName) + <> ":test:" + <> fromString (unqualCompToString testName) + pretty (CabalCopyFailed isSimpleBuildType err) = + missingExeError "[S-8027]" isSimpleBuildType $ + fillSep + [ style Shell "cabal copy" + , flow "failed. Error message:" + ] + <> line + <> pretty err + <> line instance Exception BuildPrettyException @@ -834,22 +840,42 @@ data BadDependency | BDDependencyCycleDetected ![PackageName] deriving (Eq, Ord, Show) -missingExeError :: String -> Bool -> String -> String -missingExeError errorCode isSimpleBuildType msg = unlines - $ "Error: " <> errorCode - : msg - : "Possible causes of this issue:" - : map ("* " <>) possibleCauses +missingExeError :: StyleDoc -> Bool -> StyleDoc -> StyleDoc +missingExeError errorCode isSimpleBuildType msg = + errorCode + <> line + <> msg + <> line + <> flow "Possible causes of this issue:" + <> line + <> bulletedList possibleCauses where - possibleCauses - = "No module named \"Main\". The 'main-is' source file should usually \ - \have a header indicating that it's a 'Main' module." - : "A Cabal file that refers to nonexistent other files (e.g. a \ - \license-file that doesn't exist). Running 'cabal check' may point \ - \out these issues." - : [ "The Setup.hs file is changing the installation target dir." - | not isSimpleBuildType - ] + possibleCauses = + [ fillSep + [ flow "No module named" + , style Shell "Main" <> "." + , "The" + , style Shell "main-is" + , flow "source file should usually have a header indicating that \ + \it's a" + , style Shell "Main" + , "module." + ] + , fillSep + [ flow "A Cabal file that refers to nonexistent other files (e.g. a" + , style Shell "license-file" + , flow "that doesn't exist). Running" + , style Shell "cabal check" + , flow "may point out these issues." + ] + ] + <> [ fillSep + [ "The" + , style File "Setup.hs" + , flow "file is changing the installation target directory." + ] + | not isSimpleBuildType + ] showBuildError :: String diff --git a/src/Stack/Types/BuildOpts.hs b/src/Stack/Types/BuildOpts.hs index 1a7da7eddd..cf7c335db8 100644 --- a/src/Stack/Types/BuildOpts.hs +++ b/src/Stack/Types/BuildOpts.hs @@ -18,6 +18,7 @@ module Stack.Types.BuildOpts , BenchmarkOpts (..) , buildOptsHaddockL , buildOptsInstallExesL + , buildOptsSemaphoreL ) where import Stack.Prelude @@ -95,6 +96,9 @@ data BuildOpts = BuildOpts , progressBar :: !ProgressBarFormat -- ^ Format of the progress bar , ddumpDir :: !(Maybe Text) + , semaphore :: !Bool + -- ^ Use Cabal's --semaphore=SEMAPHORE option to build modules of the same + -- package in parallel. } deriving Show @@ -111,6 +115,8 @@ data TestOpts = TestOpts , coverage :: !Bool -- ^ Generate a code coverage report , runTests :: !Bool -- ^ Enable running of tests , maximumTimeSeconds :: !(Maybe Int) -- ^ test suite timeout in seconds + , timeoutGraceSeconds :: !(Maybe Int) + -- ^ additional grace period after timeout before force-killing , allowStdin :: !Bool -- ^ Whether to allow standard input } deriving (Eq, Show) @@ -131,3 +137,7 @@ buildOptsInstallExesL = buildOptsHaddockL :: Lens' BuildOpts Bool buildOptsHaddockL = lens (.buildHaddocks) (\bopts t -> bopts {buildHaddocks = t}) + +buildOptsSemaphoreL :: Lens' BuildOpts Bool +buildOptsSemaphoreL = + lens (.semaphore) (\bopts t -> bopts {semaphore = t}) diff --git a/src/Stack/Types/BuildOptsMonoid.hs b/src/Stack/Types/BuildOptsMonoid.hs index 8d02a106e3..26847527bb 100644 --- a/src/Stack/Types/BuildOptsMonoid.hs +++ b/src/Stack/Types/BuildOptsMonoid.hs @@ -24,6 +24,7 @@ module Stack.Types.BuildOptsMonoid , buildOptsMonoidTestsL , buildOptsMonoidBenchmarksL , buildOptsMonoidInstallExesL + , buildOptsMonoidSemaphoreL , toFirstCabalVerbosity , readProgressBarFormat ) where @@ -43,7 +44,8 @@ import Stack.Types.ComponentUtils ( StackUnqualCompName ) -- | Build options that may be specified as non-project specific configuration -- options under the build key (with certain exceptions) or from the CLI. data BuildOptsMonoid = BuildOptsMonoid - { trace :: !Any + { semaphore :: !FirstFalse + , trace :: !Any -- ^ Cannot be specified under the build key , profile :: !Any -- ^ Cannot be specified under the build key @@ -121,8 +123,10 @@ instance FromJSON (WithJSONWarnings BuildOptsMonoid) where interleavedOutput <- FirstTrue <$> o ..:? interleavedOutputName progressBar <- First <$> o ..:? progressBarName ddumpDir <- o ..:? ddumpDirName ..!= mempty + semaphore <- FirstFalse <$> o ..:? semaphoreArgName pure BuildOptsMonoid - { trace + { semaphore + , trace , profile , noStrip , libProfile @@ -254,6 +258,9 @@ progressBarName = "progress-bar" ddumpDirName :: Text ddumpDirName = "ddump-dir" +semaphoreArgName :: Text +semaphoreArgName = "semaphore" + instance Semigroup BuildOptsMonoid where (<>) = mappenddefault @@ -267,6 +274,7 @@ data TestOptsMonoid = TestOptsMonoid , coverage :: !FirstFalse , runTests :: !FirstTrue , maximumTimeSeconds :: !(First (Maybe Int)) + , timeoutGraceSeconds :: !(First (Maybe Int)) , allowStdin :: !FirstTrue } deriving (Show, Generic) @@ -278,6 +286,7 @@ instance FromJSON (WithJSONWarnings TestOptsMonoid) where coverage <- FirstFalse <$> o ..:? coverageArgName runTests <- FirstTrue . (not <$>) <$> o ..:? noRunTestsArgName maximumTimeSeconds <- First <$> o ..:? maximumTimeSecondsArgName + timeoutGraceSeconds <- First <$> o ..:? timeoutGraceSecondsArgName allowStdin <- FirstTrue <$> o ..:? testsAllowStdinName pure TestOptsMonoid { rerunTests @@ -285,6 +294,7 @@ instance FromJSON (WithJSONWarnings TestOptsMonoid) where , coverage , runTests , maximumTimeSeconds + , timeoutGraceSeconds , allowStdin } @@ -303,6 +313,9 @@ noRunTestsArgName = "no-run-tests" maximumTimeSecondsArgName :: Text maximumTimeSecondsArgName = "test-suite-timeout" +timeoutGraceSecondsArgName :: Text +timeoutGraceSecondsArgName = "test-suite-timeout-grace" + testsAllowStdinName :: Text testsAllowStdinName = "tests-allow-stdin" @@ -403,6 +416,11 @@ buildOptsMonoidInstallExesL = lens (.installExes.firstFalse) (\buildMonoid t -> buildMonoid {installExes = FirstFalse t}) +buildOptsMonoidSemaphoreL :: Lens' BuildOptsMonoid (Maybe Bool) +buildOptsMonoidSemaphoreL = + lens (.semaphore.firstFalse) + (\buildMonoid t -> buildMonoid {semaphore = FirstFalse t}) + -- Type representing formats of Stack's progress bar when building. data ProgressBarFormat = NoBar -- No progress bar at all. diff --git a/src/Stack/Types/Cache.hs b/src/Stack/Types/Cache.hs index 154b6499b5..f114d51652 100644 --- a/src/Stack/Types/Cache.hs +++ b/src/Stack/Types/Cache.hs @@ -29,14 +29,13 @@ import Database.Persist.Sql ) import Stack.Prelude import Stack.Types.ConfigureOpts ( ConfigureOpts ) -import Stack.Types.GhcPkgId - ( GhcPkgId, ghcPkgIdToText, parseGhcPkgId ) +import Stack.Types.GhcPkgId ( GhcPkgId ) -- | Type representing types of cache in the Stack project SQLite database. data ConfigCacheType = ConfigCacheTypeConfig -- ^ Cabal configuration cache. - | ConfigCacheTypeFlagLibrary GhcPkgId + | ConfigCacheTypeFlagLibrary PackageIdentifier -- ^ Library Cabal flag cache. | ConfigCacheTypeFlagExecutable PackageIdentifier -- ^ Executable Cabal flag cache. @@ -45,25 +44,35 @@ data ConfigCacheType instance PersistField ConfigCacheType where toPersistValue ConfigCacheTypeConfig = PersistText "config" toPersistValue (ConfigCacheTypeFlagLibrary v) = - PersistText $ "lib:" <> ghcPkgIdToText v + PersistText $ "lib:" <> T.pack (packageIdentifierString v) toPersistValue (ConfigCacheTypeFlagExecutable v) = PersistText $ "exe:" <> T.pack (packageIdentifierString v) + fromPersistValue (PersistText t) = fromMaybe (Left $ "Unexpected ConfigCacheType value: " <> t) $ - config <|> fmap lib (T.stripPrefix "lib:" t) <|> - fmap exe (T.stripPrefix "exe:" t) + config + <|> flagCache ConfigCacheTypeFlagLibrary "lib:" + <|> flagCache ConfigCacheTypeFlagExecutable "exe:" where config | t == "config" = Just (Right ConfigCacheTypeConfig) | otherwise = Nothing - lib v = do - ghcPkgId <- mapLeft tshow (parseGhcPkgId v) - Right $ ConfigCacheTypeFlagLibrary ghcPkgId - exe v = do - pkgId <- - maybe (Left $ "Unexpected ConfigCacheType value: " <> t) Right $ - parsePackageIdentifier (T.unpack v) - Right $ ConfigCacheTypeFlagExecutable pkgId + + flagCache :: + (PackageIdentifier -> ConfigCacheType) + -- ^ Constructor + -> Text + -- ^ Prefex + -> Maybe (Either Text ConfigCacheType) + flagCache constructor prefix = + fmap toConfigCacheType (T.stripPrefix prefix t) + where + toConfigCacheType :: Text -> Either Text ConfigCacheType + toConfigCacheType v = do + pkgId <- + maybe (Left $ "Unexpected ConfigCacheType value: " <> t) Right $ + parsePackageIdentifier (T.unpack v) + Right $ constructor pkgId fromPersistValue _ = Left "Unexpected ConfigCacheType type" instance PersistFieldSql ConfigCacheType where diff --git a/src/Stack/Types/Config.hs b/src/Stack/Types/Config.hs index a61112314f..0beb310792 100644 --- a/src/Stack/Types/Config.hs +++ b/src/Stack/Types/Config.hs @@ -18,6 +18,7 @@ module Stack.Types.Config Config (..) , HasConfig (..) , askLatestSnapshotUrl + , askRecentSnapshotsUrl , configProjectRoot , ghcInstallHook -- * Lens helpers @@ -95,6 +96,8 @@ data Config = Config -- tinfo6) , latestSnapshot :: !Text -- ^ URL of a JSON file providing the latest LTS and Nightly snapshots. + , recentSnapshots :: !Text + -- ^ URL of a JSON file providing recently-published snapshots. , systemGHC :: !Bool -- ^ Should we use the system-installed GHC (on the PATH) if -- available? Can be overridden by command line options. @@ -240,6 +243,10 @@ configProjectRoot c = askLatestSnapshotUrl :: (MonadReader env m, HasConfig env) => m Text askLatestSnapshotUrl = view $ configL . to (.latestSnapshot) +-- | Get the URL to request the information on the recently-published snapshots +askRecentSnapshotsUrl :: (MonadReader env m, HasConfig env) => m Text +askRecentSnapshotsUrl = view $ configL . to (.recentSnapshots) + -- | @STACK_ROOT\/hooks\/@ hooksDir :: HasConfig env => RIO env (Path Abs Dir) hooksDir = do diff --git a/src/Stack/Types/ConfigExtra.hs b/src/Stack/Types/ConfigExtra.hs new file mode 100644 index 0000000000..4737cdff40 --- /dev/null +++ b/src/Stack/Types/ConfigExtra.hs @@ -0,0 +1,30 @@ +{-# LANGUAGE NoImplicitPrelude #-} + +{-| +Module : Stack.Types.ConfigExtra +License : BSD-3-Clause +-} + +module Stack.Types.ConfigExtra + ( ConfigExtra (..) + ) where + +import Stack.Prelude +import Stack.Types.Config ( Config ) +import Stack.Types.Project ( Project (..) ) + +-- | A type that represents 'Config' values together with some extra information +-- +data ConfigExtra = ConfigExtra + { config :: !Config + , mSnapshot :: !(Maybe RawSnapshotLocation) + , project :: !Project + , configFile :: !(Either (Path Abs File) (Path Abs File)) + -- ^ Either (Left) the location of the user-specific global configuration + -- file or, in most cases, (Right) the location of the project-level + -- coniguration file (stack.yaml, by default). + -- + -- Note: if the STACK_YAML environment variable is used, the location of the + -- project-level configuration file may be different from + -- projectRootL "stack.yaml" if a different file name is used. + } diff --git a/src/Stack/Types/ConfigMonoid.hs b/src/Stack/Types/ConfigMonoid.hs index b66f1d673e..beffb65ba8 100644 --- a/src/Stack/Types/ConfigMonoid.hs +++ b/src/Stack/Types/ConfigMonoid.hs @@ -21,7 +21,7 @@ module Stack.Types.ConfigMonoid , configMonoidSystemGHCName ) where -import Data.Aeson.Types ( Object, Value ) +import Data.Aeson.Types ( FromJSON (..), Object, Value ) import Data.Aeson.WarningParser ( WarningParser, WithJSONWarnings, (..:?), (..!=) , jsonSubWarnings, jsonSubWarningsT, withObjectWarnings @@ -84,6 +84,8 @@ data ConfigMonoid = ConfigMonoid -- ^ See: 'Stack.Types.Config.prefixTimestamps' , latestSnapshot :: !(First Text) -- ^ See: 'Stack.Types.Config.latestSnapshot' + , recentSnapshots :: !(First Text) + -- ^ See: 'Stack.Types.Config.recentSnapshots' , packageIndex :: !(First PackageIndexConfig) -- ^ See: 'withPantryConfig' , systemGHC :: !(First Bool) @@ -228,6 +230,43 @@ instance Monoid ConfigMonoid where mempty = memptydefault mappend = (<>) +-- | An uninterpreted representation of URLs options. Configurations may be +-- "cascaded" using mappend (left-biased). +data UrlsOptsMonoid = UrlsOptsMonoid + { latestSnapshot :: !(First Text) + -- ^ See: 'Stack.Types.Config.latestSnapshot' + , recentSnapshots :: !(First Text) + -- ^ See: 'Stack.Types.Config.recentSnapshots' + } + deriving Generic + +-- | Decode uninterpreted URLs options from JSON/YAML. +instance FromJSON (WithJSONWarnings UrlsOptsMonoid) where + parseJSON = withObjectWarnings "UrlsOptsMonoid" $ \o -> do + latestSnapshot <- First <$> o ..:? latestSnapshotArgName + recentSnapshots <- First <$> o ..:? recentSnapshotsArgName + pure UrlsOptsMonoid + { latestSnapshot + , recentSnapshots + } + +-- | Left-biased combine URLs options +instance Semigroup UrlsOptsMonoid where + (<>) = mappenddefault + +-- | Left-biased combine URLs options +instance Monoid UrlsOptsMonoid where + mempty = memptydefault + mappend = (<>) + +-- | URLs latest snapshots argument name. +latestSnapshotArgName :: Text +latestSnapshotArgName = "latest-snapshot" + +-- | URLs recent snapshots argument name. +recentSnapshotsArgName :: Text +recentSnapshotsArgName = "recent-snapshots" + parseConfigMonoid :: Path Abs Dir -> Value @@ -249,14 +288,10 @@ parseConfigMonoidObject rootDir obj = do connectionCount <- First <$> obj ..:? configMonoidConnectionCountName hideTHLoading <- FirstTrue <$> obj ..:? configMonoidHideTHLoadingName prefixTimestamps <- First <$> obj ..:? configMonoidPrefixTimestampsName - - latestSnapshot <- obj ..:? configMonoidUrlsName >>= \case - Nothing -> pure $ First Nothing - Just urls -> jsonSubWarnings $ lift $ withObjectWarnings - "urls" - (\o -> First <$> o ..:? "latest-snapshot" :: WarningParser (First Text)) - (urls :: Value) - + urlsOpts :: UrlsOptsMonoid <- + jsonSubWarnings (obj ..:? configMonoidUrlsName ..!= mempty) + let latestSnapshot = urlsOpts.latestSnapshot + recentSnapshots = urlsOpts.recentSnapshots packageIndex <- First <$> jsonSubWarningsT (obj ..:? configMonoidPackageIndexName) systemGHC <- First <$> obj ..:? configMonoidSystemGHCName @@ -380,6 +415,7 @@ parseConfigMonoidObject rootDir obj = do , hideTHLoading , prefixTimestamps , latestSnapshot + , recentSnapshots , packageIndex , systemGHC , installGHC diff --git a/src/Stack/Types/Dependency.hs b/src/Stack/Types/Dependency.hs index c6ba2f3f20..05129fbd84 100644 --- a/src/Stack/Types/Dependency.hs +++ b/src/Stack/Types/Dependency.hs @@ -43,37 +43,51 @@ data DepValue = DepValue -- data DepType = AsLibrary !DepLibrary + -- ^ Dependency is used as a library. | AsBuildTool + -- ^ Dependency is used only to provide a build tool. deriving (Eq, Show) +-- | Type repesenting dependency packages used as a library. data DepLibrary = DepLibrary { main :: !Bool + -- ^ Is the dependency on a main (unnamed) library component? , subLib :: Set StackUnqualCompName + -- ^ A set (which may be empty) of dependencies on sub-library components. } deriving (Eq, Show) +-- | A function to yield the set (which may be empty) of dependencies on +-- sub-library components. Yields 'Nothing' if the dependency is used only to +-- provide a build tool. getDepSublib :: DepValue -> Maybe (Set StackUnqualCompName) getDepSublib val = case val.depType of AsLibrary libVal -> Just libVal.subLib _ -> Nothing +-- | Represents a dependency only on a main (unnamed) library component. defaultDepLibrary :: DepLibrary defaultDepLibrary = DepLibrary True mempty +-- | Test whether the dependency is being used as a library. isDepTypeLibrary :: DepType -> Bool isDepTypeLibrary AsLibrary{} = True isDepTypeLibrary AsBuildTool = False +-- | Given a 'Cabal.Dependency', yield the Stack equivalent. cabalToStackDep :: Cabal.Dependency -> DepValue cabalToStackDep (Cabal.Dependency _ verRange libNameSet) = DepValue { versionRange = verRange, depType = AsLibrary depLibrary } where depLibrary = DepLibrary finalHasMain filteredItems + (finalHasMain, filteredItems) = foldr' iterator (False, mempty) libNameSet - iterator LMainLibName (_, newLibNameSet) = (True, newLibNameSet) - iterator (LSubLibName libName) (hasMain, newLibNameSet) = - (hasMain, Set.insert (fromCabalName libName) newLibNameSet) + where + iterator LMainLibName (_, newLibNameSet) = (True, newLibNameSet) + iterator (LSubLibName libName) (hasMain, newLibNameSet) = + (hasMain, Set.insert (fromCabalName libName) newLibNameSet) +-- | Given an 'Cabal.ExeDependency', yield the Stack equivalent. cabalExeToStackDep :: Cabal.ExeDependency -> DepValue cabalExeToStackDep (Cabal.ExeDependency _ _name verRange) = DepValue { versionRange = verRange, depType = AsBuildTool } diff --git a/src/Stack/Types/DotOpts.hs b/src/Stack/Types/DotOpts.hs index a0683c6f60..dd8f4c9ba0 100644 --- a/src/Stack/Types/DotOpts.hs +++ b/src/Stack/Types/DotOpts.hs @@ -27,6 +27,9 @@ data DotOpts = DotOpts -- fixpoint , prune :: !(Set PackageName) -- ^ Package names to prune from the graph + , reach :: !(Set PackageName) + -- ^ If not empty, packages in the pruned graph must be able to reach one or + -- more of these packages , dotTargets :: [Text] -- ^ Stack TARGETs to trace dependencies for , flags :: !(Map ApplyCLIFlag (Map FlagName Bool)) diff --git a/src/Stack/Types/Installed.hs b/src/Stack/Types/Installed.hs index ba84f66b1e..6b7a159207 100644 --- a/src/Stack/Types/Installed.hs +++ b/src/Stack/Types/Installed.hs @@ -28,8 +28,6 @@ module Stack.Types.Installed ) where import qualified Data.Map as M -import qualified Distribution.SPDX.License as SPDX -import Distribution.License ( License ) import Stack.Prelude import Stack.Types.ComponentUtils ( StackUnqualCompName ) import Stack.Types.GhcPkgId ( GhcPkgId, ghcPkgIdString ) @@ -101,37 +99,43 @@ type InstallMap = Map PackageName (InstallLocation, Version) -- information about what is installed. type InstalledMap = Map PackageName (InstallLocation, Installed) +-- TODO: This may not be the best type, as it allows invalid values to be +-- represented. data InstalledLibraryInfo = InstalledLibraryInfo - { ghcPkgId :: GhcPkgId - , license :: Maybe (Either SPDX.License License) + { mMainGhcPkgId :: Maybe GhcPkgId + -- ^ The main library, if present. If absent, there must be one or more + -- installed sublibraries. , subLib :: Map StackUnqualCompName GhcPkgId + -- ^ If there are no sublibraries, there must be a main library. } deriving (Eq, Show) -- | Type representing information about what is installed. data Installed = Library PackageIdentifier InstalledLibraryInfo - -- ^ A library, including its installed package id and, optionally, its - -- license. + -- ^ A library, including the ids of its installed packages. | Executable PackageIdentifier -- ^ An executable. deriving (Eq, Show) installedLibraryInfoFromGhcPkgId :: GhcPkgId -> InstalledLibraryInfo installedLibraryInfoFromGhcPkgId ghcPkgId = - InstalledLibraryInfo ghcPkgId Nothing mempty + InstalledLibraryInfo (Just ghcPkgId) mempty simpleInstalledLib :: PackageIdentifier - -> GhcPkgId + -> Maybe GhcPkgId + -- ^ The id of the installed main library, if any. -> Map StackUnqualCompName GhcPkgId + -- ^ The id of any sublibraries. -> Installed -simpleInstalledLib pkgIdentifier ghcPkgId = - Library pkgIdentifier . InstalledLibraryInfo ghcPkgId Nothing +simpleInstalledLib pkgIdentifier mMainGhcPkgId = + Library pkgIdentifier . InstalledLibraryInfo mMainGhcPkgId installedToPackageIdOpt :: InstalledLibraryInfo -> [String] installedToPackageIdOpt libInfo = - M.foldr' (iterator (++)) (pure $ toStr libInfo.ghcPkgId) libInfo.subLib + let acc0 = toStr <$> maybeToList libInfo.mMainGhcPkgId + in M.foldr' (iterator (++)) acc0 libInfo.subLib where toStr ghcPkgId = "-package-id=" <> ghcPkgIdString ghcPkgId iterator op ghcPkgId acc = pure (toStr ghcPkgId) `op` acc @@ -141,17 +145,17 @@ installedPackageIdentifier (Library pid _) = pid installedPackageIdentifier (Executable pid) = pid -- | A strict fold over the 'GhcPkgId' of the given installed package. This will --- iterate on both sub and main libraries, if any. +-- iterate on the main library (if any) and sublibraries (if any). foldOnGhcPkgId' :: - (Maybe StackUnqualCompName -> GhcPkgId -> resT -> resT) + (Maybe StackUnqualCompName -> GhcPkgId -> a -> a) -> Installed - -> resT - -> resT + -> a + -> a foldOnGhcPkgId' _ Executable{} res = res foldOnGhcPkgId' fn (Library _ libInfo) res = - M.foldrWithKey' (fn . Just) (base res) libInfo.subLib + M.foldrWithKey' (fn . Just) base libInfo.subLib where - base = fn Nothing libInfo.ghcPkgId + base = maybe res (\ghcPkgId -> fn Nothing ghcPkgId res) libInfo.mMainGhcPkgId -- | Get the installed Version. installedVersion :: Installed -> Version diff --git a/src/Stack/Types/MsysEnvironment.hs b/src/Stack/Types/MsysEnvironment.hs index 7372f72ff7..efee5d6e60 100644 --- a/src/Stack/Types/MsysEnvironment.hs +++ b/src/Stack/Types/MsysEnvironment.hs @@ -26,13 +26,10 @@ import Stack.Prelude data MsysEnvironment = CLANG32 | CLANG64 + -- ^ Stack's default on architecture x86_64. | CLANGARM64 | MINGW32 - -- ^ Stack's default on architecture i386, and applied if GHC version is - -- earlier than GHC 9.6. | MINGW64 - -- ^ Stack's default on architecture x86_64, and applied if GHC version is - -- earlier than GHC 9.6. | UCRT64 deriving (Eq, Ord, Show) diff --git a/src/Stack/Types/Package.hs b/src/Stack/Types/Package.hs index 488415ddea..a316fb397d 100644 --- a/src/Stack/Types/Package.hs +++ b/src/Stack/Types/Package.hs @@ -33,6 +33,7 @@ module Stack.Types.Package , dotCabalModulePath , installedMapGhcPkgId , installedPackageToGhcPkgId + , installedPackageToGhcPkgId' , lpFiles , lpFilesForComponents , memoizeRefWith @@ -40,7 +41,7 @@ module Stack.Types.Package , packageIdentifier , psVersion , runMemoizedWith - , simpleInstalledLib + , toCabalMungedPackageId , toCabalMungedPackageName , toPackageDbVariety ) where @@ -54,8 +55,6 @@ import Distribution.License ( License ) import Distribution.ModuleName ( ModuleName ) import Distribution.PackageDescription ( BuildType ) import Distribution.System ( Platform (..) ) -import Distribution.Types.MungedPackageName - ( encodeCompatPackageName ) import qualified RIO.Text as T import Stack.Prelude import Stack.Types.Cache ( FileCache ) @@ -74,7 +73,7 @@ import Stack.Types.Installed ( InstallLocation (..), InstallMap, Installed (..) , InstalledLibraryInfo (..), InstalledMap , InstalledPackageLocation (..), PackageDatabase (..) - , PackageDbVariety(..), simpleInstalledLib + , PackageDbVariety(..), installedPackageIdentifier , toPackageDbVariety ) import Stack.Types.NamedComponent ( NamedComponent ) @@ -386,43 +385,57 @@ dotCabalGetPath dcp = DotCabalFilePath fp -> fp DotCabalCFilePath fp -> fp --- | Gathers all the GhcPkgId provided by a library into a map +-- | Gathers all the GhcPkgId provided by a library into a map, where the +-- package identifier of a sublibrary is its munged package identifier. installedMapGhcPkgId :: PackageIdentifier + -- ^ The name and version of a Cabal package. -> InstalledLibraryInfo - -> Map PackageIdentifier GhcPkgId -installedMapGhcPkgId pkgId@(PackageIdentifier pkgName version) installedLib = - finalMap + -> Map MungedPackageId GhcPkgId +installedMapGhcPkgId pkgId libInfo = + mAddMainGhcPkgId libInfo.mMainGhcPkgId subLibMap where - finalMap = M.insert pkgId installedLib.ghcPkgId baseMap - baseMap = - M.mapKeysMonotonic - (toCabalMungedPackageIdentifier pkgName version) - installedLib.subLib + mAddMainGhcPkgId = maybe id (M.insert mungedMainPkgId) + mungedMainPkgId = toCabalMungedPackageId pkgId Nothing + subLibMap = + M.mapKeysMonotonic (toCabalMungedPackageId pkgId . Just) libInfo.subLib installedPackageToGhcPkgId :: PackageIdentifier + -- ^ The name and version of a Cabal package. -> Installed - -> Map PackageIdentifier GhcPkgId -installedPackageToGhcPkgId ident (Library ident' libInfo) = - assert (ident == ident') (installedMapGhcPkgId ident libInfo) -installedPackageToGhcPkgId _ (Executable _) = mempty - --- | Creates a t'MungedPackageName' identifier. -toCabalMungedPackageIdentifier :: - PackageName - -> Version - -> StackUnqualCompName - -> PackageIdentifier -toCabalMungedPackageIdentifier pkgName version = flip PackageIdentifier version - . encodeCompatPackageName . toCabalMungedPackageName pkgName + -- ^ Assumed to be for the same Cabal package name and version. + -> Map MungedPackageId GhcPkgId +installedPackageToGhcPkgId pkgId installed = + assert (pkgId == installedPackageIdentifier installed) + (installedPackageToGhcPkgId' installed) + +installedPackageToGhcPkgId' :: Installed -> Map MungedPackageId GhcPkgId +installedPackageToGhcPkgId' (Library pkgId libInfo) = + installedMapGhcPkgId pkgId libInfo +installedPackageToGhcPkgId' (Executable _) = mempty + +-- | Creates a munged package identifier. +toCabalMungedPackageId :: + PackageIdentifier + -- ^ The name and version of a Cabal package. + -> Maybe StackUnqualCompName + -- ^ 'Nothing', if a main library. + -> MungedPackageId +toCabalMungedPackageId pkgId mLibName = + MungedPackageId (toCabalMungedPackageName pkgName mLibName) version + where + PackageIdentifier pkgName version = pkgId +-- | Creates a munged package name. toCabalMungedPackageName :: PackageName - -> StackUnqualCompName + -- ^ The name of a Cabal package. + -> Maybe StackUnqualCompName + -- ^ 'Nothing', if a main library. -> MungedPackageName -toCabalMungedPackageName pkgName = - MungedPackageName pkgName . LSubLibName . toCabalName +toCabalMungedPackageName pkgName mLibName = MungedPackageName pkgName $ + maybe LMainLibName (LSubLibName . toCabalName) mLibName -- | Type representing inputs to 'Stack.Package.generateBuildInfoOpts'. data BioInput = BioInput diff --git a/src/Stack/Types/Plan.hs b/src/Stack/Types/Plan.hs index 8789f3f0d9..3a10ea02a3 100644 --- a/src/Stack/Types/Plan.hs +++ b/src/Stack/Types/Plan.hs @@ -63,8 +63,8 @@ data Task = Task -- are missing and a function which yields configure options, given a -- dictionary of those identifiers and their 'GhcPkgId'. , buildHaddocks :: !Bool - , present :: !(Map PackageIdentifier GhcPkgId) - -- ^ A dictionary of the package identifiers of already-installed + , present :: !(Map MungedPackageId GhcPkgId) + -- ^ A dictionary of the munged package identifiers of already-installed -- dependencies, and their 'GhcPkgId'. , allInOne :: !Bool -- ^ indicates that the package can be built in one step diff --git a/src/Stack/Types/ProjectConfig.hs b/src/Stack/Types/ProjectConfig.hs index 412b07b5cc..60e38093dc 100644 --- a/src/Stack/Types/ProjectConfig.hs +++ b/src/Stack/Types/ProjectConfig.hs @@ -24,7 +24,7 @@ data ProjectConfig a -- Instead, use the implicit global. | PCNoProject ![RawPackageLocationImmutable] -- ^ Use a no project run. This comes from - -- 'Stack.Types.StackYamlLocSYLNoProject'. + -- 'Stack.Types.StackYamlLoc.SYLNoProject'. -- | Yields 'True' only if the project configuration information is for the -- implicit global project. diff --git a/src/unix/Stack/Build/TestSuiteTimeout.hs b/src/unix/Stack/Build/TestSuiteTimeout.hs new file mode 100644 index 0000000000..e496a661d9 --- /dev/null +++ b/src/unix/Stack/Build/TestSuiteTimeout.hs @@ -0,0 +1,40 @@ +{-# LANGUAGE NoImplicitPrelude #-} + +{-| +Module : Stack.Build.TestSuiteTimeout +Description : OS-specific test suite timeout termination helpers. +License : BSD-3-Clause +-} + +module Stack.Build.TestSuiteTimeout + ( prepareForEscalation + , terminateGracefully + , forceKill + ) where + +import RIO.Process ( ProcessConfig, setNewSession ) +import qualified RIO.Process as RP ( Process, unsafeProcessHandle ) +import Stack.Prelude +import System.Posix.Signals + ( sigKILL, sigTERM, signalProcess, signalProcessGroup ) +import qualified System.Process as Process + +prepareForEscalation :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr +prepareForEscalation = setNewSession True + +terminateGracefully :: RP.Process stdin stdout stderr -> RIO env () +terminateGracefully p = do + let processHandle = RP.unsafeProcessHandle p + mpid <- liftIO $ Process.getPid processHandle + forM_ mpid $ \pid -> do + -- In a new session, the initial pid is also the process group id. + void $ tryAny $ liftIO $ signalProcessGroup sigTERM pid + void $ tryAny $ liftIO $ signalProcess sigTERM pid + +forceKill :: RP.Process stdin stdout stderr -> RIO env () +forceKill p = do + let processHandle = RP.unsafeProcessHandle p + mpid <- liftIO $ Process.getPid processHandle + forM_ mpid $ \pid -> do + void $ tryAny $ liftIO $ signalProcessGroup sigKILL pid + void $ tryAny $ liftIO $ signalProcess sigKILL pid diff --git a/src/windows/Stack/Build/TestSuiteTimeout.hs b/src/windows/Stack/Build/TestSuiteTimeout.hs new file mode 100644 index 0000000000..2603b01ce1 --- /dev/null +++ b/src/windows/Stack/Build/TestSuiteTimeout.hs @@ -0,0 +1,29 @@ +{-# LANGUAGE NoImplicitPrelude #-} + +{-| +Module : Stack.Build.TestSuiteTimeout +Description : OS-specific test suite timeout termination helpers. +License : BSD-3-Clause +-} + +module Stack.Build.TestSuiteTimeout + ( prepareForEscalation + , terminateGracefully + , forceKill + ) where + +import RIO.Process ( ProcessConfig ) +import qualified RIO.Process as RP ( Process, unsafeProcessHandle ) +import Stack.Prelude +import qualified System.Process as Process + +prepareForEscalation :: ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr +prepareForEscalation = id + +terminateGracefully :: RP.Process stdin stdout stderr -> RIO env () +terminateGracefully p = + void $ tryAny $ liftIO $ Process.terminateProcess $ RP.unsafeProcessHandle p + +forceKill :: RP.Process stdin stdout stderr -> RIO env () +forceKill p = + void $ tryAny $ liftIO $ Process.terminateProcess $ RP.unsafeProcessHandle p diff --git a/stack-ghc-9.12.3.yaml b/stack-ghc-9.12.3.yaml deleted file mode 100644 index a07c6c760f..0000000000 --- a/stack-ghc-9.12.3.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# This is an experimental project-level configuration, to see if Stack can be -# built with GHC 9.12.3. -# -# GHC 9.12.3 is, however, not recommended for use, due to: -# https://gitlab.haskell.org/ghc/ghc/-/issues/26711 -snapshot: nightly-2026-01-04 # GHC 9.12.3 - -extra-deps: -# nightly-2026-01-04 specifies Cabal-3.14.2.0 -- Cabal-3.16.0.0@sha256:9972c2bd263168a20bd990962a68d4fd024f50c30a00519a6b942e8871d1bd67,14455 -- Cabal-syntax-3.16.0.0@sha256:6a35036763557301876c5b7a448de4f1cb54fe1e223ff6c4c0c1fdd6df635a65,7509 - -docker: - enable: false - repo: quay.io/benz0li/ghc-musl:9.12.3 - -nix: - # --nix on the command-line to enable. - packages: - - zlib - - unzip - -flags: - stack: - developer-mode: true diff --git a/stack-ghc-9.12.3.yaml.lock b/stack-ghc-9.12.3.yaml.lock deleted file mode 100644 index b51132c024..0000000000 --- a/stack-ghc-9.12.3.yaml.lock +++ /dev/null @@ -1,26 +0,0 @@ -# This file was autogenerated by Stack. -# You should not edit this file by hand. -# For more information, please see the documentation at: -# https://docs.haskellstack.org/en/stable/topics/lock_files - -packages: -- completed: - hackage: Cabal-3.16.0.0@sha256:9972c2bd263168a20bd990962a68d4fd024f50c30a00519a6b942e8871d1bd67,14455 - pantry-tree: - sha256: ddc689c4070a034cacd73c39c1df2673ed16e0b38b5ca476fc6ef2aa87b6f40f - size: 12139 - original: - hackage: Cabal-3.16.0.0@sha256:9972c2bd263168a20bd990962a68d4fd024f50c30a00519a6b942e8871d1bd67,14455 -- completed: - hackage: Cabal-syntax-3.16.0.0@sha256:6a35036763557301876c5b7a448de4f1cb54fe1e223ff6c4c0c1fdd6df635a65,7509 - pantry-tree: - sha256: 4de976261238dd4045dd3addebf6a006d4aff3873ee680bac7af83dcbf068280 - size: 11238 - original: - hackage: Cabal-syntax-3.16.0.0@sha256:6a35036763557301876c5b7a448de4f1cb54fe1e223ff6c4c0c1fdd6df635a65,7509 -snapshots: -- completed: - sha256: b55db959b8fa7b6e87f83cfca88db0d54126158fbf8501a658c4642ba229b27c - size: 716307 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2026/1/4.yaml - original: nightly-2026-01-04 diff --git a/stack-ghc-9.12.4.yaml b/stack-ghc-9.12.4.yaml new file mode 100644 index 0000000000..40933d3278 --- /dev/null +++ b/stack-ghc-9.12.4.yaml @@ -0,0 +1,36 @@ +# This is an experimental project-level configuration, to see if Stack can be +# built with GHC 9.12.4. +snapshot: nightly-2026-04-17 # GHC 9.12.4 + +extra-deps: +# nightly-2026-04-17 specifies Cabal-3.14.2.0 +- Cabal-3.16.0.0@sha256:9972c2bd263168a20bd990962a68d4fd024f50c30a00519a6b942e8871d1bd67,14455 +- Cabal-syntax-3.16.0.0@sha256:6a35036763557301876c5b7a448de4f1cb54fe1e223ff6c4c0c1fdd6df635a65,7509 +# nightly-2026-04-17 specifies crypton-x509-1.7.7 +- crypton-x509-1.8.0@sha256:d4822ba8dcb19ee3233fc98152f5afda383ac952770a1d07f1d01168e9fcdbc2,2006 +# nightly-2026-04-17 specifies crypton-x509-store-1.6.14 +- crypton-x509-store-1.8.0@sha256:075ba50a3daa0fdbb493481a665926e1ced2135c6b4ed56f97398aa855f0aecb,1674 +# nightly-2026-04-17 specifies crypton-x509-system-1.6.8 +- crypton-x509-system-1.8.0@sha256:76bab32c7d9cb3ea356a905f85829c70967fb6f9b4b890f00d67dc54130d45ca,1521 +# nightly-2026-04-17 specifies crypton-x509-validation-1.6.14 +- crypton-x509-validation-1.8.0@sha256:63acb2df06f28c3ffdddaf6d9402105b9026796036aa10d7347ae4f7db51c36b,2018 +# nightly-2026-04-17 specifies hpack-0.39.3 +- hpack-0.39.5@sha256:c214f49ed3df75ce75201709927fa27e08f642023ed4b4ca8cc43604e5199ced,5263 +# nightly-2026-04-17 specifies rio-prettyprint-0.1.8.0 +- rio-prettyprint-0.1.9.0@sha256:f48afbfe28ed7be4d1a1bb96705669593dd5df12f28ed908516c6dfc4e0becbb,1375 +# nightly-2026-04-17 specifies tls-2.1.14 +- tls-2.2.2@sha256:95f5acd4ce76cbd6bdc46b737370dcbd93c59cf1cd1934a30e55c61c1dc140e9,7283 + +docker: + enable: false + repo: quay.io/benz0li/ghc-musl:9.12.4 + +nix: + # --nix on the command-line to enable. + packages: + - zlib + - unzip + +flags: + stack: + developer-mode: true diff --git a/stack-ghc-9.12.4.yaml.lock b/stack-ghc-9.12.4.yaml.lock new file mode 100644 index 0000000000..bc32ccd938 --- /dev/null +++ b/stack-ghc-9.12.4.yaml.lock @@ -0,0 +1,75 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/topics/lock_files + +packages: +- completed: + hackage: Cabal-3.16.0.0@sha256:9972c2bd263168a20bd990962a68d4fd024f50c30a00519a6b942e8871d1bd67,14455 + pantry-tree: + sha256: ddc689c4070a034cacd73c39c1df2673ed16e0b38b5ca476fc6ef2aa87b6f40f + size: 12139 + original: + hackage: Cabal-3.16.0.0@sha256:9972c2bd263168a20bd990962a68d4fd024f50c30a00519a6b942e8871d1bd67,14455 +- completed: + hackage: Cabal-syntax-3.16.0.0@sha256:6a35036763557301876c5b7a448de4f1cb54fe1e223ff6c4c0c1fdd6df635a65,7509 + pantry-tree: + sha256: 4de976261238dd4045dd3addebf6a006d4aff3873ee680bac7af83dcbf068280 + size: 11238 + original: + hackage: Cabal-syntax-3.16.0.0@sha256:6a35036763557301876c5b7a448de4f1cb54fe1e223ff6c4c0c1fdd6df635a65,7509 +- completed: + hackage: crypton-x509-1.8.0@sha256:d4822ba8dcb19ee3233fc98152f5afda383ac952770a1d07f1d01168e9fcdbc2,2006 + pantry-tree: + sha256: 882a699e305fffcb77dd40bd40f959f062a8997a53560dca64462087aed3e4cd + size: 1132 + original: + hackage: crypton-x509-1.8.0@sha256:d4822ba8dcb19ee3233fc98152f5afda383ac952770a1d07f1d01168e9fcdbc2,2006 +- completed: + hackage: crypton-x509-store-1.8.0@sha256:075ba50a3daa0fdbb493481a665926e1ced2135c6b4ed56f97398aa855f0aecb,1674 + pantry-tree: + sha256: 2c7e00e593d399624264172cbd5e2fa55feaf8239cf33bee7e33bbc7509d0a2e + size: 458 + original: + hackage: crypton-x509-store-1.8.0@sha256:075ba50a3daa0fdbb493481a665926e1ced2135c6b4ed56f97398aa855f0aecb,1674 +- completed: + hackage: crypton-x509-system-1.8.0@sha256:76bab32c7d9cb3ea356a905f85829c70967fb6f9b4b890f00d67dc54130d45ca,1521 + pantry-tree: + sha256: 9ac33c993a82ac4da84804028c5398caec7aada7a83beeec3f28883fe470d68f + size: 512 + original: + hackage: crypton-x509-system-1.8.0@sha256:76bab32c7d9cb3ea356a905f85829c70967fb6f9b4b890f00d67dc54130d45ca,1521 +- completed: + hackage: crypton-x509-validation-1.8.0@sha256:63acb2df06f28c3ffdddaf6d9402105b9026796036aa10d7347ae4f7db51c36b,2018 + pantry-tree: + sha256: 64baf1be6e65ade9ad8eaef819c9cc4c0fcb7d3b968641dcf28a3f859fe87dc5 + size: 691 + original: + hackage: crypton-x509-validation-1.8.0@sha256:63acb2df06f28c3ffdddaf6d9402105b9026796036aa10d7347ae4f7db51c36b,2018 +- completed: + hackage: hpack-0.39.5@sha256:c214f49ed3df75ce75201709927fa27e08f642023ed4b4ca8cc43604e5199ced,5263 + pantry-tree: + sha256: 75fe87db5a37bf3941e29e2273f530ee7b2932d64bf813b55151a889e97305ca + size: 3799 + original: + hackage: hpack-0.39.5@sha256:c214f49ed3df75ce75201709927fa27e08f642023ed4b4ca8cc43604e5199ced,5263 +- completed: + hackage: rio-prettyprint-0.1.9.0@sha256:f48afbfe28ed7be4d1a1bb96705669593dd5df12f28ed908516c6dfc4e0becbb,1375 + pantry-tree: + sha256: c840f1193718b7af6c004fc62a67919e223b56cc1658a168c8e490e53a632aa0 + size: 779 + original: + hackage: rio-prettyprint-0.1.9.0@sha256:f48afbfe28ed7be4d1a1bb96705669593dd5df12f28ed908516c6dfc4e0becbb,1375 +- completed: + hackage: tls-2.2.2@sha256:95f5acd4ce76cbd6bdc46b737370dcbd93c59cf1cd1934a30e55c61c1dc140e9,7283 + pantry-tree: + sha256: 6ddac1e644efe75dbf62bbd35fa38897caca307d62bac538ae29b0c54bf6ff00 + size: 7056 + original: + hackage: tls-2.2.2@sha256:95f5acd4ce76cbd6bdc46b737370dcbd93c59cf1cd1934a30e55c61c1dc140e9,7283 +snapshots: +- completed: + sha256: f4d90db84aefb7c9590dd224ebdabfd8304f81bbad4652a715ee8350c4b9d396 + size: 738802 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2026/4/17.yaml + original: nightly-2026-04-17 diff --git a/stack-ghc-9.14.1.yaml b/stack-ghc-9.14.1.yaml index aaeb09c513..27af9a4ec9 100644 --- a/stack-ghc-9.14.1.yaml +++ b/stack-ghc-9.14.1.yaml @@ -1,8 +1,31 @@ # This is an experimental project-level configuration, to see if Stack can be # built with GHC 9.14.1. -snapshot: nightly-2025-12-20 # GHC 9.12.2 +snapshot: nightly-2026-04-17 # GHC 9.12.4 compiler: ghc-9.14.1 +extra-deps: +# nightly-2026-04-17 specifies Cabal-3.14.2.0 +- Cabal-3.16.0.0@sha256:9972c2bd263168a20bd990962a68d4fd024f50c30a00519a6b942e8871d1bd67,14455 +- Cabal-syntax-3.16.0.0@sha256:6a35036763557301876c5b7a448de4f1cb54fe1e223ff6c4c0c1fdd6df635a65,7509 +# nightly-2026-04-17 specifies crypton-x509-1.7.7 +- crypton-x509-1.8.0@sha256:d4822ba8dcb19ee3233fc98152f5afda383ac952770a1d07f1d01168e9fcdbc2,2006 +# nightly-2026-04-17 specifies crypton-x509-store-1.6.14 +- crypton-x509-store-1.8.0@sha256:075ba50a3daa0fdbb493481a665926e1ced2135c6b4ed56f97398aa855f0aecb,1674 +# nightly-2026-04-17 specifies crypton-x509-system-1.6.8 +- crypton-x509-system-1.8.0@sha256:76bab32c7d9cb3ea356a905f85829c70967fb6f9b4b890f00d67dc54130d45ca,1521 +# nightly-2026-04-17 specifies crypton-x509-validation-1.6.14 +- crypton-x509-validation-1.8.0@sha256:63acb2df06f28c3ffdddaf6d9402105b9026796036aa10d7347ae4f7db51c36b,2018 +# nightly-2026-04-17 specifies http-api-data-0.6.7 +- http-api-data-0.7@sha256:b8145755fced98db1ac67f4f98c8010cd5f82c121a82b65addea2556b5fbd6d5,3157 +# nightly-2026-04-17 specifies hpack-0.39.3 +- hpack-0.39.5@sha256:c214f49ed3df75ce75201709927fa27e08f642023ed4b4ca8cc43604e5199ced,5263 +# nightly-2026-04-17 specifies rio-prettyprint-0.1.8.0 +- rio-prettyprint-0.1.9.0@sha256:f48afbfe28ed7be4d1a1bb96705669593dd5df12f28ed908516c6dfc4e0becbb,1375 +# nightly-2026-04-17 specifies tagged-0.8.9 +- tagged-0.8.10@sha256:e9b97c98e9827981d62f37c5febf9e6bbb67acec92b8bd41fd9f7ace5eb31d32,2201 +# nightly-2026-04-17 specifies tls-2.1.14 +- tls-2.2.2@sha256:95f5acd4ce76cbd6bdc46b737370dcbd93c59cf1cd1934a30e55c61c1dc140e9,7283 + docker: enable: false repo: quay.io/benz0li/ghc-musl:9.14.1 diff --git a/stack-ghc-9.14.1.yaml.lock b/stack-ghc-9.14.1.yaml.lock index 683fe18dcf..741ab25b36 100644 --- a/stack-ghc-9.14.1.yaml.lock +++ b/stack-ghc-9.14.1.yaml.lock @@ -3,10 +3,87 @@ # For more information, please see the documentation at: # https://docs.haskellstack.org/en/stable/topics/lock_files -packages: [] +packages: +- completed: + hackage: Cabal-3.16.0.0@sha256:9972c2bd263168a20bd990962a68d4fd024f50c30a00519a6b942e8871d1bd67,14455 + pantry-tree: + sha256: ddc689c4070a034cacd73c39c1df2673ed16e0b38b5ca476fc6ef2aa87b6f40f + size: 12139 + original: + hackage: Cabal-3.16.0.0@sha256:9972c2bd263168a20bd990962a68d4fd024f50c30a00519a6b942e8871d1bd67,14455 +- completed: + hackage: Cabal-syntax-3.16.0.0@sha256:6a35036763557301876c5b7a448de4f1cb54fe1e223ff6c4c0c1fdd6df635a65,7509 + pantry-tree: + sha256: 4de976261238dd4045dd3addebf6a006d4aff3873ee680bac7af83dcbf068280 + size: 11238 + original: + hackage: Cabal-syntax-3.16.0.0@sha256:6a35036763557301876c5b7a448de4f1cb54fe1e223ff6c4c0c1fdd6df635a65,7509 +- completed: + hackage: crypton-x509-1.8.0@sha256:d4822ba8dcb19ee3233fc98152f5afda383ac952770a1d07f1d01168e9fcdbc2,2006 + pantry-tree: + sha256: 882a699e305fffcb77dd40bd40f959f062a8997a53560dca64462087aed3e4cd + size: 1132 + original: + hackage: crypton-x509-1.8.0@sha256:d4822ba8dcb19ee3233fc98152f5afda383ac952770a1d07f1d01168e9fcdbc2,2006 +- completed: + hackage: crypton-x509-store-1.8.0@sha256:075ba50a3daa0fdbb493481a665926e1ced2135c6b4ed56f97398aa855f0aecb,1674 + pantry-tree: + sha256: 2c7e00e593d399624264172cbd5e2fa55feaf8239cf33bee7e33bbc7509d0a2e + size: 458 + original: + hackage: crypton-x509-store-1.8.0@sha256:075ba50a3daa0fdbb493481a665926e1ced2135c6b4ed56f97398aa855f0aecb,1674 +- completed: + hackage: crypton-x509-system-1.8.0@sha256:76bab32c7d9cb3ea356a905f85829c70967fb6f9b4b890f00d67dc54130d45ca,1521 + pantry-tree: + sha256: 9ac33c993a82ac4da84804028c5398caec7aada7a83beeec3f28883fe470d68f + size: 512 + original: + hackage: crypton-x509-system-1.8.0@sha256:76bab32c7d9cb3ea356a905f85829c70967fb6f9b4b890f00d67dc54130d45ca,1521 +- completed: + hackage: crypton-x509-validation-1.8.0@sha256:63acb2df06f28c3ffdddaf6d9402105b9026796036aa10d7347ae4f7db51c36b,2018 + pantry-tree: + sha256: 64baf1be6e65ade9ad8eaef819c9cc4c0fcb7d3b968641dcf28a3f859fe87dc5 + size: 691 + original: + hackage: crypton-x509-validation-1.8.0@sha256:63acb2df06f28c3ffdddaf6d9402105b9026796036aa10d7347ae4f7db51c36b,2018 +- completed: + hackage: http-api-data-0.7@sha256:b8145755fced98db1ac67f4f98c8010cd5f82c121a82b65addea2556b5fbd6d5,3157 + pantry-tree: + sha256: 4e67cbe25b355b6af68aee79c36b0f3c78428dbdd1be4298f4afaf000f3bc9a9 + size: 819 + original: + hackage: http-api-data-0.7@sha256:b8145755fced98db1ac67f4f98c8010cd5f82c121a82b65addea2556b5fbd6d5,3157 +- completed: + hackage: hpack-0.39.5@sha256:c214f49ed3df75ce75201709927fa27e08f642023ed4b4ca8cc43604e5199ced,5263 + pantry-tree: + sha256: 75fe87db5a37bf3941e29e2273f530ee7b2932d64bf813b55151a889e97305ca + size: 3799 + original: + hackage: hpack-0.39.5@sha256:c214f49ed3df75ce75201709927fa27e08f642023ed4b4ca8cc43604e5199ced,5263 +- completed: + hackage: rio-prettyprint-0.1.9.0@sha256:f48afbfe28ed7be4d1a1bb96705669593dd5df12f28ed908516c6dfc4e0becbb,1375 + pantry-tree: + sha256: c840f1193718b7af6c004fc62a67919e223b56cc1658a168c8e490e53a632aa0 + size: 779 + original: + hackage: rio-prettyprint-0.1.9.0@sha256:f48afbfe28ed7be4d1a1bb96705669593dd5df12f28ed908516c6dfc4e0becbb,1375 +- completed: + hackage: tagged-0.8.10@sha256:e9b97c98e9827981d62f37c5febf9e6bbb67acec92b8bd41fd9f7ace5eb31d32,2201 + pantry-tree: + sha256: 5ba1ff7ad9a676b89a2a6ab00ac2100f30a21440ef8e04094614ab5b5f494b3f + size: 438 + original: + hackage: tagged-0.8.10@sha256:e9b97c98e9827981d62f37c5febf9e6bbb67acec92b8bd41fd9f7ace5eb31d32,2201 +- completed: + hackage: tls-2.2.2@sha256:95f5acd4ce76cbd6bdc46b737370dcbd93c59cf1cd1934a30e55c61c1dc140e9,7283 + pantry-tree: + sha256: 6ddac1e644efe75dbf62bbd35fa38897caca307d62bac538ae29b0c54bf6ff00 + size: 7056 + original: + hackage: tls-2.2.2@sha256:95f5acd4ce76cbd6bdc46b737370dcbd93c59cf1cd1934a30e55c61c1dc140e9,7283 snapshots: - completed: - sha256: 8dd2b298abf5214ce1cc339f1282b9d424d66c511d433f874c12a92989dc3007 - size: 715169 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2025/12/20.yaml - original: nightly-2025-12-20 + sha256: f4d90db84aefb7c9590dd224ebdabfd8304f81bbad4652a715ee8350c4b9d396 + size: 738802 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2026/4/17.yaml + original: nightly-2026-04-17 diff --git a/stack.cabal b/stack.cabal index fd26e2066e..6b0581354a 100644 --- a/stack.cabal +++ b/stack.cabal @@ -5,7 +5,7 @@ cabal-version: 2.2 -- see: https://github.com/sol/hpack name: stack -version: 3.9.4 +version: 3.12.0 synopsis: A program for developing Haskell projects description: Stack (the Haskell Tool Stack) is a program for developing Haskell projects. It is aimed at new and experienced users of Haskell and seeks to support them @@ -82,6 +82,7 @@ extra-source-files: doc/configure/environment_variables.md doc/configure/global_flags.md doc/configure/index.md + doc/configure/yaml/include.md doc/configure/yaml/index.md doc/configure/yaml/non-project.md doc/configure/yaml/project.md @@ -340,6 +341,7 @@ library Stack.Types.Component Stack.Types.ComponentUtils Stack.Types.Config + Stack.Types.ConfigExtra Stack.Types.Config.Exception Stack.Types.ConfigMonoid Stack.Types.ConfigSetOpts @@ -474,6 +476,7 @@ library , random , rio >=0.1.22.0 && (<0.1.23.0 || >0.1.23.0) , rio-prettyprint >=0.1.8.0 + , semaphore-compat , split , stm , tar >=0.6.2.0 @@ -509,6 +512,7 @@ library cpp-options: -DSTACK_DISABLE_STACK_UPLOAD=False if os(windows) other-modules: + Stack.Build.TestSuiteTimeout Stack.Constants.UsrLibDirs Stack.Docker.Handlers System.Posix.User @@ -517,6 +521,7 @@ library src/windows/ else other-modules: + Stack.Build.TestSuiteTimeout Stack.Constants.UsrLibDirs Stack.Docker.Handlers System.Uname @@ -597,6 +602,7 @@ executable stack , random , rio >=0.1.22.0 && (<0.1.23.0 || >0.1.23.0) , rio-prettyprint >=0.1.8.0 + , semaphore-compat , split , stack , stm @@ -702,6 +708,7 @@ executable stack-integration-test , random , rio >=0.1.22.0 && (<0.1.23.0 || >0.1.23.0) , rio-prettyprint >=0.1.8.0 + , semaphore-compat , split , stm , tar >=0.6.2.0 @@ -820,6 +827,7 @@ test-suite stack-unit-test , raw-strings-qq , rio >=0.1.22.0 && (<0.1.23.0 || >0.1.23.0) , rio-prettyprint >=0.1.8.0 + , semaphore-compat , split , stack , stm diff --git a/stack.yaml b/stack.yaml index e70fd9b25b..158c56cd66 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,15 +1,31 @@ -snapshot: lts-24.24 # GHC 9.10.3 +snapshot: lts-24.43 # GHC 9.10.3 extra-deps: -# lts-24.24 specifies Cabal-3.12.1.0 -- Cabal-3.16.0.0@sha256:9972c2bd263168a20bd990962a68d4fd024f50c30a00519a6b942e8871d1bd67,14455 -- Cabal-syntax-3.16.0.0@sha256:6a35036763557301876c5b7a448de4f1cb54fe1e223ff6c4c0c1fdd6df635a65,7509 -# lts-24.24 specifies hpack-0.38.3 -- hpack-0.39.1@sha256:d7378debd96e805760540e3640aeda3a1ebee1d000dac99726ed55c827c81a94,5229 -# lts-24.24 specifies pantry-0.10.1 +# lts-24.43 specifies Cabal-3.12.1.0 +- Cabal-3.16.1.0@sha256:39873317ab895194547c3fd72c91cdb97c800a49b2656920854747ee466627ca,14459 +- Cabal-syntax-3.16.1.0@sha256:17cf54d07d7aa65ea24ba4045912b8a8af065f10e429fd1811d43810b313c504,7778 +# lts-24.43 does not include crypton-asn1-* +- crypton-asn1-encoding-0.10.0@sha256:45494a1723a047a815d0d620481c1028dca28a4ea5cf2554868687da90753961,2497 +- crypton-asn1-parse-0.10.0@sha256:4a2cfc4980957d1a279ef69137ee5f665c247ccd8bb962812d5b071d543893fb,1359 +- crypton-asn1-types-0.4.1@sha256:02f3ec473011b3da92f7bf738bea19cadf88a6470b25a6cb5042216c7549c912,1326 +# lts-24.43 specifies crypton-x509-1.7.7 +- crypton-x509-1.8.0@sha256:d4822ba8dcb19ee3233fc98152f5afda383ac952770a1d07f1d01168e9fcdbc2,2006 +# lts-24.43 specifies crypton-x509-store-1.6.14 +- crypton-x509-store-1.8.0@sha256:075ba50a3daa0fdbb493481a665926e1ced2135c6b4ed56f97398aa855f0aecb,1674 +# lts-24.43 specifies crypton-x509-system-1.6.8 +- crypton-x509-system-1.8.0@sha256:76bab32c7d9cb3ea356a905f85829c70967fb6f9b4b890f00d67dc54130d45ca,1521 +# lts-24.43 specifies crypton-x509-validation-1.6.14 +- crypton-x509-validation-1.8.0@sha256:63acb2df06f28c3ffdddaf6d9402105b9026796036aa10d7347ae4f7db51c36b,2018 +# lts-24.43 specifies hpack-0.38.3 +- hpack-0.39.5@sha256:c214f49ed3df75ce75201709927fa27e08f642023ed4b4ca8cc43604e5199ced,5263 +# lts-24.43 specifies pantry-0.10.1 - pantry-0.11.2@sha256:bc14e75f512deb22e0d9d645e62eb63b319d1732bfed6509491601215ecbd307,7896 -# lts-24.24 specifies persistent-2.17.1.0 -- persistent-2.18.0.0@sha256:baa3e0959cf10bbd1da462efeb61d4f073d0cc924a149325494ba5ce29bc17a4,7096 +# lts-24.43 specifies persistent-2.17.1.0 +- persistent-2.18.1.0@sha256:6a111b26c3e710f1e080a7543cf93766c4cc53ac560dbaa0d4b7ddc98a2f7b1d,7096 +# lts-24.43 does not include time-hourglass +- time-hourglass-0.3.0@sha256:ee02356fe24919ec43ae17fc0007398c2fd0bbe822833b2d7a9c849537b90580,3114 +# lts-24.43 specifies tls-2.1.8 +- tls-2.2.2@sha256:95f5acd4ce76cbd6bdc46b737370dcbd93c59cf1cd1934a30e55c61c1dc140e9,7283 docker: enable: false diff --git a/stack.yaml.lock b/stack.yaml.lock index 02abb3fef1..bd75109783 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -5,26 +5,75 @@ packages: - completed: - hackage: Cabal-3.16.0.0@sha256:9972c2bd263168a20bd990962a68d4fd024f50c30a00519a6b942e8871d1bd67,14455 + hackage: Cabal-3.16.1.0@sha256:39873317ab895194547c3fd72c91cdb97c800a49b2656920854747ee466627ca,14459 pantry-tree: - sha256: ddc689c4070a034cacd73c39c1df2673ed16e0b38b5ca476fc6ef2aa87b6f40f + sha256: b6ac49163659ec305805fc0d2c0564c35fac7132f4c5be6689d0c80a6405ecf0 size: 12139 original: - hackage: Cabal-3.16.0.0@sha256:9972c2bd263168a20bd990962a68d4fd024f50c30a00519a6b942e8871d1bd67,14455 + hackage: Cabal-3.16.1.0@sha256:39873317ab895194547c3fd72c91cdb97c800a49b2656920854747ee466627ca,14459 - completed: - hackage: Cabal-syntax-3.16.0.0@sha256:6a35036763557301876c5b7a448de4f1cb54fe1e223ff6c4c0c1fdd6df635a65,7509 + hackage: Cabal-syntax-3.16.1.0@sha256:17cf54d07d7aa65ea24ba4045912b8a8af065f10e429fd1811d43810b313c504,7778 pantry-tree: - sha256: 4de976261238dd4045dd3addebf6a006d4aff3873ee680bac7af83dcbf068280 + sha256: 1db24d3ca877095a7c4f99fda3c58155a33d8041dfe9faa886420c43572330a3 size: 11238 original: - hackage: Cabal-syntax-3.16.0.0@sha256:6a35036763557301876c5b7a448de4f1cb54fe1e223ff6c4c0c1fdd6df635a65,7509 + hackage: Cabal-syntax-3.16.1.0@sha256:17cf54d07d7aa65ea24ba4045912b8a8af065f10e429fd1811d43810b313c504,7778 - completed: - hackage: hpack-0.39.1@sha256:d7378debd96e805760540e3640aeda3a1ebee1d000dac99726ed55c827c81a94,5229 + hackage: crypton-asn1-encoding-0.10.0@sha256:45494a1723a047a815d0d620481c1028dca28a4ea5cf2554868687da90753961,2497 pantry-tree: - sha256: 5f7ca06ce0556a87c8a38813bc7caf9725ba6ad6c0c05ab2c3dd002373973b2f + sha256: c2ff6c426e6910075a971ee2801d200c8dc0f88cfcb8619534097902e6e655a8 + size: 1011 + original: + hackage: crypton-asn1-encoding-0.10.0@sha256:45494a1723a047a815d0d620481c1028dca28a4ea5cf2554868687da90753961,2497 +- completed: + hackage: crypton-asn1-parse-0.10.0@sha256:4a2cfc4980957d1a279ef69137ee5f665c247ccd8bb962812d5b071d543893fb,1359 + pantry-tree: + sha256: c78bd2c09da1390c124cff07844ddb99778a8cff82df98c5d53b52adb04dfef9 + size: 326 + original: + hackage: crypton-asn1-parse-0.10.0@sha256:4a2cfc4980957d1a279ef69137ee5f665c247ccd8bb962812d5b071d543893fb,1359 +- completed: + hackage: crypton-asn1-types-0.4.1@sha256:02f3ec473011b3da92f7bf738bea19cadf88a6470b25a6cb5042216c7549c912,1326 + pantry-tree: + sha256: 03e810ce724980eacfd49ed816d769ae74769f3941d8cc3c9067de4a896eedf2 + size: 722 + original: + hackage: crypton-asn1-types-0.4.1@sha256:02f3ec473011b3da92f7bf738bea19cadf88a6470b25a6cb5042216c7549c912,1326 +- completed: + hackage: crypton-x509-1.8.0@sha256:d4822ba8dcb19ee3233fc98152f5afda383ac952770a1d07f1d01168e9fcdbc2,2006 + pantry-tree: + sha256: 882a699e305fffcb77dd40bd40f959f062a8997a53560dca64462087aed3e4cd + size: 1132 + original: + hackage: crypton-x509-1.8.0@sha256:d4822ba8dcb19ee3233fc98152f5afda383ac952770a1d07f1d01168e9fcdbc2,2006 +- completed: + hackage: crypton-x509-store-1.8.0@sha256:075ba50a3daa0fdbb493481a665926e1ced2135c6b4ed56f97398aa855f0aecb,1674 + pantry-tree: + sha256: 2c7e00e593d399624264172cbd5e2fa55feaf8239cf33bee7e33bbc7509d0a2e + size: 458 + original: + hackage: crypton-x509-store-1.8.0@sha256:075ba50a3daa0fdbb493481a665926e1ced2135c6b4ed56f97398aa855f0aecb,1674 +- completed: + hackage: crypton-x509-system-1.8.0@sha256:76bab32c7d9cb3ea356a905f85829c70967fb6f9b4b890f00d67dc54130d45ca,1521 + pantry-tree: + sha256: 9ac33c993a82ac4da84804028c5398caec7aada7a83beeec3f28883fe470d68f + size: 512 + original: + hackage: crypton-x509-system-1.8.0@sha256:76bab32c7d9cb3ea356a905f85829c70967fb6f9b4b890f00d67dc54130d45ca,1521 +- completed: + hackage: crypton-x509-validation-1.8.0@sha256:63acb2df06f28c3ffdddaf6d9402105b9026796036aa10d7347ae4f7db51c36b,2018 + pantry-tree: + sha256: 64baf1be6e65ade9ad8eaef819c9cc4c0fcb7d3b968641dcf28a3f859fe87dc5 + size: 691 + original: + hackage: crypton-x509-validation-1.8.0@sha256:63acb2df06f28c3ffdddaf6d9402105b9026796036aa10d7347ae4f7db51c36b,2018 +- completed: + hackage: hpack-0.39.5@sha256:c214f49ed3df75ce75201709927fa27e08f642023ed4b4ca8cc43604e5199ced,5263 + pantry-tree: + sha256: 75fe87db5a37bf3941e29e2273f530ee7b2932d64bf813b55151a889e97305ca size: 3799 original: - hackage: hpack-0.39.1@sha256:d7378debd96e805760540e3640aeda3a1ebee1d000dac99726ed55c827c81a94,5229 + hackage: hpack-0.39.5@sha256:c214f49ed3df75ce75201709927fa27e08f642023ed4b4ca8cc43604e5199ced,5263 - completed: hackage: pantry-0.11.2@sha256:bc14e75f512deb22e0d9d645e62eb63b319d1732bfed6509491601215ecbd307,7896 pantry-tree: @@ -33,15 +82,29 @@ packages: original: hackage: pantry-0.11.2@sha256:bc14e75f512deb22e0d9d645e62eb63b319d1732bfed6509491601215ecbd307,7896 - completed: - hackage: persistent-2.18.0.0@sha256:baa3e0959cf10bbd1da462efeb61d4f073d0cc924a149325494ba5ce29bc17a4,7096 + hackage: persistent-2.18.1.0@sha256:6a111b26c3e710f1e080a7543cf93766c4cc53ac560dbaa0d4b7ddc98a2f7b1d,7096 pantry-tree: - sha256: 41480a227b9c2ff72b29a8f6a8fddb4888bc656be052ad58f2fef508378089f3 + sha256: bddc723b5069ed2dbf2eee6e01f8eaac00e324eee3520c32ced3044072372172 size: 7184 original: - hackage: persistent-2.18.0.0@sha256:baa3e0959cf10bbd1da462efeb61d4f073d0cc924a149325494ba5ce29bc17a4,7096 + hackage: persistent-2.18.1.0@sha256:6a111b26c3e710f1e080a7543cf93766c4cc53ac560dbaa0d4b7ddc98a2f7b1d,7096 +- completed: + hackage: time-hourglass-0.3.0@sha256:ee02356fe24919ec43ae17fc0007398c2fd0bbe822833b2d7a9c849537b90580,3114 + pantry-tree: + sha256: 7d6acc1a643fe8692d1858c96cc04a417b8da53e53b6bdba6fe0ce6aa6aba774 + size: 1594 + original: + hackage: time-hourglass-0.3.0@sha256:ee02356fe24919ec43ae17fc0007398c2fd0bbe822833b2d7a9c849537b90580,3114 +- completed: + hackage: tls-2.2.2@sha256:95f5acd4ce76cbd6bdc46b737370dcbd93c59cf1cd1934a30e55c61c1dc140e9,7283 + pantry-tree: + sha256: 6ddac1e644efe75dbf62bbd35fa38897caca307d62bac538ae29b0c54bf6ff00 + size: 7056 + original: + hackage: tls-2.2.2@sha256:95f5acd4ce76cbd6bdc46b737370dcbd93c59cf1cd1934a30e55c61c1dc140e9,7283 snapshots: - completed: - sha256: 4bc8e0388916c4000645c068dff642482d6ed1b68b747c2d4d444857979963e0 - size: 726334 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/24/24.yaml - original: lts-24.24 + sha256: 3c412a7c13dba6d3d808455a458e0776c58b6cf99b8a7961a2f5e55589d6f1d6 + size: 729011 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/24/43.yaml + original: lts-24.43 diff --git a/tests/integration/README.md b/tests/integration/README.md index 42b430d9a5..e95ef6e0fe 100644 --- a/tests/integration/README.md +++ b/tests/integration/README.md @@ -1,24 +1,98 @@ # Stack Integration Tests -This directory contains a bunch of integration tests for Stack. Each -directory inside the `tests` subdirectory represents a single -test. Each of those directories has: +This directory, `tests/integration`, contains integration tests for Stack. Each +directory inside its `tests` subdirectory represents a single test. Each of +those directories has: -* A `Main.hs` file, which provides the script to be run -* A `files `directory, providing the working directory the script will be run - from. (If you have a test that does not require any specific working +* a `Main.hs` file, which provides the script to be run; and +* a `files `directory, providing the working directory the script will be run + from. (If you have a test that does not require any specific working directory, there may be no `files` directory.) -It would be great to expand this file into a full tutorial, but for now, the -easiest way to get started with writing an integration test is to copy an -existing example. +The easiest way to create a new integration test is to use existing examples as +a foundation. + +## Form + +Most integration tests have a similar form, as follows. + +An initial comment in the `Main.hs` file explains what the integration test is +testing. If the test is prompted by a GitHub issue, the commment includes a URL +to that issue. Tests prompted by a GitHub issue are usually named after that +issue. + +Packages in tests are usually described by `package.yaml` files. The associated +Cabal file is usually not checked in. Consequently, a `.gitignore` file lists +the Cabal file that is to be ignored. + +The most complicated 'generic' test package has the description below. The +`spec-version: 0.36.0` avoids Hpack's legacy syntax and the package version is +`0.0.0` by default. + +A main (unnamed) library module is usually named `Lib.hs` in directory `src`. A +private named sublibrary (an internal library) is usually named `Internal.hs` in +directory `int`. + +~~~yaml +# package.yaml +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src + dependencies: + - myPackage:internal + +internal-libraries: + internal: + source-dirs: int + sublib: + visibility: public + source-dirs: sub + dependencies: + - myPackage:internal + +executables: + myExe: + source-dirs: app + main: Main.hs + dependencies: + - myPackage + - myPackage:{internal, sublib} + +tests: + test: + source-dirs: test + main: Main.hs + dependencies: + - myPackage + - myPackage:{internal, sublib} + +benchmarks: + bench: + source-dirs: bench + main: Main.hs + dependencies: + - myPackage + - myPackage:{internal, sublib} +~~~ + +Usually, a test package does not need a `Setup.hs` file. + +Many tests require only a compiler version snapshot. + +If an extra-dep is required, `ansi-missiles-0.3` is often used. ## Running One simple way to run a single test is: * Change into the `files` directory -* Run the command `stack runghc -- -i../../../lib ../Main.hs` +* Run the command `stack runghc -- -i"../../../lib" ../Main.hs` A more thorough way to run the tests is with command: diff --git a/tests/integration/lib/StackTest.hs b/tests/integration/lib/StackTest.hs index d6987c5d2c..52e0e6e75f 100644 --- a/tests/integration/lib/StackTest.hs +++ b/tests/integration/lib/StackTest.hs @@ -278,7 +278,7 @@ isMacOSX = os == "darwin" -- the main @stack.yaml@. -- defaultSnapshotArg :: String -defaultSnapshotArg = "--snapshot=lts-24.24" +defaultSnapshotArg = "--snapshot=lts-24.43" -- | Remove a file and ignore any warnings about missing files. removeFileIgnore :: HasCallStack => FilePath -> IO () diff --git a/tests/integration/tests/111-custom-snapshot/Main.hs b/tests/integration/tests/111-custom-snapshot/Main.hs index e61b083aa4..b6498ef21a 100644 --- a/tests/integration/tests/111-custom-snapshot/Main.hs +++ b/tests/integration/tests/111-custom-snapshot/Main.hs @@ -1,4 +1,9 @@ -import StackTest +-- Stack should build a package when a custom snapshot is specified in the +-- project-level configuration file. +-- +-- See: https://github.com/commercialhaskell/stack/issues/111 + +import StackTest main :: IO () main = stack ["build"] diff --git a/tests/integration/tests/111-custom-snapshot/files/.gitignore b/tests/integration/tests/111-custom-snapshot/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/111-custom-snapshot/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/111-custom-snapshot/files/files.cabal b/tests/integration/tests/111-custom-snapshot/files/files.cabal deleted file mode 100644 index 66525ce056..0000000000 --- a/tests/integration/tests/111-custom-snapshot/files/files.cabal +++ /dev/null @@ -1,10 +0,0 @@ -name: files -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5, mtl - default-language: Haskell2010 diff --git a/tests/integration/tests/111-custom-snapshot/files/my-snapshot.yaml b/tests/integration/tests/111-custom-snapshot/files/my-snapshot.yaml index 8d13ffd0dc..9f6da9150c 100644 --- a/tests/integration/tests/111-custom-snapshot/files/my-snapshot.yaml +++ b/tests/integration/tests/111-custom-snapshot/files/my-snapshot.yaml @@ -1,4 +1,5 @@ -compiler: ghc-9.10.3 name: my-snapshot + +compiler: ghc-9.10.3 packages: -- mtl-2.3.1 +- acme-missiles-0.3 diff --git a/tests/integration/tests/111-custom-snapshot/files/package.yaml b/tests/integration/tests/111-custom-snapshot/files/package.yaml new file mode 100644 index 0000000000..c80a013e52 --- /dev/null +++ b/tests/integration/tests/111-custom-snapshot/files/package.yaml @@ -0,0 +1,10 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base +- acme-missiles + +library: + source-dirs: src diff --git a/tests/integration/tests/111-custom-snapshot/files/src/Lib.hs b/tests/integration/tests/111-custom-snapshot/files/src/Lib.hs index 4844564d1b..3635ec4a52 100644 --- a/tests/integration/tests/111-custom-snapshot/files/src/Lib.hs +++ b/tests/integration/tests/111-custom-snapshot/files/src/Lib.hs @@ -1,8 +1,5 @@ module Lib - ( someFunc - ) where + ( launchMissiles + ) where -import Control.Monad.Reader () - -someFunc :: IO () -someFunc = putStrLn "someFunc" +import Acme.Missiles ( launchMissiles ) diff --git a/tests/integration/tests/1198-multiple-exes-with-same-name/Main.hs b/tests/integration/tests/1198-multiple-exes-with-same-name/Main.hs index de8bfef1b9..1dcedba320 100644 --- a/tests/integration/tests/1198-multiple-exes-with-same-name/Main.hs +++ b/tests/integration/tests/1198-multiple-exes-with-same-name/Main.hs @@ -1,27 +1,28 @@ -import Control.Monad (unless,when) -import Data.List (isInfixOf) -import StackTest +-- Stack warns when more than one project package has an executable component of +-- the same name. +-- +-- See: https://github.com/commercialhaskell/stack/issues/1198 + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest main :: IO () main = do - stack [defaultSnapshotArg, "clean"] - stack [defaultSnapshotArg, "init", "--force"] - stackCheckStderr - ["build", "also-has-exe-foo", "has-exe-foo"] - (expectMessage buildMessage1) - stackCheckStderr - ["build", "has-exe-foo-too"] - (expectMessage buildMessage2) + stackCheckStderr + ["build", "myPackageA", "myPackageB"] + (expectMessage buildMessage1) + stackCheckStderr + ["build", "myPackageC"] + (expectMessage buildMessage2) expectMessage :: String -> String -> IO () expectMessage msg stderr = - unless (msg `isInfixOf` stderr) - (error $ "Expected a warning: \n" ++ show msg) + unless (msg `isInfixOf` stderr) + (error $ "Expected a warning: \n" ++ show msg) -- Use short message fragment because prettyWarn formatting and colour -buildMessage1 = - "Building several executables with the same name:" +buildMessage1 = "Building several executables with the same name:" -- Use short message fragment because prettyWarn formatting and colour -buildMessage2 = - "Other executables with the same name" +buildMessage2 = "Other executables with the same name" diff --git a/tests/integration/tests/1198-multiple-exes-with-same-name/files/.gitignore b/tests/integration/tests/1198-multiple-exes-with-same-name/files/.gitignore index 684dbffa96..c4ea0f5ab0 100644 --- a/tests/integration/tests/1198-multiple-exes-with-same-name/files/.gitignore +++ b/tests/integration/tests/1198-multiple-exes-with-same-name/files/.gitignore @@ -1 +1,3 @@ -stack.yaml +myPackageA.cabal +myPackageB.cabal +myPackageC.cabal diff --git a/tests/integration/tests/1198-multiple-exes-with-same-name/files/also-has-exe-foo/also-has-exe-foo.cabal b/tests/integration/tests/1198-multiple-exes-with-same-name/files/also-has-exe-foo/also-has-exe-foo.cabal deleted file mode 100644 index 97d9c1fd90..0000000000 --- a/tests/integration/tests/1198-multiple-exes-with-same-name/files/also-has-exe-foo/also-has-exe-foo.cabal +++ /dev/null @@ -1,11 +0,0 @@ -name: also-has-exe-foo -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -executable foo - hs-source-dirs: app - main-is: Main.hs - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: base - default-language: Haskell2010 diff --git a/tests/integration/tests/1198-multiple-exes-with-same-name/files/also-has-exe-foo/app/Main.hs b/tests/integration/tests/1198-multiple-exes-with-same-name/files/also-has-exe-foo/app/Main.hs deleted file mode 100644 index ed0f47faf7..0000000000 --- a/tests/integration/tests/1198-multiple-exes-with-same-name/files/also-has-exe-foo/app/Main.hs +++ /dev/null @@ -1,4 +0,0 @@ -module Main where - -main :: IO () -main = putStrLn "This is foo from also-has-exe-foo" diff --git a/tests/integration/tests/1198-multiple-exes-with-same-name/files/app/Main.hs b/tests/integration/tests/1198-multiple-exes-with-same-name/files/app/Main.hs deleted file mode 100644 index d62e2f2117..0000000000 --- a/tests/integration/tests/1198-multiple-exes-with-same-name/files/app/Main.hs +++ /dev/null @@ -1,4 +0,0 @@ -module Main where - -main :: IO () -main = putStrLn "This is foo from has-exe-foo" diff --git a/tests/integration/tests/1198-multiple-exes-with-same-name/files/has-exe-foo-too/app/Main.hs b/tests/integration/tests/1198-multiple-exes-with-same-name/files/has-exe-foo-too/app/Main.hs deleted file mode 100644 index 90ac2ae946..0000000000 --- a/tests/integration/tests/1198-multiple-exes-with-same-name/files/has-exe-foo-too/app/Main.hs +++ /dev/null @@ -1,4 +0,0 @@ -module Main where - -main :: IO () -main = putStrLn "This is foo from has-exe-foo-too" diff --git a/tests/integration/tests/1198-multiple-exes-with-same-name/files/has-exe-foo-too/has-exe-foo-too.cabal b/tests/integration/tests/1198-multiple-exes-with-same-name/files/has-exe-foo-too/has-exe-foo-too.cabal deleted file mode 100644 index 05db41b4b7..0000000000 --- a/tests/integration/tests/1198-multiple-exes-with-same-name/files/has-exe-foo-too/has-exe-foo-too.cabal +++ /dev/null @@ -1,11 +0,0 @@ -name: has-exe-foo-too -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -executable foo - hs-source-dirs: app - main-is: Main.hs - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: base - default-language: Haskell2010 diff --git a/tests/integration/tests/1198-multiple-exes-with-same-name/files/has-exe-foo.cabal b/tests/integration/tests/1198-multiple-exes-with-same-name/files/has-exe-foo.cabal deleted file mode 100644 index 19b222b3a1..0000000000 --- a/tests/integration/tests/1198-multiple-exes-with-same-name/files/has-exe-foo.cabal +++ /dev/null @@ -1,11 +0,0 @@ -name: has-exe-foo -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -executable foo - hs-source-dirs: app - main-is: Main.hs - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: base - default-language: Haskell2010 diff --git a/tests/integration/tests/1659-skip-component/files/app/MainFail.hs b/tests/integration/tests/1198-multiple-exes-with-same-name/files/myPackageA/app/Main.hs similarity index 100% rename from tests/integration/tests/1659-skip-component/files/app/MainFail.hs rename to tests/integration/tests/1198-multiple-exes-with-same-name/files/myPackageA/app/Main.hs diff --git a/tests/integration/tests/1198-multiple-exes-with-same-name/files/myPackageA/package.yaml b/tests/integration/tests/1198-multiple-exes-with-same-name/files/myPackageA/package.yaml new file mode 100644 index 0000000000..7a3a634c04 --- /dev/null +++ b/tests/integration/tests/1198-multiple-exes-with-same-name/files/myPackageA/package.yaml @@ -0,0 +1,11 @@ +spec-version: 0.36.0 + +name: myPackageA + +dependencies: +- base + +executables: + myExe: + source-dirs: app + main: Main.hs diff --git a/tests/integration/tests/1198-multiple-exes-with-same-name/files/myPackageB/app/Main.hs b/tests/integration/tests/1198-multiple-exes-with-same-name/files/myPackageB/app/Main.hs new file mode 100644 index 0000000000..89ad4b3e08 --- /dev/null +++ b/tests/integration/tests/1198-multiple-exes-with-same-name/files/myPackageB/app/Main.hs @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = pure () diff --git a/tests/integration/tests/1198-multiple-exes-with-same-name/files/myPackageB/package.yaml b/tests/integration/tests/1198-multiple-exes-with-same-name/files/myPackageB/package.yaml new file mode 100644 index 0000000000..9ef40bf495 --- /dev/null +++ b/tests/integration/tests/1198-multiple-exes-with-same-name/files/myPackageB/package.yaml @@ -0,0 +1,11 @@ +spec-version: 0.36.0 + +name: myPackageB + +dependencies: +- base + +executables: + myExe: + source-dirs: app + main: Main.hs diff --git a/tests/integration/tests/1198-multiple-exes-with-same-name/files/myPackageC/app/Main.hs b/tests/integration/tests/1198-multiple-exes-with-same-name/files/myPackageC/app/Main.hs new file mode 100644 index 0000000000..89ad4b3e08 --- /dev/null +++ b/tests/integration/tests/1198-multiple-exes-with-same-name/files/myPackageC/app/Main.hs @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = pure () diff --git a/tests/integration/tests/1198-multiple-exes-with-same-name/files/myPackageC/package.yaml b/tests/integration/tests/1198-multiple-exes-with-same-name/files/myPackageC/package.yaml new file mode 100644 index 0000000000..add5c45908 --- /dev/null +++ b/tests/integration/tests/1198-multiple-exes-with-same-name/files/myPackageC/package.yaml @@ -0,0 +1,11 @@ +spec-version: 0.36.0 + +name: myPackageC + +dependencies: +- base + +executables: + myExe: + source-dirs: app + main: Main.hs diff --git a/tests/integration/tests/1198-multiple-exes-with-same-name/files/stack.yaml b/tests/integration/tests/1198-multiple-exes-with-same-name/files/stack.yaml new file mode 100644 index 0000000000..14a33de5df --- /dev/null +++ b/tests/integration/tests/1198-multiple-exes-with-same-name/files/stack.yaml @@ -0,0 +1,6 @@ +snapshot: ghc-9.10.3 + +packages: +- myPackageA +- myPackageB +- myPackageC diff --git a/tests/integration/tests/1265-extensible-snapshots/Main.hs b/tests/integration/tests/1265-extensible-snapshots/Main.hs index 506ddbd941..a44bcc205b 100644 --- a/tests/integration/tests/1265-extensible-snapshots/Main.hs +++ b/tests/integration/tests/1265-extensible-snapshots/Main.hs @@ -1,10 +1,28 @@ +-- Stack supports extensible snapshots. +-- +-- See: https://github.com/commercialhaskell/stack/issues/1198 + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) import StackTest main :: IO () main = do - stack ["build", "async"] - stackErr ["build", "zlib-bindings"] - stack ["build", "--stack-yaml", "stack-modify-lts.yaml", "async"] - stack ["build", "--stack-yaml", "stack-local-snapshot.yaml", "async"] - stack ["build", "--stack-yaml", "stack-remote-snapshot.yaml", "acme-missiles"] - stackErr ["build", "--stack-yaml", "stack-modify-lts.yaml", "zlib-bindings"] + stack ["build", "myPackageA", "--dry-run"] + -- Should fail because myPackageB depends on acme-box, which has been dropped: + stackErrStderr ["build", "myPackageB", "--dry-run"] (expectMessage acmeBoxNeeded) + stack ["build", "--stack-yaml", "stack-modify-lts.yaml", "myPackageA", "--dry-run"] + stack ["build", "--stack-yaml", "stack-local-snapshot.yaml", "myPackageC", "--dry-run"] + stack ["build", "--stack-yaml", "stack-remote-snapshot.yaml", "myPackageA", "--dry-run"] + -- Should fail because myPackageD depends on zlib, which has been dropped: + stackErrStderr + ["build", "--stack-yaml", "stack-modify-lts.yaml", "myPackageD", "--dry-run"] + (expectMessage zlibNeeded) + where + acmeBoxNeeded = "acme-box needed, but no version" + zlibNeeded = "zlib needed, but no version" + +expectMessage :: String -> String -> IO () +expectMessage msg stderr = do + unless (words msg `isInfixOf` words stderr) + (error $ "Expected a warning: \n" ++ show msg) diff --git a/tests/integration/tests/1265-extensible-snapshots/files/.gitignore b/tests/integration/tests/1265-extensible-snapshots/files/.gitignore new file mode 100644 index 0000000000..5087095541 --- /dev/null +++ b/tests/integration/tests/1265-extensible-snapshots/files/.gitignore @@ -0,0 +1,4 @@ +myPackageA.cabal +myPackageB.cabal +myPackageC.cabal +myPackageD.cabal diff --git a/tests/integration/tests/1265-extensible-snapshots/files/myPackageA/package.yaml b/tests/integration/tests/1265-extensible-snapshots/files/myPackageA/package.yaml new file mode 100644 index 0000000000..ec081f26c0 --- /dev/null +++ b/tests/integration/tests/1265-extensible-snapshots/files/myPackageA/package.yaml @@ -0,0 +1,10 @@ +spec-version: 0.36.0 + +name: myPackageA + +dependencies: +- base +- acme-missiles + +library: + source-dirs: src diff --git a/tests/integration/tests/1265-extensible-snapshots/files/myPackageA/src/Lib.hs b/tests/integration/tests/1265-extensible-snapshots/files/myPackageA/src/Lib.hs new file mode 100644 index 0000000000..889210c825 --- /dev/null +++ b/tests/integration/tests/1265-extensible-snapshots/files/myPackageA/src/Lib.hs @@ -0,0 +1,5 @@ +module Lib + ( launchMissiles + ) where + +import Acme.Missiles ( launchMissiles ) diff --git a/tests/integration/tests/1265-extensible-snapshots/files/myPackageB/package.yaml b/tests/integration/tests/1265-extensible-snapshots/files/myPackageB/package.yaml new file mode 100644 index 0000000000..0ef22e6550 --- /dev/null +++ b/tests/integration/tests/1265-extensible-snapshots/files/myPackageB/package.yaml @@ -0,0 +1,10 @@ +spec-version: 0.36.0 + +name: myPackageB + +dependencies: +- base +- acme-box + +library: + source-dirs: src diff --git a/tests/integration/tests/1265-extensible-snapshots/files/myPackageB/src/Lib.hs b/tests/integration/tests/1265-extensible-snapshots/files/myPackageB/src/Lib.hs new file mode 100644 index 0000000000..af8de0c696 --- /dev/null +++ b/tests/integration/tests/1265-extensible-snapshots/files/myPackageB/src/Lib.hs @@ -0,0 +1,5 @@ +module Lib + ( box + ) where + +import Acme.Box ( box ) diff --git a/tests/integration/tests/1265-extensible-snapshots/files/myPackageC/package.yaml b/tests/integration/tests/1265-extensible-snapshots/files/myPackageC/package.yaml new file mode 100644 index 0000000000..17a516d2c4 --- /dev/null +++ b/tests/integration/tests/1265-extensible-snapshots/files/myPackageC/package.yaml @@ -0,0 +1,10 @@ +spec-version: 0.36.0 + +name: myPackageC + +dependencies: +- base +- myPackage + +library: + source-dirs: src diff --git a/tests/integration/tests/1265-extensible-snapshots/files/myPackageC/src/Lib.hs b/tests/integration/tests/1265-extensible-snapshots/files/myPackageC/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/1265-extensible-snapshots/files/myPackageC/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/1265-extensible-snapshots/files/myPackageD/package.yaml b/tests/integration/tests/1265-extensible-snapshots/files/myPackageD/package.yaml new file mode 100644 index 0000000000..766e1dd84a --- /dev/null +++ b/tests/integration/tests/1265-extensible-snapshots/files/myPackageD/package.yaml @@ -0,0 +1,10 @@ +spec-version: 0.36.0 + +name: myPackageD + +dependencies: +- base +- zlib + +library: + source-dirs: src diff --git a/tests/integration/tests/1265-extensible-snapshots/files/myPackageD/src/Lib.hs b/tests/integration/tests/1265-extensible-snapshots/files/myPackageD/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/1265-extensible-snapshots/files/myPackageD/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/1265-extensible-snapshots/files/snapshot-2.yaml b/tests/integration/tests/1265-extensible-snapshots/files/snapshot-2.yaml index 58134d368e..67a1547355 100644 --- a/tests/integration/tests/1265-extensible-snapshots/files/snapshot-2.yaml +++ b/tests/integration/tests/1265-extensible-snapshots/files/snapshot-2.yaml @@ -1,11 +1,7 @@ -snapshot: ghc-9.10.3 name: test-snapshot-2 + +snapshot: ghc-9.10.3 + packages: -- async-2.2.5 -- hashable-1.5.0.0 -- os-string-2.0.7 -- stm-2.5.3.1 -- zlib-0.7.1.0@rev:2 -# FIXME: test these here -flags: {} -ghc-options: {} +- acme-missiles-0.3 +- acme-box-0.0.0.0 diff --git a/tests/integration/tests/1265-extensible-snapshots/files/snapshot-modify-lts.yaml b/tests/integration/tests/1265-extensible-snapshots/files/snapshot-modify-lts.yaml index d2ecc1f55b..626cbb71a6 100644 --- a/tests/integration/tests/1265-extensible-snapshots/files/snapshot-modify-lts.yaml +++ b/tests/integration/tests/1265-extensible-snapshots/files/snapshot-modify-lts.yaml @@ -1,4 +1,9 @@ -snapshot: lts-24.24 name: snapshot-modify-lts + +snapshot: lts-24.43 + +packages: +- acme-missiles-0.3 + drop-packages: - zlib diff --git a/tests/integration/tests/1265-extensible-snapshots/files/snapshot.yaml b/tests/integration/tests/1265-extensible-snapshots/files/snapshot.yaml index a95f8e7b38..bd797eccb9 100644 --- a/tests/integration/tests/1265-extensible-snapshots/files/snapshot.yaml +++ b/tests/integration/tests/1265-extensible-snapshots/files/snapshot.yaml @@ -1,6 +1,6 @@ -snapshot: snapshot-2.yaml name: test-snapshot -packages: -- microlens-0.4.14.0 + +snapshot: snapshot-2.yaml + drop-packages: -- zlib +- acme-box diff --git a/tests/integration/tests/1265-extensible-snapshots/files/snapshots/local-snapshot.yaml b/tests/integration/tests/1265-extensible-snapshots/files/snapshots/local-snapshot.yaml index b51fac3cde..feb04c6e76 100644 --- a/tests/integration/tests/1265-extensible-snapshots/files/snapshots/local-snapshot.yaml +++ b/tests/integration/tests/1265-extensible-snapshots/files/snapshots/local-snapshot.yaml @@ -1,4 +1,6 @@ -snapshot: lts-24.24 name: local-snapshot + +snapshot: ghc-9.10.3 + packages: -- archive: package-0.1.2.3.tar.gz +- archive: myPackage-0.1.0.0.tar.gz diff --git a/tests/integration/tests/1265-extensible-snapshots/files/snapshots/myPackage-0.1.0.0.tar.gz b/tests/integration/tests/1265-extensible-snapshots/files/snapshots/myPackage-0.1.0.0.tar.gz new file mode 100644 index 0000000000..ce1a9e2a00 Binary files /dev/null and b/tests/integration/tests/1265-extensible-snapshots/files/snapshots/myPackage-0.1.0.0.tar.gz differ diff --git a/tests/integration/tests/1265-extensible-snapshots/files/snapshots/package-0.1.2.3.tar.gz b/tests/integration/tests/1265-extensible-snapshots/files/snapshots/package-0.1.2.3.tar.gz deleted file mode 100644 index a28a03742b..0000000000 Binary files a/tests/integration/tests/1265-extensible-snapshots/files/snapshots/package-0.1.2.3.tar.gz and /dev/null differ diff --git a/tests/integration/tests/1265-extensible-snapshots/files/snapshots/remote-snapshot.yaml b/tests/integration/tests/1265-extensible-snapshots/files/snapshots/remote-snapshot.yaml index 1eae88d171..d93db09f54 100644 --- a/tests/integration/tests/1265-extensible-snapshots/files/snapshots/remote-snapshot.yaml +++ b/tests/integration/tests/1265-extensible-snapshots/files/snapshots/remote-snapshot.yaml @@ -1,4 +1,4 @@ -snapshot: lts-24.24 name: remote-snapshot +snapshot: ghc-9.10.3 packages: - archive: https://s3.amazonaws.com/hackage.fpcomplete.com/package/acme-missiles-0.3.tar.gz diff --git a/tests/integration/tests/1265-extensible-snapshots/files/stack-local-snapshot.yaml b/tests/integration/tests/1265-extensible-snapshots/files/stack-local-snapshot.yaml index 59e7c5b620..85d9a380b5 100644 --- a/tests/integration/tests/1265-extensible-snapshots/files/stack-local-snapshot.yaml +++ b/tests/integration/tests/1265-extensible-snapshots/files/stack-local-snapshot.yaml @@ -1,3 +1,4 @@ snapshot: snapshots/local-snapshot.yaml -packages: [] -allow-newer: true + +packages: +- myPackageC diff --git a/tests/integration/tests/1265-extensible-snapshots/files/stack-modify-lts.yaml b/tests/integration/tests/1265-extensible-snapshots/files/stack-modify-lts.yaml index 144a246a17..cc8cca4759 100644 --- a/tests/integration/tests/1265-extensible-snapshots/files/stack-modify-lts.yaml +++ b/tests/integration/tests/1265-extensible-snapshots/files/stack-modify-lts.yaml @@ -1,2 +1,5 @@ snapshot: snapshot-modify-lts.yaml -packages: [] + +packages: +- myPackageA +- myPackageD diff --git a/tests/integration/tests/1265-extensible-snapshots/files/stack-remote-snapshot.yaml b/tests/integration/tests/1265-extensible-snapshots/files/stack-remote-snapshot.yaml index 0d4edfed64..faa16c1912 100644 --- a/tests/integration/tests/1265-extensible-snapshots/files/stack-remote-snapshot.yaml +++ b/tests/integration/tests/1265-extensible-snapshots/files/stack-remote-snapshot.yaml @@ -1,3 +1,4 @@ snapshot: snapshots/remote-snapshot.yaml -packages: [] -allow-newer: true + +packages: +- myPackageA diff --git a/tests/integration/tests/1265-extensible-snapshots/files/stack.yaml b/tests/integration/tests/1265-extensible-snapshots/files/stack.yaml index da6ffb5007..105c1ae1d7 100644 --- a/tests/integration/tests/1265-extensible-snapshots/files/stack.yaml +++ b/tests/integration/tests/1265-extensible-snapshots/files/stack.yaml @@ -1,3 +1,5 @@ snapshot: snapshot.yaml -packages: [] -allow-newer: true + +packages: +- myPackageA +- myPackageB diff --git a/tests/integration/tests/1336-1337-new-package-names/.gitignore b/tests/integration/tests/1336-1337-new-package-names/.gitignore index 027271b9b2..ed73754e8e 100644 --- a/tests/integration/tests/1336-1337-new-package-names/.gitignore +++ b/tests/integration/tests/1336-1337-new-package-names/.gitignore @@ -1 +1,7 @@ -files +1b3d-a2c4/ +1234-abcd/ +abcd-1234/ +1234-ば日本-4本/ +ば日本-4本/ +אבהץש/ +ΔΘΩϬ/ diff --git a/tests/integration/tests/1336-1337-new-package-names/Main.hs b/tests/integration/tests/1336-1337-new-package-names/Main.hs index 56722c43f6..83d15d9d0d 100644 --- a/tests/integration/tests/1336-1337-new-package-names/Main.hs +++ b/tests/integration/tests/1336-1337-new-package-names/Main.hs @@ -1,28 +1,29 @@ -import StackTest -import Control.Monad -import System.Directory -import System.FilePath +-- Stack's new command accepts project names that are valid Cabal package names +-- and rejects those that are not without creating a project directory. +-- +-- See: https://github.com/commercialhaskell/stack/issues/1336 +-- https://github.com/commercialhaskell/stack/issues/1337 + +import Control.Monad ( unless, when ) +import StackTest +import System.Directory + ( doesDirectoryExist, removeDirectoryRecursive ) -{-# ANN module "HLint: ignore Use unless" #-} main :: IO () -main = - if isWindows - then logInfo "Disabled on Windows (see https://github.com/commercialhaskell/stack/issues/1337#issuecomment-166118678)" - else when isLinux $ do - safeNew "1234a-4b-b4-abc-12b34" - doesExist "./1234a-4b-b4-abc-12b34/stack.yaml" - stackErr ["new", "1234-abc"] - doesNotExist "./1234-abc/stack.yaml" - doesNotExist "./1234-abc" - stackErr ["new", "1-abc"] - stackErr ["new", "44444444444444"] - stackErr ["new", "abc-1"] - stackErr ["new", "444-ば日本-4本"] - unless isMacOSX $ safeNew "ば日本-4本" - safeNew "אבהץש" - safeNew "ΔΘΩϬ" - doesExist "./ΔΘΩϬ/stack.yaml" - doesExist "./ΔΘΩϬ/ΔΘΩϬ.cabal" +main = do + safeNew "1b3d-a2c4" + doesExist "./1b3d-a2c4/stack.yaml" + doesExist "./1b3d-a2c4/1b3d-a2c4.cabal" + stackErr ["new", "1234-abcd"] + doesNotExist "./1234-abcd" + stackErr ["new", "abcd-1234"] + -- The GitHub windows-latest (Microsoft Windows Server 2025) environment + -- appears to be unable to handle these Unicode code points. + unless isWindows $ do + stackErr ["new", "1234-ば日本-4本"] + safeNew "ば日本-4本" + safeNew "אבהץש" + safeNew "ΔΘΩϬ" safeNew :: String -> IO () safeNew name = do diff --git a/tests/integration/tests/1337-unicode-everywhere/Main.hs b/tests/integration/tests/1337-unicode-everywhere/Main.hs index 2b34396fbd..4083a0c34f 100644 --- a/tests/integration/tests/1337-unicode-everywhere/Main.hs +++ b/tests/integration/tests/1337-unicode-everywhere/Main.hs @@ -1,10 +1,14 @@ -import StackTest +-- Stack accepts Unicode code points outside of the Basic Latin Unicode block +-- (ASCII). +-- +-- See: https://github.com/commercialhaskell/stack/issues/1337 + +import Control.Monad ( unless ) +import StackTest -{-# ANN module "HLint: ignore Use unless" #-} main :: IO () -main = - if isWindows - then logInfo "Disabled on Windows (see https://github.com/commercialhaskell/stack/issues/1337#issuecomment-166118678)" - else do - stack ["build"] - stack ["exec", "以-exe"] +-- The GitHub windows-latest (Microsoft Windows Server 2025) environment appears +-- to be unable to handle these Unicode code points. +main = unless isWindows $ do + stack ["build"] + stack ["exec", "以-exe"] diff --git a/tests/integration/tests/1337-unicode-everywhere/files/.gitignore b/tests/integration/tests/1337-unicode-everywhere/files/.gitignore new file mode 100644 index 0000000000..207edb0d40 --- /dev/null +++ b/tests/integration/tests/1337-unicode-everywhere/files/.gitignore @@ -0,0 +1 @@ +以.cabal diff --git a/tests/integration/tests/1337-unicode-everywhere/files/Setup.hs b/tests/integration/tests/1337-unicode-everywhere/files/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/1337-unicode-everywhere/files/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/1337-unicode-everywhere/files/app/Main.hs b/tests/integration/tests/1337-unicode-everywhere/files/app/Main.hs index 0bb0cef9be..c33747aa40 100644 --- a/tests/integration/tests/1337-unicode-everywhere/files/app/Main.hs +++ b/tests/integration/tests/1337-unicode-everywhere/files/app/Main.hs @@ -1,6 +1,6 @@ module Main where -import Пσε +import Пσε ( θυπε ) main :: IO () main = putStrLn θυπε diff --git "a/tests/integration/tests/1337-unicode-everywhere/files/\344\273\245.cabal" b/tests/integration/tests/1337-unicode-everywhere/files/package.yaml similarity index 56% rename from "tests/integration/tests/1337-unicode-everywhere/files/\344\273\245.cabal" rename to tests/integration/tests/1337-unicode-everywhere/files/package.yaml index 8c683dac94..3211b0f2e7 100644 --- "a/tests/integration/tests/1337-unicode-everywhere/files/\344\273\245.cabal" +++ b/tests/integration/tests/1337-unicode-everywhere/files/package.yaml @@ -1,7 +1,8 @@ -name: 以 -version: 0.1.0.0 -synopsis: سقوط المدن من ذات. -description: +spec-version: 0.36.0 + +name: 以 +synopsis: سقوط المدن من ذات. +description: | 以呂波耳本部止 千利奴流乎和加 餘多連曽津祢那 @@ -29,13 +30,24 @@ description: μελιβόαν ὕμνον ἀναγνέων Αἰολίδ᾽ ἂμ βαρύβρομον ἁρμονίαν - Ед эож алььтэрюм витюпэраторебуз, фалля пожйдонёюм нэ квуй. Зюаз атоморюм эю вэл, экз агам магна жкряпшэрит нам. Примич вокынт дэлььякатезшимя эа мэль, ыам факэтэ пытынтёюм волуптатум ку. Квуым квюаэчтио йн пэр, дольор форынчйбюж ут еюж. Эжт нонюмэш янвыняры эю. + Ед эож алььтэрюм витюпэраторебуз, фалля пожйдонёюм нэ квуй. Зюаз атоморюм эю + вэл, экз агам магна жкряпшэрит нам. Примич вокынт дэлььякатезшимя эа мэль, + ыам факэтэ пытынтёюм волуптатум ку. Квуым квюаэчтио йн пэр, дольор + форынчйбюж ут еюж. Эжт нонюмэш янвыняры эю. - Υθ φιμ λιβερ δισερετ κυαεστιο. Νε δυο σονγυε φιθυπερατοριβυς, θε φις αθκυι σενσεριτ δεφινιεβας, μολλις θαμκυαμ ηας εα. Ιν φιμ εραντ μυσιυς, αλιι δισαντ σομμοδο νο συμ. Πρι αμετ πορρω σονσεκυυντυρ ατ. Ιδ σεα ηομερω αδιπισι, ομνεσκυε επισυρει ετ μελ, σεα αφφερθ σωνσεκυαθ θε. + Υθ φιμ λιβερ δισερετ κυαεστιο. Νε δυο σονγυε φιθυπερατοριβυς, θε φις αθκυι + σενσεριτ δεφινιεβας, μολλις θαμκυαμ ηας εα. Ιν φιμ εραντ μυσιυς, αλιι δισαντ + σομμοδο νο συμ. Πρι αμετ πορρω σονσεκυυντυρ ατ. Ιδ σεα ηομερω αδιπισι, + ομνεσκυε επισυρει ετ μελ, σεα αφφερθ σωνσεκυαθ θε. - नीचे खरिदे समस्याओ व्रुद्धि सुना शीघ्र व्याख्या निरपेक्ष शुरुआत असरकारक अविरोधता खरिदे मेमत उसीएक् असरकारक आंतरकार्यक्षमता केवल करता। असक्षम सामूहिक विवरण हीकम सुनत सदस्य खरिदने उदेशीत + नीचे खरिदे समस्याओ व्रुद्धि सुना शीघ्र व्याख्या निरपेक्ष शुरुआत असरकारक अविरोधता खरिदे मेमत उसीएक् + असरकारक आंतरकार्यक्षमता केवल करता। असक्षम सामूहिक विवरण हीकम सुनत सदस्य खरिदने उदेशीत - 引全堀記物質行上初野年謝止質警細物競。委目態政業諸好岡積米真香冒班分団時大一夏。帝同手怠問来視旧記次禁身妨性直権員。州駅都稿頂風著報計個勢意時言進整。作敗約秘都並断旬検面事真区。則局世紙文般百校車社金名室権金練危。水夫動間始旅円典中所場針仁暮中。書稿準提選別推五玲常能船岡味。詩聞誌寧真身性業遠国無軽春臨個鳥相契断者。 + 引全堀記物質行上初野年謝止質警細物競。委目態政業諸好岡積米真香冒班分団時大一夏。 + 帝同手怠問来視旧記次禁身妨性直権員。州駅都稿頂風著報計個勢意時言進整。 + 作敗約秘都並断旬検面事真区。則局世紙文般百校車社金名室権金練危。 + 水夫動間始旅円典中所場針仁暮中。書稿準提選別推五玲常能船岡味。 + 詩聞誌寧真身性業遠国無軽春臨個鳥相契断者。 紙ウ主転ね加必キト聴4水そない岩者づど会前ラシ総過権ぜ聞快にクげそ庫辺はぴず意掲ひに真価トしざが。体ろ名録ふいに公問築ムミ数基ー原多ぞぎすど済進ハレ見況ヤラエロ館刊キイ構読増禎ヨモメ提信最フ済席ワモキル弘28思弾5健はーろ提館ぱっるけ社除左てがひ。全てれ理時渉ン勝境チ測試ヌエマラ年9億ち込全クテヒカ土止びぎこぐ署進アカモヌ同賞誕傾吹敏こ。 @@ -47,26 +59,21 @@ description: ➀➁➂➃➄➅➆➇➈➉ ♀♁♂♃♄♅♆♇♈♉♊♋♌♍♎♏ 💩 -homepage: http://invalid/以#readme -license: BSD3 -license-file: いろは-LICENSE -author: Fake 💩💩💩💩💩 Name -maintainer: 以呂波耳本部止@invalid -copyright: BSD3 -category: Δσαντ -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: ארץ - exposed-modules: Пσε - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 - -executable 以-exe - hs-source-dirs: app - main-is: Main.hs - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: base - , 以 - default-language: Haskell2010 +homepage: http://invalid/以#readme +author: Fake 💩💩💩💩💩 Name +maintainer: 以呂波耳本部止@invalid +license-file: いろは-LICENSE +category: Δσαντ + +dependencies: +- base + +library: + source-dirs: ארץ + +executables: + 以-exe: + source-dirs: app + main: Main.hs + dependencies: + - 以 diff --git a/tests/integration/tests/1337-unicode-everywhere/files/stack.yaml b/tests/integration/tests/1337-unicode-everywhere/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/1337-unicode-everywhere/files/stack.yaml +++ b/tests/integration/tests/1337-unicode-everywhere/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git "a/tests/integration/tests/1337-unicode-everywhere/files/\327\220\327\250\327\245/\320\237\317\203\316\265.hs" "b/tests/integration/tests/1337-unicode-everywhere/files/\327\220\327\250\327\245/\320\237\317\203\316\265.hs" index c3df827706..197831ba8e 100644 --- "a/tests/integration/tests/1337-unicode-everywhere/files/\327\220\327\250\327\245/\320\237\317\203\316\265.hs" +++ "b/tests/integration/tests/1337-unicode-everywhere/files/\327\220\327\250\327\245/\320\237\317\203\316\265.hs" @@ -1,6 +1,6 @@ module Пσε - ( θυπε - ) where + ( θυπε + ) where θυπε :: String θυπε = "以呂波耳本部止" diff --git "a/tests/integration/tests/1337-unicode-everywhere/files/\343\201\204\343\202\215\343\201\257-LICENSE" "b/tests/integration/tests/1337-unicode-everywhere/files/\343\201\204\343\202\215\343\201\257-LICENSE" index ce91414e00..3d8104feae 100644 --- "a/tests/integration/tests/1337-unicode-everywhere/files/\343\201\204\343\202\215\343\201\257-LICENSE" +++ "b/tests/integration/tests/1337-unicode-everywhere/files/\343\201\204\343\202\215\343\201\257-LICENSE" @@ -1 +1,30 @@ -Whatever license. This is a project that only exists for integration testing and all rights are granted to it to whoever wants to do anything with it. It's mostly automatically generated content anyway. +Copyright فلان الفلاني (c) 2026 + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of Author name here nor the names of other + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tests/integration/tests/1438-configure-options/Main.hs b/tests/integration/tests/1438-configure-options/Main.hs index 6ee5b65040..200dd344b2 100644 --- a/tests/integration/tests/1438-configure-options/Main.hs +++ b/tests/integration/tests/1438-configure-options/Main.hs @@ -1,12 +1,21 @@ -import StackTest -import Control.Monad (unless) -import Data.Foldable (for_) -import Data.List (isInfixOf) +-- Stack allows Cabal configuration options to be set. +-- +-- See: https://github.com/commercialhaskell/stack/issues/1337 + +import Control.Monad ( unless ) +import Data.Foldable ( for_ ) +import Data.List ( isInfixOf ) +import StackTest main :: IO () main = do stackCleanFull - let stackYamlFiles = words "stack-locals.yaml stack-everything.yaml stack-targets.yaml stack-name.yaml" + let stackYamlFiles = + [ "stack-locals.yaml" + , "stack-everything.yaml" + , "stack-targets.yaml" + , "stack-myPackage.yaml" + ] for_ stackYamlFiles $ \stackYaml -> stackErrStderr ["build", "--stack-yaml", stackYaml] $ \str -> unless ("invalid option" `isInfixOf` str) $ diff --git a/tests/integration/tests/1438-configure-options/files/.gitignore b/tests/integration/tests/1438-configure-options/files/.gitignore index e9c64431ea..eae186286f 100644 --- a/tests/integration/tests/1438-configure-options/files/.gitignore +++ b/tests/integration/tests/1438-configure-options/files/.gitignore @@ -1 +1,2 @@ -name.cabal +myPackage.cabal +*.yaml.lock diff --git a/tests/integration/tests/1438-configure-options/files/package.yaml b/tests/integration/tests/1438-configure-options/files/package.yaml index 13ccbf73ec..a7305a77cf 100644 --- a/tests/integration/tests/1438-configure-options/files/package.yaml +++ b/tests/integration/tests/1438-configure-options/files/package.yaml @@ -1,5 +1,9 @@ -name: name -version: 0 +spec-version: 0.36.0 -dependencies: base -library: {} +name: myPackage + +dependencies: +- base + +library: + source-dirs: src diff --git a/tests/integration/tests/1438-configure-options/files/src/Lib.hs b/tests/integration/tests/1438-configure-options/files/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/1438-configure-options/files/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/1438-configure-options/files/stack-everything.yaml.lock b/tests/integration/tests/1438-configure-options/files/stack-everything.yaml.lock deleted file mode 100644 index 1c8044c146..0000000000 --- a/tests/integration/tests/1438-configure-options/files/stack-everything.yaml.lock +++ /dev/null @@ -1,14 +0,0 @@ -# This file was autogenerated by Stack. -# You should not edit this file by hand. -# For more information, please see the documentation at: -# https://docs.haskellstack.org/en/stable/lock_files - -packages: -- completed: - hackage: acme-dont-1.1@sha256:8264ad3e5113d3e0417b46e71d5a9c0914a1f03b5b81319cc329f1dc0f49b96c,602 - pantry-tree: - sha256: 79dbeddaf0fd507611687cefe9511c8fda489849fb0cac3894925716936290b2 - size: 206 - original: - hackage: acme-dont-1.1@rev:0 -snapshots: [] diff --git a/tests/integration/tests/1438-configure-options/files/stack-locals.yaml.lock b/tests/integration/tests/1438-configure-options/files/stack-locals.yaml.lock deleted file mode 100644 index 1c8044c146..0000000000 --- a/tests/integration/tests/1438-configure-options/files/stack-locals.yaml.lock +++ /dev/null @@ -1,14 +0,0 @@ -# This file was autogenerated by Stack. -# You should not edit this file by hand. -# For more information, please see the documentation at: -# https://docs.haskellstack.org/en/stable/lock_files - -packages: -- completed: - hackage: acme-dont-1.1@sha256:8264ad3e5113d3e0417b46e71d5a9c0914a1f03b5b81319cc329f1dc0f49b96c,602 - pantry-tree: - sha256: 79dbeddaf0fd507611687cefe9511c8fda489849fb0cac3894925716936290b2 - size: 206 - original: - hackage: acme-dont-1.1@rev:0 -snapshots: [] diff --git a/tests/integration/tests/1438-configure-options/files/stack-name.yaml b/tests/integration/tests/1438-configure-options/files/stack-myPackage.yaml similarity index 91% rename from tests/integration/tests/1438-configure-options/files/stack-name.yaml rename to tests/integration/tests/1438-configure-options/files/stack-myPackage.yaml index 4201e42892..2e66b8b9ab 100644 --- a/tests/integration/tests/1438-configure-options/files/stack-name.yaml +++ b/tests/integration/tests/1438-configure-options/files/stack-myPackage.yaml @@ -4,7 +4,7 @@ extra-deps: - acme-dont-1.1@rev:0 configure-options: - name: + myPackage: - this is an invalid option acme-dont: - this is an invalid option diff --git a/tests/integration/tests/1659-skip-component/Main.hs b/tests/integration/tests/1659-skip-component/Main.hs index 47ff86f83e..f5282d88d8 100644 --- a/tests/integration/tests/1659-skip-component/Main.hs +++ b/tests/integration/tests/1659-skip-component/Main.hs @@ -1,16 +1,10 @@ -import StackTest +-- Stack can be commanded to skip the building of specific package components. +-- +-- See: https://github.com/commercialhaskell/stack/issues/1659 -import Control.Exception (bracket) -import qualified Data.ByteString as S +import StackTest main :: IO () main = do - -- we need to build all the executables first to be able to skip them later (see issue #3229) - stack ["build"] - bracket - (S.readFile "app/MainFail.hs") - (S.writeFile "app/MainFail.hs") - (const $ do - writeFile "app/MainFail.hs" "bdsf" - stack ["build", "--test", "--bench", "--skip", "failing-test", "--skip", "failing-bench", "--skip", "failing-exe"] - stack ["build", ":failing-test", ":failing-bench", ":exe", ":failing-exe", "--skip", "failing-test", "--skip", "failing-bench", "--skip", "failing-exe"]) + stack ["build", "--test", "--bench", "--skip", "test-failing", "--skip", "bench-failing", "--skip", "myExe-failing"] + stack ["build", ":test-failing", ":bench-failing", ":myExe", ":myExe-failing", "--skip", "test-failing", "--skip", "bench-failing", "--skip", "myExe-failing"] diff --git a/tests/integration/tests/1659-skip-component/files/.gitignore b/tests/integration/tests/1659-skip-component/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/1659-skip-component/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/1659-skip-component/files/README.md b/tests/integration/tests/1659-skip-component/files/README.md deleted file mode 100644 index 560a646766..0000000000 --- a/tests/integration/tests/1659-skip-component/files/README.md +++ /dev/null @@ -1 +0,0 @@ -# files diff --git a/tests/integration/tests/1659-skip-component/files/Setup.hs b/tests/integration/tests/1659-skip-component/files/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/1659-skip-component/files/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/1659-skip-component/files/app-failing/Main.hs b/tests/integration/tests/1659-skip-component/files/app-failing/Main.hs new file mode 100644 index 0000000000..fed6cef32a --- /dev/null +++ b/tests/integration/tests/1659-skip-component/files/app-failing/Main.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE CPP #-} + +module Main where + +main :: IO () +main = pure () + +-- Avoid problems with CPP and HLint +#ifndef __HLINT__ + +#error Not going to compile, sorry + +#endif diff --git a/tests/integration/tests/1659-skip-component/files/bench/Bench.hs b/tests/integration/tests/1659-skip-component/files/bench/Bench.hs deleted file mode 100644 index d3f940c1ef..0000000000 --- a/tests/integration/tests/1659-skip-component/files/bench/Bench.hs +++ /dev/null @@ -1,2 +0,0 @@ -main :: IO () -main = asdf diff --git a/tests/integration/tests/1659-skip-component/files/bench/Main.hs b/tests/integration/tests/1659-skip-component/files/bench/Main.hs new file mode 100644 index 0000000000..55ef017a49 --- /dev/null +++ b/tests/integration/tests/1659-skip-component/files/bench/Main.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE CPP #-} + +main :: IO () +main = pure () + +-- Avoid problems with CPP and HLint +#ifndef __HLINT__ + +#error Not going to compile, sorry + +#endif diff --git a/tests/integration/tests/1659-skip-component/files/package.yaml b/tests/integration/tests/1659-skip-component/files/package.yaml new file mode 100644 index 0000000000..0b15e2fbce --- /dev/null +++ b/tests/integration/tests/1659-skip-component/files/package.yaml @@ -0,0 +1,27 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src + +executables: + myExe: + source-dirs: app + main: Main.hs + myExe-failing: + source-dirs: app-failing + main: Main.hs + +tests: + test-failing: + source-dirs: test + main: Main.hs + +benchmarks: + bench-failing: + source-dirs: bench + main: Main.hs diff --git a/tests/integration/tests/1659-skip-component/files/skip-component.cabal b/tests/integration/tests/1659-skip-component/files/skip-component.cabal deleted file mode 100644 index 2b4def57e6..0000000000 --- a/tests/integration/tests/1659-skip-component/files/skip-component.cabal +++ /dev/null @@ -1,44 +0,0 @@ -name: skip-component -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 - -executable exe - hs-source-dirs: app - main-is: Main.hs - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: base - default-language: Haskell2010 - -executable failing-exe - hs-source-dirs: app - main-is: MainFail.hs - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: base - default-language: Haskell2010 - -test-suite failing-test - type: exitcode-stdio-1.0 - hs-source-dirs: test - main-is: Spec.hs - build-depends: base - ghc-options: -threaded -rtsopts -with-rtsopts=-N - default-language: Haskell2010 - -benchmark failing-bench - type: exitcode-stdio-1.0 - hs-source-dirs: bench - main-is: Bench.hs - build-depends: base - ghc-options: -threaded -rtsopts -with-rtsopts=-N - default-language: Haskell2010 - -source-repository head - type: git - location: https://github.com/githubuser/files diff --git a/tests/integration/tests/1659-skip-component/files/src/Lib.hs b/tests/integration/tests/1659-skip-component/files/src/Lib.hs index d36ff2714d..6d85a26fe1 100644 --- a/tests/integration/tests/1659-skip-component/files/src/Lib.hs +++ b/tests/integration/tests/1659-skip-component/files/src/Lib.hs @@ -1,6 +1 @@ -module Lib - ( someFunc - ) where - -someFunc :: IO () -someFunc = putStrLn "someFunc" +module Lib where diff --git a/tests/integration/tests/1659-skip-component/files/stack.yaml b/tests/integration/tests/1659-skip-component/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/1659-skip-component/files/stack.yaml +++ b/tests/integration/tests/1659-skip-component/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/1659-skip-component/files/test/Main.hs b/tests/integration/tests/1659-skip-component/files/test/Main.hs new file mode 100644 index 0000000000..55ef017a49 --- /dev/null +++ b/tests/integration/tests/1659-skip-component/files/test/Main.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE CPP #-} + +main :: IO () +main = pure () + +-- Avoid problems with CPP and HLint +#ifndef __HLINT__ + +#error Not going to compile, sorry + +#endif diff --git a/tests/integration/tests/1659-skip-component/files/test/Spec.hs b/tests/integration/tests/1659-skip-component/files/test/Spec.hs deleted file mode 100644 index d3f940c1ef..0000000000 --- a/tests/integration/tests/1659-skip-component/files/test/Spec.hs +++ /dev/null @@ -1,2 +0,0 @@ -main :: IO () -main = asdf diff --git a/tests/integration/tests/1884-url-to-tarball/Main.hs b/tests/integration/tests/1884-url-to-tarball/Main.hs index c93c2e734d..62e48d315c 100644 --- a/tests/integration/tests/1884-url-to-tarball/Main.hs +++ b/tests/integration/tests/1884-url-to-tarball/Main.hs @@ -1,6 +1,8 @@ -import StackTest +-- Stack allows an extra-dep to be specified as a URL for an archive file. +-- +-- See: https://github.com/commercialhaskell/stack/issues/1884 + +import StackTest main :: IO () -main = do - stackCleanFull - stack ["build", "--dry-run"] +main = stack ["build", "--dry-run"] diff --git a/tests/integration/tests/1884-url-to-tarball/files/.gitignore b/tests/integration/tests/1884-url-to-tarball/files/.gitignore index d43d807c0d..b0a5a052a1 100644 --- a/tests/integration/tests/1884-url-to-tarball/files/.gitignore +++ b/tests/integration/tests/1884-url-to-tarball/files/.gitignore @@ -1 +1 @@ -*.cabal +myPackage.cabal diff --git a/tests/integration/tests/1884-url-to-tarball/files/package.yaml b/tests/integration/tests/1884-url-to-tarball/files/package.yaml index 2ab76b4002..a410102517 100644 --- a/tests/integration/tests/1884-url-to-tarball/files/package.yaml +++ b/tests/integration/tests/1884-url-to-tarball/files/package.yaml @@ -1,5 +1,9 @@ -name: foo +spec-version: 0.36.0 + +name: myPackage + dependencies: - base -- half +- acme-missiles + library: {} diff --git a/tests/integration/tests/1884-url-to-tarball/files/stack.yaml b/tests/integration/tests/1884-url-to-tarball/files/stack.yaml index 73ddc159cd..515a3914f1 100644 --- a/tests/integration/tests/1884-url-to-tarball/files/stack.yaml +++ b/tests/integration/tests/1884-url-to-tarball/files/stack.yaml @@ -1,5 +1,6 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 + extra-deps: -- location: https://hackage.haskell.org/package/half-0.2.2.3/half-0.2.2.3.tar.gz - sha256: 85c244c80d1c889a3d79073a6f5a99d9e769dbe3c574ca11d992b2b4f7599a5c - size: 6050 +- location: https://hackage.haskell.org/package/acme-missiles-0.3/acme-missiles-0.3.tar.gz + sha256: e563d8b524017a06b32768c4db8eff1f822f3fb22a90320b7e414402647b735b + size: 1442 diff --git a/tests/integration/tests/2195-depend-on-exe/Main.hs b/tests/integration/tests/2195-depend-on-exe/Main.hs index 11f81255a9..19fd17a3f0 100644 --- a/tests/integration/tests/2195-depend-on-exe/Main.hs +++ b/tests/integration/tests/2195-depend-on-exe/Main.hs @@ -1,11 +1,18 @@ -import Control.Monad (unless) -import Data.List (isInfixOf) -import StackTest +-- Stack reports an error if a package component depends on a package that has +-- no library component. +-- +-- See: https://github.com/commercialhaskell/stack/issues/2195 + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest main :: IO () -main = stackErrStderr ["build"] (expectMessage "package provides no library") +main = stackErrStderr + ["build", "myPackageB"] + (expectMessage "package provides no library") expectMessage :: String -> String -> IO () expectMessage msg stderr = - unless (msg `isInfixOf` stderr) - (error $ "Expected a warning: \n" ++ show msg) + unless (msg `isInfixOf` stderr) + (error $ "Expected a warning: \n" ++ show msg) diff --git a/tests/integration/tests/2195-depend-on-exe/files/.gitignore b/tests/integration/tests/2195-depend-on-exe/files/.gitignore new file mode 100644 index 0000000000..f9a6e152d2 --- /dev/null +++ b/tests/integration/tests/2195-depend-on-exe/files/.gitignore @@ -0,0 +1,2 @@ +myPackageA.cabal +myPackageB.cabal diff --git a/tests/integration/tests/2195-depend-on-exe/files/files.cabal b/tests/integration/tests/2195-depend-on-exe/files/files.cabal deleted file mode 100644 index 5edf065804..0000000000 --- a/tests/integration/tests/2195-depend-on-exe/files/files.cabal +++ /dev/null @@ -1,7 +0,0 @@ -name: files -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - build-depends: happy diff --git a/tests/integration/tests/2195-depend-on-exe/files/myPackageA/app/Main.hs b/tests/integration/tests/2195-depend-on-exe/files/myPackageA/app/Main.hs new file mode 100644 index 0000000000..89ad4b3e08 --- /dev/null +++ b/tests/integration/tests/2195-depend-on-exe/files/myPackageA/app/Main.hs @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = pure () diff --git a/tests/integration/tests/2195-depend-on-exe/files/myPackageA/package.yaml b/tests/integration/tests/2195-depend-on-exe/files/myPackageA/package.yaml new file mode 100644 index 0000000000..dc117d34c9 --- /dev/null +++ b/tests/integration/tests/2195-depend-on-exe/files/myPackageA/package.yaml @@ -0,0 +1,11 @@ +spec-version: 0.36.0 + +name: myPackageA + +dependencies: +- base + +executables: + myExeA: + source-dirs: app + main: Main.hs diff --git a/tests/integration/tests/2195-depend-on-exe/files/myPackageB/package.yaml b/tests/integration/tests/2195-depend-on-exe/files/myPackageB/package.yaml new file mode 100644 index 0000000000..e5f489eebf --- /dev/null +++ b/tests/integration/tests/2195-depend-on-exe/files/myPackageB/package.yaml @@ -0,0 +1,10 @@ +spec-version: 0.36.0 + +name: myPackageB + +dependencies: +- base +- myPackageA + +library: + source-dirs: src diff --git a/tests/integration/tests/2195-depend-on-exe/files/myPackageB/src/Lib.hs b/tests/integration/tests/2195-depend-on-exe/files/myPackageB/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/2195-depend-on-exe/files/myPackageB/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/2195-depend-on-exe/files/stack.yaml b/tests/integration/tests/2195-depend-on-exe/files/stack.yaml index b54fd809bf..68891a8d7c 100644 --- a/tests/integration/tests/2195-depend-on-exe/files/stack.yaml +++ b/tests/integration/tests/2195-depend-on-exe/files/stack.yaml @@ -1 +1,5 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 + +packages: +- myPackageA +- myPackageB diff --git a/tests/integration/tests/2433-ghc-by-version/Main.hs b/tests/integration/tests/2433-ghc-by-version/Main.hs index 271c259449..edec7684ea 100644 --- a/tests/integration/tests/2433-ghc-by-version/Main.hs +++ b/tests/integration/tests/2433-ghc-by-version/Main.hs @@ -1,7 +1,13 @@ -import System.Process (rawSystem) -import Control.Exception (throwIO) -import StackTest -import Control.Monad (unless) +-- If using a 'system' GHC, Stack uses the specified version of GHC on the PATH +-- and not 'ghc' (without a version) on the PATH. +-- +-- See: https://github.com/commercialhaskell/stack/issues/2433 + +import Control.Exception ( throwIO ) +import Control.Monad ( unless ) +import StackTest +import System.Process ( rawSystem ) main :: IO () -main = unless isWindows $ rawSystem "bash" ["run.sh"] >>= throwIO +main = unless isWindows $ + rawSystem "bash" ["run.sh"] >>= throwIO diff --git a/tests/integration/tests/2433-ghc-by-version/files/run.sh b/tests/integration/tests/2433-ghc-by-version/files/run.sh index d872149b5c..a7d103d1d3 100644 --- a/tests/integration/tests/2433-ghc-by-version/files/run.sh +++ b/tests/integration/tests/2433-ghc-by-version/files/run.sh @@ -2,10 +2,10 @@ set -exuo pipefail -export PATH=$(pwd)/fake-path:$("$STACK_EXE" path --resolver ghc-9.10.3 --compiler-bin):$PATH +export PATH=$(pwd)/fake-path:$("$STACK_EXE" path --snapshot ghc-9.10.3 --compiler-bin):$PATH export STACK_ROOT=$(pwd)/fake-root which ghc -"$STACK_EXE" --system-ghc --no-install-ghc --resolver ghc-9.10.3 ghc -- --info -"$STACK_EXE" --system-ghc --no-install-ghc --resolver ghc-9.10.3 runghc foo.hs +"$STACK_EXE" --system-ghc --no-install-ghc --snapshot ghc-9.10.3 ghc -- --info +"$STACK_EXE" --system-ghc --no-install-ghc --snapshot ghc-9.10.3 runghc test.hs diff --git a/tests/integration/tests/2433-ghc-by-version/files/foo.hs b/tests/integration/tests/2433-ghc-by-version/files/test.hs similarity index 100% rename from tests/integration/tests/2433-ghc-by-version/files/foo.hs rename to tests/integration/tests/2433-ghc-by-version/files/test.hs diff --git a/tests/integration/tests/2465-init-no-packages/Main.hs b/tests/integration/tests/2465-init-no-packages/Main.hs index ec50de4782..3000a9dbc7 100644 --- a/tests/integration/tests/2465-init-no-packages/Main.hs +++ b/tests/integration/tests/2465-init-no-packages/Main.hs @@ -1,10 +1,13 @@ -import StackTest -import System.Directory -import Control.Monad (unless) +-- Stack can initialise a project directory that contains no project packages. +-- +-- See: https://github.com/commercialhaskell/stack/issues/2465 + +import Control.Monad ( unless ) +import StackTest +import System.Directory ( doesFileExist ) main :: IO () main = do - removeFileIgnore "stack.yaml" - stack ["init", "--snapshot", "ghc-9.2.4"] + stack ["--snapshot", "ghc-9.10.3", "init"] exists <- doesFileExist "stack.yaml" unless exists $ error "stack.yaml not created!" diff --git a/tests/integration/tests/2643-copy-compiler-tool/Main.hs b/tests/integration/tests/2643-copy-compiler-tool/Main.hs index cbb05b4819..d4e5d631ed 100644 --- a/tests/integration/tests/2643-copy-compiler-tool/Main.hs +++ b/tests/integration/tests/2643-copy-compiler-tool/Main.hs @@ -1,64 +1,50 @@ -import StackTest -import System.Directory -import Control.Monad (unless) +-- Stack can install targets that are executables as compiler tools. -main :: IO () -main = do - -- init - removeFileIgnore "stack.yaml" - removeDirIgnore ".stack-work" - stack ["init", defaultSnapshotArg] +-- See: https://github.com/commercialhaskell/stack/issues/2643 - -- place to throw some exes - removeDirIgnore "binny" - createDirectory "binny" - - -- check assumptions on exec and the build flags and clean - stack ["build", "--flag", "copy-compiler-tool-test:build-baz"] - stack ["exec", "--", "baz-exe" ++ exeExt] - stackErr ["exec", "--", "bar-exe" ++ exeExt] - stackCleanFull - -- See #4936. The Windows condition is because `stackCleanFull` may have - -- failed. - unless isWindows $ stackErr ["exec", "--", "baz-exe" ++ exeExt] +import Control.Monad ( unless ) +import StackTest +import System.Directory () - -- install one exe normally +main :: IO () +main = do + -- Install myExeA executable normally: stack ["install", - "--local-bin-path", "./binny", - "--flag", "*:build-foo" + "--local-bin-path", "./bin", + "--flag", "myPackage:build-myExeA" ] - -- and install two compiler-tools, opposite ways - -- (build or install) + -- Install myExeB and myExeC executables as compiler tools, in alternative + -- ways (build or install): stack ["build", - "--local-bin-path", "./binny", + "--local-bin-path", "./bin", "--copy-compiler-tool", - "--flag", "*:build-bar" + "--flag", "myPackage:build-myExeB" ] stack ["install", - "--local-bin-path", "./binny", + "--local-bin-path", "./bin", "--copy-compiler-tool", - "--flag", "*:build-baz" + "--flag", "myPackage:build-myExeC" ] - -- nuke the built things that go in .stack-work/, so we can test if - -- the installed ones exist for sure + -- Remove .stack-work/, so we can test if the installed ones exist: stackCleanFull - -- bar and baz were installed as compiler tools, should work fine - stack ["exec", "--", "bar-exe" ++ exeExt] - stack ["exec", "--", "baz-exe" ++ exeExt] + -- myExeB and myExeC were installed as compiler tools and should work: + stack ["exec", "--", "myExeB" <> exeExt] + stack ["exec", "--", "myExeC" <> exeExt] + + -- myExeA was installed in .bin/, which is not on the PATH, and should not + -- work. - -- foo was installed as a normal exe (in .binny/, which can't be on PATH), - -- so shouldn't - -- See #4936. The Windows condition is because `stackCleanFull` may have - -- failed. - unless isWindows $ stackErr ["exec", "--", "foo-exe" ++ exeExt] + -- The Windows condition is because `stackCleanFull` may have failed (see + -- issue #4936): + unless isWindows $ stackErr ["exec", "--", "myExeA" <> exeExt] - -- check existences make sense - doesExist $ "./binny/foo-exe" ++ exeExt - doesNotExist $ "./binny/bar-exe" ++ exeExt - doesNotExist $ "./binny/baz-exe" ++ exeExt + -- Check existences make sense: + doesExist $ "./bin/myExeA" <> exeExt + doesNotExist $ "./bin/myExeB" <> exeExt + doesNotExist $ "./bin/myExeC" <> exeExt - -- just check that this exists + -- Check that this exists stack ["path", "--compiler-tools-bin"] diff --git a/tests/integration/tests/2643-copy-compiler-tool/files/.gitignore b/tests/integration/tests/2643-copy-compiler-tool/files/.gitignore index 56f4748f50..f3f0a84c6f 100644 --- a/tests/integration/tests/2643-copy-compiler-tool/files/.gitignore +++ b/tests/integration/tests/2643-copy-compiler-tool/files/.gitignore @@ -1,2 +1,3 @@ -binny/ -stack.yaml +.stack-work/ +bin/ +myPackage.cabal diff --git a/tests/integration/tests/2643-copy-compiler-tool/files/Bar.hs b/tests/integration/tests/2643-copy-compiler-tool/files/Bar.hs deleted file mode 100644 index 7498d2965c..0000000000 --- a/tests/integration/tests/2643-copy-compiler-tool/files/Bar.hs +++ /dev/null @@ -1 +0,0 @@ -main = putStrLn "twotwotwo" diff --git a/tests/integration/tests/2643-copy-compiler-tool/files/Baz.hs b/tests/integration/tests/2643-copy-compiler-tool/files/Baz.hs deleted file mode 100644 index 3f276659c9..0000000000 --- a/tests/integration/tests/2643-copy-compiler-tool/files/Baz.hs +++ /dev/null @@ -1 +0,0 @@ -main = putStrLn "threethreethree" diff --git a/tests/integration/tests/2643-copy-compiler-tool/files/Foo.hs b/tests/integration/tests/2643-copy-compiler-tool/files/Foo.hs deleted file mode 100644 index 8abe1be7d5..0000000000 --- a/tests/integration/tests/2643-copy-compiler-tool/files/Foo.hs +++ /dev/null @@ -1 +0,0 @@ -main = putStrLn "oneoneone" diff --git a/tests/integration/tests/2643-copy-compiler-tool/files/LICENSE b/tests/integration/tests/2643-copy-compiler-tool/files/LICENSE deleted file mode 100644 index d05408d876..0000000000 --- a/tests/integration/tests/2643-copy-compiler-tool/files/LICENSE +++ /dev/null @@ -1,30 +0,0 @@ -Copyright (c) 2000 - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Your name here nor the names of other - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tests/integration/tests/2643-copy-compiler-tool/files/Setup.hs b/tests/integration/tests/2643-copy-compiler-tool/files/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/2643-copy-compiler-tool/files/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/2643-copy-compiler-tool/files/appA/Main.hs b/tests/integration/tests/2643-copy-compiler-tool/files/appA/Main.hs new file mode 100644 index 0000000000..a31c5a029d --- /dev/null +++ b/tests/integration/tests/2643-copy-compiler-tool/files/appA/Main.hs @@ -0,0 +1,4 @@ +module Main (main) where + +main :: IO () +main = pure () diff --git a/tests/integration/tests/2643-copy-compiler-tool/files/appB/Main.hs b/tests/integration/tests/2643-copy-compiler-tool/files/appB/Main.hs new file mode 100644 index 0000000000..a31c5a029d --- /dev/null +++ b/tests/integration/tests/2643-copy-compiler-tool/files/appB/Main.hs @@ -0,0 +1,4 @@ +module Main (main) where + +main :: IO () +main = pure () diff --git a/tests/integration/tests/2643-copy-compiler-tool/files/appC/Main.hs b/tests/integration/tests/2643-copy-compiler-tool/files/appC/Main.hs new file mode 100644 index 0000000000..a31c5a029d --- /dev/null +++ b/tests/integration/tests/2643-copy-compiler-tool/files/appC/Main.hs @@ -0,0 +1,4 @@ +module Main (main) where + +main :: IO () +main = pure () diff --git a/tests/integration/tests/2643-copy-compiler-tool/files/copy-compiler-tool-test.cabal b/tests/integration/tests/2643-copy-compiler-tool/files/copy-compiler-tool-test.cabal deleted file mode 100644 index e1f66caf91..0000000000 --- a/tests/integration/tests/2643-copy-compiler-tool/files/copy-compiler-tool-test.cabal +++ /dev/null @@ -1,54 +0,0 @@ -name: copy-compiler-tool-test -version: 0.1.0.0 -synopsis: Initial project template from stack -description: Please see README.md -homepage: http://invalid/ -license: BSD3 -license-file: LICENSE -author: Your name here -maintainer: your.address@example.com --- copyright: -category: Web -build-type: Simple --- extra-source-files: -cabal-version: >=1.10 - -flag build-foo - manual: True - default: False - description: Build foo - -flag build-bar - manual: True - default: False - description: Build bar - -flag build-baz - manual: True - default: False - description: Build baz - -executable foo-exe - main-is: Foo.hs - build-depends: base - default-language: Haskell2010 - if !flag(build-foo) - buildable: False - -executable bar-exe - main-is: Bar.hs - build-depends: base - default-language: Haskell2010 - if !flag(build-bar) - buildable: False - -executable baz-exe - main-is: Baz.hs - build-depends: base - default-language: Haskell2010 - if !flag(build-baz) - buildable: False - -source-repository head - type: git - location: https://invalid/ diff --git a/tests/integration/tests/2643-copy-compiler-tool/files/package.yaml b/tests/integration/tests/2643-copy-compiler-tool/files/package.yaml new file mode 100644 index 0000000000..8759081629 --- /dev/null +++ b/tests/integration/tests/2643-copy-compiler-tool/files/package.yaml @@ -0,0 +1,40 @@ +spec-version: 0.36.0 + +name: myPackage + +flags: + build-myExeA: + description: Build myExeA + default: false + manual: true + build-myExeB: + description: Build myExeB + default: false + manual: true + build-myExeC: + description: Build myExeC + default: false + manual: true + +dependencies: +- base + +executables: + myExeA: + source-dirs: appA + main: Main.hs + when: + - condition: "!flag(build-myExeA)" + buildable: false + myExeB: + source-dirs: appB + main: Main.hs + when: + - condition: "!flag(build-myExeB)" + buildable: false + myExeC: + source-dirs: appC + main: Main.hs + when: + - condition: "!flag(build-myExeC)" + buildable: false diff --git a/tests/integration/tests/no-rerun-tests/files/stack.yaml b/tests/integration/tests/2643-copy-compiler-tool/files/stack.yaml similarity index 100% rename from tests/integration/tests/no-rerun-tests/files/stack.yaml rename to tests/integration/tests/2643-copy-compiler-tool/files/stack.yaml diff --git a/tests/integration/tests/2781-shadow-bug/Main.hs b/tests/integration/tests/2781-shadow-bug/Main.hs index 057606262e..7f9e65e4ba 100644 --- a/tests/integration/tests/2781-shadow-bug/Main.hs +++ b/tests/integration/tests/2781-shadow-bug/Main.hs @@ -1,10 +1,13 @@ -import StackTest -import System.Directory +-- Stack rebuilds a benchmark when an indirect dependency changes. +-- +-- See: https://github.com/commercialhaskell/stack/issues/2781 + +import StackTest +import System.Directory ( createDirectoryIfMissing ) main :: IO () main = do - createDirectoryIfMissing True "foo/src" - readFile "foo/v1/Foo.hs" >>= writeFile "foo/src/Foo.hs" + copy "myPackageB/v1/MyPackageB-v1.hs" "myPackageB/src/MyPackageB.hs" stack ["bench"] - readFile "foo/v2/Foo.hs" >>= writeFile "foo/src/Foo.hs" + copy "myPackageB/v2/MyPackageB-v2.hs" "myPackageB/src/MyPackageB.hs" stack ["bench"] diff --git a/tests/integration/tests/2781-shadow-bug/files/.gitignore b/tests/integration/tests/2781-shadow-bug/files/.gitignore index da86f0dbe2..f9a6e152d2 100644 --- a/tests/integration/tests/2781-shadow-bug/files/.gitignore +++ b/tests/integration/tests/2781-shadow-bug/files/.gitignore @@ -1 +1,2 @@ -foo/src/ +myPackageA.cabal +myPackageB.cabal diff --git a/tests/integration/tests/2781-shadow-bug/files/bar/bar.cabal b/tests/integration/tests/2781-shadow-bug/files/bar/bar.cabal deleted file mode 100644 index 19985b85a0..0000000000 --- a/tests/integration/tests/2781-shadow-bug/files/bar/bar.cabal +++ /dev/null @@ -1,18 +0,0 @@ -name: bar -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Bar - build-depends: base, foo - default-language: Haskell2010 - -benchmark bench - type: exitcode-stdio-1.0 - hs-source-dirs: bench - main-is: bench.hs - build-depends: base - , bar - default-language: Haskell2010 diff --git a/tests/integration/tests/2781-shadow-bug/files/bar/src/Bar.hs b/tests/integration/tests/2781-shadow-bug/files/bar/src/Bar.hs deleted file mode 100644 index 3eef52eeed..0000000000 --- a/tests/integration/tests/2781-shadow-bug/files/bar/src/Bar.hs +++ /dev/null @@ -1,8 +0,0 @@ -module Bar - ( bar - ) where - -import Foo - -bar :: IO () -bar = foo diff --git a/tests/integration/tests/2781-shadow-bug/files/foo/foo.cabal b/tests/integration/tests/2781-shadow-bug/files/foo/foo.cabal deleted file mode 100644 index 4b9dc19942..0000000000 --- a/tests/integration/tests/2781-shadow-bug/files/foo/foo.cabal +++ /dev/null @@ -1,10 +0,0 @@ -name: foo -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Foo - build-depends: base - default-language: Haskell2010 diff --git a/tests/integration/tests/2781-shadow-bug/files/foo/v1/Foo.hs b/tests/integration/tests/2781-shadow-bug/files/foo/v1/Foo.hs deleted file mode 100644 index 0783893feb..0000000000 --- a/tests/integration/tests/2781-shadow-bug/files/foo/v1/Foo.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Foo - ( foo - ) where - -foo :: IO () -foo = putStrLn "foo1" diff --git a/tests/integration/tests/2781-shadow-bug/files/foo/v2/Foo.hs b/tests/integration/tests/2781-shadow-bug/files/foo/v2/Foo.hs deleted file mode 100644 index 819d884e1e..0000000000 --- a/tests/integration/tests/2781-shadow-bug/files/foo/v2/Foo.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Foo - ( foo - ) where - -foo :: IO () -foo = putStrLn "foo2" diff --git a/tests/integration/tests/2781-shadow-bug/files/bar/bench/bench.hs b/tests/integration/tests/2781-shadow-bug/files/myPackageA/bench/bench.hs similarity index 100% rename from tests/integration/tests/2781-shadow-bug/files/bar/bench/bench.hs rename to tests/integration/tests/2781-shadow-bug/files/myPackageA/bench/bench.hs diff --git a/tests/integration/tests/2781-shadow-bug/files/myPackageA/package.yaml b/tests/integration/tests/2781-shadow-bug/files/myPackageA/package.yaml new file mode 100644 index 0000000000..eeb7c4fcc3 --- /dev/null +++ b/tests/integration/tests/2781-shadow-bug/files/myPackageA/package.yaml @@ -0,0 +1,18 @@ +spec-version: 0.36.0 + +name: myPackageA + +dependencies: +- base + +library: + source-dirs: src + dependencies: + - myPackageB + +benchmarks: + bench: + source-dirs: bench + main: bench.hs + dependencies: + - myPackageA diff --git a/tests/integration/tests/2781-shadow-bug/files/myPackageA/src/MyPackageA.hs b/tests/integration/tests/2781-shadow-bug/files/myPackageA/src/MyPackageA.hs new file mode 100644 index 0000000000..16b38c3d34 --- /dev/null +++ b/tests/integration/tests/2781-shadow-bug/files/myPackageA/src/MyPackageA.hs @@ -0,0 +1,8 @@ +module MyPackageA + ( funcA + ) where + +import MyPackageB ( funcB ) + +funcA :: IO () +funcA = funcB diff --git a/tests/integration/tests/2997-ensure-warnings-output/files/bar/package.yaml b/tests/integration/tests/2781-shadow-bug/files/myPackageB/package.yaml similarity index 54% rename from tests/integration/tests/2997-ensure-warnings-output/files/bar/package.yaml rename to tests/integration/tests/2781-shadow-bug/files/myPackageB/package.yaml index 0c7f62c5c5..03b4ec87d3 100644 --- a/tests/integration/tests/2997-ensure-warnings-output/files/bar/package.yaml +++ b/tests/integration/tests/2781-shadow-bug/files/myPackageB/package.yaml @@ -1,9 +1,9 @@ -name: bar -version: 0 +spec-version: 0.36.0 + +name: myPackageB dependencies: - base library: source-dirs: src - ghc-options: -Wall diff --git a/tests/integration/tests/2781-shadow-bug/files/myPackageB/src/MyPackageB.hs b/tests/integration/tests/2781-shadow-bug/files/myPackageB/src/MyPackageB.hs new file mode 100644 index 0000000000..e50e86ed07 --- /dev/null +++ b/tests/integration/tests/2781-shadow-bug/files/myPackageB/src/MyPackageB.hs @@ -0,0 +1 @@ +To be replaced. diff --git a/tests/integration/tests/2781-shadow-bug/files/myPackageB/v1/MyPackageB-v1.hs b/tests/integration/tests/2781-shadow-bug/files/myPackageB/v1/MyPackageB-v1.hs new file mode 100644 index 0000000000..38ae9f9985 --- /dev/null +++ b/tests/integration/tests/2781-shadow-bug/files/myPackageB/v1/MyPackageB-v1.hs @@ -0,0 +1,6 @@ +module MyPackageB + ( funcB + ) where + +funcB :: IO () +funcB = putStrLn "version 1" diff --git a/tests/integration/tests/2781-shadow-bug/files/myPackageB/v2/MyPackageB-v2.hs b/tests/integration/tests/2781-shadow-bug/files/myPackageB/v2/MyPackageB-v2.hs new file mode 100644 index 0000000000..a4584de18e --- /dev/null +++ b/tests/integration/tests/2781-shadow-bug/files/myPackageB/v2/MyPackageB-v2.hs @@ -0,0 +1,6 @@ +module MyPackageB + ( funcB + ) where + +funcB :: IO () +funcB = putStrLn "version 2" diff --git a/tests/integration/tests/2781-shadow-bug/files/stack.yaml b/tests/integration/tests/2781-shadow-bug/files/stack.yaml index e0a635d446..68891a8d7c 100644 --- a/tests/integration/tests/2781-shadow-bug/files/stack.yaml +++ b/tests/integration/tests/2781-shadow-bug/files/stack.yaml @@ -1,4 +1,5 @@ snapshot: ghc-9.10.3 + packages: -- foo -- bar +- myPackageA +- myPackageB diff --git a/tests/integration/tests/2997-ensure-warnings-output/Main.hs b/tests/integration/tests/2997-ensure-warnings-output/Main.hs index ff41be9abb..3b0b049dca 100644 --- a/tests/integration/tests/2997-ensure-warnings-output/Main.hs +++ b/tests/integration/tests/2997-ensure-warnings-output/Main.hs @@ -1,10 +1,14 @@ -import StackTest -import Data.List (isInfixOf) +-- Stack dumps logs with GHC warnings for multi-package projects and +-- non-interleaved output. +-- +-- See: https://github.com/commercialhaskell/stack/issues/2997 + +import Data.List ( isInfixOf ) +import StackTest main :: IO () main = do - stackCleanFull - stackCheckStderr ["build", "--terminal", "--color=always"] $ \str -> + stackCheckStderr ["build", "--no-interleaved-output"] $ \str -> if "no type signature" `isInfixOf` str then pure () else error "Warnings are not being shown" diff --git a/tests/integration/tests/2997-ensure-warnings-output/files/.gitignore b/tests/integration/tests/2997-ensure-warnings-output/files/.gitignore index d43d807c0d..f9a6e152d2 100644 --- a/tests/integration/tests/2997-ensure-warnings-output/files/.gitignore +++ b/tests/integration/tests/2997-ensure-warnings-output/files/.gitignore @@ -1 +1,2 @@ -*.cabal +myPackageA.cabal +myPackageB.cabal diff --git a/tests/integration/tests/2997-ensure-warnings-output/files/bar/src/Bar.hs b/tests/integration/tests/2997-ensure-warnings-output/files/bar/src/Bar.hs deleted file mode 100644 index 08a38856f5..0000000000 --- a/tests/integration/tests/2997-ensure-warnings-output/files/bar/src/Bar.hs +++ /dev/null @@ -1,3 +0,0 @@ -module Bar where - -bar = () diff --git a/tests/integration/tests/2997-ensure-warnings-output/files/foo/src/Foo.hs b/tests/integration/tests/2997-ensure-warnings-output/files/foo/src/Foo.hs deleted file mode 100644 index 11391a4814..0000000000 --- a/tests/integration/tests/2997-ensure-warnings-output/files/foo/src/Foo.hs +++ /dev/null @@ -1,3 +0,0 @@ -module Foo where - -foo = () diff --git a/tests/integration/tests/2997-ensure-warnings-output/files/myPackageA/package.yaml b/tests/integration/tests/2997-ensure-warnings-output/files/myPackageA/package.yaml new file mode 100644 index 0000000000..5cb84d72e6 --- /dev/null +++ b/tests/integration/tests/2997-ensure-warnings-output/files/myPackageA/package.yaml @@ -0,0 +1,12 @@ +spec-version: 0.36.0 + +name: myPackageA + +dependencies: +- base + +ghc-options: +- -Wall + +library: + source-dirs: src diff --git a/tests/integration/tests/2997-ensure-warnings-output/files/myPackageA/src/Lib.hs b/tests/integration/tests/2997-ensure-warnings-output/files/myPackageA/src/Lib.hs new file mode 100644 index 0000000000..2bcd1d55c1 --- /dev/null +++ b/tests/integration/tests/2997-ensure-warnings-output/files/myPackageA/src/Lib.hs @@ -0,0 +1,3 @@ +module Lib where + +func = () diff --git a/tests/integration/tests/2997-ensure-warnings-output/files/myPackageB/package.yaml b/tests/integration/tests/2997-ensure-warnings-output/files/myPackageB/package.yaml new file mode 100644 index 0000000000..77d87303d7 --- /dev/null +++ b/tests/integration/tests/2997-ensure-warnings-output/files/myPackageB/package.yaml @@ -0,0 +1,12 @@ +spec-version: 0.36.0 + +name: myPackageB + +dependencies: +- base + +ghc-options: +- -Wall + +library: + source-dirs: src diff --git a/tests/integration/tests/2997-ensure-warnings-output/files/myPackageB/src/Lib.hs b/tests/integration/tests/2997-ensure-warnings-output/files/myPackageB/src/Lib.hs new file mode 100644 index 0000000000..2bcd1d55c1 --- /dev/null +++ b/tests/integration/tests/2997-ensure-warnings-output/files/myPackageB/src/Lib.hs @@ -0,0 +1,3 @@ +module Lib where + +func = () diff --git a/tests/integration/tests/2997-ensure-warnings-output/files/stack.yaml b/tests/integration/tests/2997-ensure-warnings-output/files/stack.yaml index ccbffc5198..46f3e0977c 100644 --- a/tests/integration/tests/2997-ensure-warnings-output/files/stack.yaml +++ b/tests/integration/tests/2997-ensure-warnings-output/files/stack.yaml @@ -1,5 +1,7 @@ snapshot: ghc-9.10.3 + packages: -- foo -- bar +- myPackageA +- myPackageB + dump-logs: warning diff --git a/tests/integration/tests/32-unlisted-module/Main.hs b/tests/integration/tests/32-unlisted-module/Main.hs index 1559b530c7..bc0feae92f 100644 --- a/tests/integration/tests/32-unlisted-module/Main.hs +++ b/tests/integration/tests/32-unlisted-module/Main.hs @@ -1,25 +1,30 @@ -import Control.Concurrent -import StackTest +-- Stack should rebuild a package when files required for building are dirty, +-- even if the files are not listed in the package's Cabal file. +-- +-- See: https://github.com/commercialhaskell/stack/issues/32 + +import Control.Concurrent ( threadDelay ) +import StackTest main :: IO () main = do - copy "src/Unlisted_OK.hs" "src/Unlisted.hs" - copy "embed_OK.txt" "embed.txt" - stack ["build"] - pause - copy "src/Unlisted_FAIL.hs" "src/Unlisted.hs" - stackErr ["build"] - pause - copy "src/Unlisted_OK.hs" "src/Unlisted.hs" - stack ["build"] - stack ["exec", "files-exe"] - pause - copy "embed_FAIL.txt" "embed.txt" - stack ["build"] - stackErr ["exec", "files-exe"] - pause - copy "embed_OK.txt" "embed.txt" - stack ["build"] - stack ["exec", "files-exe"] - -pause = threadDelay 1000000 + copy "app/Unlisted_OK.hs" "app/Unlisted.hs" + copy "embed_OK.txt" "embed.txt" + stack ["build"] + pause + copy "app/Unlisted_FAIL.hs" "app/Unlisted.hs" + stackErr ["build"] + pause + copy "app/Unlisted_OK.hs" "app/Unlisted.hs" + stack ["build"] + stack ["exec", "fail-if-fail"] + pause + copy "embed_FAIL.txt" "embed.txt" + stack ["build"] + stackErr ["exec", "fail-if-fail"] + pause + copy "embed_OK.txt" "embed.txt" + stack ["build"] + stack ["exec", "fail-if-fail"] + where + pause = threadDelay 1000000 diff --git a/tests/integration/tests/32-unlisted-module/files/.gitignore b/tests/integration/tests/32-unlisted-module/files/.gitignore index 6c87a5ea83..5983ce17cb 100644 --- a/tests/integration/tests/32-unlisted-module/files/.gitignore +++ b/tests/integration/tests/32-unlisted-module/files/.gitignore @@ -1,2 +1,3 @@ embed.txt -src/Unlisted.hs +app/Unlisted.hs +myPackage.cabal diff --git a/tests/integration/tests/32-unlisted-module/files/app/Main.hs b/tests/integration/tests/32-unlisted-module/files/app/Main.hs new file mode 100644 index 0000000000..6328508c11 --- /dev/null +++ b/tests/integration/tests/32-unlisted-module/files/app/Main.hs @@ -0,0 +1,16 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE OverloadedStrings #-} + +module Main where + +import Control.Monad ( when ) +import qualified Data.ByteString.Char8 as C8 +import Data.FileEmbed ( embedFile ) +import Unlisted ( unlistedFunc ) + +main :: IO () +main = do + unlistedFunc + when ("FAIL" `C8.isPrefixOf` embedded) $ error "embedded contains FAIL" + +embedded = $(embedFile "embed.txt") diff --git a/tests/integration/tests/32-unlisted-module/files/app/Unlisted_FAIL.hs b/tests/integration/tests/32-unlisted-module/files/app/Unlisted_FAIL.hs new file mode 100644 index 0000000000..35b46d7b50 --- /dev/null +++ b/tests/integration/tests/32-unlisted-module/files/app/Unlisted_FAIL.hs @@ -0,0 +1,3 @@ +-- | Version of Unlisted with a different export that causes Main to fail to +-- compile. +module Unlisted where diff --git a/tests/integration/tests/32-unlisted-module/files/app/Unlisted_OK.hs b/tests/integration/tests/32-unlisted-module/files/app/Unlisted_OK.hs new file mode 100644 index 0000000000..000f75684c --- /dev/null +++ b/tests/integration/tests/32-unlisted-module/files/app/Unlisted_OK.hs @@ -0,0 +1,5 @@ +-- | Version of Unlisted that does not cause Main to fail to compile. +module Unlisted where + +unlistedFunc :: IO () +unlistedFunc = pure () diff --git a/tests/integration/tests/32-unlisted-module/files/files.cabal b/tests/integration/tests/32-unlisted-module/files/files.cabal deleted file mode 100644 index b789af591e..0000000000 --- a/tests/integration/tests/32-unlisted-module/files/files.cabal +++ /dev/null @@ -1,17 +0,0 @@ -name: files -version: 0.1.0.0 -synopsis: Initial project template from stack -description: Please see README.md -homepage: http://github.com/githubuser/files#readme -license: BSD3 -build-type: Simple --- extra-source-files: -cabal-version: >=1.10 - -executable files-exe - hs-source-dirs: src/../src - main-is: Main.hs - build-depends: base >= 4.7 && < 5 - , bytestring - , file-embed - default-language: Haskell2010 diff --git a/tests/integration/tests/32-unlisted-module/files/package.yaml b/tests/integration/tests/32-unlisted-module/files/package.yaml new file mode 100644 index 0000000000..bf5bf390a9 --- /dev/null +++ b/tests/integration/tests/32-unlisted-module/files/package.yaml @@ -0,0 +1,14 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base +- bytestring +- file-embed + +executables: + fail-if-fail: + source-dirs: app + main: Main.hs + other-modules: [] diff --git a/tests/integration/tests/32-unlisted-module/files/src/Main.hs b/tests/integration/tests/32-unlisted-module/files/src/Main.hs deleted file mode 100644 index dde0892cc5..0000000000 --- a/tests/integration/tests/32-unlisted-module/files/src/Main.hs +++ /dev/null @@ -1,16 +0,0 @@ -{-# LANGUAGE TemplateHaskell #-} -{-# LANGUAGE OverloadedStrings #-} -module Main where - -import Control.Monad -import qualified Data.ByteString.Char8 as C8 -import Data.FileEmbed -import Data.List -import Unlisted - -main :: IO () -main = do - putStrLn ("main " ++ show foo ++ " " ++ show embedded) - when ("FAIL" `C8.isPrefixOf` embedded) $ error "embedded contains FAIL" - -embedded = $(embedFile "embed.txt") diff --git a/tests/integration/tests/32-unlisted-module/files/src/Unlisted_FAIL.hs b/tests/integration/tests/32-unlisted-module/files/src/Unlisted_FAIL.hs deleted file mode 100644 index b15130820b..0000000000 --- a/tests/integration/tests/32-unlisted-module/files/src/Unlisted_FAIL.hs +++ /dev/null @@ -1,5 +0,0 @@ --- | Version of Unlisted with different export that causes failure to compile. -module Unlisted where - -fooRenamed :: String -fooRenamed = "foo" diff --git a/tests/integration/tests/32-unlisted-module/files/src/Unlisted_OK.hs b/tests/integration/tests/32-unlisted-module/files/src/Unlisted_OK.hs deleted file mode 100644 index 73caa00bcc..0000000000 --- a/tests/integration/tests/32-unlisted-module/files/src/Unlisted_OK.hs +++ /dev/null @@ -1,4 +0,0 @@ -module Unlisted where - -foo :: String -foo = "foo" diff --git a/tests/integration/tests/32-unlisted-module/files/src/main/Main.hs b/tests/integration/tests/32-unlisted-module/files/src/main/Main.hs deleted file mode 100644 index b768742deb..0000000000 --- a/tests/integration/tests/32-unlisted-module/files/src/main/Main.hs +++ /dev/null @@ -1,3 +0,0 @@ -module Main where - -main = do putStrLn "Hello, world." diff --git a/tests/integration/tests/32-unlisted-module/files/stack.yaml b/tests/integration/tests/32-unlisted-module/files/stack.yaml index b54fd809bf..5490d5880f 100644 --- a/tests/integration/tests/32-unlisted-module/files/stack.yaml +++ b/tests/integration/tests/32-unlisted-module/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: lts-24.43 diff --git a/tests/integration/tests/3229-exe-targets/Main.hs b/tests/integration/tests/3229-exe-targets/Main.hs deleted file mode 100644 index 0cc4674561..0000000000 --- a/tests/integration/tests/3229-exe-targets/Main.hs +++ /dev/null @@ -1,42 +0,0 @@ --- | Stack should build all executables once, and in subsequent --- invocations only build those executables requested by the program --- arguments. --- --- Issue: https://github.com/commercialhaskell/stack/issues/3229 - -module Main where - -import Control.Exception -import Control.Monad (unless, when) -import qualified Data.ByteString as S -import Data.List (isInfixOf) -import StackTest - -main :: IO () -main = do - removeDirIgnore ".stack-work" - removeFileIgnore "stack.yaml" - stack [defaultSnapshotArg, "init"] - stack ["build", ":alpha"] - bracket - (S.readFile alphaFile) - (S.writeFile alphaFile) - (const - (do appendFile alphaFile "\n--" - stackCheckStderr - ["build", ":alpha"] - (rejectMessage - (unlines - ["Preprocessing executable 'beta' for foo-0..."])))) - where - alphaFile = "app/Alpha.hs" - -expectMessage :: String -> String -> IO () -expectMessage msg stderr = - unless (msg `isInfixOf` stderr) - (error $ "Expected in output: \n" ++ show msg) - -rejectMessage :: String -> String -> IO () -rejectMessage msg stderr = - when (msg `isInfixOf` stderr) - (error $ "Did not expect message here: \n" ++ show msg) diff --git a/tests/integration/tests/3229-exe-targets/files/.gitignore b/tests/integration/tests/3229-exe-targets/files/.gitignore deleted file mode 100644 index 684dbffa96..0000000000 --- a/tests/integration/tests/3229-exe-targets/files/.gitignore +++ /dev/null @@ -1 +0,0 @@ -stack.yaml diff --git a/tests/integration/tests/3229-exe-targets/files/app/Alpha.hs b/tests/integration/tests/3229-exe-targets/files/app/Alpha.hs deleted file mode 100644 index 76a9bdb5d4..0000000000 --- a/tests/integration/tests/3229-exe-targets/files/app/Alpha.hs +++ /dev/null @@ -1 +0,0 @@ -main = pure () diff --git a/tests/integration/tests/3229-exe-targets/files/app/Beta.hs b/tests/integration/tests/3229-exe-targets/files/app/Beta.hs deleted file mode 100644 index 76a9bdb5d4..0000000000 --- a/tests/integration/tests/3229-exe-targets/files/app/Beta.hs +++ /dev/null @@ -1 +0,0 @@ -main = pure () diff --git a/tests/integration/tests/3229-exe-targets/files/foo.cabal b/tests/integration/tests/3229-exe-targets/files/foo.cabal deleted file mode 100644 index 4a68648e6d..0000000000 --- a/tests/integration/tests/3229-exe-targets/files/foo.cabal +++ /dev/null @@ -1,22 +0,0 @@ -name: foo -version: 0 -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Foo - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 - -executable alpha - hs-source-dirs: app - main-is: Alpha.hs - build-depends: base, foo - default-language: Haskell2010 - -executable beta - hs-source-dirs: app - main-is: Beta.hs - build-depends: base, foo - default-language: Haskell2010 diff --git a/tests/integration/tests/3229-exe-targets/files/src/Foo.hs b/tests/integration/tests/3229-exe-targets/files/src/Foo.hs deleted file mode 100644 index efbf93bbde..0000000000 --- a/tests/integration/tests/3229-exe-targets/files/src/Foo.hs +++ /dev/null @@ -1 +0,0 @@ -module Foo where diff --git a/tests/integration/tests/3315-multi-ghc-options/Main.hs b/tests/integration/tests/3315-multi-ghc-options/Main.hs index 60d8c9eec4..bf93687b96 100644 --- a/tests/integration/tests/3315-multi-ghc-options/Main.hs +++ b/tests/integration/tests/3315-multi-ghc-options/Main.hs @@ -1,6 +1,10 @@ -import StackTest.Repl +-- Stack allows one or more GHC options to be specified on the command line. +-- +-- See: https://github.com/commercialhaskell/stack/issues/3315 + +import StackTest.Repl main :: IO () main = do - stack ["build", "--ghc-options=-ddump-simpl -ddump-asm -DBAR -DBAZ"] + stack ["build", "--ghc-options=-ddump-simpl -ddump-asm -DVARIABLE_A -DVARIABLE_B"] stackRepl ["--ghc-options=-ddump-simpl -ddump-asm"] (pure ()) diff --git a/tests/integration/tests/3315-multi-ghc-options/files/.gitignore b/tests/integration/tests/3315-multi-ghc-options/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/3315-multi-ghc-options/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/3315-multi-ghc-options/files/multi-ghc-options.cabal b/tests/integration/tests/3315-multi-ghc-options/files/multi-ghc-options.cabal deleted file mode 100644 index 2f25278446..0000000000 --- a/tests/integration/tests/3315-multi-ghc-options/files/multi-ghc-options.cabal +++ /dev/null @@ -1,10 +0,0 @@ -name: multi-ghc-options -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 diff --git a/tests/integration/tests/2997-ensure-warnings-output/files/foo/package.yaml b/tests/integration/tests/3315-multi-ghc-options/files/package.yaml similarity index 54% rename from tests/integration/tests/2997-ensure-warnings-output/files/foo/package.yaml rename to tests/integration/tests/3315-multi-ghc-options/files/package.yaml index 0de19a6188..a7305a77cf 100644 --- a/tests/integration/tests/2997-ensure-warnings-output/files/foo/package.yaml +++ b/tests/integration/tests/3315-multi-ghc-options/files/package.yaml @@ -1,9 +1,9 @@ -name: foo -version: 0 +spec-version: 0.36.0 + +name: myPackage dependencies: - base library: source-dirs: src - ghc-options: -Wall diff --git a/tests/integration/tests/3315-multi-ghc-options/files/src/Lib.hs b/tests/integration/tests/3315-multi-ghc-options/files/src/Lib.hs index b3b76855c2..71ccd7f83b 100644 --- a/tests/integration/tests/3315-multi-ghc-options/files/src/Lib.hs +++ b/tests/integration/tests/3315-multi-ghc-options/files/src/Lib.hs @@ -5,12 +5,12 @@ module Lib where -- Avoid problems with CPP and HLint #ifndef __HLINT__ -#ifndef BAR -#error BAR isn't defined +#ifndef VARIABLE_A +#error VARIABLE_A isn't defined #endif -#ifndef BAZ -#error BAZ isn't defined +#ifndef VARIABLE_B +#error VARIABLE_B isn't defined #endif #endif diff --git a/tests/integration/tests/3315-multi-ghc-options/files/stack.yaml b/tests/integration/tests/3315-multi-ghc-options/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/3315-multi-ghc-options/files/stack.yaml +++ b/tests/integration/tests/3315-multi-ghc-options/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/335-multi-package-flags/Main.hs b/tests/integration/tests/335-multi-package-flags/Main.hs index e9ff7fa6ac..4e6aa05311 100644 --- a/tests/integration/tests/335-multi-package-flags/Main.hs +++ b/tests/integration/tests/335-multi-package-flags/Main.hs @@ -1,8 +1,13 @@ -import StackTest +-- Stack should be able to specify Cabal flags for all packages that have a +-- Cabal flag of the same name. +-- +-- See: https://github.com/commercialhaskell/stack/issues/335 + +import StackTest main :: IO () main = do - stackErr ["build"] - stack ["build", "--flag", "new-template:necessary"] - stackErr ["build"] - stack ["build", "--flag", "*:necessary"] + stackErr ["build"] + stack ["build", "--flag", "myPackage:necessary"] + stackErr ["build"] + stack ["build", "--flag", "*:necessary"] diff --git a/tests/integration/tests/335-multi-package-flags/files/.gitignore b/tests/integration/tests/335-multi-package-flags/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/335-multi-package-flags/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/335-multi-package-flags/files/Setup.hs b/tests/integration/tests/335-multi-package-flags/files/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/335-multi-package-flags/files/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/335-multi-package-flags/files/new-template.cabal b/tests/integration/tests/335-multi-package-flags/files/new-template.cabal deleted file mode 100644 index 50876be0ce..0000000000 --- a/tests/integration/tests/335-multi-package-flags/files/new-template.cabal +++ /dev/null @@ -1,17 +0,0 @@ -name: new-template -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -flag necessary - manual: True - default: False - description: Won't build without this flag on - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base - default-language: Haskell2010 - if flag(necessary) - cpp-options: -DWORK diff --git a/tests/integration/tests/335-multi-package-flags/files/package.yaml b/tests/integration/tests/335-multi-package-flags/files/package.yaml new file mode 100644 index 0000000000..973e01a4f6 --- /dev/null +++ b/tests/integration/tests/335-multi-package-flags/files/package.yaml @@ -0,0 +1,18 @@ +spec-version: 0.36.0 + +name: myPackage + +flags: + necessary: + description: The package will not build unless this flag is true. + manual: true + default: false + +dependencies: +- base + +library: + source-dirs: src + when: + - condition: flag(necessary) + cpp-options: -DWORK diff --git a/tests/integration/tests/335-multi-package-flags/files/src/Lib.hs b/tests/integration/tests/335-multi-package-flags/files/src/Lib.hs index 12a75ea899..eccdf60245 100644 --- a/tests/integration/tests/335-multi-package-flags/files/src/Lib.hs +++ b/tests/integration/tests/335-multi-package-flags/files/src/Lib.hs @@ -1,10 +1,6 @@ {-# LANGUAGE CPP #-} -module Lib - ( someFunc - ) where -someFunc :: IO () -someFunc = putStrLn "someFunc" +module Lib where -- Avoid problems with CPP and HLint #ifndef __HLINT__ diff --git a/tests/integration/tests/335-multi-package-flags/files/stack.yaml b/tests/integration/tests/335-multi-package-flags/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/335-multi-package-flags/files/stack.yaml +++ b/tests/integration/tests/335-multi-package-flags/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/3390-unbuildable-test/Main.hs b/tests/integration/tests/3390-unbuildable-test/Main.hs index fb222afc69..d6e021b8b4 100644 --- a/tests/integration/tests/3390-unbuildable-test/Main.hs +++ b/tests/integration/tests/3390-unbuildable-test/Main.hs @@ -1,4 +1,8 @@ -import StackTest +-- Stack ignores test suites that are not buildable. +-- +-- See: https://github.com/commercialhaskell/stack/issues/3390 + +import StackTest main :: IO () main = stack ["test"] diff --git a/tests/integration/tests/3390-unbuildable-test/files/.gitignore b/tests/integration/tests/3390-unbuildable-test/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/3390-unbuildable-test/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/3390-unbuildable-test/files/files.cabal b/tests/integration/tests/3390-unbuildable-test/files/files.cabal deleted file mode 100644 index 4909fb438a..0000000000 --- a/tests/integration/tests/3390-unbuildable-test/files/files.cabal +++ /dev/null @@ -1,18 +0,0 @@ -name: files -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base - default-language: Haskell2010 - -test-suite test - type: exitcode-stdio-1.0 - hs-source-dirs: test - main-is: Spec.hs - build-depends: base - default-language: Haskell2010 - buildable: False \ No newline at end of file diff --git a/tests/integration/tests/3390-unbuildable-test/files/package.yaml b/tests/integration/tests/3390-unbuildable-test/files/package.yaml new file mode 100644 index 0000000000..da5df8ac33 --- /dev/null +++ b/tests/integration/tests/3390-unbuildable-test/files/package.yaml @@ -0,0 +1,9 @@ +spec-version: 0.36.0 + +name: myPackage + +tests: + myTest: + source-dirs: test + main: Main.hs + buildable: false diff --git a/tests/integration/tests/3390-unbuildable-test/files/src/Lib.hs b/tests/integration/tests/3390-unbuildable-test/files/src/Lib.hs deleted file mode 100644 index e1ee993010..0000000000 --- a/tests/integration/tests/3390-unbuildable-test/files/src/Lib.hs +++ /dev/null @@ -1 +0,0 @@ -module Lib () where diff --git a/tests/integration/tests/3390-unbuildable-test/files/test/Spec.hs b/tests/integration/tests/3390-unbuildable-test/files/test/Main.hs similarity index 100% rename from tests/integration/tests/3390-unbuildable-test/files/test/Spec.hs rename to tests/integration/tests/3390-unbuildable-test/files/test/Main.hs diff --git a/tests/integration/tests/3431-precompiled-works/Main.hs b/tests/integration/tests/3431-precompiled-works/Main.hs index 7d9e8ce5c5..33d2ef971a 100644 --- a/tests/integration/tests/3431-precompiled-works/Main.hs +++ b/tests/integration/tests/3431-precompiled-works/Main.hs @@ -1,10 +1,14 @@ -import StackTest -import Control.Monad -import Data.List +-- Stack uses pre-compiled immutable packages where it can. +-- +-- See: https://github.com/commercialhaskell/stack/issues/3431 + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest main :: IO () main = do - stack ["build", "random-1.1", "--stack-yaml", "custom1/stack.yaml"] - stackCheckStderr ["build", "random-1.1", "--stack-yaml", "custom2/stack.yaml"] $ \out -> do - print out - unless ("precompiled" `isInfixOf` out) $ error "Didn't use precompiled!" + stack ["build", "random-1.1", "--stack-yaml", "custom1/stack.yaml"] + stackCheckStderr ["build", "random-1.1", "--stack-yaml", "custom2/stack.yaml"] $ \out -> do + print out + unless ("precompiled" `isInfixOf` out) $ error "Didn't use precompiled!" diff --git a/tests/integration/tests/3431-precompiled-works/files/custom1/custom1.yaml b/tests/integration/tests/3431-precompiled-works/files/custom1/custom1.yaml index f0236625e2..5223c8b3e3 100644 --- a/tests/integration/tests/3431-precompiled-works/files/custom1/custom1.yaml +++ b/tests/integration/tests/3431-precompiled-works/files/custom1/custom1.yaml @@ -1,4 +1,4 @@ -snapshot: ghc-9.10.3 name: custom1 +snapshot: ghc-9.10.3 packages: - acme-missiles-0.3 diff --git a/tests/integration/tests/3431-precompiled-works/files/custom2/custom2.yaml b/tests/integration/tests/3431-precompiled-works/files/custom2/custom2.yaml index 8f88ff08da..566739fa3e 100644 --- a/tests/integration/tests/3431-precompiled-works/files/custom2/custom2.yaml +++ b/tests/integration/tests/3431-precompiled-works/files/custom2/custom2.yaml @@ -1,4 +1,4 @@ -snapshot: ghc-9.10.3 name: custom2 +snapshot: ghc-9.10.3 packages: - acme-missiles-0.2 diff --git a/tests/integration/tests/345-override-bytestring/Main.hs b/tests/integration/tests/345-override-bytestring/Main.hs index 248a59a3df..1e1d847024 100644 --- a/tests/integration/tests/345-override-bytestring/Main.hs +++ b/tests/integration/tests/345-override-bytestring/Main.hs @@ -1,6 +1,9 @@ -import StackTest +-- An extra-dep in a project-level configuration file should be able to shadow a +-- GHC boot package such as bytestring. +-- +-- See: https://github.com/commercialhaskell/stack/issues/345 + +import StackTest main :: IO () -main = do - stack ["build", "--dry-run"] -- for useful error output - stack ["build"] +main = stack ["build"] diff --git a/tests/integration/tests/345-override-bytestring/files/.gitignore b/tests/integration/tests/345-override-bytestring/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/345-override-bytestring/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/345-override-bytestring/files/Foo.hs b/tests/integration/tests/345-override-bytestring/files/Foo.hs deleted file mode 100644 index d282cc6fb6..0000000000 --- a/tests/integration/tests/345-override-bytestring/files/Foo.hs +++ /dev/null @@ -1,4 +0,0 @@ -module Foo where - -import Data.Binary () -import Data.ByteString () diff --git a/tests/integration/tests/345-override-bytestring/files/foo.cabal b/tests/integration/tests/345-override-bytestring/files/foo.cabal deleted file mode 100644 index 4c23cac18d..0000000000 --- a/tests/integration/tests/345-override-bytestring/files/foo.cabal +++ /dev/null @@ -1,10 +0,0 @@ -name: foo -version: 0.0.0 -synopsis: foo -build-type: Simple -cabal-version: >=1.10 - -library - exposed-modules: Foo - build-depends: base, bytestring, binary - default-language: Haskell2010 diff --git a/tests/integration/tests/345-override-bytestring/files/package.yaml b/tests/integration/tests/345-override-bytestring/files/package.yaml new file mode 100644 index 0000000000..4259e06ace --- /dev/null +++ b/tests/integration/tests/345-override-bytestring/files/package.yaml @@ -0,0 +1,10 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base +- bytestring + +library: + source-dirs: src diff --git a/tests/integration/tests/345-override-bytestring/files/src/Lib.hs b/tests/integration/tests/345-override-bytestring/files/src/Lib.hs new file mode 100644 index 0000000000..c06ea6cd1f --- /dev/null +++ b/tests/integration/tests/345-override-bytestring/files/src/Lib.hs @@ -0,0 +1,3 @@ +module Lib where + +import Data.ByteString () diff --git a/tests/integration/tests/345-override-bytestring/files/stack.yaml b/tests/integration/tests/345-override-bytestring/files/stack.yaml index a5b500081d..8d391e6d16 100644 --- a/tests/integration/tests/345-override-bytestring/files/stack.yaml +++ b/tests/integration/tests/345-override-bytestring/files/stack.yaml @@ -1,4 +1,5 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 + extra-deps: -- bytestring-0.11.5.4 -- binary-0.8.9.0 +# GHC 9.10.3 comes with bytestring-0.12.2.0 +- bytestring-0.12.1.0 diff --git a/tests/integration/tests/3520-revision-matching/Main.hs b/tests/integration/tests/3520-revision-matching/Main.hs deleted file mode 100644 index 5d01c83bf3..0000000000 --- a/tests/integration/tests/3520-revision-matching/Main.hs +++ /dev/null @@ -1,16 +0,0 @@ -import StackTest -import Control.Monad -import Data.List -import System.Directory - -main :: IO () -main = do - putStrLn "Test disabled due to switch to pantry" - {- - copyFile "bad-stack.yaml" "stack.yaml" - stackErrStderr ["build", "--dry-run"] $ \msg -> - unless ("legacy 00-index.tar.gz" `isInfixOf` msg) $ - error "Expected a warning about 00-index usage" - copyFile "good-stack.yaml" "stack.yaml" - stack ["build", "--dry-run"] - -} diff --git a/tests/integration/tests/3520-revision-matching/files/.gitignore b/tests/integration/tests/3520-revision-matching/files/.gitignore deleted file mode 100644 index b894371d9b..0000000000 --- a/tests/integration/tests/3520-revision-matching/files/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -stack.yaml -*.cabal diff --git a/tests/integration/tests/3520-revision-matching/files/bad-stack.yaml b/tests/integration/tests/3520-revision-matching/files/bad-stack.yaml deleted file mode 100644 index a3f25cb2cf..0000000000 --- a/tests/integration/tests/3520-revision-matching/files/bad-stack.yaml +++ /dev/null @@ -1,6 +0,0 @@ -snapshot: lts-10.10 - -package-indices: -- name: Hackage00 - download-prefix: https://hackage.haskell.org/package - http: https://hackage.haskell.org/00-index.tar.gz diff --git a/tests/integration/tests/3520-revision-matching/files/good-stack.yaml b/tests/integration/tests/3520-revision-matching/files/good-stack.yaml deleted file mode 100644 index da70439a3d..0000000000 --- a/tests/integration/tests/3520-revision-matching/files/good-stack.yaml +++ /dev/null @@ -1,8 +0,0 @@ -snapshot: lts-10.10 - -package-indices: -- name: Hackage00 - download-prefix: https://hackage.haskell.org/package - http: https://hackage.haskell.org/00-index.tar.gz - -ignore-revision-mismatch: true diff --git a/tests/integration/tests/3520-revision-matching/files/src/Foo.hs b/tests/integration/tests/3520-revision-matching/files/src/Foo.hs deleted file mode 100644 index efbf93bbde..0000000000 --- a/tests/integration/tests/3520-revision-matching/files/src/Foo.hs +++ /dev/null @@ -1 +0,0 @@ -module Foo where diff --git a/tests/integration/tests/3533-extra-deps-solver/Main.hs b/tests/integration/tests/3533-extra-deps-solver/Main.hs deleted file mode 100644 index b5bafedd7b..0000000000 --- a/tests/integration/tests/3533-extra-deps-solver/Main.hs +++ /dev/null @@ -1,15 +0,0 @@ -{-- - -import StackTest -import System.Directory - -main :: IO () -main = do - copyFile "orig-stack.yaml" "stack.yaml" - stack [defaultResolverArg, "solver", "--update-config"] - stack ["build"] - -// --} - -main :: IO () -main = putStrLn "This test is disabled (see https://github.com/commercialhaskell/stack/issues/4410)." diff --git a/tests/integration/tests/3533-extra-deps-solver/files/.gitignore b/tests/integration/tests/3533-extra-deps-solver/files/.gitignore deleted file mode 100644 index 4c65edffd7..0000000000 --- a/tests/integration/tests/3533-extra-deps-solver/files/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.stack-work/ -*.cabal -stack.yaml diff --git a/tests/integration/tests/3533-extra-deps-solver/files/local-mmorph/package.yaml b/tests/integration/tests/3533-extra-deps-solver/files/local-mmorph/package.yaml deleted file mode 100644 index 05a16e68a5..0000000000 --- a/tests/integration/tests/3533-extra-deps-solver/files/local-mmorph/package.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: mmorph -version: 1.2.0 - -dependencies: -- base -- acme-missiles - -library: - source-dirs: - - src diff --git a/tests/integration/tests/3533-extra-deps-solver/files/orig-stack.yaml b/tests/integration/tests/3533-extra-deps-solver/files/orig-stack.yaml deleted file mode 100644 index 3557343998..0000000000 --- a/tests/integration/tests/3533-extra-deps-solver/files/orig-stack.yaml +++ /dev/null @@ -1,5 +0,0 @@ -snapshot: lts-24.24 - -packages: -- ./local-mmorph -- ./uses-mmorph diff --git a/tests/integration/tests/3533-extra-deps-solver/files/uses-mmorph/package.yaml b/tests/integration/tests/3533-extra-deps-solver/files/uses-mmorph/package.yaml deleted file mode 100644 index cd73e5ab0f..0000000000 --- a/tests/integration/tests/3533-extra-deps-solver/files/uses-mmorph/package.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: uses-mmorph -version: 1.2.0 - -dependencies: -- base -- mmorph >= 1.1 - -library: - source-dirs: - - src diff --git a/tests/integration/tests/3533-extra-deps-solver/files/uses-mmorph/src/Lib.hs b/tests/integration/tests/3533-extra-deps-solver/files/uses-mmorph/src/Lib.hs deleted file mode 100644 index d36ff2714d..0000000000 --- a/tests/integration/tests/3533-extra-deps-solver/files/uses-mmorph/src/Lib.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Lib - ( someFunc - ) where - -someFunc :: IO () -someFunc = putStrLn "someFunc" diff --git a/tests/integration/tests/3574-extra-dep-local/Main.hs b/tests/integration/tests/3574-extra-dep-local/Main.hs index b1b93683df..e9b1b0286b 100644 --- a/tests/integration/tests/3574-extra-dep-local/Main.hs +++ b/tests/integration/tests/3574-extra-dep-local/Main.hs @@ -1,4 +1,9 @@ -import StackTest +-- Stack can target a local extra-dep and distinguishes local extra-deps from +-- local packages, when applying GHC options to local packages. +-- +-- See: https://github.com/commercialhaskell/stack/issues/3574 + +import StackTest main :: IO () -main = stack ["build", "foo"] +main = stack ["build", "myPackage"] diff --git a/tests/integration/tests/3574-extra-dep-local/files/.gitignore b/tests/integration/tests/3574-extra-dep-local/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/3574-extra-dep-local/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/3574-extra-dep-local/files/foo/Foo.hs b/tests/integration/tests/3574-extra-dep-local/files/foo/Foo.hs deleted file mode 100644 index a23b501b27..0000000000 --- a/tests/integration/tests/3574-extra-dep-local/files/foo/Foo.hs +++ /dev/null @@ -1,3 +0,0 @@ -module Foo(foo) where - -foo = "foo" diff --git a/tests/integration/tests/3574-extra-dep-local/files/foo/foo.cabal b/tests/integration/tests/3574-extra-dep-local/files/foo/foo.cabal deleted file mode 100644 index b37e615a97..0000000000 --- a/tests/integration/tests/3574-extra-dep-local/files/foo/foo.cabal +++ /dev/null @@ -1,8 +0,0 @@ -cabal-version: >= 1.2 -build-type: Simple -name: foo -version: 0 - -library - build-depends: base - exposed-modules: Foo diff --git a/tests/integration/tests/3574-extra-dep-local/files/myPackage/package.yaml b/tests/integration/tests/3574-extra-dep-local/files/myPackage/package.yaml new file mode 100644 index 0000000000..a7305a77cf --- /dev/null +++ b/tests/integration/tests/3574-extra-dep-local/files/myPackage/package.yaml @@ -0,0 +1,9 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src diff --git a/tests/integration/tests/3574-extra-dep-local/files/myPackage/src/Lib.hs b/tests/integration/tests/3574-extra-dep-local/files/myPackage/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/3574-extra-dep-local/files/myPackage/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/3574-extra-dep-local/files/stack.yaml b/tests/integration/tests/3574-extra-dep-local/files/stack.yaml index 828a411b7a..991c6d6ede 100644 --- a/tests/integration/tests/3574-extra-dep-local/files/stack.yaml +++ b/tests/integration/tests/3574-extra-dep-local/files/stack.yaml @@ -3,7 +3,7 @@ snapshot: ghc-9.10.3 packages: [] extra-deps: -- foo +- myPackage ghc-options: - $locals: -bob + $locals: -dummy diff --git a/tests/integration/tests/3591-cabal-warnings-once/Main.hs b/tests/integration/tests/3591-cabal-warnings-once/Main.hs index 4efb8cb5e8..c094b33158 100644 --- a/tests/integration/tests/3591-cabal-warnings-once/Main.hs +++ b/tests/integration/tests/3591-cabal-warnings-once/Main.hs @@ -1,10 +1,14 @@ -import StackTest -import Data.List (isInfixOf) +-- Stack warns about unknown fields in Cabal files, but only once. +-- +-- https://github.com/commercialhaskell/stack/issues/3591 + +import Data.List ( isInfixOf ) +import StackTest main :: IO () main = do stackCheckStderr ["build", "--dry-run"] $ \str -> - case filter ("unknown-field-name" `isInfixOf`) (lines str) of - [] -> error "unknown-field-name didn't appear once" + case filter ("unknown-cabal-field-name" `isInfixOf`) (lines str) of + [] -> error "unknown-Cabal-field-name didn't appear once" [_] -> pure () - _:_:_ -> error "unknown-field-name appeared multiple times" + _:_:_ -> error "unknown-Cabal-field-name appeared multiple times" diff --git a/tests/integration/tests/3591-cabal-warnings-once/files/.gitignore b/tests/integration/tests/3591-cabal-warnings-once/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/3591-cabal-warnings-once/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/3591-cabal-warnings-once/files/foo.cabal b/tests/integration/tests/3591-cabal-warnings-once/files/foo.cabal deleted file mode 100644 index 411bd8742d..0000000000 --- a/tests/integration/tests/3591-cabal-warnings-once/files/foo.cabal +++ /dev/null @@ -1,16 +0,0 @@ --- This file has been generated from package.yaml by hpack version 0.20.0. --- --- see: https://github.com/sol/hpack --- --- hash: 43a4e1612fc5dee2ab88c588fee639840be01569a600ab2955961c341b89058d - -name: foo -version: 0.1.0.0 -build-type: Simple -cabal-version: >= 1.10 - -unknown-field-name: makes a warning! - -library - hs-source-dirs: src - exposed-modules: Lib diff --git a/tests/integration/tests/3591-cabal-warnings-once/files/package.yaml b/tests/integration/tests/3591-cabal-warnings-once/files/package.yaml new file mode 100644 index 0000000000..a3a9b0e627 --- /dev/null +++ b/tests/integration/tests/3591-cabal-warnings-once/files/package.yaml @@ -0,0 +1,12 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src + +verbatim: + unknown-Cabal-field-name: makes a warning! diff --git a/tests/integration/tests/3591-cabal-warnings-once/files/stack.yaml b/tests/integration/tests/3591-cabal-warnings-once/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/3591-cabal-warnings-once/files/stack.yaml +++ b/tests/integration/tests/3591-cabal-warnings-once/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/3631-build-http2/Main.hs b/tests/integration/tests/3631-build-http2/Main.hs index 0a9bc97218..86e1a37637 100644 --- a/tests/integration/tests/3631-build-http2/Main.hs +++ b/tests/integration/tests/3631-build-http2/Main.hs @@ -1,4 +1,8 @@ -import StackTest +-- Stack can build the http2 package. +-- +-- https://github.com/commercialhaskell/stack/issues/3631 + +import StackTest main :: IO () main = do diff --git a/tests/integration/tests/365-invalid-success/Main.hs b/tests/integration/tests/365-invalid-success/Main.hs index b978282dd4..64a1e640a0 100644 --- a/tests/integration/tests/365-invalid-success/Main.hs +++ b/tests/integration/tests/365-invalid-success/Main.hs @@ -1,11 +1,17 @@ -import StackTest +-- If Stack fails to build a package once, it should fail to build it +-- (unchanged) a second time. +-- +-- See: https://github.com/commercialhaskell/stack/issues/365 + +import StackTest main :: IO () main = do - stackErr ["build"] - stackErr ["build"] - writeFile "app/Foo.hs" "module Foo where" - stack ["build"] - writeFile "app/Foo.hs" "module Foo wher e" - stackErr ["build"] - stackErr ["build"] + copy "src/Lib_FAIL.hs" "src/Lib.hs" + stackErr ["build"] + stackErr ["build"] + copy "src/Lib_OK.hs" "src/Lib.hs" + stack ["build"] + copy "src/Lib_FAIL.hs" "src/Lib.hs" + stackErr ["build"] + stackErr ["build"] diff --git a/tests/integration/tests/365-invalid-success/files/.gitignore b/tests/integration/tests/365-invalid-success/files/.gitignore index 8fec4903f5..bf0c94dd4e 100644 --- a/tests/integration/tests/365-invalid-success/files/.gitignore +++ b/tests/integration/tests/365-invalid-success/files/.gitignore @@ -1 +1,2 @@ -app/Foo.hs +src/Lib.hs +myPackage.cabal diff --git a/tests/integration/tests/365-invalid-success/files/new-template.cabal b/tests/integration/tests/365-invalid-success/files/new-template.cabal deleted file mode 100644 index 6ab719dc58..0000000000 --- a/tests/integration/tests/365-invalid-success/files/new-template.cabal +++ /dev/null @@ -1,12 +0,0 @@ -name: new-template -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -executable new-template-exe - hs-source-dirs: app - main-is: Main.hs - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: base - default-language: Haskell2010 - other-modules: Foo diff --git a/tests/integration/tests/365-invalid-success/files/package.yaml b/tests/integration/tests/365-invalid-success/files/package.yaml new file mode 100644 index 0000000000..bb02298ab5 --- /dev/null +++ b/tests/integration/tests/365-invalid-success/files/package.yaml @@ -0,0 +1,12 @@ +spec-version: 0.36.0 + +name: myPackageA + +dependencies: +- base + +library: + source-dirs: src + exposed-modules: + - Lib + other-modules: [] diff --git a/tests/integration/tests/365-invalid-success/files/src/Lib_FAIL.hs b/tests/integration/tests/365-invalid-success/files/src/Lib_FAIL.hs new file mode 100644 index 0000000000..764550ce44 --- /dev/null +++ b/tests/integration/tests/365-invalid-success/files/src/Lib_FAIL.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE CPP #-} + +-- | Version of Lib that does not compile. +module Lib where + +-- Avoid problems with CPP and HLint +#ifndef __HLINT__ + +#error Not going to compile, sorry + +#endif diff --git a/tests/integration/tests/365-invalid-success/files/src/Lib_OK.hs b/tests/integration/tests/365-invalid-success/files/src/Lib_OK.hs new file mode 100644 index 0000000000..8745d54bd6 --- /dev/null +++ b/tests/integration/tests/365-invalid-success/files/src/Lib_OK.hs @@ -0,0 +1,2 @@ +-- | Version of Lib that does compile. +module Lib where diff --git a/tests/integration/tests/365-invalid-success/files/stack.yaml b/tests/integration/tests/365-invalid-success/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/365-invalid-success/files/stack.yaml +++ b/tests/integration/tests/365-invalid-success/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/366-non-root-dir/Main.hs b/tests/integration/tests/366-non-root-dir/Main.hs index f1dd62cefb..1a7697a78a 100644 --- a/tests/integration/tests/366-non-root-dir/Main.hs +++ b/tests/integration/tests/366-non-root-dir/Main.hs @@ -1,10 +1,12 @@ -import StackTest -import System.Directory +-- Stack builds when commanded from a subdirectory of the project directory. +-- +-- See: https://github.com/commercialhaskell/stack/issues/366 + +import StackTest +import System.Directory ( setCurrentDirectory ) main :: IO () main = do - removeDirIgnore ".stack-work" - stackErr ["exec", "hello-world"] - setCurrentDirectory "app" - stack ["build"] - stack ["exec", "hello-world"] + setCurrentDirectory "app" + stack ["build"] + stack ["exec", "myExe"] diff --git a/tests/integration/tests/366-non-root-dir/files/.gitignore b/tests/integration/tests/366-non-root-dir/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/366-non-root-dir/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/366-non-root-dir/files/app/Main.hs b/tests/integration/tests/366-non-root-dir/files/app/Main.hs index d582e1e36a..89ad4b3e08 100644 --- a/tests/integration/tests/366-non-root-dir/files/app/Main.hs +++ b/tests/integration/tests/366-non-root-dir/files/app/Main.hs @@ -1,2 +1,4 @@ +module Main where + main :: IO () main = pure () diff --git a/tests/integration/tests/366-non-root-dir/files/new-template.cabal b/tests/integration/tests/366-non-root-dir/files/new-template.cabal deleted file mode 100644 index 1ce3458647..0000000000 --- a/tests/integration/tests/366-non-root-dir/files/new-template.cabal +++ /dev/null @@ -1,11 +0,0 @@ -name: new-template -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -executable hello-world - hs-source-dirs: app - main-is: Main.hs - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: base - default-language: Haskell2010 diff --git a/tests/integration/tests/366-non-root-dir/files/package.yaml b/tests/integration/tests/366-non-root-dir/files/package.yaml new file mode 100644 index 0000000000..ee1f9f8afa --- /dev/null +++ b/tests/integration/tests/366-non-root-dir/files/package.yaml @@ -0,0 +1,11 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +executables: + myExe: + source-dirs: app + main: Main.hs diff --git a/tests/integration/tests/366-non-root-dir/files/stack.yaml b/tests/integration/tests/366-non-root-dir/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/366-non-root-dir/files/stack.yaml +++ b/tests/integration/tests/366-non-root-dir/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/3685-config-yaml-for-allow-newer/Main.hs b/tests/integration/tests/3685-config-yaml-for-allow-newer/Main.hs index f9679e8a0b..09d8c46d6e 100644 --- a/tests/integration/tests/3685-config-yaml-for-allow-newer/Main.hs +++ b/tests/integration/tests/3685-config-yaml-for-allow-newer/Main.hs @@ -1,19 +1,21 @@ -import Control.Monad (unless) -import Data.List (isInfixOf) -import StackTest -import System.Directory +-- Stack advises the use of allow-newer in a configuration file if the package +-- versions needed are not the version in the snapshot. +-- +-- See: https://github.com/commercialhaskell/stack/issues/3685 + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest planRecommendation :: String planRecommendation = "To ignore all version constraints" main :: IO () -main = do - removeFileIgnore "stack.yaml" - stack ["init", defaultSnapshotArg] +main = -- intero-0.1.23 chosen because it depends on ghc >=7.8 && <8.2.2. stackErrStderr ["install", "intero-0.1.23"] (expectMessage planRecommendation) expectMessage :: String -> String -> IO () expectMessage msg stderr = do - unless (words msg `isInfixOf` words stderr) - (error $ "Expected a recommendation: \n" ++ show msg) + unless (words msg `isInfixOf` words stderr) $ + error $ "Expected a recommendation: \n" ++ show msg diff --git a/tests/integration/tests/3685-config-yaml-for-allow-newer/files/.gitignore b/tests/integration/tests/3685-config-yaml-for-allow-newer/files/.gitignore deleted file mode 100644 index 684dbffa96..0000000000 --- a/tests/integration/tests/3685-config-yaml-for-allow-newer/files/.gitignore +++ /dev/null @@ -1 +0,0 @@ -stack.yaml diff --git a/tests/integration/tests/3685-config-yaml-for-allow-newer/files/stack.yaml b/tests/integration/tests/3685-config-yaml-for-allow-newer/files/stack.yaml new file mode 100644 index 0000000000..5bb59ca11d --- /dev/null +++ b/tests/integration/tests/3685-config-yaml-for-allow-newer/files/stack.yaml @@ -0,0 +1,3 @@ +snapshot: lts-24.43 + +packages: [] diff --git a/tests/integration/tests/370-invalid-setup-hs/Main.hs b/tests/integration/tests/370-invalid-setup-hs/Main.hs index e61b083aa4..08d1440472 100644 --- a/tests/integration/tests/370-invalid-setup-hs/Main.hs +++ b/tests/integration/tests/370-invalid-setup-hs/Main.hs @@ -1,4 +1,8 @@ -import StackTest +-- Stack ignores a package's Setup.hs file when the Cabal build type is Simple. +-- +-- See: https://github.com/commercialhaskell/stack/issues/370 + +import StackTest main :: IO () main = stack ["build"] diff --git a/tests/integration/tests/370-invalid-setup-hs/files/.gitignore b/tests/integration/tests/370-invalid-setup-hs/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/370-invalid-setup-hs/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/370-invalid-setup-hs/files/LICENSE b/tests/integration/tests/370-invalid-setup-hs/files/LICENSE deleted file mode 100644 index d05408d876..0000000000 --- a/tests/integration/tests/370-invalid-setup-hs/files/LICENSE +++ /dev/null @@ -1,30 +0,0 @@ -Copyright (c) 2000 - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Your name here nor the names of other - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tests/integration/tests/370-invalid-setup-hs/files/Setup.hs b/tests/integration/tests/370-invalid-setup-hs/files/Setup.hs index 4b147db695..58838f89a6 100644 --- a/tests/integration/tests/370-invalid-setup-hs/files/Setup.hs +++ b/tests/integration/tests/370-invalid-setup-hs/files/Setup.hs @@ -1,2 +1,10 @@ -import Distribution.Make (defaultMain) -main = defaultMain +{-# LANGUAGE CPP #-} + +-- A bogus Setup.hs file that does not compile + +-- Avoid problems with CPP and HLint +#ifndef __HLINT__ + +#error Not going to compile, sorry + +#endif diff --git a/tests/integration/tests/370-invalid-setup-hs/files/new-template.cabal b/tests/integration/tests/370-invalid-setup-hs/files/new-template.cabal deleted file mode 100644 index 7306959dcc..0000000000 --- a/tests/integration/tests/370-invalid-setup-hs/files/new-template.cabal +++ /dev/null @@ -1,18 +0,0 @@ -name: new-template -version: 0.1.0.0 -synopsis: Initial project template from stack -description: Please see README.md -homepage: http://github.com/name/project -license: BSD3 -license-file: LICENSE -author: Your name here -maintainer: your.address@example.com -category: Web -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 diff --git a/tests/integration/tests/370-invalid-setup-hs/files/package.yaml b/tests/integration/tests/370-invalid-setup-hs/files/package.yaml new file mode 100644 index 0000000000..a7305a77cf --- /dev/null +++ b/tests/integration/tests/370-invalid-setup-hs/files/package.yaml @@ -0,0 +1,9 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src diff --git a/tests/integration/tests/370-invalid-setup-hs/files/src/Lib.hs b/tests/integration/tests/370-invalid-setup-hs/files/src/Lib.hs index d36ff2714d..6d85a26fe1 100644 --- a/tests/integration/tests/370-invalid-setup-hs/files/src/Lib.hs +++ b/tests/integration/tests/370-invalid-setup-hs/files/src/Lib.hs @@ -1,6 +1 @@ -module Lib - ( someFunc - ) where - -someFunc :: IO () -someFunc = putStrLn "someFunc" +module Lib where diff --git a/tests/integration/tests/3770-no-rerun-tests/Main.hs b/tests/integration/tests/3770-no-rerun-tests/Main.hs new file mode 100644 index 0000000000..a4c98951aa --- /dev/null +++ b/tests/integration/tests/3770-no-rerun-tests/Main.hs @@ -0,0 +1,25 @@ +-- | Stack can avoid re-running successful test suites. +-- +-- See: https://github.com/commercialhaskell/stack/pull/3770 + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest + +main :: IO () +main = do + stackCheckStderr ["test"] (expectMessage testSuitePassed) + stackCheckStderr + ["test", "--no-rerun-tests"] + (expectMessage skippedAlreadyPassedTest) + +testSuitePassed :: String +testSuitePassed = "Test suite test passed" + +skippedAlreadyPassedTest :: String +skippedAlreadyPassedTest = "skipping already passed test" + +expectMessage :: String -> String -> IO () +expectMessage msg stderr = do + unless (words msg `isInfixOf` words stderr) $ + error $ "Expected output: \n" ++ show msg diff --git a/tests/integration/tests/3770-no-rerun-tests/files/.gitignore b/tests/integration/tests/3770-no-rerun-tests/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/3770-no-rerun-tests/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/3770-no-rerun-tests/files/package.yaml b/tests/integration/tests/3770-no-rerun-tests/files/package.yaml new file mode 100644 index 0000000000..9a50489941 --- /dev/null +++ b/tests/integration/tests/3770-no-rerun-tests/files/package.yaml @@ -0,0 +1,11 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +tests: + test: + source-dirs: test + main: Main.hs diff --git a/tests/integration/tests/3770-no-rerun-tests/files/stack.yaml b/tests/integration/tests/3770-no-rerun-tests/files/stack.yaml new file mode 100644 index 0000000000..e674eab75a --- /dev/null +++ b/tests/integration/tests/3770-no-rerun-tests/files/stack.yaml @@ -0,0 +1 @@ +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/copy-bins-works/files/src/Main.hs b/tests/integration/tests/3770-no-rerun-tests/files/test/Main.hs similarity index 100% rename from tests/integration/tests/copy-bins-works/files/src/Main.hs rename to tests/integration/tests/3770-no-rerun-tests/files/test/Main.hs diff --git a/tests/integration/tests/3787-internal-libs-with-no-main-lib/Main.hs b/tests/integration/tests/3787-internal-libs-with-no-main-lib/Main.hs index 09bd4aa3b0..415d810f0a 100644 --- a/tests/integration/tests/3787-internal-libs-with-no-main-lib/Main.hs +++ b/tests/integration/tests/3787-internal-libs-with-no-main-lib/Main.hs @@ -1,6 +1,9 @@ -import StackTest +-- Stack builds a package with a private named sublibrary (an internal library) +-- but no main library. +-- +-- See: https://github.com/commercialhaskell/stack/issues/3787 + +import StackTest main :: IO () -main = do - stack ["clean"] - stack ["build"] +main = stack ["build"] diff --git a/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/.gitignore b/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/app/Main.hs b/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/app/Main.hs new file mode 100644 index 0000000000..a392820cc0 --- /dev/null +++ b/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/app/Main.hs @@ -0,0 +1,6 @@ +module Main where + +import Lib ( someFunc ) + +main :: IO () +main = someFunc diff --git a/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/exe/Main.hs b/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/exe/Main.hs deleted file mode 100644 index 83db768ed3..0000000000 --- a/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/exe/Main.hs +++ /dev/null @@ -1 +0,0 @@ -main = putStrLn "OK" diff --git a/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/files.cabal b/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/files.cabal deleted file mode 100644 index 631f10c48d..0000000000 --- a/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/files.cabal +++ /dev/null @@ -1,16 +0,0 @@ -name: files -version: 0.1.0.0 -build-type: Simple -cabal-version: >= 2.0 - -library sublib - exposed-modules: B - hs-source-dirs: src-sublib - build-depends: base - default-language: Haskell2010 - -executable exe - main-is: Main.hs - hs-source-dirs: exe - build-depends: base, sublib - default-language: Haskell2010 diff --git a/tests/integration/tests/cabal-public-sublibraries/files/src/Lib.hs b/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/int/Lib.hs similarity index 57% rename from tests/integration/tests/cabal-public-sublibraries/files/src/Lib.hs rename to tests/integration/tests/3787-internal-libs-with-no-main-lib/files/int/Lib.hs index d999e20553..35dc3b3347 100644 --- a/tests/integration/tests/cabal-public-sublibraries/files/src/Lib.hs +++ b/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/int/Lib.hs @@ -3,5 +3,4 @@ module Lib ) where someFunc :: IO () -someFunc = do - putStrLn "hello world" +someFunc = pure () diff --git a/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/package.yaml b/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/package.yaml new file mode 100644 index 0000000000..c3b0d2aaf8 --- /dev/null +++ b/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/package.yaml @@ -0,0 +1,17 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +internal-libraries: + internal: + source-dirs: int + +executables: + myExe: + source-dirs: app + main: Main.hs + dependencies: + - internal diff --git a/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/src-sublib/B.hs b/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/src-sublib/B.hs deleted file mode 100644 index 53253d5dcc..0000000000 --- a/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/src-sublib/B.hs +++ /dev/null @@ -1,5 +0,0 @@ -module B where - --- | A function of the internal library -funInternal :: Int -> Int -funInternal = pred diff --git a/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/stack.yaml b/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/stack.yaml +++ b/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/stack.yaml.lock b/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/stack.yaml.lock deleted file mode 100644 index e845f3fe93..0000000000 --- a/tests/integration/tests/3787-internal-libs-with-no-main-lib/files/stack.yaml.lock +++ /dev/null @@ -1,12 +0,0 @@ -# This file was autogenerated by Stack. -# You should not edit this file by hand. -# For more information, please see the documentation at: -# https://docs.haskellstack.org/en/stable/lock_files - -packages: [] -snapshots: -- completed: - sha256: bfafe5735ccb74527d754b1f9999ded72d7c3a6c3a88529449661431ccfbd6cc - size: 649327 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/8.yaml - original: lts-20.8 diff --git a/tests/integration/tests/384-local-deps/Main.hs b/tests/integration/tests/384-local-deps/Main.hs index f226e5f577..ae4c43fa95 100644 --- a/tests/integration/tests/384-local-deps/Main.hs +++ b/tests/integration/tests/384-local-deps/Main.hs @@ -1,7 +1,11 @@ -import StackTest +-- Stack can initialise a multi-project package where one project package +-- depends on another project package. +-- +-- See: https://github.com/commercialhaskell/stack/issues/384 + +import StackTest main :: IO () main = do - removeFileIgnore "stack.yaml" - stack ["init", defaultSnapshotArg] - stack ["test"] + stack ["init"] + stack ["build"] diff --git a/tests/integration/tests/384-local-deps/files/.gitignore b/tests/integration/tests/384-local-deps/files/.gitignore index 684dbffa96..11a5409872 100644 --- a/tests/integration/tests/384-local-deps/files/.gitignore +++ b/tests/integration/tests/384-local-deps/files/.gitignore @@ -1 +1,3 @@ stack.yaml +myPackageA.cabal +myPackageB.cabal diff --git a/tests/integration/tests/384-local-deps/files/dir1/dir1.cabal b/tests/integration/tests/384-local-deps/files/dir1/dir1.cabal deleted file mode 100644 index 87ea412999..0000000000 --- a/tests/integration/tests/384-local-deps/files/dir1/dir1.cabal +++ /dev/null @@ -1,10 +0,0 @@ -name: dir1 -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 diff --git a/tests/integration/tests/384-local-deps/files/dir1/src/Lib.hs b/tests/integration/tests/384-local-deps/files/dir1/src/Lib.hs deleted file mode 100644 index d36ff2714d..0000000000 --- a/tests/integration/tests/384-local-deps/files/dir1/src/Lib.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Lib - ( someFunc - ) where - -someFunc :: IO () -someFunc = putStrLn "someFunc" diff --git a/tests/integration/tests/384-local-deps/files/dir2/dir2.cabal b/tests/integration/tests/384-local-deps/files/dir2/dir2.cabal deleted file mode 100644 index 40d8a85084..0000000000 --- a/tests/integration/tests/384-local-deps/files/dir2/dir2.cabal +++ /dev/null @@ -1,10 +0,0 @@ -name: dir2 -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5, dir1 - default-language: Haskell2010 diff --git a/tests/integration/tests/384-local-deps/files/dir2/src/Lib.hs b/tests/integration/tests/384-local-deps/files/dir2/src/Lib.hs deleted file mode 100644 index d36ff2714d..0000000000 --- a/tests/integration/tests/384-local-deps/files/dir2/src/Lib.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Lib - ( someFunc - ) where - -someFunc :: IO () -someFunc = putStrLn "someFunc" diff --git a/tests/integration/tests/384-local-deps/files/myPackageA/package.yaml b/tests/integration/tests/384-local-deps/files/myPackageA/package.yaml new file mode 100644 index 0000000000..d26b472ded --- /dev/null +++ b/tests/integration/tests/384-local-deps/files/myPackageA/package.yaml @@ -0,0 +1,9 @@ +spec-version: 0.36.0 + +name: myPackageA + +dependencies: +- base + +library: + source-dirs: src diff --git a/tests/integration/tests/384-local-deps/files/myPackageA/src/Lib.hs b/tests/integration/tests/384-local-deps/files/myPackageA/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/384-local-deps/files/myPackageA/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/384-local-deps/files/myPackageB/package.yaml b/tests/integration/tests/384-local-deps/files/myPackageB/package.yaml new file mode 100644 index 0000000000..e5f489eebf --- /dev/null +++ b/tests/integration/tests/384-local-deps/files/myPackageB/package.yaml @@ -0,0 +1,10 @@ +spec-version: 0.36.0 + +name: myPackageB + +dependencies: +- base +- myPackageA + +library: + source-dirs: src diff --git a/tests/integration/tests/384-local-deps/files/myPackageB/src/Lib.hs b/tests/integration/tests/384-local-deps/files/myPackageB/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/384-local-deps/files/myPackageB/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/3850-cached-templates-network-errors/Main.hs b/tests/integration/tests/3850-cached-templates-network-errors/Main.hs index e136507279..80c1c706ad 100644 --- a/tests/integration/tests/3850-cached-templates-network-errors/Main.hs +++ b/tests/integration/tests/3850-cached-templates-network-errors/Main.hs @@ -1,38 +1,40 @@ -import StackTest -import Control.Monad (when, unless) -import Data.List (isInfixOf) -import Data.Maybe (fromMaybe) -import System.Directory -import System.Environment (lookupEnv, setEnv) -import System.FilePath +-- Stack can used cached Stack project templates. +-- +-- See: https://github.com/commercialhaskell/stack/issues/3850 + +import Control.Exception ( bracket ) +import Control.Monad ( unless, when ) +import Data.List ( isInfixOf ) +import Data.Maybe ( fromMaybe ) +import StackTest +import System.Directory ( removeDirectoryRecursive ) +import System.Environment ( lookupEnv, setEnv ) main :: IO () main = when isLinux $ do - performCachingTest templateUrl - performCachingTest githubTemplate - where - performCachingTest :: String -> IO () - performCachingTest template = do - let arguments = ["new", "tmp", template] - originalHttpProxy <- lookupEnv "HTTPS_PROXY" - stack arguments - removeDirectoryRecursive "tmp" - setEnv "HTTPS_PROXY" "http://sdsgsfgslfgsjflgkjs" -- make https requests fail - stackCheckStderr arguments $ \stderr -> - unless ("Using cached local version" `isInfixOf` stderr) - (error "stack didn't load the cached template") - - removeDirectoryRecursive "tmp" - setEnv "HTTPS_PROXY" (fromMaybe "" originalHttpProxy) - - -- this template has a `stack.yaml` file - -- so `stack new` does not have to `stack init` - -- and therefore the test runs faster - templateUrl :: String - templateUrl = - "https://raw.githubusercontent.com/commercialhaskell/stack-templates/986836cc85b0c8c5bbb78d7b94347ba095089b03/tasty-discover.hsfiles" + performCachingTest "myProjectA" "myProjectB" templateUrl + performCachingTest "myProjectC" "myProjectD" githubTemplate + where + performCachingTest :: String -> String -> String -> IO () + performCachingTest projectName1 projectName2 template = do + let arguments = ["new", projectName1, template] + bracket + ( lookupEnv "HTTPS_PROXY" ) + ( (setEnv "HTTPS_PROXY") . (fromMaybe "") ) + ( const $ do + stack ["new", projectName1, template] + setEnv "HTTPS_PROXY" "http://sdsgsfgslfgsjflgkjs" -- make https requests fail + stackCheckStderr ["new", projectName2, template] $ \stderr -> + unless ("Using cached local version." `isInfixOf` stderr) $ + error "stack didn't load the cached template" + ) - -- the same template, cached differently - githubTemplate :: String - githubTemplate = "github:commercialhaskell/tasty-discover.hsfiles" + -- This template has a `stack.yaml` file so `stack new` does not have to + -- `stack init` and therefore the test runs faster + templateUrl :: String + templateUrl = + "https://raw.githubusercontent.com/commercialhaskell/stack-templates/refs/heads/master/tasty-discover.hsfiles" + -- The same template, cached differently + githubTemplate :: String + githubTemplate = "github:commercialhaskell/tasty-discover.hsfiles" diff --git a/tests/integration/tests/3861-ignore-bounds-in-snapshots/Main.hs b/tests/integration/tests/3861-ignore-bounds-in-snapshots/Main.hs index 38e0123f5b..5786914f26 100644 --- a/tests/integration/tests/3861-ignore-bounds-in-snapshots/Main.hs +++ b/tests/integration/tests/3861-ignore-bounds-in-snapshots/Main.hs @@ -1,7 +1,11 @@ -import StackTest +-- Stack trusts package versions in a snapshot over Cabal file dependency +-- information. +-- +-- See: https://github.com/commercialhaskell/stack/issues/3861 + +import StackTest main :: IO () main = do - stackIgnoreException ["clean", "--stack-yaml", "stack-good.yaml", "--full"] stackErr ["build", "--stack-yaml", "stack-bad.yaml"] stack ["build", "--stack-yaml", "stack-good.yaml"] diff --git a/tests/integration/tests/3861-ignore-bounds-in-snapshots/files/.gitignore b/tests/integration/tests/3861-ignore-bounds-in-snapshots/files/.gitignore index 0afa51175a..b0a5a052a1 100644 --- a/tests/integration/tests/3861-ignore-bounds-in-snapshots/files/.gitignore +++ b/tests/integration/tests/3861-ignore-bounds-in-snapshots/files/.gitignore @@ -1 +1 @@ -foo.cabal +myPackage.cabal diff --git a/tests/integration/tests/3861-ignore-bounds-in-snapshots/files/package.yaml b/tests/integration/tests/3861-ignore-bounds-in-snapshots/files/package.yaml index aaa0f35c7c..ab04bf7f95 100644 --- a/tests/integration/tests/3861-ignore-bounds-in-snapshots/files/package.yaml +++ b/tests/integration/tests/3861-ignore-bounds-in-snapshots/files/package.yaml @@ -1,5 +1,6 @@ -name: foo -version: 0 +spec-version: 0.36.0 + +name: myPackage dependencies: - base diff --git a/tests/integration/tests/3863-purge-command/Main.hs b/tests/integration/tests/3863-purge-command/Main.hs index d86acfcf21..140de74b76 100644 --- a/tests/integration/tests/3863-purge-command/Main.hs +++ b/tests/integration/tests/3863-purge-command/Main.hs @@ -1,12 +1,15 @@ {-# LANGUAGE ViewPatterns #-} -import StackTest -import Data.Char (isSpace) -import Data.List (dropWhileEnd) -import Data.Maybe (listToMaybe, fromMaybe) -import Control.Monad (unless) -import System.Directory -import System.FilePath +-- Stack can purge all Stack work directories. +-- +-- See: https://github.com/commercialhaskell/stack/issues/3863 + +import Control.Monad ( unless ) +import Data.Char ( isSpace ) +import Data.List ( dropWhileEnd ) +import Data.Maybe ( fromMaybe, listToMaybe ) +import StackTest +import System.FilePath ( splitDirectories ) trimEnd :: String -> String trimEnd = dropWhileEnd isSpace @@ -15,27 +18,27 @@ main :: IO () main = -- For these commands, we'll need to know the `dist` directory. -- This is usually `.stack-work/dist/$compiler-variant/Cabal-xxxx` - stackCheckStdout [defaultSnapshotArg, "path", "--dist-dir"] $ \(trimEnd -> distDir) -> do - stackCheckStdout [defaultSnapshotArg, "path", "--local-install-root"] $ \(trimEnd -> localInstallRoot) -> do + stackCheckStdout ["path", "--dist-dir"] $ \(trimEnd -> distDir) -> do + stackCheckStdout ["path", "--local-install-root"] $ \(trimEnd -> localInstallRoot) -> do -- Usually `.stack-work` let stackWork = fromMaybe (error "There must be a Stack working directory.") $ listToMaybe (splitDirectories distDir) -- First, clean the .stack-work directory. -- This is only necessary when running individual tests. - stackIgnoreException [defaultSnapshotArg, "purge"] + stackIgnoreException ["purge"] -- See #4936 for details regarding the windows condition unless isWindows $ doesNotExist stackWork -- The dist directory should exist after a build - stack [defaultSnapshotArg, "build"] + stack ["build"] doesExist distDir doesExist localInstallRoot doesExist stackWork -- The dist directory should not exist after a clean, whereas the -- .stack-work directory should - stackIgnoreException [defaultSnapshotArg, "clean"] + stackIgnoreException ["clean"] -- See #4936 for details regarding the windows condition unless isWindows $ do doesNotExist distDir @@ -43,6 +46,6 @@ main = doesExist stackWork -- The .stack-work directory should not exist after a purge - stackIgnoreException [defaultSnapshotArg, "purge"] + stackIgnoreException ["purge"] -- See #4936 for details regarding the windows condition unless isWindows $ doesNotExist stackWork diff --git a/tests/integration/tests/3863-purge-command/files/.gitignore b/tests/integration/tests/3863-purge-command/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/3863-purge-command/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/3863-purge-command/files/new-template.cabal b/tests/integration/tests/3863-purge-command/files/new-template.cabal deleted file mode 100644 index 192e0b2dfb..0000000000 --- a/tests/integration/tests/3863-purge-command/files/new-template.cabal +++ /dev/null @@ -1,11 +0,0 @@ -name: new-template -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 diff --git a/tests/integration/tests/3863-purge-command/files/package.yaml b/tests/integration/tests/3863-purge-command/files/package.yaml new file mode 100644 index 0000000000..a7305a77cf --- /dev/null +++ b/tests/integration/tests/3863-purge-command/files/package.yaml @@ -0,0 +1,9 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src diff --git a/tests/integration/tests/3863-purge-command/files/src/Lib.hs b/tests/integration/tests/3863-purge-command/files/src/Lib.hs index 1c88a82644..6d85a26fe1 100644 --- a/tests/integration/tests/3863-purge-command/files/src/Lib.hs +++ b/tests/integration/tests/3863-purge-command/files/src/Lib.hs @@ -1,4 +1 @@ module Lib where - -someFunc :: () -someFunc = () diff --git a/tests/integration/tests/3863-purge-command/files/stack.yaml b/tests/integration/tests/3863-purge-command/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/3863-purge-command/files/stack.yaml +++ b/tests/integration/tests/3863-purge-command/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/3899-dont-rebuild-sublibraries/Main.hs b/tests/integration/tests/3899-dont-rebuild-sublibraries/Main.hs index fa6835ebe7..8f76c8d683 100644 --- a/tests/integration/tests/3899-dont-rebuild-sublibraries/Main.hs +++ b/tests/integration/tests/3899-dont-rebuild-sublibraries/Main.hs @@ -1,10 +1,14 @@ -import Control.Monad (unless) -import Data.List (isInfixOf) -import StackTest +-- Stack does not recompile a package with a private named sublibrary (an +-- internal library) on a second build. +-- +-- See: https://github.com/commercialhaskell/stack/issues/3899 + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest main :: IO () main = do - stack ["clean"] stack ["build"] res <- compilingModulesLines . snd <$> stackStderr ["build"] unless (null res) $ fail "Stack recompiled code" diff --git a/tests/integration/tests/3899-dont-rebuild-sublibraries/files/.gitignore b/tests/integration/tests/3899-dont-rebuild-sublibraries/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/3899-dont-rebuild-sublibraries/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/3899-dont-rebuild-sublibraries/files/Setup.hs b/tests/integration/tests/3899-dont-rebuild-sublibraries/files/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/3899-dont-rebuild-sublibraries/files/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/multi-test/files/app/Main.hs b/tests/integration/tests/3899-dont-rebuild-sublibraries/files/app/Main.hs similarity index 73% rename from tests/integration/tests/multi-test/files/app/Main.hs rename to tests/integration/tests/3899-dont-rebuild-sublibraries/files/app/Main.hs index de1c1ab35c..ac9093c87d 100644 --- a/tests/integration/tests/multi-test/files/app/Main.hs +++ b/tests/integration/tests/3899-dont-rebuild-sublibraries/files/app/Main.hs @@ -3,4 +3,4 @@ module Main where import Lib main :: IO () -main = someFunc +main = pure () diff --git a/tests/integration/tests/3899-dont-rebuild-sublibraries/files/files.cabal b/tests/integration/tests/3899-dont-rebuild-sublibraries/files/files.cabal deleted file mode 100644 index 867797cb7b..0000000000 --- a/tests/integration/tests/3899-dont-rebuild-sublibraries/files/files.cabal +++ /dev/null @@ -1,22 +0,0 @@ -name: files -version: 0.1.0.0 -build-type: Simple -cabal-version: >= 2.0 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base, lib - default-language: Haskell2010 - -library lib - hs-source-dirs: src-internal - exposed-modules: Internal - build-depends: base - default-language: Haskell2010 - -executable exe - hs-source-dirs: src-exe - main-is: Main.hs - build-depends: base, files - default-language: Haskell2010 diff --git a/tests/integration/tests/3899-dont-rebuild-sublibraries/files/src-internal/Internal.hs b/tests/integration/tests/3899-dont-rebuild-sublibraries/files/int/Internal.hs similarity index 100% rename from tests/integration/tests/3899-dont-rebuild-sublibraries/files/src-internal/Internal.hs rename to tests/integration/tests/3899-dont-rebuild-sublibraries/files/int/Internal.hs diff --git a/tests/integration/tests/3899-dont-rebuild-sublibraries/files/package.yaml b/tests/integration/tests/3899-dont-rebuild-sublibraries/files/package.yaml new file mode 100644 index 0000000000..d3ca861409 --- /dev/null +++ b/tests/integration/tests/3899-dont-rebuild-sublibraries/files/package.yaml @@ -0,0 +1,22 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src + dependencies: + - internal + +internal-libraries: + internal: + source-dirs: int + +executables: + myExe: + source-dirs: app + main: Main.hs + dependencies: + - myPackage diff --git a/tests/integration/tests/3899-dont-rebuild-sublibraries/files/src-exe/Main.hs b/tests/integration/tests/3899-dont-rebuild-sublibraries/files/src-exe/Main.hs deleted file mode 100644 index cafae24793..0000000000 --- a/tests/integration/tests/3899-dont-rebuild-sublibraries/files/src-exe/Main.hs +++ /dev/null @@ -1,7 +0,0 @@ -module Main where - -import Lib - -main :: IO () -main = do - putStrLn "hello world" diff --git a/tests/integration/tests/3899-dont-rebuild-sublibraries/files/stack.yaml b/tests/integration/tests/3899-dont-rebuild-sublibraries/files/stack.yaml index 01c7b866fc..e674eab75a 100644 --- a/tests/integration/tests/3899-dont-rebuild-sublibraries/files/stack.yaml +++ b/tests/integration/tests/3899-dont-rebuild-sublibraries/files/stack.yaml @@ -1,4 +1 @@ snapshot: ghc-9.10.3 -extra-deps: -- stm-2.4.4.1 -- mtl-2.2.1 diff --git a/tests/integration/tests/3926-ghci-with-sublibraries/Main.hs b/tests/integration/tests/3926-ghci-with-sublibraries/Main.hs index 2685fe87e4..838ab61a93 100644 --- a/tests/integration/tests/3926-ghci-with-sublibraries/Main.hs +++ b/tests/integration/tests/3926-ghci-with-sublibraries/Main.hs @@ -1,29 +1,32 @@ -import Control.Monad.IO.Class -import Control.Monad -import Data.List +-- Stack does not recompile a package with a private named sublibrary (an +-- internal library) on a second build. +-- +-- See: https://github.com/commercialhaskell/stack/issues/3926 -import StackTest.Repl +import Control.Monad ( unless, when ) +import Control.Monad.IO.Class ( liftIO ) +import Data.List ( isInfixOf, isSuffixOf ) +import StackTest.Repl main :: IO () main = do - stack ["clean"] -- to make sure we can load the code even after a clean copy "src/Lib.v1" "src/Lib.hs" - copy "src-internal/Internal.v1" "src-internal/Internal.hs" + copy "int/Internal.v1" "int/Internal.hs" stack ["build"] -- need a build before ghci at the moment, see #4148 stackRepl [] $ do nextPrompt replCommand ":main" line <- replGetLine - let expected = "hello world" + let expected = "Successful!" when (line /= expected) $ error $ "Main module didn't load correctly.\n" <> "Expected: " <> expected <> "\n" <> "Actual : " <> line <> "\n" - liftIO $ copy "src-internal/Internal.v2" "src-internal/Internal.hs" - reloadAndTest "testInt" "42" "Internal library didn't reload." + liftIO $ copy "int/Internal.v2" "int/Internal.hs" + reloadAndTest "checkInternal" "\"OK\"" "Internal library didn't reload." liftIO $ copy "src/Lib.v2" "src/Lib.hs" - reloadAndTest "testStr" "\"OK\"" "Main library didn't reload." + reloadAndTest "checkLib" "\"OK\"" "Main library didn't reload." reloadAndTest :: String -> String -> String -> Repl () reloadAndTest cmd exp err = do @@ -35,5 +38,5 @@ reloadAndTest cmd exp err = do reload :: Repl () reload = replCommand ":reload" >> loop - where - loop = replGetLine >>= \line -> unless ("Ok" `isInfixOf` line) loop + where + loop = replGetLine >>= \line -> unless ("Ok" `isInfixOf` line) loop diff --git a/tests/integration/tests/3926-ghci-with-sublibraries/files/.gitignore b/tests/integration/tests/3926-ghci-with-sublibraries/files/.gitignore index 54bdefd6ee..b0a5a052a1 100644 --- a/tests/integration/tests/3926-ghci-with-sublibraries/files/.gitignore +++ b/tests/integration/tests/3926-ghci-with-sublibraries/files/.gitignore @@ -1,2 +1 @@ -src/Lib.hs -src-internal/Internal.hs +myPackage.cabal diff --git a/tests/integration/tests/3926-ghci-with-sublibraries/files/Setup.hs b/tests/integration/tests/3926-ghci-with-sublibraries/files/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/3926-ghci-with-sublibraries/files/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/3926-ghci-with-sublibraries/files/src-exe/Main.hs b/tests/integration/tests/3926-ghci-with-sublibraries/files/app/Main.hs similarity index 56% rename from tests/integration/tests/3926-ghci-with-sublibraries/files/src-exe/Main.hs rename to tests/integration/tests/3926-ghci-with-sublibraries/files/app/Main.hs index cafae24793..7eaf6f21c1 100644 --- a/tests/integration/tests/3926-ghci-with-sublibraries/files/src-exe/Main.hs +++ b/tests/integration/tests/3926-ghci-with-sublibraries/files/app/Main.hs @@ -3,5 +3,4 @@ module Main where import Lib main :: IO () -main = do - putStrLn "hello world" +main = putStrLn "Successful!" diff --git a/tests/integration/tests/3926-ghci-with-sublibraries/files/files.cabal b/tests/integration/tests/3926-ghci-with-sublibraries/files/files.cabal deleted file mode 100644 index c661c0e007..0000000000 --- a/tests/integration/tests/3926-ghci-with-sublibraries/files/files.cabal +++ /dev/null @@ -1,23 +0,0 @@ -cabal-version: 2.0 - -name: files -version: 0.1.0.0 -build-type: Simple - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base, lib - default-language: Haskell2010 - -library lib - hs-source-dirs: src-internal - exposed-modules: Internal - build-depends: base - default-language: Haskell2010 - -executable exe - hs-source-dirs: src-exe - main-is: Main.hs - build-depends: base, files - default-language: Haskell2010 diff --git a/tests/integration/tests/3926-ghci-with-sublibraries/files/src-internal/Internal.v1 b/tests/integration/tests/3926-ghci-with-sublibraries/files/int/Internal.hs similarity index 100% rename from tests/integration/tests/3926-ghci-with-sublibraries/files/src-internal/Internal.v1 rename to tests/integration/tests/3926-ghci-with-sublibraries/files/int/Internal.hs diff --git a/tests/integration/tests/3926-ghci-with-sublibraries/files/int/Internal.v1 b/tests/integration/tests/3926-ghci-with-sublibraries/files/int/Internal.v1 new file mode 100644 index 0000000000..d066bb085e --- /dev/null +++ b/tests/integration/tests/3926-ghci-with-sublibraries/files/int/Internal.v1 @@ -0,0 +1 @@ +module Internal where diff --git a/tests/integration/tests/3926-ghci-with-sublibraries/files/int/Internal.v2 b/tests/integration/tests/3926-ghci-with-sublibraries/files/int/Internal.v2 new file mode 100644 index 0000000000..771c9f2365 --- /dev/null +++ b/tests/integration/tests/3926-ghci-with-sublibraries/files/int/Internal.v2 @@ -0,0 +1,6 @@ +module Internal + ( checkInternal + ) where + +checkInternal :: String +checkInternal = "OK" diff --git a/tests/integration/tests/3926-ghci-with-sublibraries/files/package.yaml b/tests/integration/tests/3926-ghci-with-sublibraries/files/package.yaml new file mode 100644 index 0000000000..d3ca861409 --- /dev/null +++ b/tests/integration/tests/3926-ghci-with-sublibraries/files/package.yaml @@ -0,0 +1,22 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src + dependencies: + - internal + +internal-libraries: + internal: + source-dirs: int + +executables: + myExe: + source-dirs: app + main: Main.hs + dependencies: + - myPackage diff --git a/tests/integration/tests/3926-ghci-with-sublibraries/files/src-internal/Internal.v2 b/tests/integration/tests/3926-ghci-with-sublibraries/files/src-internal/Internal.v2 deleted file mode 100644 index da8a642c7b..0000000000 --- a/tests/integration/tests/3926-ghci-with-sublibraries/files/src-internal/Internal.v2 +++ /dev/null @@ -1,4 +0,0 @@ -module Internal where - -testInt :: Int -testInt = 42 diff --git a/tests/integration/tests/3926-ghci-with-sublibraries/files/src/Lib.hs b/tests/integration/tests/3926-ghci-with-sublibraries/files/src/Lib.hs new file mode 100644 index 0000000000..1369151610 --- /dev/null +++ b/tests/integration/tests/3926-ghci-with-sublibraries/files/src/Lib.hs @@ -0,0 +1,3 @@ +module Lib where + +import Internal diff --git a/tests/integration/tests/3926-ghci-with-sublibraries/files/src/Lib.v2 b/tests/integration/tests/3926-ghci-with-sublibraries/files/src/Lib.v2 index d9892d6826..ef8bb078c5 100644 --- a/tests/integration/tests/3926-ghci-with-sublibraries/files/src/Lib.v2 +++ b/tests/integration/tests/3926-ghci-with-sublibraries/files/src/Lib.v2 @@ -1,6 +1,8 @@ -module Lib where +module Lib + ( checkLib + ) where import Internal -testStr :: String -testStr = "OK" +checkLib :: String +checkLib = "OK" diff --git a/tests/integration/tests/3926-ghci-with-sublibraries/files/stack.yaml b/tests/integration/tests/3926-ghci-with-sublibraries/files/stack.yaml index 911c9c7645..e674eab75a 100644 --- a/tests/integration/tests/3926-ghci-with-sublibraries/files/stack.yaml +++ b/tests/integration/tests/3926-ghci-with-sublibraries/files/stack.yaml @@ -1,4 +1 @@ snapshot: ghc-9.10.3 -extra-deps: -- stm-2.5.1.0 -- mtl-2.2.2 diff --git a/tests/integration/tests/3940-base-upgrade-warning/Main.hs b/tests/integration/tests/3940-base-upgrade-warning/Main.hs index 75baa69992..1dff182949 100644 --- a/tests/integration/tests/3940-base-upgrade-warning/Main.hs +++ b/tests/integration/tests/3940-base-upgrade-warning/Main.hs @@ -1,6 +1,12 @@ -import Control.Monad (unless) -import Data.List (isInfixOf) -import StackTest +-- Stack provides appropriate advice if the version of base required is not that +-- specified by the snapshot. Stack warns that base is a wired-in package before +-- GHC 9.12.1. +-- +-- See: https://github.com/commercialhaskell/stack/issues/3940 + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest -- Use short message fragment because prettyWarn formatting and colour unattainableBaseWarning :: String @@ -19,5 +25,5 @@ main = do expectMessage :: String -> String -> IO () expectMessage msg stderr = - unless (words msg `isInfixOf` words stderr) - (error $ "Expected a warning: \n" ++ show msg) + unless (words msg `isInfixOf` words stderr) $ + error $ "Expected a warning: \n" ++ show msg diff --git a/tests/integration/tests/3940-base-upgrade-warning/files/.gitignore b/tests/integration/tests/3940-base-upgrade-warning/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/3940-base-upgrade-warning/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/3940-base-upgrade-warning/files/files.cabal b/tests/integration/tests/3940-base-upgrade-warning/files/files.cabal deleted file mode 100644 index 1a0eb3c82e..0000000000 --- a/tests/integration/tests/3940-base-upgrade-warning/files/files.cabal +++ /dev/null @@ -1,10 +0,0 @@ -name: files -version: 0.0.1.0 -build-type: Simple -cabal-version: >= 1.18 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base < 4.10 && >= 4.6.0.1 - default-language: Haskell2010 diff --git a/tests/integration/tests/3940-base-upgrade-warning/files/no-base-upgrade.yaml b/tests/integration/tests/3940-base-upgrade-warning/files/no-base-upgrade.yaml index 49177786b8..22e1252a91 100644 --- a/tests/integration/tests/3940-base-upgrade-warning/files/no-base-upgrade.yaml +++ b/tests/integration/tests/3940-base-upgrade-warning/files/no-base-upgrade.yaml @@ -1,3 +1,3 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 extra-deps: - base-4.10.1.0 diff --git a/tests/integration/tests/3940-base-upgrade-warning/files/package.yaml b/tests/integration/tests/3940-base-upgrade-warning/files/package.yaml new file mode 100644 index 0000000000..d734612453 --- /dev/null +++ b/tests/integration/tests/3940-base-upgrade-warning/files/package.yaml @@ -0,0 +1,9 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base < 4.20 + +library: + source-dirs: src diff --git a/tests/integration/tests/3940-base-upgrade-warning/files/src/Lib.hs b/tests/integration/tests/3940-base-upgrade-warning/files/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/3940-base-upgrade-warning/files/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/3940-base-upgrade-warning/files/unattainable-base.yaml b/tests/integration/tests/3940-base-upgrade-warning/files/unattainable-base.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/3940-base-upgrade-warning/files/unattainable-base.yaml +++ b/tests/integration/tests/3940-base-upgrade-warning/files/unattainable-base.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/3942-solver-error-output/Main.hs b/tests/integration/tests/3942-solver-error-output/Main.hs index 4866d6baa7..e8369562ab 100644 --- a/tests/integration/tests/3942-solver-error-output/Main.hs +++ b/tests/integration/tests/3942-solver-error-output/Main.hs @@ -1,6 +1,10 @@ -import Control.Monad (unless) -import Data.List (isInfixOf) -import StackTest +-- Stack build fails if a dependency is not available. +-- +-- See: https://github.com/commercialhaskell/stack/issues/3942 + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest -- | Stack's error code for failing to construct a build plan. planFailure :: String @@ -13,5 +17,5 @@ main = do expectMessage :: String -> String -> IO () expectMessage msg stderr = do - unless (words msg `isInfixOf` words stderr) - (error $ "Expected a warning: \n" ++ show msg) + unless (words msg `isInfixOf` words stderr) $ + error $ "Expected a warning: \n" ++ show msg diff --git a/tests/integration/tests/3942-solver-error-output/files/.gitignore b/tests/integration/tests/3942-solver-error-output/files/.gitignore index 4c65edffd7..191b37bd49 100644 --- a/tests/integration/tests/3942-solver-error-output/files/.gitignore +++ b/tests/integration/tests/3942-solver-error-output/files/.gitignore @@ -1,3 +1,2 @@ -.stack-work/ -*.cabal -stack.yaml +no-deps.cabal +one-deps.cabal diff --git a/tests/integration/tests/3942-solver-error-output/files/no-deps/package.yaml b/tests/integration/tests/3942-solver-error-output/files/no-deps/package.yaml index 63f22d1796..48ede3554f 100644 --- a/tests/integration/tests/3942-solver-error-output/files/no-deps/package.yaml +++ b/tests/integration/tests/3942-solver-error-output/files/no-deps/package.yaml @@ -1,15 +1,9 @@ +spec-version: 0.36.0 + name: no-deps -version: 0.1.0.0 synopsis: A package with no dependencies, other than base -license: BSD3 -author: Author name here -copyright: 2000 Author name here -category: Development -extra-source-files: [] dependencies: - base -library: - source-dirs: '.' - exposed-modules: [] +library: {} diff --git a/tests/integration/tests/3942-solver-error-output/files/one-deps/package.yaml b/tests/integration/tests/3942-solver-error-output/files/one-deps/package.yaml index 59dce7c0fe..0cabd80dac 100644 --- a/tests/integration/tests/3942-solver-error-output/files/one-deps/package.yaml +++ b/tests/integration/tests/3942-solver-error-output/files/one-deps/package.yaml @@ -1,16 +1,10 @@ +spec-version: 0.36.0 + name: one-deps -version: 0.1.0.0 synopsis: A package with one dependency (no-deps) other than base -license: BSD3 -author: Author name here -copyright: 2000 Author name here -category: Development -extra-source-files: [] dependencies: - base - no-deps -library: - source-dirs: '.' - exposed-modules: [] +library: {} diff --git a/tests/integration/tests/3942-solver-error-output/files/script.hs b/tests/integration/tests/3942-solver-error-output/files/script.hs index 51083db266..fde3259536 100644 --- a/tests/integration/tests/3942-solver-error-output/files/script.hs +++ b/tests/integration/tests/3942-solver-error-output/files/script.hs @@ -2,4 +2,4 @@ -- stack runhaskell --stack-yaml test-stack.yml --package one-deps main :: IO () -main = putStrLn "yo" +main = pure () diff --git a/tests/integration/tests/3942-solver-error-output/files/test-stack.yml b/tests/integration/tests/3942-solver-error-output/files/test-stack.yml index 8d15631053..c2035ec9bc 100644 --- a/tests/integration/tests/3942-solver-error-output/files/test-stack.yml +++ b/tests/integration/tests/3942-solver-error-output/files/test-stack.yml @@ -1,4 +1,4 @@ -resolver: lts-24.24 +snapshot: ghc-9.10.3 packages: [] diff --git a/tests/integration/tests/3959-order-of-flags/Main.hs b/tests/integration/tests/3959-order-of-flags/Main.hs index 4825c04053..479eae7be6 100644 --- a/tests/integration/tests/3959-order-of-flags/Main.hs +++ b/tests/integration/tests/3959-order-of-flags/Main.hs @@ -1,21 +1,28 @@ -import StackTest +-- Stack allows build flags or options to be specified before or after the build +-- command. +-- +-- See: https://github.com/commercialhaskell/stack/issues/3959 -import Control.Monad (unless) -import Data.List (isInfixOf) +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest --- Integration test for https://github.com/commercialhaskell/stack/issues/3959 main :: IO () main = do checkFlagsBeforeCommand checkFlagsAfterCommand checkFlagsBeforeCommand :: IO () -checkFlagsBeforeCommand = stackCheckStderr ["--test", "--no-run-tests", "build"] checker +checkFlagsBeforeCommand = + stackCheckStderr ["--test", "--no-run-tests", "build"] checker checkFlagsAfterCommand :: IO () -checkFlagsAfterCommand = stackCheckStderr ["build", "--test", "--no-run-tests"] checker +checkFlagsAfterCommand = + stackCheckStderr ["build", "--test", "--no-run-tests"] checker checker :: String -> IO () checker output = do - let testsAreDisabled = any (\ln -> "All test running disabled by" `isInfixOf` ln) (lines output) - unless testsAreDisabled $ fail "Tests should not be run" + let testsAreDisabled = + any (\ln -> "All test running disabled by" `isInfixOf` ln) (lines output) + unless testsAreDisabled $ + fail "Tests should not be run" diff --git a/tests/integration/tests/3959-order-of-flags/files/.gitignore b/tests/integration/tests/3959-order-of-flags/files/.gitignore index d43d807c0d..b0a5a052a1 100644 --- a/tests/integration/tests/3959-order-of-flags/files/.gitignore +++ b/tests/integration/tests/3959-order-of-flags/files/.gitignore @@ -1 +1 @@ -*.cabal +myPackage.cabal diff --git a/tests/integration/tests/3959-order-of-flags/files/package.yaml b/tests/integration/tests/3959-order-of-flags/files/package.yaml index 0eb6d8f2f9..ee1a6463a8 100644 --- a/tests/integration/tests/3959-order-of-flags/files/package.yaml +++ b/tests/integration/tests/3959-order-of-flags/files/package.yaml @@ -1,10 +1,11 @@ -name: issue3959 -version: 0.1.0.0 +spec-version: 0.36.0 + +name: myPackage dependencies: - base tests: test: - main: Spec.hs + main: Main.hs source-dirs: test diff --git a/tests/integration/tests/3959-order-of-flags/files/stack.yaml b/tests/integration/tests/3959-order-of-flags/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/3959-order-of-flags/files/stack.yaml +++ b/tests/integration/tests/3959-order-of-flags/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/3959-order-of-flags/files/test/Spec.hs b/tests/integration/tests/3959-order-of-flags/files/test/Main.hs similarity index 100% rename from tests/integration/tests/3959-order-of-flags/files/test/Spec.hs rename to tests/integration/tests/3959-order-of-flags/files/test/Main.hs diff --git a/tests/integration/tests/397-case-insensitive-flags/Main.hs b/tests/integration/tests/397-case-insensitive-flags/Main.hs index 65bbe49cc7..e499de5c9d 100644 --- a/tests/integration/tests/397-case-insensitive-flags/Main.hs +++ b/tests/integration/tests/397-case-insensitive-flags/Main.hs @@ -1,10 +1,11 @@ -import StackTest +-- Cabal flags are case-insensitive and Stack treats them as such. +-- +-- See: https://github.com/commercialhaskell/stack/issues/397 + +import StackTest main :: IO () main = do - stackErr ["build"] - stack ["build", "--flag", "new-template:fixIt"] - stack ["build", "--flag", "new-template:fixit"] - stack ["build", "--flag", "new-template:fiXit"] - stack ["build", "--flag", "*:fiXit"] - stackErr ["build", "--flag", "*:fiXit-else"] + stackErr ["build"] + stack ["build", "--flag", "myPackage:nEcEssAry"] + stack ["build", "--flag", "*:nEcEssAry"] diff --git a/tests/integration/tests/397-case-insensitive-flags/files/.gitignore b/tests/integration/tests/397-case-insensitive-flags/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/397-case-insensitive-flags/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/397-case-insensitive-flags/files/new-template.cabal b/tests/integration/tests/397-case-insensitive-flags/files/new-template.cabal deleted file mode 100644 index f9c9dd087a..0000000000 --- a/tests/integration/tests/397-case-insensitive-flags/files/new-template.cabal +++ /dev/null @@ -1,18 +0,0 @@ -name: new-template -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -flag fixIt - manual: True - default: False - description: Make the build work - -library - hs-source-dirs: src - exposed-modules: Lib - default-language: Haskell2010 - if flag(fixIt) - build-depends: base >= 4.7 - else - build-depends: base < 4.7 && > 4.7 diff --git a/tests/integration/tests/397-case-insensitive-flags/files/package.yaml b/tests/integration/tests/397-case-insensitive-flags/files/package.yaml new file mode 100644 index 0000000000..973e01a4f6 --- /dev/null +++ b/tests/integration/tests/397-case-insensitive-flags/files/package.yaml @@ -0,0 +1,18 @@ +spec-version: 0.36.0 + +name: myPackage + +flags: + necessary: + description: The package will not build unless this flag is true. + manual: true + default: false + +dependencies: +- base + +library: + source-dirs: src + when: + - condition: flag(necessary) + cpp-options: -DWORK diff --git a/tests/integration/tests/397-case-insensitive-flags/files/src/Lib.hs b/tests/integration/tests/397-case-insensitive-flags/files/src/Lib.hs index d36ff2714d..eccdf60245 100644 --- a/tests/integration/tests/397-case-insensitive-flags/files/src/Lib.hs +++ b/tests/integration/tests/397-case-insensitive-flags/files/src/Lib.hs @@ -1,6 +1,12 @@ -module Lib - ( someFunc - ) where +{-# LANGUAGE CPP #-} -someFunc :: IO () -someFunc = putStrLn "someFunc" +module Lib where + +-- Avoid problems with CPP and HLint +#ifndef __HLINT__ + +#if !WORK +#error Not going to work, sorry +#endif + +#endif diff --git a/tests/integration/tests/397-case-insensitive-flags/files/stack.yaml b/tests/integration/tests/397-case-insensitive-flags/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/397-case-insensitive-flags/files/stack.yaml +++ b/tests/integration/tests/397-case-insensitive-flags/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/3996-sublib-not-depended-upon/.gitignore b/tests/integration/tests/3996-sublib-not-depended-upon/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/3996-sublib-not-depended-upon/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/3996-sublib-not-depended-upon/Main.hs b/tests/integration/tests/3996-sublib-not-depended-upon/Main.hs index d2479bd056..0ba51d1aea 100644 --- a/tests/integration/tests/3996-sublib-not-depended-upon/Main.hs +++ b/tests/integration/tests/3996-sublib-not-depended-upon/Main.hs @@ -1,8 +1,10 @@ -import Control.Monad (unless) -import Data.List (isInfixOf) -import StackTest +-- Stack should build a package with a main library and an internal library (a +-- private named sublibrary) even if the main library does not depend on the +-- sublibrary. +-- +-- See: https://github.com/commercialhaskell/stack/issues/3996 + +import StackTest main :: IO () -main = do - stack ["clean"] - stack ["build"] +main = stack ["build"] diff --git a/tests/integration/tests/3996-sublib-not-depended-upon/files/Setup.hs b/tests/integration/tests/3996-sublib-not-depended-upon/files/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/3996-sublib-not-depended-upon/files/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/3996-sublib-not-depended-upon/files/files.cabal b/tests/integration/tests/3996-sublib-not-depended-upon/files/files.cabal deleted file mode 100644 index bf9a55bd17..0000000000 --- a/tests/integration/tests/3996-sublib-not-depended-upon/files/files.cabal +++ /dev/null @@ -1,16 +0,0 @@ -name: files -version: 0.1.0.0 -build-type: Simple -cabal-version: >= 2.0 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base - default-language: Haskell2010 - -library lib - hs-source-dirs: src-internal - exposed-modules: Internal - build-depends: base - default-language: Haskell2010 diff --git a/tests/integration/tests/3996-sublib-not-depended-upon/files/int/Internal.hs b/tests/integration/tests/3996-sublib-not-depended-upon/files/int/Internal.hs new file mode 100644 index 0000000000..d066bb085e --- /dev/null +++ b/tests/integration/tests/3996-sublib-not-depended-upon/files/int/Internal.hs @@ -0,0 +1 @@ +module Internal where diff --git a/tests/integration/tests/3996-sublib-not-depended-upon/files/package.yaml b/tests/integration/tests/3996-sublib-not-depended-upon/files/package.yaml new file mode 100644 index 0000000000..ef6e5935e5 --- /dev/null +++ b/tests/integration/tests/3996-sublib-not-depended-upon/files/package.yaml @@ -0,0 +1,13 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src + +internal-libraries: + internal: + source-dirs: int diff --git a/tests/integration/tests/3996-sublib-not-depended-upon/files/src-internal/Internal.hs b/tests/integration/tests/3996-sublib-not-depended-upon/files/src-internal/Internal.hs deleted file mode 100644 index 462baca786..0000000000 --- a/tests/integration/tests/3996-sublib-not-depended-upon/files/src-internal/Internal.hs +++ /dev/null @@ -1,4 +0,0 @@ -module Internal where - -test :: Int -test = 42 diff --git a/tests/integration/tests/3996-sublib-not-depended-upon/files/src/Lib.hs b/tests/integration/tests/3996-sublib-not-depended-upon/files/src/Lib.hs index a35e444b85..6d85a26fe1 100644 --- a/tests/integration/tests/3996-sublib-not-depended-upon/files/src/Lib.hs +++ b/tests/integration/tests/3996-sublib-not-depended-upon/files/src/Lib.hs @@ -1,4 +1 @@ module Lib where - -testLib :: Int -testLib = 42 diff --git a/tests/integration/tests/3996-sublib-not-depended-upon/files/stack.yaml b/tests/integration/tests/3996-sublib-not-depended-upon/files/stack.yaml index 01c7b866fc..e674eab75a 100644 --- a/tests/integration/tests/3996-sublib-not-depended-upon/files/stack.yaml +++ b/tests/integration/tests/3996-sublib-not-depended-upon/files/stack.yaml @@ -1,4 +1 @@ snapshot: ghc-9.10.3 -extra-deps: -- stm-2.4.4.1 -- mtl-2.2.1 diff --git a/tests/integration/tests/3997-coverage-with-cabal-3/Main.hs b/tests/integration/tests/3997-coverage-with-cabal-3/Main.hs index 9e3d9a0e65..c6f049f66f 100644 --- a/tests/integration/tests/3997-coverage-with-cabal-3/Main.hs +++ b/tests/integration/tests/3997-coverage-with-cabal-3/Main.hs @@ -1,10 +1,13 @@ -import Control.Monad (unless) -import Data.List (isInfixOf) -import StackTest +-- Stack can create a coverage report for a test suite. +-- +-- See: https://github.com/commercialhaskell/stack/issues/3997 + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest main :: IO () main = do - stack ["setup"] - stackCheckStderr ["test", "--coverage"] $ \out -> do - unless ("The coverage report for foo's test-suite foo-test is available at" `isInfixOf` out) $ - fail "Coverage report didn't build" + stackCheckStderr ["test", "--coverage"] $ \out -> do + unless ("The coverage report for myPackage's test-suite test is available at" `isInfixOf` out) $ + fail "Coverage report didn't build" diff --git a/tests/integration/tests/3997-coverage-with-cabal-3/files/.gitignore b/tests/integration/tests/3997-coverage-with-cabal-3/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/3997-coverage-with-cabal-3/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/3997-coverage-with-cabal-3/files/package.yaml b/tests/integration/tests/3997-coverage-with-cabal-3/files/package.yaml index d4a5b288c7..3ba4c450a6 100644 --- a/tests/integration/tests/3997-coverage-with-cabal-3/files/package.yaml +++ b/tests/integration/tests/3997-coverage-with-cabal-3/files/package.yaml @@ -1,4 +1,6 @@ -name: foo +spec-version: 0.36.0 + +name: myPackage dependencies: - base @@ -7,8 +9,8 @@ library: source-dirs: src tests: - foo-test: + test: source-dirs: test main: Main.hs dependencies: - - foo + - myPackage diff --git a/tests/integration/tests/3997-coverage-with-cabal-3/files/stack.yaml b/tests/integration/tests/3997-coverage-with-cabal-3/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/3997-coverage-with-cabal-3/files/stack.yaml +++ b/tests/integration/tests/3997-coverage-with-cabal-3/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/4001-excess-recompilation/Main.hs b/tests/integration/tests/4001-excess-recompilation/Main.hs index 20b99b9a5a..03a19bcd10 100644 --- a/tests/integration/tests/4001-excess-recompilation/Main.hs +++ b/tests/integration/tests/4001-excess-recompilation/Main.hs @@ -1,19 +1,24 @@ -import Control.Monad (unless) -import Data.List (isInfixOf) -import StackTest +-- Stack does not recompile a package when a test suite or benchmark is dirty +-- but the test suite or benchmark is not a build target. +-- +-- See: https://github.com/commercialhaskell/stack/issues/4001 + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest main :: IO () main = do - copy "test/Main1.hs" "test/Main.hs" - copy "bench/Main1.hs" "bench/Main.hs" + copy "test/Main.v1" "test/Main.hs" + copy "bench/Main.v1" "bench/Main.hs" stack ["build"] - copy "test/Main2.hs" "test/Main.hs" - copy "bench/Main2.hs" "bench/Main.hs" + copy "test/Main.v2" "test/Main.hs" + copy "bench/Main.v2" "bench/Main.hs" res <- unregisteringLines . snd <$> stackStderr ["build"] - removeFileIgnore "test/Main.hs" - removeFileIgnore "bench/Main.hs" - unless (null res) $ fail "Stack recompiled when a test or benchmark file was changed, but only the library was targeted" + unless (null res) $ + fail "Stack recompiled when a test or benchmark file was changed, but only \ + \the library was targeted." unregisteringLines :: String -> [String] unregisteringLines = filter (isInfixOf " unregistering ") . lines diff --git a/tests/integration/tests/4001-excess-recompilation/files/.gitignore b/tests/integration/tests/4001-excess-recompilation/files/.gitignore new file mode 100644 index 0000000000..f54a4084b1 --- /dev/null +++ b/tests/integration/tests/4001-excess-recompilation/files/.gitignore @@ -0,0 +1 @@ +myPackage.Cabal diff --git a/tests/integration/tests/4001-excess-recompilation/files/Setup.hs b/tests/integration/tests/4001-excess-recompilation/files/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/4001-excess-recompilation/files/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/365-invalid-success/files/app/Main.hs b/tests/integration/tests/4001-excess-recompilation/files/bench/Main.hs similarity index 71% rename from tests/integration/tests/365-invalid-success/files/app/Main.hs rename to tests/integration/tests/4001-excess-recompilation/files/bench/Main.hs index 0d6c14399b..6fca540825 100644 --- a/tests/integration/tests/365-invalid-success/files/app/Main.hs +++ b/tests/integration/tests/4001-excess-recompilation/files/bench/Main.hs @@ -1,4 +1,4 @@ -import Foo +import Lib main :: IO () main = pure () diff --git a/tests/integration/tests/4001-excess-recompilation/files/bench/Main.v1 b/tests/integration/tests/4001-excess-recompilation/files/bench/Main.v1 new file mode 100644 index 0000000000..a0e060b7ca --- /dev/null +++ b/tests/integration/tests/4001-excess-recompilation/files/bench/Main.v1 @@ -0,0 +1,4 @@ +import Lib + +main :: IO () +main = putStrLn "Version 1" diff --git a/tests/integration/tests/4001-excess-recompilation/files/bench/Main.v2 b/tests/integration/tests/4001-excess-recompilation/files/bench/Main.v2 new file mode 100644 index 0000000000..d1741bc55f --- /dev/null +++ b/tests/integration/tests/4001-excess-recompilation/files/bench/Main.v2 @@ -0,0 +1,4 @@ +import Lib + +main :: IO () +main = putStrLn "Version 2" diff --git a/tests/integration/tests/4001-excess-recompilation/files/bench/Main1.hs b/tests/integration/tests/4001-excess-recompilation/files/bench/Main1.hs deleted file mode 100644 index dbd8a1e159..0000000000 --- a/tests/integration/tests/4001-excess-recompilation/files/bench/Main1.hs +++ /dev/null @@ -1,5 +0,0 @@ -import Lib - -main :: IO () -main = putStrLn "I am Main1" - diff --git a/tests/integration/tests/4001-excess-recompilation/files/bench/Main2.hs b/tests/integration/tests/4001-excess-recompilation/files/bench/Main2.hs deleted file mode 100644 index 9c51c0f9ef..0000000000 --- a/tests/integration/tests/4001-excess-recompilation/files/bench/Main2.hs +++ /dev/null @@ -1,5 +0,0 @@ -import Lib - -main :: IO () -main = putStrLn "I am Main2" - diff --git a/tests/integration/tests/4001-excess-recompilation/files/files.cabal b/tests/integration/tests/4001-excess-recompilation/files/files.cabal deleted file mode 100644 index 00c3ca0303..0000000000 --- a/tests/integration/tests/4001-excess-recompilation/files/files.cabal +++ /dev/null @@ -1,25 +0,0 @@ -name: files -version: 0.1.0.0 -build-type: Simple -cabal-version: >= 2.0 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base - default-language: Haskell2010 - -test-suite test - hs-source-dirs: test - main-is: Main.hs - build-depends: base, files - default-language: Haskell2010 - type: exitcode-stdio-1.0 - -benchmark bench - hs-source-dirs: bench - main-is: Main.hs - build-depends: base, files - default-language: Haskell2010 - type: exitcode-stdio-1.0 - diff --git a/tests/integration/tests/4001-excess-recompilation/files/package.yaml b/tests/integration/tests/4001-excess-recompilation/files/package.yaml new file mode 100644 index 0000000000..5817077e48 --- /dev/null +++ b/tests/integration/tests/4001-excess-recompilation/files/package.yaml @@ -0,0 +1,23 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src + +tests: + test: + source-dirs: test + main: Main.hs + dependencies: + - myPackage + +benchmarks: + bench: + source-dirs: bench + main: Main.hs + dependencies: + - myPackage diff --git a/tests/integration/tests/multi-test/files/test-2/Spec.hs b/tests/integration/tests/4001-excess-recompilation/files/test/Main.hs similarity index 71% rename from tests/integration/tests/multi-test/files/test-2/Spec.hs rename to tests/integration/tests/4001-excess-recompilation/files/test/Main.hs index c85feb952a..6fca540825 100644 --- a/tests/integration/tests/multi-test/files/test-2/Spec.hs +++ b/tests/integration/tests/4001-excess-recompilation/files/test/Main.hs @@ -1,4 +1,4 @@ -import Lib +import Lib main :: IO () main = pure () diff --git a/tests/integration/tests/4001-excess-recompilation/files/test/Main.v1 b/tests/integration/tests/4001-excess-recompilation/files/test/Main.v1 new file mode 100644 index 0000000000..a0e060b7ca --- /dev/null +++ b/tests/integration/tests/4001-excess-recompilation/files/test/Main.v1 @@ -0,0 +1,4 @@ +import Lib + +main :: IO () +main = putStrLn "Version 1" diff --git a/tests/integration/tests/4001-excess-recompilation/files/test/Main.v2 b/tests/integration/tests/4001-excess-recompilation/files/test/Main.v2 new file mode 100644 index 0000000000..d1741bc55f --- /dev/null +++ b/tests/integration/tests/4001-excess-recompilation/files/test/Main.v2 @@ -0,0 +1,4 @@ +import Lib + +main :: IO () +main = putStrLn "Version 2" diff --git a/tests/integration/tests/4001-excess-recompilation/files/test/Main1.hs b/tests/integration/tests/4001-excess-recompilation/files/test/Main1.hs deleted file mode 100644 index dbd8a1e159..0000000000 --- a/tests/integration/tests/4001-excess-recompilation/files/test/Main1.hs +++ /dev/null @@ -1,5 +0,0 @@ -import Lib - -main :: IO () -main = putStrLn "I am Main1" - diff --git a/tests/integration/tests/4001-excess-recompilation/files/test/Main2.hs b/tests/integration/tests/4001-excess-recompilation/files/test/Main2.hs deleted file mode 100644 index 9c51c0f9ef..0000000000 --- a/tests/integration/tests/4001-excess-recompilation/files/test/Main2.hs +++ /dev/null @@ -1,5 +0,0 @@ -import Lib - -main :: IO () -main = putStrLn "I am Main2" - diff --git a/tests/integration/tests/4044-no-run-tests-config/Main.hs b/tests/integration/tests/4044-no-run-tests-config/Main.hs index 81d3e5a402..afd68b4d03 100644 --- a/tests/integration/tests/4044-no-run-tests-config/Main.hs +++ b/tests/integration/tests/4044-no-run-tests-config/Main.hs @@ -1,6 +1,10 @@ -import StackTest +-- Stack can be configured not to run test suites. +-- +-- See: https://github.com/commercialhaskell/stack/issues/4044 + +import StackTest main :: IO () main = do stack ["test"] - stack ["build", "foo:test:foo"] + stack ["build", "myPackage:test:test"] diff --git a/tests/integration/tests/4044-no-run-tests-config/files/.gitignore b/tests/integration/tests/4044-no-run-tests-config/files/.gitignore index d43d807c0d..b0a5a052a1 100644 --- a/tests/integration/tests/4044-no-run-tests-config/files/.gitignore +++ b/tests/integration/tests/4044-no-run-tests-config/files/.gitignore @@ -1 +1 @@ -*.cabal +myPackage.cabal diff --git a/tests/integration/tests/4044-no-run-tests-config/files/Test.hs b/tests/integration/tests/4044-no-run-tests-config/files/Test.hs deleted file mode 100644 index 72891941af..0000000000 --- a/tests/integration/tests/4044-no-run-tests-config/files/Test.hs +++ /dev/null @@ -1,2 +0,0 @@ -main :: IO () -main = error "You shall not pass!" diff --git a/tests/integration/tests/4044-no-run-tests-config/files/package.yaml b/tests/integration/tests/4044-no-run-tests-config/files/package.yaml index ba64b2afad..28ed00191b 100644 --- a/tests/integration/tests/4044-no-run-tests-config/files/package.yaml +++ b/tests/integration/tests/4044-no-run-tests-config/files/package.yaml @@ -1,10 +1,14 @@ -name: foo -version: 0 +spec-version: 0.36.0 + +name: myPackage +version: 0.1.0.0 + dependencies: - base library: {} tests: - foo: - main: Test.hs + test: + source-dirs: test + main: Main.hs diff --git a/tests/integration/tests/4044-no-run-tests-config/files/test/Main.hs b/tests/integration/tests/4044-no-run-tests-config/files/test/Main.hs new file mode 100644 index 0000000000..40565d378d --- /dev/null +++ b/tests/integration/tests/4044-no-run-tests-config/files/test/Main.hs @@ -0,0 +1,2 @@ +main :: IO () +main = error "This test will fail if run." diff --git a/tests/integration/tests/4085-insufficient-error-message/Main.hs b/tests/integration/tests/4085-insufficient-error-message/Main.hs index 1f69420f6d..6ec7afb6c5 100644 --- a/tests/integration/tests/4085-insufficient-error-message/Main.hs +++ b/tests/integration/tests/4085-insufficient-error-message/Main.hs @@ -1,3 +1,5 @@ +-- See: https://github.com/commercialhaskell/stack/issues/4044 + {-# LANGUAGE OverloadedStrings #-} {-- diff --git a/tests/integration/tests/4095-utf8-pure-nix/Main.hs b/tests/integration/tests/4095-utf8-pure-nix/Main.hs index cbbb0dfc02..34ee080b98 100644 --- a/tests/integration/tests/4095-utf8-pure-nix/Main.hs +++ b/tests/integration/tests/4095-utf8-pure-nix/Main.hs @@ -1,8 +1,11 @@ -import StackTest +-- Stack supports Unicode code points in a Nix environment. +-- +-- See: https://github.com/commercialhaskell/stack/issues/4095 -import Control.Monad ( unless ) -import Data.Maybe ( isJust ) -import System.Environment ( lookupEnv ) +import Control.Monad ( unless ) +import Data.Maybe ( isJust ) +import StackTest +import System.Environment ( lookupEnv ) -- This test requires that Nix is installed and that the NIX_PATH has been set -- so as to allow the path to be used. @@ -18,7 +21,7 @@ main isInContainer <- getInContainer unless isInContainer $ do stack ["build", "--nix-pure"] - stack ["exec", "--nix-pure", "ShowUnicode"] + stack ["exec", "--nix-pure", "myExe"] -- | 'True' if we are currently running inside a Docker container. getInContainer :: IO Bool diff --git a/tests/integration/tests/4095-utf8-pure-nix/files/.gitignore b/tests/integration/tests/4095-utf8-pure-nix/files/.gitignore index d43d807c0d..b0a5a052a1 100644 --- a/tests/integration/tests/4095-utf8-pure-nix/files/.gitignore +++ b/tests/integration/tests/4095-utf8-pure-nix/files/.gitignore @@ -1 +1 @@ -*.cabal +myPackage.cabal diff --git a/tests/integration/tests/4095-utf8-pure-nix/files/ShowUnicode.hs b/tests/integration/tests/4095-utf8-pure-nix/files/ShowUnicode.hs deleted file mode 100644 index 91011a6576..0000000000 --- a/tests/integration/tests/4095-utf8-pure-nix/files/ShowUnicode.hs +++ /dev/null @@ -1,5 +0,0 @@ -import System.IO (stdout) -import Text.Printf (hPrintf) - -main :: IO () -main = hPrintf stdout "平和" diff --git a/tests/integration/tests/4095-utf8-pure-nix/files/app/Main.hs b/tests/integration/tests/4095-utf8-pure-nix/files/app/Main.hs new file mode 100644 index 0000000000..3350958478 --- /dev/null +++ b/tests/integration/tests/4095-utf8-pure-nix/files/app/Main.hs @@ -0,0 +1,5 @@ +import System.IO ( stdout ) +import Text.Printf ( hPrintf ) + +main :: IO () +main = hPrintf stdout "平和" diff --git a/tests/integration/tests/4095-utf8-pure-nix/files/package.yaml b/tests/integration/tests/4095-utf8-pure-nix/files/package.yaml index 87c99e38ea..ee1f9f8afa 100644 --- a/tests/integration/tests/4095-utf8-pure-nix/files/package.yaml +++ b/tests/integration/tests/4095-utf8-pure-nix/files/package.yaml @@ -1,8 +1,11 @@ -name: foo -version: 0 +spec-version: 0.36.0 + +name: myPackage + dependencies: - base executables: - ShowUnicode: - main: ShowUnicode.hs + myExe: + source-dirs: app + main: Main.hs diff --git a/tests/integration/tests/4095-utf8-pure-nix/files/stack.yaml b/tests/integration/tests/4095-utf8-pure-nix/files/stack.yaml index 59a3225477..6eed06afb0 100644 --- a/tests/integration/tests/4095-utf8-pure-nix/files/stack.yaml +++ b/tests/integration/tests/4095-utf8-pure-nix/files/stack.yaml @@ -1,4 +1,10 @@ -# As of 20 August 2023, there is no Nix package haskell.compiler.ghc946. -# Available options include ghc92 (GHC 9.2.8), ghc926, ghc927, -# ghc94 (GHC 9.4.5), ghc942, ghc943 or ghc944. -snapshot: lts-20.26 # GHC 9.2.8 +# As of 2026-03-01, with channel nixos-25.11, avaiable Nix packages +# haskell.compiler.ghc*, based on: +# +# $ nix-instantiate --eval -E "with import {}; lib.attrNames haskell.compiler" +# +# are: +# +# 948 (GHC 9.4.8), 967 (GHC 9.6.7), 984 (GHC 9.8.4), 9102 (GHC 9.10.2), +# 9103 (GHC 9.10.3), 9122 (GHC 9.12.2). +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/4101-dependency-tree/Main.hs b/tests/integration/tests/4101-dependency-tree/Main.hs index 0edaa6370c..913b2db802 100644 --- a/tests/integration/tests/4101-dependency-tree/Main.hs +++ b/tests/integration/tests/4101-dependency-tree/Main.hs @@ -1,13 +1,17 @@ -import Control.Monad (when, unless) -import StackTest -import System.Directory (getCurrentDirectory) -import Data.List (isPrefixOf) +-- Stack can report the dependency tree of project packages. +-- +-- See: https://github.com/commercialhaskell/stack/issues/4101 + +import Control.Monad ( unless, when ) +import Data.List ( isPrefixOf ) +import StackTest +import System.Directory ( getCurrentDirectory ) main :: IO () main = unless isWindows $ do stackCheckStdout ["ls", "dependencies", "tree"] $ \stdOut -> do let expected = unlines [ "Packages" - , "├─┬ files 0.1.0.0" + , "├─┬ myPackageA 0.0.0" , "│ ├─┬ base 4.20.2.0" ] unless (expected `isPrefixOf` stdOut) $ @@ -15,20 +19,20 @@ main = unless isWindows $ do stackCheckStdout ["ls", "dependencies", "tree", "--depth=1"] $ \stdOut -> do let expected = unlines [ "Packages" - , "├─┬ files 0.1.0.0" + , "├─┬ myPackageA 0.0.0" , "│ ├── base 4.20.2.0" , "│ ├── filelock 0.1.1.2" , "│ ├── mtl 2.3.1" - , "│ └── subproject 0.1.0.0" - , "└─┬ subproject 0.1.0.0" + , "│ └── myPackageB 0.0.0" + , "└─┬ myPackageB 0.0.0" , " └── base 4.20.2.0" ] when (stdOut /= expected) $ error $ unlines [ "Expected:", expected, "Actual:", stdOut ] - stackCheckStdout ["ls", "dependencies", "tree", "subproject"] $ \stdOut -> do + stackCheckStdout ["ls", "dependencies", "tree", "myPackageB"] $ \stdOut -> do let expected = unlines [ "Packages" - , "└─┬ subproject 0.1.0.0" + , "└─┬ myPackageB 0.0.0" , " └─┬ base 4.20.2.0" , " ├─┬ ghc-internal 9.1003.0" , " │ ├─┬ ghc-bignum 1.3" diff --git a/tests/integration/tests/4101-dependency-tree/files/.gitignore b/tests/integration/tests/4101-dependency-tree/files/.gitignore new file mode 100644 index 0000000000..f9a6e152d2 --- /dev/null +++ b/tests/integration/tests/4101-dependency-tree/files/.gitignore @@ -0,0 +1,2 @@ +myPackageA.cabal +myPackageB.cabal diff --git a/tests/integration/tests/4101-dependency-tree/files/files.cabal b/tests/integration/tests/4101-dependency-tree/files/files.cabal deleted file mode 100644 index bd96bcbf9c..0000000000 --- a/tests/integration/tests/4101-dependency-tree/files/files.cabal +++ /dev/null @@ -1,10 +0,0 @@ -name: files -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5, mtl, subproject, filelock - default-language: Haskell2010 diff --git a/tests/integration/tests/4101-dependency-tree/files/myPackageB/package.yaml b/tests/integration/tests/4101-dependency-tree/files/myPackageB/package.yaml new file mode 100644 index 0000000000..f94636c710 --- /dev/null +++ b/tests/integration/tests/4101-dependency-tree/files/myPackageB/package.yaml @@ -0,0 +1,8 @@ +spec-version: 0.36.0 + +name: myPackageB + +dependencies: +- base + +library: {} diff --git a/tests/integration/tests/4101-dependency-tree/files/myPackageB/src/Lib.hs b/tests/integration/tests/4101-dependency-tree/files/myPackageB/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/4101-dependency-tree/files/myPackageB/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/4101-dependency-tree/files/package.yaml b/tests/integration/tests/4101-dependency-tree/files/package.yaml new file mode 100644 index 0000000000..682e620e4c --- /dev/null +++ b/tests/integration/tests/4101-dependency-tree/files/package.yaml @@ -0,0 +1,11 @@ +spec-version: 0.36.0 + +name: myPackageA + +dependencies: +- base +- filelock +- mtl +- myPackageB + +library: {} diff --git a/tests/integration/tests/4101-dependency-tree/files/src/Lib.hs b/tests/integration/tests/4101-dependency-tree/files/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/4101-dependency-tree/files/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/4101-dependency-tree/files/src/Main.hs b/tests/integration/tests/4101-dependency-tree/files/src/Main.hs deleted file mode 100644 index 9cd992d9e5..0000000000 --- a/tests/integration/tests/4101-dependency-tree/files/src/Main.hs +++ /dev/null @@ -1,5 +0,0 @@ -module Main where - -main :: IO () -main = do - putStrLn "hello world" diff --git a/tests/integration/tests/4101-dependency-tree/files/stack.yaml b/tests/integration/tests/4101-dependency-tree/files/stack.yaml index a9b178dba9..2438be841e 100644 --- a/tests/integration/tests/4101-dependency-tree/files/stack.yaml +++ b/tests/integration/tests/4101-dependency-tree/files/stack.yaml @@ -1,7 +1,9 @@ -snapshot: lts-24.24 +snapshot: lts-24.43 + packages: - . -- subproject +- myPackageB + extra-deps: - github: snoyberg/filelock commit: 4f080496d8bf153fbe26e64d1f52cf73c7db25f6 diff --git a/tests/integration/tests/4101-dependency-tree/files/subproject/src/Main.hs b/tests/integration/tests/4101-dependency-tree/files/subproject/src/Main.hs deleted file mode 100644 index 9cd992d9e5..0000000000 --- a/tests/integration/tests/4101-dependency-tree/files/subproject/src/Main.hs +++ /dev/null @@ -1,5 +0,0 @@ -module Main where - -main :: IO () -main = do - putStrLn "hello world" diff --git a/tests/integration/tests/4101-dependency-tree/files/subproject/subproject.cabal b/tests/integration/tests/4101-dependency-tree/files/subproject/subproject.cabal deleted file mode 100644 index 6c3a2f939d..0000000000 --- a/tests/integration/tests/4101-dependency-tree/files/subproject/subproject.cabal +++ /dev/null @@ -1,10 +0,0 @@ -name: subproject -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 diff --git a/tests/integration/tests/4105-test-coverage-of-internal-lib/Main.hs b/tests/integration/tests/4105-test-coverage-of-internal-lib/Main.hs index 8a02ae060e..3d8d2dc4f7 100644 --- a/tests/integration/tests/4105-test-coverage-of-internal-lib/Main.hs +++ b/tests/integration/tests/4105-test-coverage-of-internal-lib/Main.hs @@ -1,6 +1,11 @@ -import Control.Monad ( unless ) -import Data.List ( isInfixOf, isPrefixOf ) -import StackTest +-- Stack generates coverage reports for main libraries and private named +-- libraries (internal libraries). +-- +-- See: https://github.com/commercialhaskell/stack/issues/4105 + +import Control.Monad ( unless ) +import Data.List ( isInfixOf, isPrefixOf ) +import StackTest main :: IO () main = do diff --git a/tests/integration/tests/4105-test-coverage-of-internal-lib/files/.gitignore b/tests/integration/tests/4105-test-coverage-of-internal-lib/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/4105-test-coverage-of-internal-lib/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/4105-test-coverage-of-internal-lib/files/files.cabal b/tests/integration/tests/4105-test-coverage-of-internal-lib/files/files.cabal deleted file mode 100644 index 49cd5a2431..0000000000 --- a/tests/integration/tests/4105-test-coverage-of-internal-lib/files/files.cabal +++ /dev/null @@ -1,23 +0,0 @@ -name: files -version: 0.1.0.0 -build-type: Simple -cabal-version: >= 2.0 - -library - exposed-modules: Src - hs-source-dirs: src - build-depends: base - default-language: Haskell2010 - -library sublib - exposed-modules: B - hs-source-dirs: src-sublib - build-depends: base - default-language: Haskell2010 - -test-suite test - type: exitcode-stdio-1.0 - main-is: Main.hs - hs-source-dirs: test - build-depends: base, files, sublib - default-language: Haskell2010 diff --git a/tests/integration/tests/4105-test-coverage-of-internal-lib/files/int/Internal.hs b/tests/integration/tests/4105-test-coverage-of-internal-lib/files/int/Internal.hs new file mode 100644 index 0000000000..cd713ec4e2 --- /dev/null +++ b/tests/integration/tests/4105-test-coverage-of-internal-lib/files/int/Internal.hs @@ -0,0 +1,7 @@ +module Internal + ( funcInternal + ) where + +-- | A function of the internal library +funcInternal :: Int -> Int +funcInternal = pred diff --git a/tests/integration/tests/4105-test-coverage-of-internal-lib/files/package.yaml b/tests/integration/tests/4105-test-coverage-of-internal-lib/files/package.yaml new file mode 100644 index 0000000000..18ae9cc898 --- /dev/null +++ b/tests/integration/tests/4105-test-coverage-of-internal-lib/files/package.yaml @@ -0,0 +1,21 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src + +internal-libraries: + internal: + source-dirs: int + +tests: + test: + source-dirs: test + main: Main.hs + dependencies: + - internal + - myPackage diff --git a/tests/integration/tests/4105-test-coverage-of-internal-lib/files/src-sublib/B.hs b/tests/integration/tests/4105-test-coverage-of-internal-lib/files/src-sublib/B.hs deleted file mode 100644 index 53253d5dcc..0000000000 --- a/tests/integration/tests/4105-test-coverage-of-internal-lib/files/src-sublib/B.hs +++ /dev/null @@ -1,5 +0,0 @@ -module B where - --- | A function of the internal library -funInternal :: Int -> Int -funInternal = pred diff --git a/tests/integration/tests/4105-test-coverage-of-internal-lib/files/src/Lib.hs b/tests/integration/tests/4105-test-coverage-of-internal-lib/files/src/Lib.hs new file mode 100644 index 0000000000..034418635a --- /dev/null +++ b/tests/integration/tests/4105-test-coverage-of-internal-lib/files/src/Lib.hs @@ -0,0 +1,7 @@ +module Lib + ( funcLib + ) where + +-- | A function of the main library +funcLib :: Int -> Int +funcLib = succ diff --git a/tests/integration/tests/4105-test-coverage-of-internal-lib/files/src/Src.hs b/tests/integration/tests/4105-test-coverage-of-internal-lib/files/src/Src.hs deleted file mode 100644 index 0f8db7fb77..0000000000 --- a/tests/integration/tests/4105-test-coverage-of-internal-lib/files/src/Src.hs +++ /dev/null @@ -1,5 +0,0 @@ -module Src where - --- | A function of the main library -funMainLib :: Int -> Int -funMainLib = succ diff --git a/tests/integration/tests/4105-test-coverage-of-internal-lib/files/stack.yaml b/tests/integration/tests/4105-test-coverage-of-internal-lib/files/stack.yaml index b54fd809bf..5490d5880f 100644 --- a/tests/integration/tests/4105-test-coverage-of-internal-lib/files/stack.yaml +++ b/tests/integration/tests/4105-test-coverage-of-internal-lib/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: lts-24.43 diff --git a/tests/integration/tests/4105-test-coverage-of-internal-lib/files/test/Main.hs b/tests/integration/tests/4105-test-coverage-of-internal-lib/files/test/Main.hs index b1cf81b0dc..967f9031e2 100644 --- a/tests/integration/tests/4105-test-coverage-of-internal-lib/files/test/Main.hs +++ b/tests/integration/tests/4105-test-coverage-of-internal-lib/files/test/Main.hs @@ -1,6 +1,6 @@ -import Control.Monad (when) +import Control.Monad ( when ) -import Src -import B +import Lib ( funcLib ) +import Internal ( funcInternal ) -main = when (funMainLib 41 /= funInternal 43) $ error "test failed" +main = when (funcLib 41 /= funcInternal 43) $ error "test failed" diff --git a/tests/integration/tests/4181-clean-wo-dl-ghc/Main.hs b/tests/integration/tests/4181-clean-wo-dl-ghc/Main.hs index 415380a7e6..cc0f41d298 100644 --- a/tests/integration/tests/4181-clean-wo-dl-ghc/Main.hs +++ b/tests/integration/tests/4181-clean-wo-dl-ghc/Main.hs @@ -1,8 +1,9 @@ --- | --- The integration tests have no ghc present, initially. Stack should not --- require ghc present to run the `clean` command. +-- Stack's clean command should not require the presence of the specified +-- version of GHC. +-- +-- See: https://github.com/commercialhaskell/stack/issues/4181 -import StackTest +import StackTest main :: IO () main = do diff --git a/tests/integration/tests/4181-clean-wo-dl-ghc/files/.gitignore b/tests/integration/tests/4181-clean-wo-dl-ghc/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/4181-clean-wo-dl-ghc/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/4181-clean-wo-dl-ghc/files/foo.cabal b/tests/integration/tests/4181-clean-wo-dl-ghc/files/foo.cabal deleted file mode 100644 index 45446b7f9c..0000000000 --- a/tests/integration/tests/4181-clean-wo-dl-ghc/files/foo.cabal +++ /dev/null @@ -1,13 +0,0 @@ -cabal-version: >= 1.10 - --- This file has been generated from package.yaml by hpack version 0.29.6. --- --- see: https://github.com/sol/hpack --- --- hash: 941a1ab4bea2f0ee229dd6ab7fe9730517a0397fb9141fe2841a0f9748dbfd57 - -name: foo -version: 0.1.0.0 -build-type: Simple - -library diff --git a/tests/integration/tests/4181-clean-wo-dl-ghc/files/package.yaml b/tests/integration/tests/4181-clean-wo-dl-ghc/files/package.yaml new file mode 100644 index 0000000000..4b373ba746 --- /dev/null +++ b/tests/integration/tests/4181-clean-wo-dl-ghc/files/package.yaml @@ -0,0 +1,8 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: {} diff --git a/tests/integration/tests/4215-missing-unregister/Main.hs b/tests/integration/tests/4215-missing-unregister/Main.hs index 83056eb580..4542b9dbaf 100644 --- a/tests/integration/tests/4215-missing-unregister/Main.hs +++ b/tests/integration/tests/4215-missing-unregister/Main.hs @@ -1,6 +1,12 @@ -import StackTest +-- Even if the project directory is unchanged and the project package name and +-- version is the same, Stack recognises when a project package is different to +-- a project package that has been built previously. +-- +-- See: https://github.com/commercialhaskell/stack/issues/4215 + +import StackTest main :: IO () main = do - stack ["build", "--stack-yaml", "stack1.yaml"] - stack ["build", "--stack-yaml", "stack2.yaml"] + stack ["--stack-yaml", "stack1.yaml", "build"] + stack ["--stack-yaml", "stack2.yaml", "build"] diff --git a/tests/integration/tests/4215-missing-unregister/files/.gitignore b/tests/integration/tests/4215-missing-unregister/files/.gitignore index 0afa51175a..b0a5a052a1 100644 --- a/tests/integration/tests/4215-missing-unregister/files/.gitignore +++ b/tests/integration/tests/4215-missing-unregister/files/.gitignore @@ -1 +1 @@ -foo.cabal +myPackage.cabal diff --git a/tests/integration/tests/4215-missing-unregister/files/stack1.yaml b/tests/integration/tests/4215-missing-unregister/files/stack1.yaml index b671072761..365c421b18 100644 --- a/tests/integration/tests/4215-missing-unregister/files/stack1.yaml +++ b/tests/integration/tests/4215-missing-unregister/files/stack1.yaml @@ -1,3 +1,4 @@ snapshot: ghc-9.10.3 + packages: - v1 diff --git a/tests/integration/tests/4215-missing-unregister/files/stack2.yaml b/tests/integration/tests/4215-missing-unregister/files/stack2.yaml index 9ed3d120f8..02a50554ec 100644 --- a/tests/integration/tests/4215-missing-unregister/files/stack2.yaml +++ b/tests/integration/tests/4215-missing-unregister/files/stack2.yaml @@ -1,3 +1,4 @@ snapshot: ghc-9.10.3 + packages: - v2 diff --git a/tests/integration/tests/4215-missing-unregister/files/v1/package.yaml b/tests/integration/tests/4215-missing-unregister/files/v1/package.yaml index 7bcacfcb87..4b373ba746 100644 --- a/tests/integration/tests/4215-missing-unregister/files/v1/package.yaml +++ b/tests/integration/tests/4215-missing-unregister/files/v1/package.yaml @@ -1,5 +1,6 @@ -name: foo -version: 1 +spec-version: 0.36.0 + +name: myPackage dependencies: - base diff --git a/tests/integration/tests/4215-missing-unregister/files/v2/package.yaml b/tests/integration/tests/4215-missing-unregister/files/v2/package.yaml index e49b4fdc65..4b373ba746 100644 --- a/tests/integration/tests/4215-missing-unregister/files/v2/package.yaml +++ b/tests/integration/tests/4215-missing-unregister/files/v2/package.yaml @@ -1,5 +1,6 @@ -name: foo -version: 2 +spec-version: 0.36.0 + +name: myPackage dependencies: - base diff --git a/tests/integration/tests/4270-files-order/Main.hs b/tests/integration/tests/4270-files-order/Main.hs index c4b1a56588..e51067ba08 100644 --- a/tests/integration/tests/4270-files-order/Main.hs +++ b/tests/integration/tests/4270-files-order/Main.hs @@ -1,6 +1,11 @@ -import Control.Monad -import StackTest -import StackTest.Repl +-- Stack's ghci command can load a project with c-sources, if the package +-- description lists the C source files in dependency order. +-- +-- See: https://github.com/commercialhaskell/stack/issues/4270 + +import Control.Monad ( when ) +import StackTest +import StackTest.Repl main :: IO () main = do diff --git a/tests/integration/tests/4270-files-order/files/.gitignore b/tests/integration/tests/4270-files-order/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/4270-files-order/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/4270-files-order/files/cbits-ordering.cabal b/tests/integration/tests/4270-files-order/files/cbits-ordering.cabal deleted file mode 100644 index d1444093b3..0000000000 --- a/tests/integration/tests/4270-files-order/files/cbits-ordering.cabal +++ /dev/null @@ -1,22 +0,0 @@ -cabal-version: 3.4 - -name: cbits-ordering -version: 0.0.0 -build-type: Simple - -library - exposed-modules: - Lib - other-modules: - Paths_cbits_ordering - hs-source-dirs: - src - include-dirs: - cbits - c-sources: - cbits/the_dependency.c - cbits/a_dependent.c - - build-depends: - base >=4.7 && <5 - default-language: GHC2021 diff --git a/tests/integration/tests/4270-files-order/files/package.yaml b/tests/integration/tests/4270-files-order/files/package.yaml new file mode 100644 index 0000000000..70fc7a38c9 --- /dev/null +++ b/tests/integration/tests/4270-files-order/files/package.yaml @@ -0,0 +1,13 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src + include-dirs: cbits + c-sources: + - cbits/the_dependency.c + - cbits/a_dependent.c diff --git a/tests/integration/tests/4270-files-order/files/src/Lib.hs b/tests/integration/tests/4270-files-order/files/src/Lib.hs index 43b103779b..a1d89f1b4f 100644 --- a/tests/integration/tests/4270-files-order/files/src/Lib.hs +++ b/tests/integration/tests/4270-files-order/files/src/Lib.hs @@ -1,7 +1,7 @@ module Lib where -import Foreign.C.String -import System.IO.Unsafe +import Foreign.C.String ( CString, peekCString ) +import System.IO.Unsafe ( unsafePerformIO) foreign import ccall unsafe "a_dependent.h greeting" c_greeting :: CString diff --git a/tests/integration/tests/4270-files-order/files/stack.yaml b/tests/integration/tests/4270-files-order/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/4270-files-order/files/stack.yaml +++ b/tests/integration/tests/4270-files-order/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/4324-dot-includes-boot-packages/Main.hs b/tests/integration/tests/4324-dot-includes-boot-packages/Main.hs index 493cd2b8ca..20c4bff744 100644 --- a/tests/integration/tests/4324-dot-includes-boot-packages/Main.hs +++ b/tests/integration/tests/4324-dot-includes-boot-packages/Main.hs @@ -1,9 +1,13 @@ -import StackTest -import Control.Monad (unless) -import Data.List (isInfixOf) +-- Stack's dot command includes the dependencies of GHC's boot packages. +-- +-- See: https://github.com/commercialhaskell/stack/issues/4324 + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest main :: IO () main = do stackCheckStdout ["dot", "--external"] $ \str -> unless ("\n\"process\" ->" `isInfixOf` str) $ - error "Not showing dependencies of process" + error "Not showing dependencies of process" diff --git a/tests/integration/tests/4324-dot-includes-boot-packages/files/.gitignore b/tests/integration/tests/4324-dot-includes-boot-packages/files/.gitignore index d43d807c0d..b0a5a052a1 100644 --- a/tests/integration/tests/4324-dot-includes-boot-packages/files/.gitignore +++ b/tests/integration/tests/4324-dot-includes-boot-packages/files/.gitignore @@ -1 +1 @@ -*.cabal +myPackage.cabal diff --git a/tests/integration/tests/4324-dot-includes-boot-packages/files/package.yaml b/tests/integration/tests/4324-dot-includes-boot-packages/files/package.yaml index 0708d2f2d3..ff5d3bfd91 100644 --- a/tests/integration/tests/4324-dot-includes-boot-packages/files/package.yaml +++ b/tests/integration/tests/4324-dot-includes-boot-packages/files/package.yaml @@ -1,4 +1,6 @@ -name: foo +spec-version: 0.36.0 + +name: myPackage dependencies: - base diff --git a/tests/integration/tests/4390-dot-no-ghc/Main.hs b/tests/integration/tests/4390-dot-no-ghc/Main.hs index ae94e7eeda..9463c22f72 100644 --- a/tests/integration/tests/4390-dot-no-ghc/Main.hs +++ b/tests/integration/tests/4390-dot-no-ghc/Main.hs @@ -1,4 +1,8 @@ -import StackTest +-- Stack's dot command does not require the presence of the specified GHC. +-- +-- See: https://github.com/commercialhaskell/stack/issues/4390 + +import StackTest main :: IO () main = do diff --git a/tests/integration/tests/4390-dot-no-ghc/files/.gitignore b/tests/integration/tests/4390-dot-no-ghc/files/.gitignore index d43d807c0d..b0a5a052a1 100644 --- a/tests/integration/tests/4390-dot-no-ghc/files/.gitignore +++ b/tests/integration/tests/4390-dot-no-ghc/files/.gitignore @@ -1 +1 @@ -*.cabal +myPackage.cabal diff --git a/tests/integration/tests/4390-dot-no-ghc/files/package.yaml b/tests/integration/tests/4390-dot-no-ghc/files/package.yaml index b1eda63d9f..4b373ba746 100644 --- a/tests/integration/tests/4390-dot-no-ghc/files/package.yaml +++ b/tests/integration/tests/4390-dot-no-ghc/files/package.yaml @@ -1,6 +1,8 @@ -name: foo -version: 0 +spec-version: 0.36.0 + +name: myPackage + dependencies: - base -- process + library: {} diff --git a/tests/integration/tests/4408-init-internal-libs/Main.hs b/tests/integration/tests/4408-init-internal-libs/Main.hs index e1cdc167be..5973d2da18 100644 --- a/tests/integration/tests/4408-init-internal-libs/Main.hs +++ b/tests/integration/tests/4408-init-internal-libs/Main.hs @@ -1,4 +1,9 @@ -import StackTest +-- Stack can initialise a project where a project package includes a private +-- named library (an internal library). +-- +-- See: https://github.com/commercialhaskell/stack/issues/4408 + +import StackTest main :: IO () -main = stack ["init", "--snapshot", "ghc-9.2.4", "--force"] +main = stack ["init"] diff --git a/tests/integration/tests/4408-init-internal-libs/files/.gitignore b/tests/integration/tests/4408-init-internal-libs/files/.gitignore index 684dbffa96..82bb5452c4 100644 --- a/tests/integration/tests/4408-init-internal-libs/files/.gitignore +++ b/tests/integration/tests/4408-init-internal-libs/files/.gitignore @@ -1 +1,2 @@ +myPackage.cabal stack.yaml diff --git a/tests/integration/tests/4408-init-internal-libs/files/foo.cabal b/tests/integration/tests/4408-init-internal-libs/files/foo.cabal deleted file mode 100644 index 0e4d4898ae..0000000000 --- a/tests/integration/tests/4408-init-internal-libs/files/foo.cabal +++ /dev/null @@ -1,15 +0,0 @@ -cabal-version: 2.0 -name: foo -version: 0 -build-type: Simple - -library - hs-source-dirs: src - build-depends: base, some-internal-lib - default-language: Haskell2010 - -library some-internal-lib - hs-source-dirs: src-internal - exposed-modules: Internal - build-depends: base - default-language: Haskell2010 diff --git a/tests/integration/tests/4408-init-internal-libs/files/int/Internal.hs b/tests/integration/tests/4408-init-internal-libs/files/int/Internal.hs new file mode 100644 index 0000000000..d066bb085e --- /dev/null +++ b/tests/integration/tests/4408-init-internal-libs/files/int/Internal.hs @@ -0,0 +1 @@ +module Internal where diff --git a/tests/integration/tests/4408-init-internal-libs/files/package.yaml b/tests/integration/tests/4408-init-internal-libs/files/package.yaml new file mode 100644 index 0000000000..ab1ff55ee9 --- /dev/null +++ b/tests/integration/tests/4408-init-internal-libs/files/package.yaml @@ -0,0 +1,15 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src + dependencies: + - internal + +internal-libraries: + internal: + source-dirs: int diff --git a/tests/integration/tests/4408-init-internal-libs/files/src/Lib.hs b/tests/integration/tests/4408-init-internal-libs/files/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/4408-init-internal-libs/files/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/443-specify-path/.gitignore b/tests/integration/tests/443-specify-path/.gitignore deleted file mode 100644 index 027271b9b2..0000000000 --- a/tests/integration/tests/443-specify-path/.gitignore +++ /dev/null @@ -1 +0,0 @@ -files diff --git a/tests/integration/tests/443-specify-path/Main.hs b/tests/integration/tests/443-specify-path/Main.hs index 8dca6aa4e5..56e5e074fa 100644 --- a/tests/integration/tests/443-specify-path/Main.hs +++ b/tests/integration/tests/443-specify-path/Main.hs @@ -1,30 +1,30 @@ +-- Stack can specify the directory to which built executable binary files are +-- copied. +-- +-- See: https://github.com/commercialhaskell/stack/issues/443 + import StackTest -import System.Directory -import System.FilePath -import System.Info (os) +import System.Directory ( createDirectory, getCurrentDirectory ) +import System.FilePath ( () ) main :: IO () main = do - -- install in relative path - removeDirIgnore "bin" - createDirectory "bin" - stack [defaultSnapshotArg, "--local-bin-path", "./bin", "install" , "happy"] - doesExist ("./bin/happy" ++ exeExt) - -- Default install - -- This seems to fail due to directory being cleaned up, - -- a manual test of the default stack install is required - -- defaultDir <- getAppUserDataDirectory "local" - -- stack ["install", "happy"] - -- doesExist (defaultDir ++ "/bin/happy" ++ exeExt) + -- A manual test of the default stack install is required - -- install in current dir - stack [defaultSnapshotArg, "--local-bin-path", ".", "install", "happy" ] - doesExist ("happy" ++ exeExt) + -- Install in current dir + stack [ "--local-bin-path", ".", "install" ] + doesExist myExe + + -- Install in relative path + createDirectory "bin" + stack [ "--local-bin-path", "./bin", "install" ] + doesExist ("./bin/" <> myExe) - -- install in absolute path - tmpDirectory <- fmap ( "absolute-bin") getCurrentDirectory - removeDirIgnore tmpDirectory + -- Install in absolute path + tmpDirectory <- fmap ( "bin-absolute") getCurrentDirectory createDirectory tmpDirectory - stack [defaultSnapshotArg, "--local-bin-path", tmpDirectory, "install", "happy" ] - doesExist (tmpDirectory ("happy" ++ exeExt)) + stack [ "--local-bin-path", tmpDirectory, "install" ] + doesExist (tmpDirectory myExe) + where + myExe = "myExe" <> exeExt diff --git a/tests/integration/tests/443-specify-path/files/.gitignore b/tests/integration/tests/443-specify-path/files/.gitignore new file mode 100644 index 0000000000..e28030a9e4 --- /dev/null +++ b/tests/integration/tests/443-specify-path/files/.gitignore @@ -0,0 +1,5 @@ +bin/ +bin-absolute/ +myPackage.cabal +myPackage.exe +myPackage diff --git a/tests/integration/tests/443-specify-path/files/app/Main.hs b/tests/integration/tests/443-specify-path/files/app/Main.hs new file mode 100644 index 0000000000..89ad4b3e08 --- /dev/null +++ b/tests/integration/tests/443-specify-path/files/app/Main.hs @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = pure () diff --git a/tests/integration/tests/443-specify-path/files/package.yaml b/tests/integration/tests/443-specify-path/files/package.yaml new file mode 100644 index 0000000000..ee1f9f8afa --- /dev/null +++ b/tests/integration/tests/443-specify-path/files/package.yaml @@ -0,0 +1,11 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +executables: + myExe: + source-dirs: app + main: Main.hs diff --git a/tests/integration/tests/443-specify-path/files/stack.yaml b/tests/integration/tests/443-specify-path/files/stack.yaml new file mode 100644 index 0000000000..e674eab75a --- /dev/null +++ b/tests/integration/tests/443-specify-path/files/stack.yaml @@ -0,0 +1 @@ +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/444-package-option/Main.hs b/tests/integration/tests/444-package-option/Main.hs index a5baaca85f..cf0f314fc4 100644 --- a/tests/integration/tests/444-package-option/Main.hs +++ b/tests/integration/tests/444-package-option/Main.hs @@ -1,8 +1,9 @@ -import StackTest +-- Stack's runghc command allows packages to be identified for use with scripts. +-- +-- See: https://github.com/commercialhaskell/stack/issues/444 + +import StackTest main :: IO () -main = do - isAlpine <- getIsAlpine - if isAlpine || isARM - then logInfo "Disabled on Alpine Linux and ARM since it cannot yet install its own GHC." - else stack [defaultSnapshotArg, "--install-ghc", "runghc", "--package", "safe", "Test.hs"] +main = stack + ["--snapshot", "mySnapshot.yaml", "runghc", "--package", "acme-missiles", "Script.hs"] diff --git a/tests/integration/tests/444-package-option/files/Script.hs b/tests/integration/tests/444-package-option/files/Script.hs new file mode 100644 index 0000000000..97f6a45c8d --- /dev/null +++ b/tests/integration/tests/444-package-option/files/Script.hs @@ -0,0 +1,4 @@ +import Acme.Missiles ( launchMissiles ) + +main :: IO () +main = launchMissiles diff --git a/tests/integration/tests/444-package-option/files/Test.hs b/tests/integration/tests/444-package-option/files/Test.hs deleted file mode 100644 index 681ec416d9..0000000000 --- a/tests/integration/tests/444-package-option/files/Test.hs +++ /dev/null @@ -1,4 +0,0 @@ -import Safe - -main :: IO () -main = print $ headMay ([] :: [Int]) diff --git a/tests/integration/tests/444-package-option/files/mySnapshot.yaml b/tests/integration/tests/444-package-option/files/mySnapshot.yaml new file mode 100644 index 0000000000..09bb7df5ab --- /dev/null +++ b/tests/integration/tests/444-package-option/files/mySnapshot.yaml @@ -0,0 +1,6 @@ +name: mySnapshot + +snapshot: ghc-9.10.3 + +packages: +- acme-missiles-0.3 diff --git a/tests/integration/tests/4453-detailed/Main.hs b/tests/integration/tests/4453-detailed/Main.hs index c54e4a21c5..fe56218f86 100644 --- a/tests/integration/tests/4453-detailed/Main.hs +++ b/tests/integration/tests/4453-detailed/Main.hs @@ -1,7 +1,8 @@ -import StackTest -import System.Directory +-- Stack supports tests of type detailed-0.9. +-- +-- See: https://github.com/commercialhaskell/stack/issues/4453 + +import StackTest main :: IO () -main = do - removeDirIgnore ".stack-work" - stack [defaultSnapshotArg, "test"] +main = stack ["test"] diff --git a/tests/integration/tests/4453-detailed/files/.gitignore b/tests/integration/tests/4453-detailed/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/4453-detailed/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/4453-detailed/files/package.yaml b/tests/integration/tests/4453-detailed/files/package.yaml new file mode 100644 index 0000000000..8ecf25e975 --- /dev/null +++ b/tests/integration/tests/4453-detailed/files/package.yaml @@ -0,0 +1,16 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +tests: + test: + verbatim: + type: detailed-0.9 + test-module: Test + source-dirs: test + other-modules: [] + dependencies: + - Cabal >= 1.20 diff --git a/tests/integration/tests/4453-detailed/files/src/Lib.hs b/tests/integration/tests/4453-detailed/files/src/Lib.hs deleted file mode 100644 index d36ff2714d..0000000000 --- a/tests/integration/tests/4453-detailed/files/src/Lib.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Lib - ( someFunc - ) where - -someFunc :: IO () -someFunc = putStrLn "someFunc" diff --git a/tests/integration/tests/4453-detailed/files/stack.yaml b/tests/integration/tests/4453-detailed/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/4453-detailed/files/stack.yaml +++ b/tests/integration/tests/4453-detailed/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/4453-detailed/files/test-detailed-example.cabal b/tests/integration/tests/4453-detailed/files/test-detailed-example.cabal deleted file mode 100644 index 87a973ce4d..0000000000 --- a/tests/integration/tests/4453-detailed/files/test-detailed-example.cabal +++ /dev/null @@ -1,18 +0,0 @@ -name: test-detailed-example -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.20 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 - -test-suite test-detailed-example-test - type: detailed-0.9 - hs-source-dirs: test - test-module: Spec - build-depends: base >= 4.7, - Cabal >= 1.20 - default-language: Haskell2010 diff --git a/tests/integration/tests/4453-detailed/files/test/Spec.hs b/tests/integration/tests/4453-detailed/files/test/Spec.hs deleted file mode 100644 index 3084a22747..0000000000 --- a/tests/integration/tests/4453-detailed/files/test/Spec.hs +++ /dev/null @@ -1,20 +0,0 @@ -module Spec (tests) where - -import Distribution.TestSuite - -tests :: IO [Test] -tests = do - pure [ - test "foo" Pass - ] - -test :: String -> Result -> Test -test name r = Test t - where - t = TestInstance { - run = pure (Finished r) - , name = name - , tags = [] - , options = [] - , setOption = \_ _ -> Right t - } diff --git a/tests/integration/tests/4453-detailed/files/test/Test.hs b/tests/integration/tests/4453-detailed/files/test/Test.hs new file mode 100644 index 0000000000..c0e8be21d2 --- /dev/null +++ b/tests/integration/tests/4453-detailed/files/test/Test.hs @@ -0,0 +1,20 @@ +module Test + ( tests + ) where + +import Distribution.TestSuite + ( Progress (..), Result (..), Test (..), TestInstance (..) ) + +tests :: IO [Test] +tests = pure [ test "test" Pass ] + +test :: String -> Result -> Test +test name r = Test testInstance + where + testInstance = TestInstance + { run = pure (Finished r) + , name = name + , tags = [] + , options = [] + , setOption = \_ _ -> Right testInstance + } diff --git a/tests/integration/tests/4488-newer-cabal-version/Main.hs b/tests/integration/tests/4488-newer-cabal-version/Main.hs index 0b87c0ee1d..c246a1ee4f 100644 --- a/tests/integration/tests/4488-newer-cabal-version/Main.hs +++ b/tests/integration/tests/4488-newer-cabal-version/Main.hs @@ -1,11 +1,11 @@ -import StackTest +-- Stack can build with a version of Cabal (the library) other than that which +-- is a boot package of the specified GHC version. +-- +-- See: https://github.com/commercialhaskell/stack/issues/4488 + +import StackTest main :: IO () main = do - -- Sibi: Commenting this because we are supporting latest cabal - -- version with this change. You can uncomment it when a newer cabal - -- release is made. - -- https://cabal.readthedocs.io/en/3.6/file-format-changelog.html - -- stackErr ["--stack-yaml", "stack-bad.yaml", "build", "--dry-run"] - -- + stackErr ["--stack-yaml", "stack-bad.yaml", "build", "--dry-run"] stack ["--stack-yaml", "stack-good.yaml", "build", "--dry-run"] diff --git a/tests/integration/tests/4488-newer-cabal-version/files/.gitignore b/tests/integration/tests/4488-newer-cabal-version/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/4488-newer-cabal-version/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/4488-newer-cabal-version/files/Setup.hs b/tests/integration/tests/4488-newer-cabal-version/files/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/4488-newer-cabal-version/files/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/4488-newer-cabal-version/files/foo.cabal b/tests/integration/tests/4488-newer-cabal-version/files/foo.cabal deleted file mode 100644 index fcc3fda5bd..0000000000 --- a/tests/integration/tests/4488-newer-cabal-version/files/foo.cabal +++ /dev/null @@ -1,7 +0,0 @@ -cabal-version: 3.6 -name: foo -version: 0 -build-type: Simple - -library - default-language: Haskell2010 diff --git a/tests/integration/tests/4488-newer-cabal-version/files/package.yaml b/tests/integration/tests/4488-newer-cabal-version/files/package.yaml new file mode 100644 index 0000000000..f695f01228 --- /dev/null +++ b/tests/integration/tests/4488-newer-cabal-version/files/package.yaml @@ -0,0 +1,12 @@ +spec-version: 0.36.0 + +name: myPackage +custom-setup: + dependencies: + - base + - Cabal == 3.16.1.0 + +dependencies: +- base + +library: {} diff --git a/tests/integration/tests/4488-newer-cabal-version/files/stack-good.yaml b/tests/integration/tests/4488-newer-cabal-version/files/stack-good.yaml index 04b1b6ac84..578b1f2a09 100644 --- a/tests/integration/tests/4488-newer-cabal-version/files/stack-good.yaml +++ b/tests/integration/tests/4488-newer-cabal-version/files/stack-good.yaml @@ -1,3 +1,6 @@ snapshot: ghc-9.10.3 + extra-deps: -- Cabal-2.4.1.0 +- Cabal-3.16.1.0 +- Cabal-syntax-3.16.1.0 +- alex-3.5.4.2 diff --git a/tests/integration/tests/4706-ignore-ghc-env-files/Main.hs b/tests/integration/tests/4706-ignore-ghc-env-files/Main.hs index d15e82e2ad..e7e1666c54 100644 --- a/tests/integration/tests/4706-ignore-ghc-env-files/Main.hs +++ b/tests/integration/tests/4706-ignore-ghc-env-files/Main.hs @@ -1,13 +1,16 @@ -import StackTest -import Control.Exception (bracket_) -import Control.Monad (when) -import System.Environment -import System.Directory -import System.Info (arch, os) +-- Stack ignores GHC_ENVIRONMENT. +-- +-- See: https://github.com/commercialhaskell/stack/issues/4706 + +import Control.Exception ( bracket_ ) +import StackTest +import System.Directory ( canonicalizePath, removeFile ) +import System.Environment ( setEnv ) +import System.Info (arch, os) main :: IO () -main = when False $ do -- skip this test until we start using GHC 8.4.4 or later for integration tests - let ghcVer = "8.4.4" +main = do + let ghcVer = "9.10.3" fp = concat [ ".ghc.environment." , arch @@ -16,12 +19,12 @@ main = when False $ do -- skip this test until we start using GHC 8.4.4 or later , "-" , ghcVer ] - writeFile "stack.yaml" $ "snapshot: ghc-" ++ ghcVer bracket_ (writeFile fp "This is an invalid GHC environment file") - (removeFile fp) $ do - envFile <- canonicalizePath fp - setEnv "GHC_ENVIRONMENT" envFile - stack ["clean"] - stack ["build"] - stack ["runghc", "Main.hs"] + (removeFile fp) + ( do + envFile <- canonicalizePath fp + setEnv "GHC_ENVIRONMENT" envFile + stack ["build"] + stack ["runghc", "Main.hs"] + ) diff --git a/tests/integration/tests/4706-ignore-ghc-env-files/files/.gitignore b/tests/integration/tests/4706-ignore-ghc-env-files/files/.gitignore index 0afaa560b3..b0a5a052a1 100644 --- a/tests/integration/tests/4706-ignore-ghc-env-files/files/.gitignore +++ b/tests/integration/tests/4706-ignore-ghc-env-files/files/.gitignore @@ -1,2 +1 @@ -foo.cabal -stack.yaml +myPackage.cabal diff --git a/tests/integration/tests/4706-ignore-ghc-env-files/files/package.yaml b/tests/integration/tests/4706-ignore-ghc-env-files/files/package.yaml index 9bd223a0a0..4b373ba746 100644 --- a/tests/integration/tests/4706-ignore-ghc-env-files/files/package.yaml +++ b/tests/integration/tests/4706-ignore-ghc-env-files/files/package.yaml @@ -1,5 +1,6 @@ -name: foo -version: 0 +spec-version: 0.36.0 + +name: myPackage dependencies: - base diff --git a/tests/integration/tests/4706-ignore-ghc-env-files/files/stack.yaml b/tests/integration/tests/4706-ignore-ghc-env-files/files/stack.yaml new file mode 100644 index 0000000000..e674eab75a --- /dev/null +++ b/tests/integration/tests/4706-ignore-ghc-env-files/files/stack.yaml @@ -0,0 +1 @@ +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/4754-rebuild-haddocks/Main.hs b/tests/integration/tests/4754-rebuild-haddocks/Main.hs index ad3239c26c..3d5e0c499e 100644 --- a/tests/integration/tests/4754-rebuild-haddocks/Main.hs +++ b/tests/integration/tests/4754-rebuild-haddocks/Main.hs @@ -1,4 +1,7 @@ -import StackTest +-- +-- See: https://github.com/commercialhaskell/stack/issues/4754 + +import StackTest main :: IO () main = do diff --git a/tests/integration/tests/4754-rebuild-haddocks/files/.gitignore b/tests/integration/tests/4754-rebuild-haddocks/files/.gitignore index 0afa51175a..b0a5a052a1 100644 --- a/tests/integration/tests/4754-rebuild-haddocks/files/.gitignore +++ b/tests/integration/tests/4754-rebuild-haddocks/files/.gitignore @@ -1 +1 @@ -foo.cabal +myPackage.cabal diff --git a/tests/integration/tests/4754-rebuild-haddocks/files/package.yaml b/tests/integration/tests/4754-rebuild-haddocks/files/package.yaml index 42a00e8f20..3c2901b603 100644 --- a/tests/integration/tests/4754-rebuild-haddocks/files/package.yaml +++ b/tests/integration/tests/4754-rebuild-haddocks/files/package.yaml @@ -1,5 +1,6 @@ -name: foo -version: 0 +spec-version: 0.36.0 + +name: myPackage dependencies: - base diff --git a/tests/integration/tests/4754-rebuild-haddocks/files/src/Foo.hs b/tests/integration/tests/4754-rebuild-haddocks/files/src/Lib.hs similarity index 50% rename from tests/integration/tests/4754-rebuild-haddocks/files/src/Foo.hs rename to tests/integration/tests/4754-rebuild-haddocks/files/src/Lib.hs index 3caec84bf1..4aa20bc752 100644 --- a/tests/integration/tests/4754-rebuild-haddocks/files/src/Foo.hs +++ b/tests/integration/tests/4754-rebuild-haddocks/files/src/Lib.hs @@ -1,5 +1,5 @@ -module Foo where +module Lib where -- | The function below intentionally contains invalid Haddock -foo :: () -foo = () -- ^ this should fail!!! +func :: () +func = () -- ^ this should fail!!! diff --git a/tests/integration/tests/4783-doctest-deps/Main.hs b/tests/integration/tests/4783-doctest-deps/Main.hs index d35e0cf24c..ccdbd4732b 100644 --- a/tests/integration/tests/4783-doctest-deps/Main.hs +++ b/tests/integration/tests/4783-doctest-deps/Main.hs @@ -1,7 +1,9 @@ -import StackTest +-- +-- See: https://github.com/commercialhaskell/stack/issues/4783 + +import StackTest main :: IO () main = do - stackCleanFull - stack ["build", "acme-dont-copy"] + stack ["build", "myPackageB"] stack ["test"] diff --git a/tests/integration/tests/4783-doctest-deps/files/.gitignore b/tests/integration/tests/4783-doctest-deps/files/.gitignore index 0afa51175a..f9a6e152d2 100644 --- a/tests/integration/tests/4783-doctest-deps/files/.gitignore +++ b/tests/integration/tests/4783-doctest-deps/files/.gitignore @@ -1 +1,2 @@ -foo.cabal +myPackageA.cabal +myPackageB.cabal diff --git a/tests/integration/tests/4783-doctest-deps/files/acme-dont-copy/Acme/Dont.hs b/tests/integration/tests/4783-doctest-deps/files/acme-dont-copy/Acme/Dont.hs deleted file mode 100644 index e0a9cc03c3..0000000000 --- a/tests/integration/tests/4783-doctest-deps/files/acme-dont-copy/Acme/Dont.hs +++ /dev/null @@ -1,31 +0,0 @@ --- | --- Module : Acme.Dont --- Copyright : Gracjan Polak 2009 --- License : BSD-style --- Maintainer : Gracjan Polak --- Stability : experimental --- Portability : portable --- --- The Acme.Dont module provides the indispensable don't command, --- ported from Perl. --- --- For more information see influential documentation: --- --- --- Usage: --- --- > main = don't $ do --- > name <- getLine --- > putStrLn $ "hello " ++ name --- -module Acme.Dont where - --- | The Acme.Dont module provides a don't command, which is the --- opposite of Haskell's built-in do. It is used exactly like the do --- monadic construct except that, instead of executing the block it --- controls, it... well... doesn't. --- --- Regardless of the contents of the block, don't returns (). --- -don't :: (Monad m) => m a -> m () -don't _action = pure () diff --git a/tests/integration/tests/4783-doctest-deps/files/acme-dont-copy/COPYRIGHT b/tests/integration/tests/4783-doctest-deps/files/acme-dont-copy/COPYRIGHT deleted file mode 100644 index bfa1719aa5..0000000000 --- a/tests/integration/tests/4783-doctest-deps/files/acme-dont-copy/COPYRIGHT +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (C) 2009 Gracjan Polak - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -=============================================================================== - -(end of COPYRIGHT) diff --git a/tests/integration/tests/4783-doctest-deps/files/acme-dont-copy/Setup.hs b/tests/integration/tests/4783-doctest-deps/files/acme-dont-copy/Setup.hs deleted file mode 100644 index bf6890196c..0000000000 --- a/tests/integration/tests/4783-doctest-deps/files/acme-dont-copy/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain \ No newline at end of file diff --git a/tests/integration/tests/4783-doctest-deps/files/acme-dont-copy/acme-dont-copy.cabal b/tests/integration/tests/4783-doctest-deps/files/acme-dont-copy/acme-dont-copy.cabal deleted file mode 100644 index 3e1c668a7a..0000000000 --- a/tests/integration/tests/4783-doctest-deps/files/acme-dont-copy/acme-dont-copy.cabal +++ /dev/null @@ -1,19 +0,0 @@ -Name: acme-dont-copy -Version: 1.1 -Stability: stable -Exposed-modules: Acme.Dont -Build-type: Simple -License: BSD3 -License-File: COPYRIGHT -Copyright: 2009, Gracjan Polak -Author: Gracjan Polak -Maintainer: Gracjan Polak -Synopsis: A don't construct -Description: - The Acme.Dont module provides a don't command, which is the - opposite of Haskell's built-in do. It is used exactly like the do - monadic construct except that, instead of executing the block it - controls, it... well... doesn't. -Category: Acme -Build-depends: base<1000000 -Hs-source-dirs: . diff --git a/tests/integration/tests/4783-doctest-deps/files/myPackageB/Acme/Dont.hs b/tests/integration/tests/4783-doctest-deps/files/myPackageB/Acme/Dont.hs new file mode 100644 index 0000000000..dd6e565c6f --- /dev/null +++ b/tests/integration/tests/4783-doctest-deps/files/myPackageB/Acme/Dont.hs @@ -0,0 +1,4 @@ +module Acme.Dont where + +don't :: (Monad m) => m a -> m () +don't _action = return () diff --git a/tests/integration/tests/4783-doctest-deps/files/myPackageB/package.yaml b/tests/integration/tests/4783-doctest-deps/files/myPackageB/package.yaml new file mode 100644 index 0000000000..f94636c710 --- /dev/null +++ b/tests/integration/tests/4783-doctest-deps/files/myPackageB/package.yaml @@ -0,0 +1,8 @@ +spec-version: 0.36.0 + +name: myPackageB + +dependencies: +- base + +library: {} diff --git a/tests/integration/tests/4783-doctest-deps/files/package.yaml b/tests/integration/tests/4783-doctest-deps/files/package.yaml index 251fbfb148..142bbea6b6 100644 --- a/tests/integration/tests/4783-doctest-deps/files/package.yaml +++ b/tests/integration/tests/4783-doctest-deps/files/package.yaml @@ -1,5 +1,6 @@ -name: foo -version: 0 +spec-version: 0.36.0 + +name: myPackageA dependencies: - base diff --git a/tests/integration/tests/4783-doctest-deps/files/snapshot.yaml b/tests/integration/tests/4783-doctest-deps/files/snapshot.yaml index 133d9e0f6a..313cfca96f 100644 --- a/tests/integration/tests/4783-doctest-deps/files/snapshot.yaml +++ b/tests/integration/tests/4783-doctest-deps/files/snapshot.yaml @@ -1,4 +1,6 @@ -snapshot: lts-24.24 -name: foo +name: mySnapshot + +snapshot: lts-24.43 + packages: - acme-dont-1.1@sha256:8264ad3e5113d3e0417b46e71d5a9c0914a1f03b5b81319cc329f1dc0f49b96c,602 diff --git a/tests/integration/tests/4783-doctest-deps/files/src/Foo.hs b/tests/integration/tests/4783-doctest-deps/files/src/Foo.hs deleted file mode 100644 index 936d0ccc01..0000000000 --- a/tests/integration/tests/4783-doctest-deps/files/src/Foo.hs +++ /dev/null @@ -1,8 +0,0 @@ -module Foo where - --- | --- --- >>> import Acme.Dont --- >>> don't foo -foo :: IO () -foo = error "foo" diff --git a/tests/integration/tests/4783-doctest-deps/files/src/Lib.hs b/tests/integration/tests/4783-doctest-deps/files/src/Lib.hs new file mode 100644 index 0000000000..c625fb3d19 --- /dev/null +++ b/tests/integration/tests/4783-doctest-deps/files/src/Lib.hs @@ -0,0 +1,8 @@ +module Lib where + +-- | +-- +-- >>> import Acme.Dont +-- >>> don't func +func :: IO () +func = error "func" diff --git a/tests/integration/tests/4783-doctest-deps/files/stack.yaml b/tests/integration/tests/4783-doctest-deps/files/stack.yaml index 6503818833..9cfd6e6102 100644 --- a/tests/integration/tests/4783-doctest-deps/files/stack.yaml +++ b/tests/integration/tests/4783-doctest-deps/files/stack.yaml @@ -1,4 +1,5 @@ snapshot: snapshot.yaml + extra-deps: # Include a package with a duplicated module name -- acme-dont-copy +- myPackageB diff --git a/tests/integration/tests/4783-doctest-deps/files/test/Main.hs b/tests/integration/tests/4783-doctest-deps/files/test/Main.hs index 20e4883829..241b37352a 100644 --- a/tests/integration/tests/4783-doctest-deps/files/test/Main.hs +++ b/tests/integration/tests/4783-doctest-deps/files/test/Main.hs @@ -1,4 +1,4 @@ -import Test.DocTest +import Test.DocTest main :: IO () -main = doctest ["src/Foo.hs"] +main = doctest ["src/Lib.hs"] diff --git a/tests/integration/tests/4897-boot-package-pruned/Main.hs b/tests/integration/tests/4897-boot-package-pruned/Main.hs index d843d8a772..8e9c457127 100644 --- a/tests/integration/tests/4897-boot-package-pruned/Main.hs +++ b/tests/integration/tests/4897-boot-package-pruned/Main.hs @@ -1,6 +1,10 @@ -import Control.Monad (unless) -import Data.List (isInfixOf) -import StackTest +-- Stack warns when a required GHC boot package has been pruned. +-- +-- See: https://github.com/commercialhaskell/stack/issues/4897 + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest planFailure :: String planFailure = "but this GHC boot package has been pruned" @@ -11,5 +15,5 @@ main = do expectMessage :: String -> String -> IO () expectMessage msg stderr = do - unless (words msg `isInfixOf` words stderr) - (error $ "Expected an error: \n" ++ show msg) + unless (words msg `isInfixOf` words stderr) $ + error $ "Expected an error: \n" ++ show msg diff --git a/tests/integration/tests/4897-boot-package-pruned/files/.gitignore b/tests/integration/tests/4897-boot-package-pruned/files/.gitignore new file mode 100644 index 0000000000..59d924c932 --- /dev/null +++ b/tests/integration/tests/4897-boot-package-pruned/files/.gitignore @@ -0,0 +1,2 @@ +directory.cabal +myPackage.cabal diff --git a/tests/integration/tests/4897-boot-package-pruned/files/directory/directory.cabal b/tests/integration/tests/4897-boot-package-pruned/files/directory/directory.cabal index 78abfda5cf..003b0b4583 100644 --- a/tests/integration/tests/4897-boot-package-pruned/files/directory/directory.cabal +++ b/tests/integration/tests/4897-boot-package-pruned/files/directory/directory.cabal @@ -1,8 +1,14 @@ -name: directory -version: 1.3.3.0 -build-type: Simple -cabal-version: >=1.10 +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.39.1. +-- +-- see: https://github.com/sol/hpack + +name: directory +version: 0.0.0 +build-type: Simple library - build-depends: base - default-language: Haskell2010 + build-depends: + base + default-language: Haskell2010 diff --git a/tests/integration/tests/4897-boot-package-pruned/files/directory/package.yaml b/tests/integration/tests/4897-boot-package-pruned/files/directory/package.yaml new file mode 100644 index 0000000000..f93449661a --- /dev/null +++ b/tests/integration/tests/4897-boot-package-pruned/files/directory/package.yaml @@ -0,0 +1,8 @@ +spec-version: 0.36.0 + +name: directory + +dependencies: +- base + +library: {} diff --git a/tests/integration/tests/4897-boot-package-pruned/files/files.cabal b/tests/integration/tests/4897-boot-package-pruned/files/files.cabal deleted file mode 100644 index fd7c274440..0000000000 --- a/tests/integration/tests/4897-boot-package-pruned/files/files.cabal +++ /dev/null @@ -1,8 +0,0 @@ -name: files -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - build-depends: base, directory, process - default-language: Haskell2010 diff --git a/tests/integration/tests/4897-boot-package-pruned/files/package.yaml b/tests/integration/tests/4897-boot-package-pruned/files/package.yaml new file mode 100644 index 0000000000..2a46ba72d4 --- /dev/null +++ b/tests/integration/tests/4897-boot-package-pruned/files/package.yaml @@ -0,0 +1,10 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base +- directory +- process + +library: {} diff --git a/tests/integration/tests/4897-boot-package-pruned/files/stack.yaml b/tests/integration/tests/4897-boot-package-pruned/files/stack.yaml index 78379bbba6..8a84491306 100644 --- a/tests/integration/tests/4897-boot-package-pruned/files/stack.yaml +++ b/tests/integration/tests/4897-boot-package-pruned/files/stack.yaml @@ -1,3 +1,4 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 + extra-deps: - ./directory diff --git a/tests/integration/tests/4938-non-ascii-module-names/Main.hs b/tests/integration/tests/4938-non-ascii-module-names/Main.hs index 7e30af7e02..5fe95a532b 100644 --- a/tests/integration/tests/4938-non-ascii-module-names/Main.hs +++ b/tests/integration/tests/4938-non-ascii-module-names/Main.hs @@ -1,9 +1,15 @@ -import StackTest -import Control.Monad (unless) +-- Stack accepts module names that include Unicode code points outside of the +-- Basic Latin Unicode block (ASCII). +-- +-- See: https://github.com/commercialhaskell/stack/issues/4938 + +import Control.Monad ( unless ) +import StackTest main :: IO () main = do - -- Disabled on Windows due to an error occurred in the integration tests + -- Disabled on Windows due to an error occurred in the integration tests -- regarding Unicode character. Tried to fix it (https://github.com/commercialhaskell/stack/pull/5162/commits/8f04ad9e4cbaa54370dc5af476e3307a16c84405) -- but it didn't work - unless isWindows $ stack ["build"] + unless isWindows $ + stack ["build"] diff --git a/tests/integration/tests/4938-non-ascii-module-names/files/.gitignore b/tests/integration/tests/4938-non-ascii-module-names/files/.gitignore index d43d807c0d..b0a5a052a1 100644 --- a/tests/integration/tests/4938-non-ascii-module-names/files/.gitignore +++ b/tests/integration/tests/4938-non-ascii-module-names/files/.gitignore @@ -1 +1 @@ -*.cabal +myPackage.cabal diff --git a/tests/integration/tests/4938-non-ascii-module-names/files/Lib.hs b/tests/integration/tests/4938-non-ascii-module-names/files/Lib.hs deleted file mode 100644 index d54290bd9b..0000000000 --- a/tests/integration/tests/4938-non-ascii-module-names/files/Lib.hs +++ /dev/null @@ -1,9 +0,0 @@ -module Lib - ( foo - , bar - ) where - -import Täst - -bar :: Int -bar = 42 diff --git "a/tests/integration/tests/4938-non-ascii-module-names/files/T\303\244st.hs" "b/tests/integration/tests/4938-non-ascii-module-names/files/T\303\244st.hs" deleted file mode 100644 index 16c2b18123..0000000000 --- "a/tests/integration/tests/4938-non-ascii-module-names/files/T\303\244st.hs" +++ /dev/null @@ -1,4 +0,0 @@ -module Täst where - -foo :: Int -foo = 42 diff --git a/tests/integration/tests/4938-non-ascii-module-names/files/app/Main.hs b/tests/integration/tests/4938-non-ascii-module-names/files/app/Main.hs deleted file mode 100644 index 26e9751007..0000000000 --- a/tests/integration/tests/4938-non-ascii-module-names/files/app/Main.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Main where - -import Täst - -main :: IO () -main = putStrLn "42" diff --git a/tests/integration/tests/4938-non-ascii-module-names/files/package.yaml b/tests/integration/tests/4938-non-ascii-module-names/files/package.yaml index 96a4d01977..a7305a77cf 100644 --- a/tests/integration/tests/4938-non-ascii-module-names/files/package.yaml +++ b/tests/integration/tests/4938-non-ascii-module-names/files/package.yaml @@ -1,10 +1,9 @@ -name: umlaut -dependencies: [base] +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + library: - source-dirs: . -executables: - exe: - main: Main.hs - source-dirs: app - dependencies: - - umlaut + source-dirs: src diff --git "a/tests/integration/tests/4938-non-ascii-module-names/files/src/\316\224\316\277\316\272\316\271\316\274\316\256.hs" "b/tests/integration/tests/4938-non-ascii-module-names/files/src/\316\224\316\277\316\272\316\271\316\274\316\256.hs" new file mode 100644 index 0000000000..9e2709d52d --- /dev/null +++ "b/tests/integration/tests/4938-non-ascii-module-names/files/src/\316\224\316\277\316\272\316\271\316\274\316\256.hs" @@ -0,0 +1,6 @@ +module Δοκιμή + ( func + ) where + +func :: IO () +func = pure () diff --git a/tests/integration/tests/4938-non-ascii-module-names/files/stack.yaml b/tests/integration/tests/4938-non-ascii-module-names/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/4938-non-ascii-module-names/files/stack.yaml +++ b/tests/integration/tests/4938-non-ascii-module-names/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/5180-ghc-rts-flags/Main.hs b/tests/integration/tests/5180-ghc-rts-flags/Main.hs index e13dcd9ae4..abdca100ad 100644 --- a/tests/integration/tests/5180-ghc-rts-flags/Main.hs +++ b/tests/integration/tests/5180-ghc-rts-flags/Main.hs @@ -1,6 +1,8 @@ -import StackTest +-- Stack supports GHC RTS options. +-- +-- See: https://github.com/commercialhaskell/stack/issues/5180 + +import StackTest main :: IO () -main = do - stack ["clean"] - stack ["build"] +main = stack ["build"] diff --git a/tests/integration/tests/5180-ghc-rts-flags/files/.gitignore b/tests/integration/tests/5180-ghc-rts-flags/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/5180-ghc-rts-flags/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/5180-ghc-rts-flags/files/files.cabal b/tests/integration/tests/5180-ghc-rts-flags/files/files.cabal deleted file mode 100644 index 8f21c6b6bd..0000000000 --- a/tests/integration/tests/5180-ghc-rts-flags/files/files.cabal +++ /dev/null @@ -1,11 +0,0 @@ -name: files -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5, mtl - default-language: Haskell2010 - diff --git a/tests/integration/tests/5180-ghc-rts-flags/files/package.yaml b/tests/integration/tests/5180-ghc-rts-flags/files/package.yaml new file mode 100644 index 0000000000..a7305a77cf --- /dev/null +++ b/tests/integration/tests/5180-ghc-rts-flags/files/package.yaml @@ -0,0 +1,9 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src diff --git a/tests/integration/tests/5180-ghc-rts-flags/files/src/Lib.hs b/tests/integration/tests/5180-ghc-rts-flags/files/src/Lib.hs index 7685c7c4bf..6d85a26fe1 100644 --- a/tests/integration/tests/5180-ghc-rts-flags/files/src/Lib.hs +++ b/tests/integration/tests/5180-ghc-rts-flags/files/src/Lib.hs @@ -1,4 +1 @@ module Lib where - -main :: IO () -main = putStrLn "hello world" diff --git a/tests/integration/tests/5180-ghc-rts-flags/files/stack.yaml b/tests/integration/tests/5180-ghc-rts-flags/files/stack.yaml index 063c7659dc..6f95611bd9 100644 --- a/tests/integration/tests/5180-ghc-rts-flags/files/stack.yaml +++ b/tests/integration/tests/5180-ghc-rts-flags/files/stack.yaml @@ -1,4 +1,4 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 ghc-options: "$locals": -j8 +RTS -s -A128M diff --git a/tests/integration/tests/5272-only-locals/Main.hs b/tests/integration/tests/5272-only-locals/Main.hs index 57b02a7d58..0b2d4ebc3a 100644 --- a/tests/integration/tests/5272-only-locals/Main.hs +++ b/tests/integration/tests/5272-only-locals/Main.hs @@ -1,11 +1,14 @@ -import StackTest -import Control.Monad (void) +-- Stack supports a build target limited to locals. +-- +-- See: https://github.com/commercialhaskell/stack/issues/5272 + +import Control.Monad ( void ) +import StackTest main :: IO () main = do - void $ stack' ["exec", "ghc-pkg", "unregister", "unliftio-core"] - stack ["clean"] - + -- Ensure that the acme-missiles package is not in a package database + void $ stack' ["exec", "ghc-pkg", "unregister", "acme-missiles"] stackErr ["build", "--only-locals"] stack ["build", "--only-snapshot"] stack ["build", "--only-locals"] diff --git a/tests/integration/tests/5272-only-locals/files/.gitignore b/tests/integration/tests/5272-only-locals/files/.gitignore index 0afa51175a..b0a5a052a1 100644 --- a/tests/integration/tests/5272-only-locals/files/.gitignore +++ b/tests/integration/tests/5272-only-locals/files/.gitignore @@ -1 +1 @@ -foo.cabal +myPackage.cabal diff --git a/tests/integration/tests/5272-only-locals/files/package.yaml b/tests/integration/tests/5272-only-locals/files/package.yaml index d0d7ba0a96..c80a013e52 100644 --- a/tests/integration/tests/5272-only-locals/files/package.yaml +++ b/tests/integration/tests/5272-only-locals/files/package.yaml @@ -1,9 +1,10 @@ -name: foo -version: 0.0.0 +spec-version: 0.36.0 + +name: myPackage dependencies: - base -- unliftio-core +- acme-missiles library: - source-dirs: src/ + source-dirs: src diff --git a/tests/integration/tests/5272-only-locals/files/src/Foo.hs b/tests/integration/tests/5272-only-locals/files/src/Foo.hs deleted file mode 100644 index 72e1004bad..0000000000 --- a/tests/integration/tests/5272-only-locals/files/src/Foo.hs +++ /dev/null @@ -1,3 +0,0 @@ -module Foo () where - -import Control.Monad.IO.Unlift () diff --git a/tests/integration/tests/5272-only-locals/files/src/Lib.hs b/tests/integration/tests/5272-only-locals/files/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/5272-only-locals/files/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/5272-only-locals/files/stack.yaml b/tests/integration/tests/5272-only-locals/files/stack.yaml index 63cbffa4be..bb37b901bc 100644 --- a/tests/integration/tests/5272-only-locals/files/stack.yaml +++ b/tests/integration/tests/5272-only-locals/files/stack.yaml @@ -1,5 +1,4 @@ snapshot: ghc-9.10.3 + extra-deps: -- unliftio-core-0.2.0.1@sha256:f9abcdd3f3d28e4840563efb7b8760d2de9b5707bcd6f53a87f6a0d77bb5a9f7,1082 -# Force a unique snapshot - acme-missiles-0.3@rev:0 diff --git a/tests/integration/tests/5680-share-package-across-projects/Main.hs b/tests/integration/tests/5680-share-package-across-projects/Main.hs index 1a04eb87d5..b5797bdfb8 100644 --- a/tests/integration/tests/5680-share-package-across-projects/Main.hs +++ b/tests/integration/tests/5680-share-package-across-projects/Main.hs @@ -1,8 +1,11 @@ -import StackTest +-- Stack supports project packages located outside of the project directory. +-- +-- See: https://github.com/commercialhaskell/stack/issues/5680 + +import StackTest main :: IO () main = do - stackEnv <- stackExe - withCwd "package-a" $ stack ["build"] - withCwd "package-b" $ stack ["build"] - withCwd "package-a" $ stack ["build"] + withCwd "myPackageA" $ stack ["build"] + withCwd "myPackageB" $ stack ["build"] + withCwd "myPackageA" $ stack ["build"] diff --git a/tests/integration/tests/5680-share-package-across-projects/files/.gitignore b/tests/integration/tests/5680-share-package-across-projects/files/.gitignore new file mode 100644 index 0000000000..c4ea0f5ab0 --- /dev/null +++ b/tests/integration/tests/5680-share-package-across-projects/files/.gitignore @@ -0,0 +1,3 @@ +myPackageA.cabal +myPackageB.cabal +myPackageC.cabal diff --git a/tests/integration/tests/5680-share-package-across-projects/files/myPackageA/package.yaml b/tests/integration/tests/5680-share-package-across-projects/files/myPackageA/package.yaml new file mode 100644 index 0000000000..d26b472ded --- /dev/null +++ b/tests/integration/tests/5680-share-package-across-projects/files/myPackageA/package.yaml @@ -0,0 +1,9 @@ +spec-version: 0.36.0 + +name: myPackageA + +dependencies: +- base + +library: + source-dirs: src diff --git a/tests/integration/tests/5680-share-package-across-projects/files/myPackageA/src/Lib.hs b/tests/integration/tests/5680-share-package-across-projects/files/myPackageA/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/5680-share-package-across-projects/files/myPackageA/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/5680-share-package-across-projects/files/myPackageA/stack.yaml b/tests/integration/tests/5680-share-package-across-projects/files/myPackageA/stack.yaml new file mode 100644 index 0000000000..227a659a66 --- /dev/null +++ b/tests/integration/tests/5680-share-package-across-projects/files/myPackageA/stack.yaml @@ -0,0 +1,5 @@ +snapshot: ghc-9.10.3 + +packages: +- . +- ../myPackageC diff --git a/tests/integration/tests/5680-share-package-across-projects/files/myPackageB/package.yaml b/tests/integration/tests/5680-share-package-across-projects/files/myPackageB/package.yaml new file mode 100644 index 0000000000..03b4ec87d3 --- /dev/null +++ b/tests/integration/tests/5680-share-package-across-projects/files/myPackageB/package.yaml @@ -0,0 +1,9 @@ +spec-version: 0.36.0 + +name: myPackageB + +dependencies: +- base + +library: + source-dirs: src diff --git a/tests/integration/tests/5680-share-package-across-projects/files/myPackageB/src/Lib.hs b/tests/integration/tests/5680-share-package-across-projects/files/myPackageB/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/5680-share-package-across-projects/files/myPackageB/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/5680-share-package-across-projects/files/myPackageB/stack.yaml b/tests/integration/tests/5680-share-package-across-projects/files/myPackageB/stack.yaml new file mode 100644 index 0000000000..227a659a66 --- /dev/null +++ b/tests/integration/tests/5680-share-package-across-projects/files/myPackageB/stack.yaml @@ -0,0 +1,5 @@ +snapshot: ghc-9.10.3 + +packages: +- . +- ../myPackageC diff --git a/tests/integration/tests/5680-share-package-across-projects/files/myPackageC/package.yaml b/tests/integration/tests/5680-share-package-across-projects/files/myPackageC/package.yaml new file mode 100644 index 0000000000..4ab5200b73 --- /dev/null +++ b/tests/integration/tests/5680-share-package-across-projects/files/myPackageC/package.yaml @@ -0,0 +1,9 @@ +spec-version: 0.36.0 + +name: myPackageC + +dependencies: +- base + +library: + source-dirs: src diff --git a/tests/integration/tests/3533-extra-deps-solver/files/local-mmorph/src/Lib.hs b/tests/integration/tests/5680-share-package-across-projects/files/myPackageC/src/Lib.hs similarity index 100% rename from tests/integration/tests/3533-extra-deps-solver/files/local-mmorph/src/Lib.hs rename to tests/integration/tests/5680-share-package-across-projects/files/myPackageC/src/Lib.hs diff --git a/tests/integration/tests/5680-share-package-across-projects/files/myPackageC/stack.yaml b/tests/integration/tests/5680-share-package-across-projects/files/myPackageC/stack.yaml new file mode 100644 index 0000000000..e674eab75a --- /dev/null +++ b/tests/integration/tests/5680-share-package-across-projects/files/myPackageC/stack.yaml @@ -0,0 +1 @@ +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/5680-share-package-across-projects/files/package-a/package.yaml b/tests/integration/tests/5680-share-package-across-projects/files/package-a/package.yaml deleted file mode 100644 index 73f5370e6a..0000000000 --- a/tests/integration/tests/5680-share-package-across-projects/files/package-a/package.yaml +++ /dev/null @@ -1,6 +0,0 @@ -name: package-a -version: 0.1.0.0 -dependencies: -- base >= 4.7 && < 5 -library: - source-dirs: src diff --git a/tests/integration/tests/5680-share-package-across-projects/files/package-a/src/Lib.hs b/tests/integration/tests/5680-share-package-across-projects/files/package-a/src/Lib.hs deleted file mode 100644 index d36ff2714d..0000000000 --- a/tests/integration/tests/5680-share-package-across-projects/files/package-a/src/Lib.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Lib - ( someFunc - ) where - -someFunc :: IO () -someFunc = putStrLn "someFunc" diff --git a/tests/integration/tests/5680-share-package-across-projects/files/package-a/stack.yaml b/tests/integration/tests/5680-share-package-across-projects/files/package-a/stack.yaml deleted file mode 100644 index 94af074400..0000000000 --- a/tests/integration/tests/5680-share-package-across-projects/files/package-a/stack.yaml +++ /dev/null @@ -1,4 +0,0 @@ -snapshot: lts-24.24 -packages: -- . -- ../package-c diff --git a/tests/integration/tests/5680-share-package-across-projects/files/package-b/package.yaml b/tests/integration/tests/5680-share-package-across-projects/files/package-b/package.yaml deleted file mode 100644 index b134ba60f7..0000000000 --- a/tests/integration/tests/5680-share-package-across-projects/files/package-b/package.yaml +++ /dev/null @@ -1,6 +0,0 @@ -name: package-b -version: 0.1.0.0 -dependencies: -- base >= 4.7 && < 5 -library: - source-dirs: src diff --git a/tests/integration/tests/5680-share-package-across-projects/files/package-b/src/Lib.hs b/tests/integration/tests/5680-share-package-across-projects/files/package-b/src/Lib.hs deleted file mode 100644 index d36ff2714d..0000000000 --- a/tests/integration/tests/5680-share-package-across-projects/files/package-b/src/Lib.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Lib - ( someFunc - ) where - -someFunc :: IO () -someFunc = putStrLn "someFunc" diff --git a/tests/integration/tests/5680-share-package-across-projects/files/package-b/stack.yaml b/tests/integration/tests/5680-share-package-across-projects/files/package-b/stack.yaml deleted file mode 100644 index 94af074400..0000000000 --- a/tests/integration/tests/5680-share-package-across-projects/files/package-b/stack.yaml +++ /dev/null @@ -1,4 +0,0 @@ -snapshot: lts-24.24 -packages: -- . -- ../package-c diff --git a/tests/integration/tests/5680-share-package-across-projects/files/package-c/package.yaml b/tests/integration/tests/5680-share-package-across-projects/files/package-c/package.yaml deleted file mode 100644 index 590f48c24a..0000000000 --- a/tests/integration/tests/5680-share-package-across-projects/files/package-c/package.yaml +++ /dev/null @@ -1,6 +0,0 @@ -name: package-c -version: 0.1.0.0 -dependencies: -- base >= 4.7 && < 5 -library: - source-dirs: src diff --git a/tests/integration/tests/5680-share-package-across-projects/files/package-c/src/Lib.hs b/tests/integration/tests/5680-share-package-across-projects/files/package-c/src/Lib.hs deleted file mode 100644 index d36ff2714d..0000000000 --- a/tests/integration/tests/5680-share-package-across-projects/files/package-c/src/Lib.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Lib - ( someFunc - ) where - -someFunc :: IO () -someFunc = putStrLn "someFunc" diff --git a/tests/integration/tests/5680-share-package-across-projects/files/package-c/stack.yaml b/tests/integration/tests/5680-share-package-across-projects/files/package-c/stack.yaml deleted file mode 100644 index b54fd809bf..0000000000 --- a/tests/integration/tests/5680-share-package-across-projects/files/package-c/stack.yaml +++ /dev/null @@ -1 +0,0 @@ -snapshot: lts-24.24 diff --git a/tests/integration/tests/6046-missing-sublib-unregister/Main.hs b/tests/integration/tests/6046-missing-sublib-unregister/Main.hs index 174dad3876..c43d98a66d 100644 --- a/tests/integration/tests/6046-missing-sublib-unregister/Main.hs +++ b/tests/integration/tests/6046-missing-sublib-unregister/Main.hs @@ -1,12 +1,16 @@ +-- Stack builds a package where the main library depends on a private named +-- lirary (an internal library). +-- +-- See: https://github.com/commercialhaskell/stack/issues/6046 + import StackTest -- This tests building a package with a library and an internal sub library, --- where the library depends on the sub library, first version 0.1.0.0 (the --- Cabal file is @foo.cabal1@) and then version 0.2.0.0 (the Cabal file is --- @foo.cabal2@). +-- where the library depends on the sub library, first version 0.1.0.0 and then +-- version 0.2.0.0. main :: IO () main = do - copy "foo.cabal1" "foo.cabal" + copy "package1.yaml" "package.yaml" stack ["build"] - copy "foo.cabal2" "foo.cabal" + copy "package2.yaml" "package.yaml" stack ["build"] diff --git a/tests/integration/tests/6046-missing-sublib-unregister/files/foo.cabal1 b/tests/integration/tests/6046-missing-sublib-unregister/files/foo.cabal1 deleted file mode 100644 index f6cf35e216..0000000000 --- a/tests/integration/tests/6046-missing-sublib-unregister/files/foo.cabal1 +++ /dev/null @@ -1,27 +0,0 @@ -cabal-version: 2.0 -name: foo -version: 0.1.0.0 -build-type: Simple - -library - exposed-modules: - Lib - other-modules: - Sub - hs-source-dirs: - src - ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints - build-depends: - base >=4.7 && <5 - , sub - default-language: Haskell2010 - -library sub - exposed-modules: - Sub - hs-source-dirs: - src - ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints - build-depends: - base >=4.7 && <5 - default-language: Haskell2010 diff --git a/tests/integration/tests/6046-missing-sublib-unregister/files/foo.cabal2 b/tests/integration/tests/6046-missing-sublib-unregister/files/foo.cabal2 deleted file mode 100644 index 58cd271816..0000000000 --- a/tests/integration/tests/6046-missing-sublib-unregister/files/foo.cabal2 +++ /dev/null @@ -1,27 +0,0 @@ -cabal-version: 2.0 -name: foo -version: 0.2.0.0 -build-type: Simple - -library - exposed-modules: - Lib - other-modules: - Sub - hs-source-dirs: - src - ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints - build-depends: - base >=4.7 && <5 - , sub - default-language: Haskell2010 - -library sub - exposed-modules: - Sub - hs-source-dirs: - src - ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints - build-depends: - base >=4.7 && <5 - default-language: Haskell2010 diff --git a/tests/integration/tests/6046-missing-sublib-unregister/files/int/Internal.hs b/tests/integration/tests/6046-missing-sublib-unregister/files/int/Internal.hs new file mode 100644 index 0000000000..d066bb085e --- /dev/null +++ b/tests/integration/tests/6046-missing-sublib-unregister/files/int/Internal.hs @@ -0,0 +1 @@ +module Internal where diff --git a/tests/integration/tests/6046-missing-sublib-unregister/files/package1.yaml b/tests/integration/tests/6046-missing-sublib-unregister/files/package1.yaml new file mode 100644 index 0000000000..62c65aee09 --- /dev/null +++ b/tests/integration/tests/6046-missing-sublib-unregister/files/package1.yaml @@ -0,0 +1,16 @@ +spec-version: 0.36.0 + +name: myPackage +version: 0.1.0.0 + +dependencies: +- base + +library: + source-dirs: src + dependencies: + - internal + +internal-libraries: + internal: + source-dirs: int diff --git a/tests/integration/tests/6046-missing-sublib-unregister/files/package2.yaml b/tests/integration/tests/6046-missing-sublib-unregister/files/package2.yaml new file mode 100644 index 0000000000..176e733308 --- /dev/null +++ b/tests/integration/tests/6046-missing-sublib-unregister/files/package2.yaml @@ -0,0 +1,16 @@ +spec-version: 0.36.0 + +name: myPackage +version: 0.2.0.0 + +dependencies: +- base + +library: + source-dirs: src + dependencies: + - internal + +internal-libraries: + internal: + source-dirs: int diff --git a/tests/integration/tests/6046-missing-sublib-unregister/files/src/Lib.hs b/tests/integration/tests/6046-missing-sublib-unregister/files/src/Lib.hs index 7bce5cbb19..1369151610 100644 --- a/tests/integration/tests/6046-missing-sublib-unregister/files/src/Lib.hs +++ b/tests/integration/tests/6046-missing-sublib-unregister/files/src/Lib.hs @@ -1,5 +1,3 @@ -module Lib - ( someFunc - ) where +module Lib where -import Sub ( someFunc ) +import Internal diff --git a/tests/integration/tests/6046-missing-sublib-unregister/files/src/Sub.hs b/tests/integration/tests/6046-missing-sublib-unregister/files/src/Sub.hs deleted file mode 100644 index a173e7a513..0000000000 --- a/tests/integration/tests/6046-missing-sublib-unregister/files/src/Sub.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Sub - ( someFunc - ) where - -someFunc :: IO () -someFunc = putStrLn "someFunc" diff --git a/tests/integration/tests/6046-missing-sublib-unregister/files/stack.yaml b/tests/integration/tests/6046-missing-sublib-unregister/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/6046-missing-sublib-unregister/files/stack.yaml +++ b/tests/integration/tests/6046-missing-sublib-unregister/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/606-local-version-not-exist/Main.hs b/tests/integration/tests/606-local-version-not-exist/Main.hs index 30d17c8729..cfd6a18a03 100644 --- a/tests/integration/tests/606-local-version-not-exist/Main.hs +++ b/tests/integration/tests/606-local-version-not-exist/Main.hs @@ -1,8 +1,12 @@ -import StackTest +-- Stack reports an error when the target is a project package version, +-- whether the version is correct or not. +-- +-- See: https://github.com/commercialhaskell/stack/issues/606 + +import StackTest main :: IO () main = do - stackErr ["build", "files-3"] - stackErr ["build", "files-0.1.0.0"] - stack ["build", "files"] - stack ["build", "."] + stackErr ["build", "myPackage-1"] + stackErr ["build", "myPackage-0.1.0.0"] + stack ["build", "myPackage"] diff --git a/tests/integration/tests/606-local-version-not-exist/files/.gitignore b/tests/integration/tests/606-local-version-not-exist/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/606-local-version-not-exist/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/606-local-version-not-exist/files/files.cabal b/tests/integration/tests/606-local-version-not-exist/files/files.cabal deleted file mode 100644 index 6ec3b1e471..0000000000 --- a/tests/integration/tests/606-local-version-not-exist/files/files.cabal +++ /dev/null @@ -1,10 +0,0 @@ -name: files -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 diff --git a/tests/integration/tests/3520-revision-matching/files/package.yaml b/tests/integration/tests/606-local-version-not-exist/files/package.yaml similarity index 64% rename from tests/integration/tests/3520-revision-matching/files/package.yaml rename to tests/integration/tests/606-local-version-not-exist/files/package.yaml index ed129d64f0..b20cb3407d 100644 --- a/tests/integration/tests/3520-revision-matching/files/package.yaml +++ b/tests/integration/tests/606-local-version-not-exist/files/package.yaml @@ -1,9 +1,10 @@ -name: issue3520 +spec-version: 0.36.0 + +name: myPackage version: 0.1.0.0 dependencies: - base -- mtl library: source-dirs: src diff --git a/tests/integration/tests/606-local-version-not-exist/files/src/Lib.hs b/tests/integration/tests/606-local-version-not-exist/files/src/Lib.hs index d36ff2714d..6d85a26fe1 100644 --- a/tests/integration/tests/606-local-version-not-exist/files/src/Lib.hs +++ b/tests/integration/tests/606-local-version-not-exist/files/src/Lib.hs @@ -1,6 +1 @@ -module Lib - ( someFunc - ) where - -someFunc :: IO () -someFunc = putStrLn "someFunc" +module Lib where diff --git a/tests/integration/tests/606-local-version-not-exist/files/stack.yaml b/tests/integration/tests/606-local-version-not-exist/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/606-local-version-not-exist/files/stack.yaml +++ b/tests/integration/tests/606-local-version-not-exist/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/617-extra-dep-flag/Main.hs b/tests/integration/tests/617-extra-dep-flag/Main.hs index 50fcae4fa6..b4b45ef978 100644 --- a/tests/integration/tests/617-extra-dep-flag/Main.hs +++ b/tests/integration/tests/617-extra-dep-flag/Main.hs @@ -1,4 +1,8 @@ -import StackTest +-- Stack can specify a Cabal flag for an extra-dep. +-- +-- See: https://github.com/commercialhaskell/stack/issues/617 + +import StackTest main :: IO () -main = stack ["build", "acme-dont-1.1"] +main = stack ["build", "acme-missiles-0.3"] diff --git a/tests/integration/tests/617-extra-dep-flag/files/stack.yaml b/tests/integration/tests/617-extra-dep-flag/files/stack.yaml index 33622a7c88..ae1b6d1fd9 100644 --- a/tests/integration/tests/617-extra-dep-flag/files/stack.yaml +++ b/tests/integration/tests/617-extra-dep-flag/files/stack.yaml @@ -1,7 +1,10 @@ snapshot: ghc-9.10.3 + +packages: [] + +extra-deps: +- text-1.2.0.3 + flags: text: integer-simple: false -extra-deps: -- text-1.2.0.3 -packages: [] diff --git a/tests/integration/tests/617-unused-flag-cli/Main.hs b/tests/integration/tests/617-unused-flag-cli/Main.hs index f9a2b093ea..f1123b1794 100644 --- a/tests/integration/tests/617-unused-flag-cli/Main.hs +++ b/tests/integration/tests/617-unused-flag-cli/Main.hs @@ -1,8 +1,13 @@ -import StackTest +-- Stack reports an error when a Cabal flag is specified on the command line for +-- a specific non-existent package or a non-existent Cabal flag is specified for +-- a specific project package. +-- +-- See: https://github.com/commercialhaskell/stack/issues/617 + +import StackTest main :: IO () main = do - stack ["build"] - stackErr ["build", "--flag", "foo:bar"] - stackErr ["build", "--flag", "files:bar"] - stack ["build", "--flag", "*:bar"] + stackErr ["build", "--flag", "noSuchPackage:my-flag"] + stackErr ["build", "--flag", "myPackage:no-such-flag"] + stack ["build", "--flag", "*:no-such-flag"] diff --git a/tests/integration/tests/617-unused-flag-cli/files/.gitignore b/tests/integration/tests/617-unused-flag-cli/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/617-unused-flag-cli/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/617-unused-flag-cli/files/files.cabal b/tests/integration/tests/617-unused-flag-cli/files/files.cabal deleted file mode 100644 index 6ec3b1e471..0000000000 --- a/tests/integration/tests/617-unused-flag-cli/files/files.cabal +++ /dev/null @@ -1,10 +0,0 @@ -name: files -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 diff --git a/tests/integration/tests/617-unused-flag-cli/files/package.yaml b/tests/integration/tests/617-unused-flag-cli/files/package.yaml new file mode 100644 index 0000000000..a7305a77cf --- /dev/null +++ b/tests/integration/tests/617-unused-flag-cli/files/package.yaml @@ -0,0 +1,9 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src diff --git a/tests/integration/tests/617-unused-flag-cli/files/src/Lib.hs b/tests/integration/tests/617-unused-flag-cli/files/src/Lib.hs index d36ff2714d..6d85a26fe1 100644 --- a/tests/integration/tests/617-unused-flag-cli/files/src/Lib.hs +++ b/tests/integration/tests/617-unused-flag-cli/files/src/Lib.hs @@ -1,6 +1 @@ -module Lib - ( someFunc - ) where - -someFunc :: IO () -someFunc = putStrLn "someFunc" +module Lib where diff --git a/tests/integration/tests/617-unused-flag-name-yaml/Main.hs b/tests/integration/tests/617-unused-flag-name-yaml/Main.hs index b16d43227b..576cea322d 100644 --- a/tests/integration/tests/617-unused-flag-name-yaml/Main.hs +++ b/tests/integration/tests/617-unused-flag-name-yaml/Main.hs @@ -1,4 +1,9 @@ -import StackTest +-- Stack reports an error when a non-existent Cabal flag is specified for +-- a project package. +-- +-- See: https://github.com/commercialhaskell/stack/issues/617 + +import StackTest main :: IO () main = stackErr ["build"] diff --git a/tests/integration/tests/617-unused-flag-name-yaml/files/.gitignore b/tests/integration/tests/617-unused-flag-name-yaml/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/617-unused-flag-name-yaml/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/617-unused-flag-name-yaml/files/files.cabal b/tests/integration/tests/617-unused-flag-name-yaml/files/files.cabal deleted file mode 100644 index 6ec3b1e471..0000000000 --- a/tests/integration/tests/617-unused-flag-name-yaml/files/files.cabal +++ /dev/null @@ -1,10 +0,0 @@ -name: files -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 diff --git a/tests/integration/tests/617-unused-flag-name-yaml/files/package.yaml b/tests/integration/tests/617-unused-flag-name-yaml/files/package.yaml new file mode 100644 index 0000000000..a7305a77cf --- /dev/null +++ b/tests/integration/tests/617-unused-flag-name-yaml/files/package.yaml @@ -0,0 +1,9 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src diff --git a/tests/integration/tests/617-unused-flag-name-yaml/files/src/Lib.hs b/tests/integration/tests/617-unused-flag-name-yaml/files/src/Lib.hs index d36ff2714d..6d85a26fe1 100644 --- a/tests/integration/tests/617-unused-flag-name-yaml/files/src/Lib.hs +++ b/tests/integration/tests/617-unused-flag-name-yaml/files/src/Lib.hs @@ -1,6 +1 @@ -module Lib - ( someFunc - ) where - -someFunc :: IO () -someFunc = putStrLn "someFunc" +module Lib where diff --git a/tests/integration/tests/617-unused-flag-name-yaml/files/stack.yaml b/tests/integration/tests/617-unused-flag-name-yaml/files/stack.yaml index 39fe9b5749..d7173d4dd8 100644 --- a/tests/integration/tests/617-unused-flag-name-yaml/files/stack.yaml +++ b/tests/integration/tests/617-unused-flag-name-yaml/files/stack.yaml @@ -1,4 +1,5 @@ snapshot: ghc-9.10.3 + flags: - files: - does-not-exist: false + myPackage: + no-such-flag: false diff --git a/tests/integration/tests/617-unused-flag-yaml/Main.hs b/tests/integration/tests/617-unused-flag-yaml/Main.hs index b16d43227b..0d928514db 100644 --- a/tests/integration/tests/617-unused-flag-yaml/Main.hs +++ b/tests/integration/tests/617-unused-flag-yaml/Main.hs @@ -1,4 +1,9 @@ -import StackTest +-- Stack reports an error when a Cabal flag is specified for a specific +-- non-existent package. +-- +-- See: https://github.com/commercialhaskell/stack/issues/617 + +import StackTest main :: IO () main = stackErr ["build"] diff --git a/tests/integration/tests/617-unused-flag-yaml/files/.gitignore b/tests/integration/tests/617-unused-flag-yaml/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/617-unused-flag-yaml/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/617-unused-flag-yaml/files/files.cabal b/tests/integration/tests/617-unused-flag-yaml/files/files.cabal deleted file mode 100644 index 6ec3b1e471..0000000000 --- a/tests/integration/tests/617-unused-flag-yaml/files/files.cabal +++ /dev/null @@ -1,10 +0,0 @@ -name: files -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 diff --git a/tests/integration/tests/617-unused-flag-yaml/files/package.yaml b/tests/integration/tests/617-unused-flag-yaml/files/package.yaml new file mode 100644 index 0000000000..a7305a77cf --- /dev/null +++ b/tests/integration/tests/617-unused-flag-yaml/files/package.yaml @@ -0,0 +1,9 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src diff --git a/tests/integration/tests/617-unused-flag-yaml/files/stack.yaml b/tests/integration/tests/617-unused-flag-yaml/files/stack.yaml index d17c443bee..ba4e5e5804 100644 --- a/tests/integration/tests/617-unused-flag-yaml/files/stack.yaml +++ b/tests/integration/tests/617-unused-flag-yaml/files/stack.yaml @@ -1,4 +1,5 @@ snapshot: ghc-9.10.3 + flags: - does-not-exist: - foo: false + no-such-package: + my-flag: false diff --git a/tests/integration/tests/620-env-command/Main.hs b/tests/integration/tests/620-env-command/Main.hs index 2a4e394673..94b2c35a5b 100644 --- a/tests/integration/tests/620-env-command/Main.hs +++ b/tests/integration/tests/620-env-command/Main.hs @@ -1,7 +1,12 @@ -import StackTest -import System.Process -import Control.Exception (throwIO) -import Control.Monad (unless) +-- Stack's config env command produces output that can be evaluated by bash's +-- built-in eval command. +-- +-- See: https://github.com/commercialhaskell/stack/issues/617 + +import Control.Exception ( throwIO ) +import Control.Monad ( unless ) +import StackTest +import System.Process ( rawSystem ) main :: IO () main = unless isWindows $ rawSystem "bash" ["run.sh"] >>= throwIO diff --git a/tests/integration/tests/620-env-command/files/Main.hs b/tests/integration/tests/620-env-command/files/Main.hs index bd555bc39d..d582e1e36a 100644 --- a/tests/integration/tests/620-env-command/files/Main.hs +++ b/tests/integration/tests/620-env-command/files/Main.hs @@ -1,4 +1,2 @@ -import Control.Concurrent.Async () - main :: IO () main = pure () diff --git a/tests/integration/tests/620-env-command/files/run.sh b/tests/integration/tests/620-env-command/files/run.sh index c9931d262d..f012c6363b 100644 --- a/tests/integration/tests/620-env-command/files/run.sh +++ b/tests/integration/tests/620-env-command/files/run.sh @@ -2,6 +2,5 @@ set -euxo pipefail -stack build --resolver lts-24.24 async -eval `stack config env --resolver lts-24.24` +eval `stack --snapshot lts-24.43 config env` ghc Main.hs diff --git a/tests/integration/tests/6342-say-ghc-version-in-build/.gitignore b/tests/integration/tests/6342-say-ghc-version-in-build/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/6342-say-ghc-version-in-build/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/6342-say-ghc-version-in-build/Main.hs b/tests/integration/tests/6342-say-ghc-version-in-build/Main.hs new file mode 100644 index 0000000000..51385a13ab --- /dev/null +++ b/tests/integration/tests/6342-say-ghc-version-in-build/Main.hs @@ -0,0 +1,25 @@ +-- Stack outputs the GHC version that it is using during a build. +-- +-- See: https://github.com/commercialhaskell/stack/issues/6342 + +import Control.Monad ( unless ) +import Data.Char ( isSpace ) +import Data.List ( dropWhileEnd, isInfixOf ) +import StackTest + +main :: IO () +main = + -- Query the actual compiler + stackCheckStdout ["query", "compiler", "actual"] $ \compiler -> do + stackCheckStderr ["build"] (expectMessage $ buildWith (trimEnd compiler)) + +buildWith :: String -> String +buildWith compiler = "build (lib) with " <> compiler + +expectMessage :: String -> String -> IO () +expectMessage msg stderr = do + unless (words msg `isInfixOf` words stderr) + (error $ "Expected message: \n" ++ show msg) + +trimEnd :: String -> String +trimEnd = dropWhileEnd isSpace diff --git a/tests/integration/tests/6342-say-ghc-version-in-build/files/package.yaml b/tests/integration/tests/6342-say-ghc-version-in-build/files/package.yaml new file mode 100644 index 0000000000..2e4f2c0854 --- /dev/null +++ b/tests/integration/tests/6342-say-ghc-version-in-build/files/package.yaml @@ -0,0 +1,9 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base < 5 + +library: + source-dirs: src diff --git a/tests/integration/tests/6342-say-ghc-version-in-build/files/src/Lib.hs b/tests/integration/tests/6342-say-ghc-version-in-build/files/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/6342-say-ghc-version-in-build/files/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/6342-say-ghc-version-in-build/files/stack.yaml b/tests/integration/tests/6342-say-ghc-version-in-build/files/stack.yaml new file mode 100644 index 0000000000..e674eab75a --- /dev/null +++ b/tests/integration/tests/6342-say-ghc-version-in-build/files/stack.yaml @@ -0,0 +1 @@ +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/6372-sdist-unicode-test/.gitignore b/tests/integration/tests/6372-sdist-unicode-test/.gitignore index 609770f0c7..a92d9c3b13 100644 --- a/tests/integration/tests/6372-sdist-unicode-test/.gitignore +++ b/tests/integration/tests/6372-sdist-unicode-test/.gitignore @@ -1 +1 @@ -stack.yaml.lock +test١٢٣.cabal diff --git a/tests/integration/tests/6372-sdist-unicode-test/Main.hs b/tests/integration/tests/6372-sdist-unicode-test/Main.hs index 1d546c1afc..0b33987b95 100644 --- a/tests/integration/tests/6372-sdist-unicode-test/Main.hs +++ b/tests/integration/tests/6372-sdist-unicode-test/Main.hs @@ -1,6 +1,9 @@ -import StackTest +-- Stack sdist handles Unicode code points. +-- +-- See: https://github.com/commercialhaskell/stack/issues/6372 -import Control.Monad (unless) +import Control.Monad ( unless ) +import StackTest -- | The test fails at runtime on the Windows Server 2022 GitHub-hosted runner -- only, at the point of outputting a Unicode character, with: @@ -16,7 +19,5 @@ import Control.Monad (unless) -- Windows. main :: IO () -main = unless isWindows $ do - stack ["clean"] - stack ["build", "--dry-run"] +main = unless isWindows $ stack ["sdist", "."] diff --git a/tests/integration/tests/6372-sdist-unicode-test/files/package.yaml b/tests/integration/tests/6372-sdist-unicode-test/files/package.yaml index 30b809b389..42e9845b9c 100644 --- a/tests/integration/tests/6372-sdist-unicode-test/files/package.yaml +++ b/tests/integration/tests/6372-sdist-unicode-test/files/package.yaml @@ -1,8 +1,11 @@ +spec-version: 0.36.0 + name: test١٢٣ -version: 0.1.0.0 +description: Test of non-ASCII Unicode code points in file names license: BSD-3-Clause -description: Test of Unicode characters in file names + dependencies: - base < 5 + library: source-dirs: src diff --git "a/tests/integration/tests/6372-sdist-unicode-test/files/src/Lib\316\261\316\262\316\263.hs" "b/tests/integration/tests/6372-sdist-unicode-test/files/src/Lib\316\261\316\262\316\263.hs" index 62cdaa6007..5fbed3015d 100644 --- "a/tests/integration/tests/6372-sdist-unicode-test/files/src/Lib\316\261\316\262\316\263.hs" +++ "b/tests/integration/tests/6372-sdist-unicode-test/files/src/Lib\316\261\316\262\316\263.hs" @@ -1,6 +1 @@ -module Libαβγ - ( someFunc - ) where - -someFunc :: IO () -someFunc = putStrLn "someFunc" +module Libαβγ where diff --git a/tests/integration/tests/6372-sdist-unicode-test/files/stack.yaml b/tests/integration/tests/6372-sdist-unicode-test/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/6372-sdist-unicode-test/files/stack.yaml +++ b/tests/integration/tests/6372-sdist-unicode-test/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git "a/tests/integration/tests/6372-sdist-unicode-test/files/test\331\241\331\242\331\243.cabal" "b/tests/integration/tests/6372-sdist-unicode-test/files/test\331\241\331\242\331\243.cabal" deleted file mode 100644 index 8525055843..0000000000 --- "a/tests/integration/tests/6372-sdist-unicode-test/files/test\331\241\331\242\331\243.cabal" +++ /dev/null @@ -1,24 +0,0 @@ -cabal-version: 2.2 - --- This file has been generated from package.yaml by hpack version 0.36.0. --- --- see: https://github.com/sol/hpack - -name: test١٢٣ -version: 0.1.0.0 -description: Test of Unicode characters in file names -license: BSD-3-Clause -build-type: Simple - -library - exposed-modules: - Libαβγ - other-modules: - Paths_test١٢٣ - autogen-modules: - Paths_test١٢٣ - hs-source-dirs: - src - build-depends: - base <5 - default-language: Haskell2010 diff --git a/tests/integration/tests/6451-exe-targets/Main.hs b/tests/integration/tests/6451-exe-targets/Main.hs new file mode 100644 index 0000000000..09b0f66c7e --- /dev/null +++ b/tests/integration/tests/6451-exe-targets/Main.hs @@ -0,0 +1,24 @@ +-- | Stack should build only those executables requested by the program +-- arguments. +-- +-- Issue: https://github.com/commercialhaskell/stack/issues/3229 is no longer +-- applicable. +-- +-- See: https://github.com/commercialhaskell/stack/issues/6451 + +module Main where + +import Control.Monad ( when ) +import Data.List ( isInfixOf ) +import StackTest + +main :: IO () +main = do + stackCheckStderr + ["build", ":myExeA"] + (rejectMessage "Installing executable myExeB in") + +rejectMessage :: String -> String -> IO () +rejectMessage msg stderr = + when (msg `isInfixOf` stderr) $ + error $ "Did not expect message here: \n" ++ show msg diff --git a/tests/integration/tests/6451-exe-targets/files/.gitignore b/tests/integration/tests/6451-exe-targets/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/6451-exe-targets/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/6451-exe-targets/files/appA/Main.hs b/tests/integration/tests/6451-exe-targets/files/appA/Main.hs new file mode 100644 index 0000000000..89ad4b3e08 --- /dev/null +++ b/tests/integration/tests/6451-exe-targets/files/appA/Main.hs @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = pure () diff --git a/tests/integration/tests/6451-exe-targets/files/appB/Main.hs b/tests/integration/tests/6451-exe-targets/files/appB/Main.hs new file mode 100644 index 0000000000..89ad4b3e08 --- /dev/null +++ b/tests/integration/tests/6451-exe-targets/files/appB/Main.hs @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = pure () diff --git a/tests/integration/tests/6451-exe-targets/files/package.yaml b/tests/integration/tests/6451-exe-targets/files/package.yaml new file mode 100644 index 0000000000..6338785a63 --- /dev/null +++ b/tests/integration/tests/6451-exe-targets/files/package.yaml @@ -0,0 +1,21 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src + +executables: + myExeA: + source-dirs: appA + main: Main.hs + dependencies: + - myPackage + myExeB: + source-dirs: appB + main: Main.hs + dependencies: + - myPackage diff --git a/tests/integration/tests/6451-exe-targets/files/src/Lib.hs b/tests/integration/tests/6451-exe-targets/files/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/6451-exe-targets/files/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/6451-exe-targets/files/stack.yaml b/tests/integration/tests/6451-exe-targets/files/stack.yaml new file mode 100644 index 0000000000..e674eab75a --- /dev/null +++ b/tests/integration/tests/6451-exe-targets/files/stack.yaml @@ -0,0 +1 @@ +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/6465-msys-environment/Main.hs b/tests/integration/tests/6465-msys-environment/Main.hs index efd730ccd7..8c64777059 100644 --- a/tests/integration/tests/6465-msys-environment/Main.hs +++ b/tests/integration/tests/6465-msys-environment/Main.hs @@ -1,9 +1,12 @@ -import StackTest +-- | On Windows, Stack supports different MSYS2 environments. +-- +-- See: https://github.com/commercialhaskell/stack/issues/6465 -import Control.Monad ( when ) +import Control.Monad ( when ) +import StackTest main :: IO () main = when isWindows $ do stack ["exec", "--", "pacman", "-S", "--noconfirm", "mingw-w64-ucrt-x86_64-gsl"] stack ["build"] - stack ["exec", "--", "foo"] + stack ["exec", "--", "myExe"] diff --git a/tests/integration/tests/6465-msys-environment/files/.gitignore b/tests/integration/tests/6465-msys-environment/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/6465-msys-environment/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/6465-msys-environment/files/Setup.hs b/tests/integration/tests/6465-msys-environment/files/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/6465-msys-environment/files/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/6465-msys-environment/files/Main.hs b/tests/integration/tests/6465-msys-environment/files/app/Main.hs similarity index 100% rename from tests/integration/tests/6465-msys-environment/files/Main.hs rename to tests/integration/tests/6465-msys-environment/files/app/Main.hs diff --git a/tests/integration/tests/6465-msys-environment/files/foo.cabal b/tests/integration/tests/6465-msys-environment/files/foo.cabal deleted file mode 100644 index f007e34101..0000000000 --- a/tests/integration/tests/6465-msys-environment/files/foo.cabal +++ /dev/null @@ -1,11 +0,0 @@ -cabal-version: 2.2 -name: foo -version: 0.1.0.0 -build-type: Simple - -executable foo - main-is: Main.hs - ghc-options: -threaded -rtsopts -with-rtsopts=-N - extra-libraries: gsl - build-depends: base >=4.7 && <5 - default-language: Haskell2010 diff --git a/tests/integration/tests/6465-msys-environment/files/package.yaml b/tests/integration/tests/6465-msys-environment/files/package.yaml new file mode 100644 index 0000000000..d385615dc8 --- /dev/null +++ b/tests/integration/tests/6465-msys-environment/files/package.yaml @@ -0,0 +1,14 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +extra-libraries: +- gsl + +executables: + myExe: + source-dirs: app + main: Main.hs diff --git a/tests/integration/tests/6465-msys-environment/files/stack.yaml b/tests/integration/tests/6465-msys-environment/files/stack.yaml index 159184fbd1..36d650b698 100644 --- a/tests/integration/tests/6465-msys-environment/files/stack.yaml +++ b/tests/integration/tests/6465-msys-environment/files/stack.yaml @@ -1,2 +1,3 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 + msys-environment: UCRT64 diff --git a/tests/integration/tests/6867-timeout-grace/Main.hs b/tests/integration/tests/6867-timeout-grace/Main.hs new file mode 100644 index 0000000000..e5a6d6868a --- /dev/null +++ b/tests/integration/tests/6867-timeout-grace/Main.hs @@ -0,0 +1,42 @@ +-- | Stack supports a grace period timeout for test suites. +-- +-- See: https://github.com/commercialhaskell/stack/issues/6867 + +import Control.Monad ( unless ) +import Data.Char ( toLower ) +import Data.IORef ( newIORef, readIORef, writeIORef ) +import Data.List ( isInfixOf ) +import Data.Time.Clock ( diffUTCTime, getCurrentTime) +import StackTest + +main :: IO () +main = do + stack ["test", "--no-run-tests"] -- pre-build to avoid counting build time in the test + + start <- getCurrentTime + errRef <- newIORef "" + stackErrStderr + [ "test" + , "--test-suite-timeout", "1" + , "--test-suite-timeout-grace", "1" + ] + (writeIORef errRef) + end <- getCurrentTime + err <- readIORef errRef + + let errLower = map toLower err + elapsedSecs :: Double + elapsedSecs = realToFrac (diffUTCTime end start) + + logInfo $ "Elapsed time: " ++ show elapsedSecs ++ "s" + + unless ("timed out" `isInfixOf` errLower) $ + error "Expected test-suite timeout message in stderr output." + + if isWindows + then unless (elapsedSecs < 5.0) $ + error $ "Expected timeout+grace run to finish quickly on Windows, took " + ++ show elapsedSecs ++ "s" + else unless (elapsedSecs > 1.5 && elapsedSecs < 5.0) $ + error $ "Expected timeout+grace run to take about timeout+grace on Unix, took " + ++ show elapsedSecs ++ "s" diff --git a/tests/integration/tests/6867-timeout-grace/files/.gitignore b/tests/integration/tests/6867-timeout-grace/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/6867-timeout-grace/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/6867-timeout-grace/files/package.yaml b/tests/integration/tests/6867-timeout-grace/files/package.yaml new file mode 100644 index 0000000000..c5ca426401 --- /dev/null +++ b/tests/integration/tests/6867-timeout-grace/files/package.yaml @@ -0,0 +1,15 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +tests: + test: + main: Main.hs + source-dirs: test + when: + - condition: '!os(windows)' + dependencies: + - unix diff --git a/tests/integration/tests/6867-timeout-grace/files/stack.yaml b/tests/integration/tests/6867-timeout-grace/files/stack.yaml new file mode 100644 index 0000000000..e60f7dd9d9 --- /dev/null +++ b/tests/integration/tests/6867-timeout-grace/files/stack.yaml @@ -0,0 +1,3 @@ +snapshot: lts-24.43 +packages: +- . diff --git a/tests/integration/tests/6867-timeout-grace/files/test/Main.hs b/tests/integration/tests/6867-timeout-grace/files/test/Main.hs new file mode 100644 index 0000000000..cc4bfd8036 --- /dev/null +++ b/tests/integration/tests/6867-timeout-grace/files/test/Main.hs @@ -0,0 +1,19 @@ +{-# LANGUAGE CPP #-} + +module Main + ( main + ) where + +import Control.Concurrent ( threadDelay ) + +#ifndef mingw32_HOST_OS +import System.Posix.Signals + ( Handler (Ignore), installHandler, sigTERM ) +#endif + +main :: IO () +main = do +#ifndef mingw32_HOST_OS + _ <- installHandler sigTERM Ignore Nothing +#endif + threadDelay 6000000 diff --git a/tests/integration/tests/6879-stack-yaml-includes/Main.hs b/tests/integration/tests/6879-stack-yaml-includes/Main.hs new file mode 100644 index 0000000000..60e70406ad --- /dev/null +++ b/tests/integration/tests/6879-stack-yaml-includes/Main.hs @@ -0,0 +1,59 @@ +-- | Stack supports an !include directive in YAML configuration files. +-- +-- See: https://github.com/commercialhaskell/stack/issues/6879 + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest +import System.Directory ( getCurrentDirectory ) +import System.Environment ( setEnv ) +import System.FilePath ( () ) + +main :: IO () +main = do + let + checkFor expected actual = + unless (expected == actual) $ + error ("expected " <> show expected <> "but got: " <> show actual) + + -- Check that includes in stack.yaml files are included + stackCheckStdout + ["--stack-yaml", "stack-including-flags.yaml", "run"] + (checkFor "TEST_FLAG was set\n") + + stackCheckStdout + ["--stack-yaml", "stack-including-flags-with-newline.yaml", "run"] + (checkFor "TEST_FLAG was set\n") + + stackCheckStdout + ["--stack-yaml", "stack-not-including-flags.yaml", "run"] + (checkFor "TEST_FLAG was not set\n") + + -- Check that includes in config.yaml files are included + currentDir <- getCurrentDirectory + setEnv "STACK_CONFIG" (currentDir "config-including-flags.yaml") + stackCheckStdout + ["--stack-yaml", "stack-not-including-flags.yaml", "run"] + (checkFor "TEST_FLAG was set\n") + + -- Check that 'config set' succeeds when the key already exists in a + -- stack.yaml file that uses !include directives + stackCheckStderr + ["--stack-yaml", "stack-including-flags.yaml", "config", "set", "snapshot", "ghc-9.10.3"] + (expectMessage "already") + -- Check that 'config set' succeeds when the key already exists in a + -- stack.yaml file that uses !include directives (with newline variant) + stackCheckStderr + ["--stack-yaml", "stack-including-flags-with-newline.yaml", "config", "set", "snapshot", "ghc-9.10.3"] + (expectMessage "already") + + -- Check that 'config set' raises an error when the key does not exist in a + -- stack.yaml file that uses !include directives + stackErrStderr + ["--stack-yaml", "stack-including-file-with-install-ghc.yaml", "config", "set", "install-ghc", "true"] + (expectMessage "!include") + +expectMessage :: String -> String -> IO () +expectMessage msg stderr' = do + unless (msg `isInfixOf` stderr') $ + error $ "Expected stderr to contain " ++ show msg ++ " but got:\n" ++ stderr' diff --git a/tests/integration/tests/6879-stack-yaml-includes/files/.gitignore b/tests/integration/tests/6879-stack-yaml-includes/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/6879-stack-yaml-includes/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/6879-stack-yaml-includes/files/app/Main.hs b/tests/integration/tests/6879-stack-yaml-includes/files/app/Main.hs new file mode 100644 index 0000000000..d412740785 --- /dev/null +++ b/tests/integration/tests/6879-stack-yaml-includes/files/app/Main.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE CPP #-} + +module Main + ( main + ) where + +main :: IO () +main = +#if TEST_FLAG + putStrLn "TEST_FLAG was set" +#else + putStrLn "TEST_FLAG was not set" +#endif diff --git a/tests/integration/tests/6879-stack-yaml-includes/files/config-flags.yaml b/tests/integration/tests/6879-stack-yaml-includes/files/config-flags.yaml new file mode 100644 index 0000000000..222ce796b8 --- /dev/null +++ b/tests/integration/tests/6879-stack-yaml-includes/files/config-flags.yaml @@ -0,0 +1,2 @@ +ghc-options: + "$everything": -DTEST_FLAG diff --git a/tests/integration/tests/6879-stack-yaml-includes/files/config-including-flags.yaml b/tests/integration/tests/6879-stack-yaml-includes/files/config-including-flags.yaml new file mode 100644 index 0000000000..290a0eee8a --- /dev/null +++ b/tests/integration/tests/6879-stack-yaml-includes/files/config-including-flags.yaml @@ -0,0 +1 @@ +<<: !include config-flags.yaml diff --git a/tests/integration/tests/6879-stack-yaml-includes/files/install-ghc.yaml b/tests/integration/tests/6879-stack-yaml-includes/files/install-ghc.yaml new file mode 100644 index 0000000000..fd3953b239 --- /dev/null +++ b/tests/integration/tests/6879-stack-yaml-includes/files/install-ghc.yaml @@ -0,0 +1 @@ +install-ghc: true diff --git a/tests/integration/tests/6879-stack-yaml-includes/files/package.yaml b/tests/integration/tests/6879-stack-yaml-includes/files/package.yaml new file mode 100644 index 0000000000..a211bd8344 --- /dev/null +++ b/tests/integration/tests/6879-stack-yaml-includes/files/package.yaml @@ -0,0 +1,20 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +flags: + test-flag: + description: Generate a compiler error for test purposes + default: false + manual: true + +executables: + myExe: + source-dirs: app + main: Main.hs + when: + - condition: flag(test-flag) + cpp-options: -DTEST_FLAG diff --git a/tests/integration/tests/6879-stack-yaml-includes/files/stack-flags.yaml b/tests/integration/tests/6879-stack-yaml-includes/files/stack-flags.yaml new file mode 100644 index 0000000000..81f0ef1634 --- /dev/null +++ b/tests/integration/tests/6879-stack-yaml-includes/files/stack-flags.yaml @@ -0,0 +1,3 @@ +flags: + myPackage: + test-flag: true diff --git a/tests/integration/tests/6879-stack-yaml-includes/files/stack-including-file-with-install-ghc.yaml b/tests/integration/tests/6879-stack-yaml-includes/files/stack-including-file-with-install-ghc.yaml new file mode 100644 index 0000000000..e58b5115e2 --- /dev/null +++ b/tests/integration/tests/6879-stack-yaml-includes/files/stack-including-file-with-install-ghc.yaml @@ -0,0 +1,2 @@ +snapshot: ghc-9.10.3 +<<: !include install-ghc.yaml diff --git a/tests/integration/tests/6879-stack-yaml-includes/files/stack-including-flags-with-newline.yaml b/tests/integration/tests/6879-stack-yaml-includes/files/stack-including-flags-with-newline.yaml new file mode 100644 index 0000000000..4b7216c7c8 --- /dev/null +++ b/tests/integration/tests/6879-stack-yaml-includes/files/stack-including-flags-with-newline.yaml @@ -0,0 +1,3 @@ +snapshot: ghc-9.10.3 +<<: + !include stack-flags.yaml diff --git a/tests/integration/tests/6879-stack-yaml-includes/files/stack-including-flags.yaml b/tests/integration/tests/6879-stack-yaml-includes/files/stack-including-flags.yaml new file mode 100644 index 0000000000..6f6a0cd5f3 --- /dev/null +++ b/tests/integration/tests/6879-stack-yaml-includes/files/stack-including-flags.yaml @@ -0,0 +1,2 @@ +snapshot: ghc-9.10.3 +<<: !include stack-flags.yaml diff --git a/tests/integration/tests/6879-stack-yaml-includes/files/stack-not-including-flags.yaml b/tests/integration/tests/6879-stack-yaml-includes/files/stack-not-including-flags.yaml new file mode 100644 index 0000000000..e674eab75a --- /dev/null +++ b/tests/integration/tests/6879-stack-yaml-includes/files/stack-not-including-flags.yaml @@ -0,0 +1 @@ +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/6896-custom-setup/Main.hs b/tests/integration/tests/6896-custom-setup/Main.hs new file mode 100644 index 0000000000..18cdffa792 --- /dev/null +++ b/tests/integration/tests/6896-custom-setup/Main.hs @@ -0,0 +1,36 @@ +-- | Stack can build: +-- +-- * a project package with a custom @Setup.hs@ (see @myPackageA@); +-- +-- * a project package with a custom @Setup.hs@ that depends on the main library +-- of another project package (see @myPackageB@ and @myPackageD@); and +-- +-- * a project package with a custom @Setup.hs@ that depends on the public +-- sublibrary of another project package that does not have a main library +-- (see @myPackageC@ amd @myPackageE@). +-- +-- See: https://github.com/commercialhaskell/stack/issues/6896 + +import Control.Monad ( unless) +import Data.List ( isInfixOf ) +import StackTest + +main :: IO () +main = do + stackCheckStderr ["build", "myPackageA"] (expectMessage usingCustomA) + stackCheckStderr ["build", "myPackageB"] (expectMessage usingCustomB) + stackCheckStderr ["build", "myPackageC"] (expectMessage usingCustomC) + +usingCustomA :: String +usingCustomA = "Using my custom Setup.hs for myPackageA" + +usingCustomB :: String +usingCustomB = "messageD: Using my custom Setup.hs for myPackageB" + +usingCustomC :: String +usingCustomC = "messageE: Using my custom Setup.hs for myPackageC" + +expectMessage :: String -> String -> IO () +expectMessage msg stderr = do + unless (words msg `isInfixOf` words stderr) $ + error $ "Expected output: \n" ++ show msg diff --git a/tests/integration/tests/6896-custom-setup/files/.gitignore b/tests/integration/tests/6896-custom-setup/files/.gitignore new file mode 100644 index 0000000000..ec90d3285d --- /dev/null +++ b/tests/integration/tests/6896-custom-setup/files/.gitignore @@ -0,0 +1,5 @@ +myPackageA.cabal +myPackageB.cabal +myPackageC.cabal +myPackageD.cabal +myPackageE.cabal diff --git a/tests/integration/tests/6896-custom-setup/files/myPackageA/Setup.hs b/tests/integration/tests/6896-custom-setup/files/myPackageA/Setup.hs new file mode 100644 index 0000000000..dcc59c17b5 --- /dev/null +++ b/tests/integration/tests/6896-custom-setup/files/myPackageA/Setup.hs @@ -0,0 +1,4 @@ +import Distribution.Simple +main = do + putStrLn "Using my custom Setup.hs for myPackageA" + defaultMain diff --git a/tests/integration/tests/6896-custom-setup/files/myPackageA/package.yaml b/tests/integration/tests/6896-custom-setup/files/myPackageA/package.yaml new file mode 100644 index 0000000000..4cdfea8748 --- /dev/null +++ b/tests/integration/tests/6896-custom-setup/files/myPackageA/package.yaml @@ -0,0 +1,13 @@ +spec-version: 0.36.0 + +name: myPackageA + +dependencies: +- base + +custom-setup: + dependencies: + - base + +library: + source-dirs: src diff --git a/tests/integration/tests/6896-custom-setup/files/myPackageA/src/LibA.hs b/tests/integration/tests/6896-custom-setup/files/myPackageA/src/LibA.hs new file mode 100644 index 0000000000..a02dbb2486 --- /dev/null +++ b/tests/integration/tests/6896-custom-setup/files/myPackageA/src/LibA.hs @@ -0,0 +1 @@ +module LibA where diff --git a/tests/integration/tests/6896-custom-setup/files/myPackageB/Setup.hs b/tests/integration/tests/6896-custom-setup/files/myPackageB/Setup.hs new file mode 100644 index 0000000000..d1b4ae8498 --- /dev/null +++ b/tests/integration/tests/6896-custom-setup/files/myPackageB/Setup.hs @@ -0,0 +1,6 @@ +import Distribution.Simple +import LibD ( messageD ) + +main = do + putStrLn messageD + defaultMain diff --git a/tests/integration/tests/6896-custom-setup/files/myPackageB/package.yaml b/tests/integration/tests/6896-custom-setup/files/myPackageB/package.yaml new file mode 100644 index 0000000000..06acaf9aac --- /dev/null +++ b/tests/integration/tests/6896-custom-setup/files/myPackageB/package.yaml @@ -0,0 +1,14 @@ +spec-version: 0.36.0 + +name: myPackageB + +dependencies: +- base + +custom-setup: + dependencies: + - base + - myPackageD + +library: + source-dirs: src diff --git a/tests/integration/tests/6896-custom-setup/files/myPackageB/src/LibB.hs b/tests/integration/tests/6896-custom-setup/files/myPackageB/src/LibB.hs new file mode 100644 index 0000000000..913d829c0a --- /dev/null +++ b/tests/integration/tests/6896-custom-setup/files/myPackageB/src/LibB.hs @@ -0,0 +1 @@ +module LibB where diff --git a/tests/integration/tests/6896-custom-setup/files/myPackageC/Setup.hs b/tests/integration/tests/6896-custom-setup/files/myPackageC/Setup.hs new file mode 100644 index 0000000000..282159a3b8 --- /dev/null +++ b/tests/integration/tests/6896-custom-setup/files/myPackageC/Setup.hs @@ -0,0 +1,6 @@ +import Distribution.Simple +import SublibE ( messageE ) + +main = do + putStrLn messageE + defaultMain diff --git a/tests/integration/tests/6896-custom-setup/files/myPackageC/package.yaml b/tests/integration/tests/6896-custom-setup/files/myPackageC/package.yaml new file mode 100644 index 0000000000..0f504d627a --- /dev/null +++ b/tests/integration/tests/6896-custom-setup/files/myPackageC/package.yaml @@ -0,0 +1,17 @@ +spec-version: 0.36.0 + +verbatim: + cabal-version: 3.4 + +name: myPackageC + +dependencies: +- base + +custom-setup: + dependencies: + - base + - myPackageE:myPackageE-sub + +library: + source-dirs: src diff --git a/tests/integration/tests/6896-custom-setup/files/myPackageC/src/LibC.hs b/tests/integration/tests/6896-custom-setup/files/myPackageC/src/LibC.hs new file mode 100644 index 0000000000..48da7c9108 --- /dev/null +++ b/tests/integration/tests/6896-custom-setup/files/myPackageC/src/LibC.hs @@ -0,0 +1 @@ +module LibC where diff --git a/tests/integration/tests/6896-custom-setup/files/myPackageD/package.yaml b/tests/integration/tests/6896-custom-setup/files/myPackageD/package.yaml new file mode 100644 index 0000000000..3d51f11ae8 --- /dev/null +++ b/tests/integration/tests/6896-custom-setup/files/myPackageD/package.yaml @@ -0,0 +1,9 @@ +spec-version: 0.36.0 + +name: myPackageD + +dependencies: +- base + +library: + source-dirs: src diff --git a/tests/integration/tests/6896-custom-setup/files/myPackageD/src/LibD.hs b/tests/integration/tests/6896-custom-setup/files/myPackageD/src/LibD.hs new file mode 100644 index 0000000000..19c7c8dead --- /dev/null +++ b/tests/integration/tests/6896-custom-setup/files/myPackageD/src/LibD.hs @@ -0,0 +1,6 @@ +module LibD + ( messageD + ) where + +messageD :: String +messageD = "messageD: Using my custom Setup.hs for myPackageB" diff --git a/tests/integration/tests/6896-custom-setup/files/myPackageE/package.yaml b/tests/integration/tests/6896-custom-setup/files/myPackageE/package.yaml new file mode 100644 index 0000000000..1edcb2d54d --- /dev/null +++ b/tests/integration/tests/6896-custom-setup/files/myPackageE/package.yaml @@ -0,0 +1,11 @@ +spec-version: 0.36.0 + +name: myPackageE + +dependencies: +- base + +internal-libraries: + myPackageE-sub: + visibility: public + source-dirs: sub diff --git a/tests/integration/tests/6896-custom-setup/files/myPackageE/sub/SublibE.hs b/tests/integration/tests/6896-custom-setup/files/myPackageE/sub/SublibE.hs new file mode 100644 index 0000000000..34f4adc5ec --- /dev/null +++ b/tests/integration/tests/6896-custom-setup/files/myPackageE/sub/SublibE.hs @@ -0,0 +1,6 @@ +module SublibE + ( messageE + ) where + +messageE :: String +messageE = "messageE: Using my custom Setup.hs for myPackageC" diff --git a/tests/integration/tests/6896-custom-setup/files/stack.yaml b/tests/integration/tests/6896-custom-setup/files/stack.yaml new file mode 100644 index 0000000000..f5e344c0bf --- /dev/null +++ b/tests/integration/tests/6896-custom-setup/files/stack.yaml @@ -0,0 +1,8 @@ +snapshot: ghc-9.10.3 + +packages: +- myPackageA +- myPackageB +- myPackageC +- myPackageD +- myPackageE diff --git a/tests/integration/tests/6896-dep-with-no-main-lib/Main.hs b/tests/integration/tests/6896-dep-with-no-main-lib/Main.hs new file mode 100644 index 0000000000..36b1ff3ab4 --- /dev/null +++ b/tests/integration/tests/6896-dep-with-no-main-lib/Main.hs @@ -0,0 +1,7 @@ +-- | Stack can support a dependency package that has one or more public +-- sublibraries but no unnamed main library. + +import StackTest + +main :: IO () +main = stack ["build"] diff --git a/tests/integration/tests/6896-dep-with-no-main-lib/files/.gitignore b/tests/integration/tests/6896-dep-with-no-main-lib/files/.gitignore new file mode 100644 index 0000000000..f9a6e152d2 --- /dev/null +++ b/tests/integration/tests/6896-dep-with-no-main-lib/files/.gitignore @@ -0,0 +1,2 @@ +myPackageA.cabal +myPackageB.cabal diff --git a/tests/integration/tests/6896-dep-with-no-main-lib/files/myPackageA/package.yaml b/tests/integration/tests/6896-dep-with-no-main-lib/files/myPackageA/package.yaml new file mode 100644 index 0000000000..89c90db88c --- /dev/null +++ b/tests/integration/tests/6896-dep-with-no-main-lib/files/myPackageA/package.yaml @@ -0,0 +1,11 @@ +spec-version: 0.36.0 + +name: myPackageA + +dependencies: +- base + +library: + source-dirs: src + dependencies: + - myPackageB:myPackageB-sub diff --git a/tests/integration/tests/6896-dep-with-no-main-lib/files/myPackageA/src/Lib.hs b/tests/integration/tests/6896-dep-with-no-main-lib/files/myPackageA/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/6896-dep-with-no-main-lib/files/myPackageA/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/6896-dep-with-no-main-lib/files/myPackageB/package.yaml b/tests/integration/tests/6896-dep-with-no-main-lib/files/myPackageB/package.yaml new file mode 100644 index 0000000000..05fd49c434 --- /dev/null +++ b/tests/integration/tests/6896-dep-with-no-main-lib/files/myPackageB/package.yaml @@ -0,0 +1,13 @@ +# This package has no unnamed main library. + +spec-version: 0.36.0 + +name: myPackageB + +dependencies: +- base + +internal-libraries: + myPackageB-sub: + visibility: public + source-dirs: sub diff --git a/tests/integration/tests/6896-dep-with-no-main-lib/files/myPackageB/sub/Sublib.hs b/tests/integration/tests/6896-dep-with-no-main-lib/files/myPackageB/sub/Sublib.hs new file mode 100644 index 0000000000..c41d4cbf16 --- /dev/null +++ b/tests/integration/tests/6896-dep-with-no-main-lib/files/myPackageB/sub/Sublib.hs @@ -0,0 +1 @@ +module Sublib where diff --git a/tests/integration/tests/6896-dep-with-no-main-lib/files/stack.yaml b/tests/integration/tests/6896-dep-with-no-main-lib/files/stack.yaml new file mode 100644 index 0000000000..68891a8d7c --- /dev/null +++ b/tests/integration/tests/6896-dep-with-no-main-lib/files/stack.yaml @@ -0,0 +1,5 @@ +snapshot: ghc-9.10.3 + +packages: +- myPackageA +- myPackageB diff --git a/tests/integration/tests/6905-cyclic-plan/Main.hs b/tests/integration/tests/6905-cyclic-plan/Main.hs new file mode 100644 index 0000000000..75120e5d06 --- /dev/null +++ b/tests/integration/tests/6905-cyclic-plan/Main.hs @@ -0,0 +1,27 @@ +-- | The test's project has project packages A and B. +-- +-- In terms of main libraries, the dependencies are (->- is 'depends on'): +-- +-- A ->- B +-- +-- In terms of executables (a test suite): +-- +-- B ->- A +-- +-- As, overall, A ->- B and B ->- A, packages A and B cannot be built +-- 'all-in-one'. +-- +-- This integration test tests: +-- +-- * when A is named myPackageA and B is named myPackageB; and +-- +-- * when A is named myPackageD and B is named myPackageC. +-- +-- See: https://github.com/commercialhaskell/stack/issues/6905 + +import StackTest + +main :: IO () +main = do + stack ["--stack-yaml", "stack1.yaml", "test"] + stack ["--stack-yaml", "stack2.yaml", "test"] diff --git a/tests/integration/tests/6905-cyclic-plan/files/.gitignore b/tests/integration/tests/6905-cyclic-plan/files/.gitignore new file mode 100644 index 0000000000..5087095541 --- /dev/null +++ b/tests/integration/tests/6905-cyclic-plan/files/.gitignore @@ -0,0 +1,4 @@ +myPackageA.cabal +myPackageB.cabal +myPackageC.cabal +myPackageD.cabal diff --git a/tests/integration/tests/6905-cyclic-plan/files/myPackageA/package.yaml b/tests/integration/tests/6905-cyclic-plan/files/myPackageA/package.yaml new file mode 100644 index 0000000000..bb7167768b --- /dev/null +++ b/tests/integration/tests/6905-cyclic-plan/files/myPackageA/package.yaml @@ -0,0 +1,11 @@ +spec-version: 0.36.0 + +name: myPackageA + +dependencies: +- base + +library: + source-dirs: src + dependencies: + - myPackageB diff --git a/tests/integration/tests/6905-cyclic-plan/files/myPackageA/src/LibA.hs b/tests/integration/tests/6905-cyclic-plan/files/myPackageA/src/LibA.hs new file mode 100644 index 0000000000..743d4bf8d0 --- /dev/null +++ b/tests/integration/tests/6905-cyclic-plan/files/myPackageA/src/LibA.hs @@ -0,0 +1,5 @@ +module LibA + ( funcB + ) where + +import LibB ( funcB ) diff --git a/tests/integration/tests/6905-cyclic-plan/files/myPackageB/package.yaml b/tests/integration/tests/6905-cyclic-plan/files/myPackageB/package.yaml new file mode 100644 index 0000000000..c5d19b86c3 --- /dev/null +++ b/tests/integration/tests/6905-cyclic-plan/files/myPackageB/package.yaml @@ -0,0 +1,16 @@ +spec-version: 0.36.0 + +name: myPackageB + +dependencies: +- base + +library: + source-dirs: src + +tests: + test: + source-dirs: test + main: Main.hs + dependencies: + - myPackageA diff --git a/tests/integration/tests/6905-cyclic-plan/files/myPackageB/src/LibB.hs b/tests/integration/tests/6905-cyclic-plan/files/myPackageB/src/LibB.hs new file mode 100644 index 0000000000..e714f965fe --- /dev/null +++ b/tests/integration/tests/6905-cyclic-plan/files/myPackageB/src/LibB.hs @@ -0,0 +1,6 @@ +module LibB + ( funcB + ) where + +funcB :: IO () +funcB = pure () diff --git a/tests/integration/tests/6905-cyclic-plan/files/myPackageB/test/Main.hs b/tests/integration/tests/6905-cyclic-plan/files/myPackageB/test/Main.hs new file mode 100644 index 0000000000..e7c27dd1be --- /dev/null +++ b/tests/integration/tests/6905-cyclic-plan/files/myPackageB/test/Main.hs @@ -0,0 +1,4 @@ +import LibA ( funcB ) + +main :: IO () +main = funcB diff --git a/tests/integration/tests/6905-cyclic-plan/files/myPackageC/package.yaml b/tests/integration/tests/6905-cyclic-plan/files/myPackageC/package.yaml new file mode 100644 index 0000000000..89dfd7f40b --- /dev/null +++ b/tests/integration/tests/6905-cyclic-plan/files/myPackageC/package.yaml @@ -0,0 +1,16 @@ +spec-version: 0.36.0 + +name: myPackageC + +dependencies: +- base + +library: + source-dirs: src + +tests: + test: + source-dirs: test + main: Main.hs + dependencies: + - myPackageD diff --git a/tests/integration/tests/6905-cyclic-plan/files/myPackageC/src/LibC.hs b/tests/integration/tests/6905-cyclic-plan/files/myPackageC/src/LibC.hs new file mode 100644 index 0000000000..28474cddd5 --- /dev/null +++ b/tests/integration/tests/6905-cyclic-plan/files/myPackageC/src/LibC.hs @@ -0,0 +1,6 @@ +module LibC + ( funcC + ) where + +funcC :: IO () +funcC = pure () diff --git a/tests/integration/tests/6905-cyclic-plan/files/myPackageC/test/Main.hs b/tests/integration/tests/6905-cyclic-plan/files/myPackageC/test/Main.hs new file mode 100644 index 0000000000..c438615556 --- /dev/null +++ b/tests/integration/tests/6905-cyclic-plan/files/myPackageC/test/Main.hs @@ -0,0 +1,4 @@ +import LibD ( funcC ) + +main :: IO () +main = funcC diff --git a/tests/integration/tests/6905-cyclic-plan/files/myPackageD/package.yaml b/tests/integration/tests/6905-cyclic-plan/files/myPackageD/package.yaml new file mode 100644 index 0000000000..1d913ac5ef --- /dev/null +++ b/tests/integration/tests/6905-cyclic-plan/files/myPackageD/package.yaml @@ -0,0 +1,11 @@ +spec-version: 0.36.0 + +name: myPackageD + +dependencies: +- base + +library: + source-dirs: src + dependencies: + - myPackageC diff --git a/tests/integration/tests/6905-cyclic-plan/files/myPackageD/src/LibD.hs b/tests/integration/tests/6905-cyclic-plan/files/myPackageD/src/LibD.hs new file mode 100644 index 0000000000..481d4e7f69 --- /dev/null +++ b/tests/integration/tests/6905-cyclic-plan/files/myPackageD/src/LibD.hs @@ -0,0 +1,5 @@ +module LibD + ( funcC + ) where + +import LibC ( funcC ) diff --git a/tests/integration/tests/6905-cyclic-plan/files/stack1.yaml b/tests/integration/tests/6905-cyclic-plan/files/stack1.yaml new file mode 100644 index 0000000000..68891a8d7c --- /dev/null +++ b/tests/integration/tests/6905-cyclic-plan/files/stack1.yaml @@ -0,0 +1,5 @@ +snapshot: ghc-9.10.3 + +packages: +- myPackageA +- myPackageB diff --git a/tests/integration/tests/6905-cyclic-plan/files/stack2.yaml b/tests/integration/tests/6905-cyclic-plan/files/stack2.yaml new file mode 100644 index 0000000000..740f730a48 --- /dev/null +++ b/tests/integration/tests/6905-cyclic-plan/files/stack2.yaml @@ -0,0 +1,5 @@ +snapshot: ghc-9.10.3 + +packages: +- myPackageC +- myPackageD diff --git a/tests/integration/tests/6905-invalid-cycle/Main.hs b/tests/integration/tests/6905-invalid-cycle/Main.hs new file mode 100644 index 0000000000..34e3959973 --- /dev/null +++ b/tests/integration/tests/6905-invalid-cycle/Main.hs @@ -0,0 +1,35 @@ +-- | The test's project has project packages A, B, C and D. +-- +-- In terms of main libraries, the dependencies are (->- is 'depends on'): +-- +-- A ->- B and C ->- D, D ->- C (a cycle) +-- +-- In terms of executables (a test suite): +-- +-- B ->- A, B ->- C +-- +-- As, overall, A ->- B and B ->- A, packages A and B cannot be built +-- 'all-in-one'. However, if the test suite of B is not being built, A and B can +-- be built. + +-- The test suite of B cannot be built, because C ->- D and D ->- C. +-- +-- See: https://github.com/commercialhaskell/stack/issues/6905 + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest + +main :: IO () +main = do + stack ["build", "myPackageA", "myPackageB"] + stackErrStderr ["test", "myPackageB"] (expectMessage dependencyCycleDetected) + +dependencyCycleDetected :: String +dependencyCycleDetected = + "myPackageC dependency cycle detected: myPackageC, myPackageD, myPackageC" + +expectMessage :: String -> String -> IO () +expectMessage msg stderr = + unless (words msg `isInfixOf` words stderr) + (error $ "Expected a warning: \n" ++ show msg) diff --git a/tests/integration/tests/6905-invalid-cycle/files/.gitignore b/tests/integration/tests/6905-invalid-cycle/files/.gitignore new file mode 100644 index 0000000000..5087095541 --- /dev/null +++ b/tests/integration/tests/6905-invalid-cycle/files/.gitignore @@ -0,0 +1,4 @@ +myPackageA.cabal +myPackageB.cabal +myPackageC.cabal +myPackageD.cabal diff --git a/tests/integration/tests/6905-invalid-cycle/files/myPackageA/package.yaml b/tests/integration/tests/6905-invalid-cycle/files/myPackageA/package.yaml new file mode 100644 index 0000000000..bb7167768b --- /dev/null +++ b/tests/integration/tests/6905-invalid-cycle/files/myPackageA/package.yaml @@ -0,0 +1,11 @@ +spec-version: 0.36.0 + +name: myPackageA + +dependencies: +- base + +library: + source-dirs: src + dependencies: + - myPackageB diff --git a/tests/integration/tests/6905-invalid-cycle/files/myPackageA/src/LibA.hs b/tests/integration/tests/6905-invalid-cycle/files/myPackageA/src/LibA.hs new file mode 100644 index 0000000000..743d4bf8d0 --- /dev/null +++ b/tests/integration/tests/6905-invalid-cycle/files/myPackageA/src/LibA.hs @@ -0,0 +1,5 @@ +module LibA + ( funcB + ) where + +import LibB ( funcB ) diff --git a/tests/integration/tests/6905-invalid-cycle/files/myPackageB/package.yaml b/tests/integration/tests/6905-invalid-cycle/files/myPackageB/package.yaml new file mode 100644 index 0000000000..dbdaaca9ee --- /dev/null +++ b/tests/integration/tests/6905-invalid-cycle/files/myPackageB/package.yaml @@ -0,0 +1,17 @@ +spec-version: 0.36.0 + +name: myPackageB + +dependencies: +- base + +library: + source-dirs: src + +tests: + test: + source-dirs: test + main: Main.hs + dependencies: + - myPackageA + - myPackageC diff --git a/tests/integration/tests/6905-invalid-cycle/files/myPackageB/src/LibB.hs b/tests/integration/tests/6905-invalid-cycle/files/myPackageB/src/LibB.hs new file mode 100644 index 0000000000..e714f965fe --- /dev/null +++ b/tests/integration/tests/6905-invalid-cycle/files/myPackageB/src/LibB.hs @@ -0,0 +1,6 @@ +module LibB + ( funcB + ) where + +funcB :: IO () +funcB = pure () diff --git a/tests/integration/tests/6905-invalid-cycle/files/myPackageB/test/Main.hs b/tests/integration/tests/6905-invalid-cycle/files/myPackageB/test/Main.hs new file mode 100644 index 0000000000..4443983c52 --- /dev/null +++ b/tests/integration/tests/6905-invalid-cycle/files/myPackageB/test/Main.hs @@ -0,0 +1,7 @@ +import LibA ( funcB ) +import LibC ( funcC ) + +main :: IO () +main = do + funcB + funcC diff --git a/tests/integration/tests/6905-invalid-cycle/files/myPackageC/package.yaml b/tests/integration/tests/6905-invalid-cycle/files/myPackageC/package.yaml new file mode 100644 index 0000000000..d657e99064 --- /dev/null +++ b/tests/integration/tests/6905-invalid-cycle/files/myPackageC/package.yaml @@ -0,0 +1,11 @@ +spec-version: 0.36.0 + +name: myPackageC + +dependencies: +- base + +library: + source-dirs: src + dependencies: + - myPackageD diff --git a/tests/integration/tests/6905-invalid-cycle/files/myPackageC/src/LibC.hs b/tests/integration/tests/6905-invalid-cycle/files/myPackageC/src/LibC.hs new file mode 100644 index 0000000000..b692cc5dc4 --- /dev/null +++ b/tests/integration/tests/6905-invalid-cycle/files/myPackageC/src/LibC.hs @@ -0,0 +1,8 @@ +module LibC + ( funcC + ) where + +import LibD ( funcD ) + +funcC :: IO () +funcC = funcD diff --git a/tests/integration/tests/6905-invalid-cycle/files/myPackageD/package.yaml b/tests/integration/tests/6905-invalid-cycle/files/myPackageD/package.yaml new file mode 100644 index 0000000000..1d913ac5ef --- /dev/null +++ b/tests/integration/tests/6905-invalid-cycle/files/myPackageD/package.yaml @@ -0,0 +1,11 @@ +spec-version: 0.36.0 + +name: myPackageD + +dependencies: +- base + +library: + source-dirs: src + dependencies: + - myPackageC diff --git a/tests/integration/tests/6905-invalid-cycle/files/myPackageD/src/LibD.hs b/tests/integration/tests/6905-invalid-cycle/files/myPackageD/src/LibD.hs new file mode 100644 index 0000000000..33b5940491 --- /dev/null +++ b/tests/integration/tests/6905-invalid-cycle/files/myPackageD/src/LibD.hs @@ -0,0 +1,8 @@ +module LibD + ( funcD + ) where + +import LibC ( funcC ) + +funcD :: IO () +funcD = funcC diff --git a/tests/integration/tests/6905-invalid-cycle/files/stack.yaml b/tests/integration/tests/6905-invalid-cycle/files/stack.yaml new file mode 100644 index 0000000000..240f775bdc --- /dev/null +++ b/tests/integration/tests/6905-invalid-cycle/files/stack.yaml @@ -0,0 +1,7 @@ +snapshot: ghc-9.10.3 + +packages: +- myPackageA +- myPackageB +- myPackageC +- myPackageD diff --git a/tests/integration/tests/6905-multi-test/Main.hs b/tests/integration/tests/6905-multi-test/Main.hs new file mode 100644 index 0000000000..2e21e47b41 --- /dev/null +++ b/tests/integration/tests/6905-multi-test/Main.hs @@ -0,0 +1,28 @@ +-- | The test's project has project packages A, B and C (which has no library). +-- +-- In terms of main libraries, the dependencies are (->- is 'depends on'): +-- +-- A ->- B +-- +-- In terms of executables (including test suites): +-- +-- B ->- A and C ->- A +-- +-- As, overall, A ->- B and B ->- A, packages A and B cannot be built +-- 'all-in-one'. +-- +-- A, B and C are named myPackageA, myPackageB and myPackageC respectively. +-- +-- See: https://github.com/commercialhaskell/stack/issues/6905 + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest + +main :: IO () +main = do + stackCheckStderr ["test", "--coverage"] $ \out -> do + unless ("The coverage report for myPackageA's test-suite test1 is available at" `isInfixOf` out) $ + fail "Didn't get expected report for test1" + unless ("[S-6829]" `isInfixOf` out) $ + fail "Didn't get expected empty report for test2" diff --git a/tests/integration/tests/6905-multi-test/files/.gitignore b/tests/integration/tests/6905-multi-test/files/.gitignore new file mode 100644 index 0000000000..03e2c6587b --- /dev/null +++ b/tests/integration/tests/6905-multi-test/files/.gitignore @@ -0,0 +1,6 @@ +myPackageA.cabal +myPackageB.cabal +myPackageC.cabal +myPackageD.cabal +myPackageE.cabal +myPackageF.cabal diff --git a/tests/integration/tests/6905-multi-test/files/myPackageA/app/Main.hs b/tests/integration/tests/6905-multi-test/files/myPackageA/app/Main.hs new file mode 100644 index 0000000000..df716cf71e --- /dev/null +++ b/tests/integration/tests/6905-multi-test/files/myPackageA/app/Main.hs @@ -0,0 +1,6 @@ +module Main where + +import LibA ( funcA ) + +main :: IO () +main = funcA diff --git a/tests/integration/tests/6905-multi-test/files/myPackageA/package.yaml b/tests/integration/tests/6905-multi-test/files/myPackageA/package.yaml new file mode 100644 index 0000000000..d246bd23b8 --- /dev/null +++ b/tests/integration/tests/6905-multi-test/files/myPackageA/package.yaml @@ -0,0 +1,33 @@ +spec-version: 0.36.0 + +name: myPackageA + +dependencies: +- base + +library: + source-dirs: src + dependencies: + - myPackageB + +executables: + myExeA: + source-dirs: app + main: Main.hs + dependencies: + - myPackageA + +tests: + test1: + source-dirs: test1 + main: Main.hs + dependencies: + - myPackageA + test2: + source-dirs: test2 + main: Main.hs + dependencies: + - myPackageA + test3: + source-dirs: test3 + main: Main.hs diff --git a/tests/integration/tests/6905-multi-test/files/myPackageA/src/LibA.hs b/tests/integration/tests/6905-multi-test/files/myPackageA/src/LibA.hs new file mode 100644 index 0000000000..a7981b6f2c --- /dev/null +++ b/tests/integration/tests/6905-multi-test/files/myPackageA/src/LibA.hs @@ -0,0 +1,9 @@ +module LibA + ( funcA + , funcB + ) where + +import LibB ( funcB ) + +funcA :: IO () +funcA = pure () diff --git a/tests/integration/tests/6905-multi-test/files/myPackageA/test1/Main.hs b/tests/integration/tests/6905-multi-test/files/myPackageA/test1/Main.hs new file mode 100644 index 0000000000..71c96e8fce --- /dev/null +++ b/tests/integration/tests/6905-multi-test/files/myPackageA/test1/Main.hs @@ -0,0 +1,4 @@ +import LibA ( funcA ) + +main :: IO () +main = funcA diff --git a/tests/integration/tests/6905-multi-test/files/myPackageA/test2/Main.hs b/tests/integration/tests/6905-multi-test/files/myPackageA/test2/Main.hs new file mode 100644 index 0000000000..3ca9d54762 --- /dev/null +++ b/tests/integration/tests/6905-multi-test/files/myPackageA/test2/Main.hs @@ -0,0 +1,4 @@ +import LibA + +main :: IO () +main = pure () diff --git a/tests/integration/tests/multi-test/files/test-3/Spec.hs b/tests/integration/tests/6905-multi-test/files/myPackageA/test3/Main.hs similarity index 100% rename from tests/integration/tests/multi-test/files/test-3/Spec.hs rename to tests/integration/tests/6905-multi-test/files/myPackageA/test3/Main.hs diff --git a/tests/integration/tests/6905-multi-test/files/myPackageB/package.yaml b/tests/integration/tests/6905-multi-test/files/myPackageB/package.yaml new file mode 100644 index 0000000000..c5d19b86c3 --- /dev/null +++ b/tests/integration/tests/6905-multi-test/files/myPackageB/package.yaml @@ -0,0 +1,16 @@ +spec-version: 0.36.0 + +name: myPackageB + +dependencies: +- base + +library: + source-dirs: src + +tests: + test: + source-dirs: test + main: Main.hs + dependencies: + - myPackageA diff --git a/tests/integration/tests/6905-multi-test/files/myPackageB/src/LibB.hs b/tests/integration/tests/6905-multi-test/files/myPackageB/src/LibB.hs new file mode 100644 index 0000000000..e714f965fe --- /dev/null +++ b/tests/integration/tests/6905-multi-test/files/myPackageB/src/LibB.hs @@ -0,0 +1,6 @@ +module LibB + ( funcB + ) where + +funcB :: IO () +funcB = pure () diff --git a/tests/integration/tests/6905-multi-test/files/myPackageB/test/Main.hs b/tests/integration/tests/6905-multi-test/files/myPackageB/test/Main.hs new file mode 100644 index 0000000000..e7c27dd1be --- /dev/null +++ b/tests/integration/tests/6905-multi-test/files/myPackageB/test/Main.hs @@ -0,0 +1,4 @@ +import LibA ( funcB ) + +main :: IO () +main = funcB diff --git a/tests/integration/tests/6905-multi-test/files/myPackageC/app/Main.hs b/tests/integration/tests/6905-multi-test/files/myPackageC/app/Main.hs new file mode 100644 index 0000000000..ca55d965a4 --- /dev/null +++ b/tests/integration/tests/6905-multi-test/files/myPackageC/app/Main.hs @@ -0,0 +1,4 @@ +import LibC ( funcC ) + +main :: IO () +main = funcC diff --git a/tests/integration/tests/6905-multi-test/files/myPackageC/package.yaml b/tests/integration/tests/6905-multi-test/files/myPackageC/package.yaml new file mode 100644 index 0000000000..629f8cba45 --- /dev/null +++ b/tests/integration/tests/6905-multi-test/files/myPackageC/package.yaml @@ -0,0 +1,22 @@ +spec-version: 0.36.0 + +name: myPackageC + +dependencies: +- base + +executables: + myExeC: + source-dirs: + - app + - src + main: Main.hs + +tests: + test: + source-dirs: + - src + - test + main: Main.hs + dependencies: + - myPackageA diff --git a/tests/integration/tests/6905-multi-test/files/myPackageC/src/LibC.hs b/tests/integration/tests/6905-multi-test/files/myPackageC/src/LibC.hs new file mode 100644 index 0000000000..6289d8843d --- /dev/null +++ b/tests/integration/tests/6905-multi-test/files/myPackageC/src/LibC.hs @@ -0,0 +1,6 @@ +module LibC + ( funcC + ) where + +funcC :: IO () +funcC = pure () diff --git a/tests/integration/tests/6905-multi-test/files/myPackageC/test/Main.hs b/tests/integration/tests/6905-multi-test/files/myPackageC/test/Main.hs new file mode 100644 index 0000000000..0535c37e44 --- /dev/null +++ b/tests/integration/tests/6905-multi-test/files/myPackageC/test/Main.hs @@ -0,0 +1,7 @@ +import LibA ( funcA ) +import LibC ( funcC ) + +main :: IO () +main = do + funcA + funcC diff --git a/tests/integration/tests/6905-multi-test/files/stack.yaml b/tests/integration/tests/6905-multi-test/files/stack.yaml new file mode 100644 index 0000000000..14a33de5df --- /dev/null +++ b/tests/integration/tests/6905-multi-test/files/stack.yaml @@ -0,0 +1,6 @@ +snapshot: ghc-9.10.3 + +packages: +- myPackageA +- myPackageB +- myPackageC diff --git a/tests/integration/tests/6915-config-set-inside-project/Main.hs b/tests/integration/tests/6915-config-set-inside-project/Main.hs new file mode 100644 index 0000000000..81e7e76e57 --- /dev/null +++ b/tests/integration/tests/6915-config-set-inside-project/Main.hs @@ -0,0 +1,103 @@ +-- Stack's config set commands should work as expected. + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest + +main :: IO () +main = do + stackCheckStderr + ["config", "set", "snapshot", "ghc-9.10.2"] + (expectMessage hasBeenUpdated) + stackCheckStderr + ["config", "set", "snapshot", "ghc-9.10.2"] + (expectMessage alreadyContained) + stackCheckStderr + ["--stack-yaml", "stack-alt.yaml", "config", "set", "snapshot", "ghc-9.10.3"] + (expectMessage alreadyContained) + stackCheckStderr + ["config", "set", "system-ghc", "false"] + (expectMessage hasBeenExtended) + stackCheckStderr + ["config", "set", "system-ghc", "false"] + (expectMessage alreadyContained) + stackCheckStderr + ["config", "set", "system-ghc", "true"] + (expectMessage hasBeenUpdated) + stackCheckStderr + ["config", "set", "system-ghc", "true"] + (expectMessage alreadyContained) + stackCheckStderr + ["--stack-yaml", "stack-alt.yaml", "config", "set", "system-ghc", "true"] + (expectMessage alreadyContained) + stackCheckStderr + ["config", "set", "install-ghc", "true"] + (expectMessage hasBeenExtended) + stackCheckStderr + ["config", "set", "install-ghc", "true"] + (expectMessage alreadyContained) + stackCheckStderr + ["config", "set", "install-ghc", "false"] + (expectMessage hasBeenUpdated) + stackCheckStderr + ["config", "set", "install-ghc", "false"] + (expectMessage alreadyContained) + stackCheckStderr + ["--stack-yaml", "stack-alt.yaml", "config", "set", "install-ghc", "false"] + (expectMessage alreadyContained) + stackCheckStderr + ["config", "set", "install-msys", "true"] + (expectMessage hasBeenExtended) + stackCheckStderr + ["config", "set", "install-msys", "true"] + (expectMessage alreadyContained) + stackCheckStderr + ["config", "set", "install-msys", "false"] + (expectMessage hasBeenUpdated) + stackCheckStderr + ["config", "set", "install-msys", "false"] + (expectMessage alreadyContained) + stackCheckStderr + ["--stack-yaml", "stack-alt.yaml", "config", "set", "install-msys", "false"] + (expectMessage alreadyContained) + stackCheckStderr + ["config", "set", "recommend-stack-upgrade", "--project", "true"] + (expectMessage hasBeenExtended) + stackCheckStderr + ["config", "set", "recommend-stack-upgrade", "--project", "true"] + (expectMessage alreadyContained) + stackCheckStderr + ["config", "set", "recommend-stack-upgrade", "--project", "false"] + (expectMessage hasBeenUpdated) + stackCheckStderr + ["config", "set", "recommend-stack-upgrade", "--project", "false"] + (expectMessage alreadyContained) + stackCheckStderr + ["--stack-yaml", "stack-alt.yaml", "config", "set", "recommend-stack-upgrade", "--project", "false"] + (expectMessage alreadyContained) + stackCheckStderr + ["config", "set", "package-index", "download-prefix", "https://hackage.haskell.org/"] + (expectMessage hasBeenExtended) + stackCheckStderr + ["config", "set", "package-index", "download-prefix", "https://hackage.haskell.org/"] + (expectMessage alreadyContained) + stackCheckStderr + ["--stack-yaml", "stack-alt.yaml", "config", "set", "package-index", "download-prefix", "https://hackage.haskell.org/"] + (expectMessage alreadyContained) + +hasBeenUpdated :: String +hasBeenUpdated = + "has been updated." + +alreadyContained :: String +alreadyContained = + "already contained the intended configuration and remains unchanged." + +hasBeenExtended :: String +hasBeenExtended = + "has been extended." + +expectMessage :: String -> String -> IO () +expectMessage msg stderr = do + unless (words msg `isInfixOf` words stderr) $ + error $ "Expected output: \n" ++ show msg diff --git a/tests/integration/tests/3940-base-upgrade-warning/files/src/.gitkeep b/tests/integration/tests/6915-config-set-inside-project/files/.gitignore similarity index 100% rename from tests/integration/tests/3940-base-upgrade-warning/files/src/.gitkeep rename to tests/integration/tests/6915-config-set-inside-project/files/.gitignore diff --git a/tests/integration/tests/6915-config-set-inside-project/files/myPackage.cabal b/tests/integration/tests/6915-config-set-inside-project/files/myPackage.cabal new file mode 100644 index 0000000000..e4596c30a3 --- /dev/null +++ b/tests/integration/tests/6915-config-set-inside-project/files/myPackage.cabal @@ -0,0 +1,9 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.39.5. +-- +-- see: https://github.com/sol/hpack + +name: myPackage +version: 0.0.0 +build-type: Simple diff --git a/tests/integration/tests/6915-config-set-inside-project/files/package.yaml b/tests/integration/tests/6915-config-set-inside-project/files/package.yaml new file mode 100644 index 0000000000..0a64c2a06a --- /dev/null +++ b/tests/integration/tests/6915-config-set-inside-project/files/package.yaml @@ -0,0 +1,3 @@ +spec-version: 0.36.0 + +name: myPackage diff --git a/tests/integration/tests/6915-config-set-inside-project/files/stack-alt.yaml b/tests/integration/tests/6915-config-set-inside-project/files/stack-alt.yaml new file mode 100644 index 0000000000..5157d72ac5 --- /dev/null +++ b/tests/integration/tests/6915-config-set-inside-project/files/stack-alt.yaml @@ -0,0 +1,21 @@ +snapshot: ghc-9.10.3 + +system-ghc: true + +install-ghc: false + +install-msys: false + +recommend-stack-upgrade: false + +package-index: + download-prefix: https://hackage.haskell.org/ + hackage-security: + keyids: + - 0a5c7ea47cd1b15f01f5f51a33adda7e655bc0f0b0615baa8e271f4c3351e21d + - 1ea9ba32c526d1cc91ab5e5bd364ec5e9e8cb67179a471872f6e26f0ae773d42 + - 51f0161b906011b52c6613376b1ae937670da69322113a246a09f807c62f6921 + - c7de58fc6a224b92b5b513f26fbb8b370f2d97c7cfe0075a951314a55734be93 + - fe331502606802feac15e514d9b9ea83fee8b6ffef71335479a2e68d84adc6b0 + key-threshold: 3 + ignore-expiry: true diff --git a/tests/integration/tests/6915-config-set-inside-project/files/stack.yaml b/tests/integration/tests/6915-config-set-inside-project/files/stack.yaml new file mode 100644 index 0000000000..e674eab75a --- /dev/null +++ b/tests/integration/tests/6915-config-set-inside-project/files/stack.yaml @@ -0,0 +1 @@ +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/6915-config-set-outside-project/Main.hs b/tests/integration/tests/6915-config-set-outside-project/Main.hs new file mode 100644 index 0000000000..f391e15e58 --- /dev/null +++ b/tests/integration/tests/6915-config-set-outside-project/Main.hs @@ -0,0 +1,25 @@ +-- Stack's config set commands should recreate the global-project directory, if +-- Stack needs to consult its project-level configuration file and there is no +-- file. +-- +-- See: https://github.com/commercialhaskell/stack/issues/6915 + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest + +main :: IO () +main = do + -- In a clean Stack root, there is no global-projects directory. + stackCheckStderr + ["config", "set", "install-ghc", "false"] + (expectMessage writingConfigFile) + +writingConfigFile :: String +writingConfigFile = + "Writing the configuration file for the implicit global project to:" + +expectMessage :: String -> String -> IO () +expectMessage msg stderr = do + unless (words msg `isInfixOf` words stderr) $ + error $ "Expected output: \n" ++ show msg diff --git a/tests/integration/tests/6920-dep-name-clash/files/.gitignore b/tests/integration/tests/6920-dep-name-clash/files/.gitignore new file mode 100644 index 0000000000..f9a6e152d2 --- /dev/null +++ b/tests/integration/tests/6920-dep-name-clash/files/.gitignore @@ -0,0 +1,2 @@ +myPackageA.cabal +myPackageB.cabal diff --git a/tests/integration/tests/6920-dep-name-clash/files/Main.hs b/tests/integration/tests/6920-dep-name-clash/files/Main.hs new file mode 100644 index 0000000000..e9a59d0346 --- /dev/null +++ b/tests/integration/tests/6920-dep-name-clash/files/Main.hs @@ -0,0 +1,11 @@ +-- | Stack builds a package which depends directly on a package with the same +-- name as a sublibrary or foreign library of that package. +-- +-- See: https://github.com/commercialhaskell/stack/issues/6920 + +import StackTest + +main :: IO () +main = do + stack ["build", "myPackageA"] + stack ["build", "myPackageB"] diff --git a/tests/integration/tests/6920-dep-name-clash/files/myPackageA/int/Internal.hs b/tests/integration/tests/6920-dep-name-clash/files/myPackageA/int/Internal.hs new file mode 100644 index 0000000000..9f7c4a2680 --- /dev/null +++ b/tests/integration/tests/6920-dep-name-clash/files/myPackageA/int/Internal.hs @@ -0,0 +1,5 @@ +module Internal + ( launchMissiles + ) where + +import Acme.Missiles ( launchMissiles ) diff --git a/tests/integration/tests/6920-dep-name-clash/files/myPackageA/package.yaml b/tests/integration/tests/6920-dep-name-clash/files/myPackageA/package.yaml new file mode 100644 index 0000000000..8680aff1a6 --- /dev/null +++ b/tests/integration/tests/6920-dep-name-clash/files/myPackageA/package.yaml @@ -0,0 +1,17 @@ +spec-version: 0.36.0 + +# Required, otherwise Hpack picks cabal-version: 3.0 and the dependency on +# acme-missiles is assumed to refer to the name of the internal-library. +verbatim: + cabal-version: 3.4 + +name: myPackageA + +dependencies: +- base + +internal-libraries: + acme-missiles: + source-dirs: int + dependencies: + - acme-missiles diff --git a/tests/integration/tests/6920-dep-name-clash/files/myPackageB/package.yaml b/tests/integration/tests/6920-dep-name-clash/files/myPackageB/package.yaml new file mode 100644 index 0000000000..7cda1d93a6 --- /dev/null +++ b/tests/integration/tests/6920-dep-name-clash/files/myPackageB/package.yaml @@ -0,0 +1,20 @@ +spec-version: 0.36.0 + +name: myPackageB + +dependencies: +- base + +verbatim: | + foreign-library acme-missiles + type: native-shared + other-modules: + Foreign + build-depends: + base + , acme-missiles + hs-source-dirs: + src-foreign + default-language: Haskell2010 + if os(Windows) + options: standalone diff --git a/tests/integration/tests/6920-dep-name-clash/files/myPackageB/src-foreign/Foreign.hs b/tests/integration/tests/6920-dep-name-clash/files/myPackageB/src-foreign/Foreign.hs new file mode 100644 index 0000000000..449a04a061 --- /dev/null +++ b/tests/integration/tests/6920-dep-name-clash/files/myPackageB/src-foreign/Foreign.hs @@ -0,0 +1,5 @@ +module Foreign + ( launchMissiles + ) where + +import Acme.Missiles ( launchMissiles ) diff --git a/tests/integration/tests/6920-dep-name-clash/files/stack.yaml b/tests/integration/tests/6920-dep-name-clash/files/stack.yaml new file mode 100644 index 0000000000..8933f7a96d --- /dev/null +++ b/tests/integration/tests/6920-dep-name-clash/files/stack.yaml @@ -0,0 +1,8 @@ +snapshot: ghc-9.10.3 + +packages: +- myPackageA +- myPackageB + +extra-deps: +- acme-missiles-0.3 diff --git a/tests/integration/tests/717-sdist-test/Main.hs b/tests/integration/tests/717-sdist-test/Main.hs index cce419b2a5..fdd3691cee 100644 --- a/tests/integration/tests/717-sdist-test/Main.hs +++ b/tests/integration/tests/717-sdist-test/Main.hs @@ -1,19 +1,26 @@ -import StackTest +-- Stack's test of an archive file produced by sdist should fail if the package +-- description did not list all files used by the package itself. +-- +-- https://github.com/commercialhaskell/stack/issues/717 + +import StackTest main :: IO () main = do - -- verify building works + -- Verify building works: stack ["build"] - -- keep old behavior + -- Keep old behavior: stack ["sdist"] - -- successful sdist with --test-tarball - stack ["sdist", "package-with-working-th", "--test-tarball"] - -- fails because package contains TH which depends on files which are not put into sdist tarball - stackErr ["sdist", "package-with-th", "--test-tarball"] - -- same, but inside a subdir + -- Successful sdist with --test-tarball: + stack ["sdist", "working-package-with-th", "--test-tarball"] + -- Fails because package contains TH which depends on files which are not put + -- into sdist tarball: + stackErr ["sdist", "failing-package-with-th", "--test-tarball"] + -- Same, but inside a subdir: stackErr ["sdist", "subdirs/failing-in-subdir", "--test-tarball"] - -- depends on packagea and packagec - these would fail if they were the target of sdist, - -- but since they are just dependencies, the operation should succeed + -- Depends on failing-package-with-th and failing-in-subdir - these would fail + -- if they were the target of sdist, but since they are just dependencies, the + -- operation should succeed: stack ["sdist", "subdirs/dependent-on-failing-packages", "--test-tarball"] - -- fails because a test depends on files which are not put into sdist tarball - stackErr ["sdist", "package-with-failing-test", "--test-tarball"] + -- Fails because a test depends on files which are not put into sdist tarball: + stackErr ["sdist", "failing-package-with-test", "--test-tarball"] diff --git a/tests/integration/tests/717-sdist-test/files/.gitignore b/tests/integration/tests/717-sdist-test/files/.gitignore new file mode 100644 index 0000000000..1b68608ab5 --- /dev/null +++ b/tests/integration/tests/717-sdist-test/files/.gitignore @@ -0,0 +1,5 @@ +dependent-on-failing-packages.cabal +failing-in-subdir.cabal +failing-package-with-th.cabal +failing-package-with-test.cabal +working-package-with-th.cabal diff --git a/tests/integration/tests/1659-skip-component/files/LICENSE b/tests/integration/tests/717-sdist-test/files/failing-package-with-test/LICENSE similarity index 100% rename from tests/integration/tests/1659-skip-component/files/LICENSE rename to tests/integration/tests/717-sdist-test/files/failing-package-with-test/LICENSE diff --git a/tests/integration/tests/717-sdist-test/files/failing-package-with-test/README.md b/tests/integration/tests/717-sdist-test/files/failing-package-with-test/README.md new file mode 100644 index 0000000000..d432cbeb7e --- /dev/null +++ b/tests/integration/tests/717-sdist-test/files/failing-package-with-test/README.md @@ -0,0 +1 @@ +# failing-package-with-test diff --git a/tests/integration/tests/717-sdist-test/files/failing-package-with-test/files/file.txt b/tests/integration/tests/717-sdist-test/files/failing-package-with-test/files/file.txt new file mode 100644 index 0000000000..d95f3ad14d --- /dev/null +++ b/tests/integration/tests/717-sdist-test/files/failing-package-with-test/files/file.txt @@ -0,0 +1 @@ +content diff --git a/tests/integration/tests/717-sdist-test/files/failing-package-with-test/package.yaml b/tests/integration/tests/717-sdist-test/files/failing-package-with-test/package.yaml new file mode 100644 index 0000000000..e9e6a1b866 --- /dev/null +++ b/tests/integration/tests/717-sdist-test/files/failing-package-with-test/package.yaml @@ -0,0 +1,12 @@ +spec-version: 0.36.0 + +name: failing-package-with-test +description: A package with a test suite that is incomplete if sdist. + +dependencies: +- base < 5 + +tests: + my-test: + source-dirs: test + main: Test.hs diff --git a/tests/integration/tests/717-sdist-test/files/package-with-failing-test/test/Test.hs b/tests/integration/tests/717-sdist-test/files/failing-package-with-test/test/Test.hs similarity index 100% rename from tests/integration/tests/717-sdist-test/files/package-with-failing-test/test/Test.hs rename to tests/integration/tests/717-sdist-test/files/failing-package-with-test/test/Test.hs diff --git a/tests/integration/tests/717-sdist-test/files/package-with-failing-test/LICENSE b/tests/integration/tests/717-sdist-test/files/failing-package-with-th/LICENSE similarity index 100% rename from tests/integration/tests/717-sdist-test/files/package-with-failing-test/LICENSE rename to tests/integration/tests/717-sdist-test/files/failing-package-with-th/LICENSE diff --git a/tests/integration/tests/717-sdist-test/files/failing-package-with-th/README.md b/tests/integration/tests/717-sdist-test/files/failing-package-with-th/README.md new file mode 100644 index 0000000000..6c7f4896ea --- /dev/null +++ b/tests/integration/tests/717-sdist-test/files/failing-package-with-th/README.md @@ -0,0 +1 @@ +# failing-package-with-th diff --git a/tests/integration/tests/717-sdist-test/files/failing-package-with-th/files/file.txt b/tests/integration/tests/717-sdist-test/files/failing-package-with-th/files/file.txt new file mode 100644 index 0000000000..d95f3ad14d --- /dev/null +++ b/tests/integration/tests/717-sdist-test/files/failing-package-with-th/files/file.txt @@ -0,0 +1 @@ +content diff --git a/tests/integration/tests/717-sdist-test/files/failing-package-with-th/package.yaml b/tests/integration/tests/717-sdist-test/files/failing-package-with-th/package.yaml new file mode 100644 index 0000000000..0cc7c6c00f --- /dev/null +++ b/tests/integration/tests/717-sdist-test/files/failing-package-with-th/package.yaml @@ -0,0 +1,14 @@ +spec-version: 0.36.0 + +name: failing-package-with-th +description: A package with Template Haskell that is incomplete if sdist. + +extra-source-files: +- README.md + +dependencies: +- base < 5 +- template-haskell + +library: + source-dirs: src diff --git a/tests/integration/tests/717-sdist-test/files/package-with-th/src/Lib.hs b/tests/integration/tests/717-sdist-test/files/failing-package-with-th/src/Lib.hs similarity index 62% rename from tests/integration/tests/717-sdist-test/files/package-with-th/src/Lib.hs rename to tests/integration/tests/717-sdist-test/files/failing-package-with-th/src/Lib.hs index 26d2841b8f..0e37b70732 100644 --- a/tests/integration/tests/717-sdist-test/files/package-with-th/src/Lib.hs +++ b/tests/integration/tests/717-sdist-test/files/failing-package-with-th/src/Lib.hs @@ -3,8 +3,8 @@ module Lib ( someFunc ) where -import TH -import Language.Haskell.TH +import TH ( thFunc ) +import Language.Haskell.TH () someFunc :: IO () someFunc = print $(thFunc) diff --git a/tests/integration/tests/717-sdist-test/files/failing-package-with-th/src/TH.hs b/tests/integration/tests/717-sdist-test/files/failing-package-with-th/src/TH.hs new file mode 100644 index 0000000000..a83a2014e7 --- /dev/null +++ b/tests/integration/tests/717-sdist-test/files/failing-package-with-th/src/TH.hs @@ -0,0 +1,10 @@ +module TH + ( thFunc + ) where + +import Language.Haskell.TH ( Exp (..), Lit (..), Q, runIO ) + +thFunc :: Q Exp +thFunc = runIO $ do + readFile "files/file.txt" + pure $ LitE (IntegerL 5) diff --git a/tests/integration/tests/717-sdist-test/files/package-with-failing-test/README.md b/tests/integration/tests/717-sdist-test/files/package-with-failing-test/README.md deleted file mode 100644 index 8831e9c09c..0000000000 --- a/tests/integration/tests/717-sdist-test/files/package-with-failing-test/README.md +++ /dev/null @@ -1 +0,0 @@ -# thtest diff --git a/tests/integration/tests/717-sdist-test/files/package-with-failing-test/Setup.hs b/tests/integration/tests/717-sdist-test/files/package-with-failing-test/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/717-sdist-test/files/package-with-failing-test/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/717-sdist-test/files/package-with-failing-test/files/file.txt b/tests/integration/tests/717-sdist-test/files/package-with-failing-test/files/file.txt deleted file mode 100644 index 72943a16fb..0000000000 --- a/tests/integration/tests/717-sdist-test/files/package-with-failing-test/files/file.txt +++ /dev/null @@ -1 +0,0 @@ -aaa diff --git a/tests/integration/tests/717-sdist-test/files/package-with-failing-test/package-with-failing-test.cabal b/tests/integration/tests/717-sdist-test/files/package-with-failing-test/package-with-failing-test.cabal deleted file mode 100644 index 75e8f7ae2e..0000000000 --- a/tests/integration/tests/717-sdist-test/files/package-with-failing-test/package-with-failing-test.cabal +++ /dev/null @@ -1,27 +0,0 @@ -name: package-with-failing-test -version: 0.1.0.0 -synopsis: Some package -description: Some package -homepage: https://invalid -license: BSD3 -license-file: LICENSE -author: Author name here -maintainer: example@example.com -copyright: 2000 Author name here -category: Web -build-type: Simple -extra-source-files: README.md -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5, - template-haskell - default-language: Haskell2010 - -test-suite tests - type: exitcode-stdio-1.0 - hs-source-dirs: test - main-is: Test.hs - build-depends: base >= 4.7 && < 5 diff --git a/tests/integration/tests/717-sdist-test/files/package-with-failing-test/src/Lib.hs b/tests/integration/tests/717-sdist-test/files/package-with-failing-test/src/Lib.hs deleted file mode 100644 index 0d8704c625..0000000000 --- a/tests/integration/tests/717-sdist-test/files/package-with-failing-test/src/Lib.hs +++ /dev/null @@ -1,8 +0,0 @@ -module Lib - ( someFunc - ) where - -import Language.Haskell.TH - -someFunc :: IO () -someFunc = putStrLn "aaa" diff --git a/tests/integration/tests/717-sdist-test/files/package-with-th/README.md b/tests/integration/tests/717-sdist-test/files/package-with-th/README.md deleted file mode 100644 index 8831e9c09c..0000000000 --- a/tests/integration/tests/717-sdist-test/files/package-with-th/README.md +++ /dev/null @@ -1 +0,0 @@ -# thtest diff --git a/tests/integration/tests/717-sdist-test/files/package-with-th/Setup.hs b/tests/integration/tests/717-sdist-test/files/package-with-th/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/717-sdist-test/files/package-with-th/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/717-sdist-test/files/package-with-th/files/file.txt b/tests/integration/tests/717-sdist-test/files/package-with-th/files/file.txt deleted file mode 100644 index 72943a16fb..0000000000 --- a/tests/integration/tests/717-sdist-test/files/package-with-th/files/file.txt +++ /dev/null @@ -1 +0,0 @@ -aaa diff --git a/tests/integration/tests/717-sdist-test/files/package-with-th/package-with-th.cabal b/tests/integration/tests/717-sdist-test/files/package-with-th/package-with-th.cabal deleted file mode 100644 index 972934006d..0000000000 --- a/tests/integration/tests/717-sdist-test/files/package-with-th/package-with-th.cabal +++ /dev/null @@ -1,22 +0,0 @@ -name: package-with-th -version: 0.1.0.0 -synopsis: Some package -description: Some package -homepage: https://invalid -license: BSD3 -license-file: LICENSE -author: Author name here -maintainer: example@example.com -copyright: 2000 Author name here -category: Web -build-type: Simple -extra-source-files: README.md -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib, - TH - build-depends: base >= 4.7 && < 5, - template-haskell - default-language: Haskell2010 diff --git a/tests/integration/tests/717-sdist-test/files/package-with-th/src/TH.hs b/tests/integration/tests/717-sdist-test/files/package-with-th/src/TH.hs deleted file mode 100644 index ba24a158bf..0000000000 --- a/tests/integration/tests/717-sdist-test/files/package-with-th/src/TH.hs +++ /dev/null @@ -1,8 +0,0 @@ -module TH (thFunc) where - -import Language.Haskell.TH - -thFunc :: Q Exp -thFunc = runIO $ do - readFile "files/file.txt" - pure $ LitE (IntegerL 5) diff --git a/tests/integration/tests/717-sdist-test/files/package-with-working-th/LICENSE b/tests/integration/tests/717-sdist-test/files/package-with-working-th/LICENSE deleted file mode 100644 index 60aaf72cfa..0000000000 --- a/tests/integration/tests/717-sdist-test/files/package-with-working-th/LICENSE +++ /dev/null @@ -1,30 +0,0 @@ -Copyright Author name here (c) 2000 - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Author name here nor the names of other - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tests/integration/tests/717-sdist-test/files/package-with-working-th/README.md b/tests/integration/tests/717-sdist-test/files/package-with-working-th/README.md deleted file mode 100644 index 8831e9c09c..0000000000 --- a/tests/integration/tests/717-sdist-test/files/package-with-working-th/README.md +++ /dev/null @@ -1 +0,0 @@ -# thtest diff --git a/tests/integration/tests/717-sdist-test/files/package-with-working-th/Setup.hs b/tests/integration/tests/717-sdist-test/files/package-with-working-th/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/717-sdist-test/files/package-with-working-th/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/717-sdist-test/files/package-with-working-th/files/file.txt b/tests/integration/tests/717-sdist-test/files/package-with-working-th/files/file.txt deleted file mode 100644 index 72943a16fb..0000000000 --- a/tests/integration/tests/717-sdist-test/files/package-with-working-th/files/file.txt +++ /dev/null @@ -1 +0,0 @@ -aaa diff --git a/tests/integration/tests/717-sdist-test/files/package-with-working-th/package-with-working-th.cabal b/tests/integration/tests/717-sdist-test/files/package-with-working-th/package-with-working-th.cabal deleted file mode 100644 index cbeb18c3ee..0000000000 --- a/tests/integration/tests/717-sdist-test/files/package-with-working-th/package-with-working-th.cabal +++ /dev/null @@ -1,22 +0,0 @@ -name: package-with-working-th -version: 0.1.0.0 -synopsis: Some package -description: Some package -homepage: https://invalid -license: BSD3 -license-file: LICENSE -author: Author name here -maintainer: example@example.com -copyright: 2000 Author name here -category: Web -build-type: Simple -extra-source-files: README.md -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib, - TH - build-depends: base >= 4.7 && < 5, - template-haskell - default-language: Haskell2010 diff --git a/tests/integration/tests/717-sdist-test/files/package-with-working-th/src/TH.hs b/tests/integration/tests/717-sdist-test/files/package-with-working-th/src/TH.hs deleted file mode 100644 index e47d6eaab9..0000000000 --- a/tests/integration/tests/717-sdist-test/files/package-with-working-th/src/TH.hs +++ /dev/null @@ -1,7 +0,0 @@ -module TH (thFunc) where - -import Language.Haskell.TH - -thFunc :: Q Exp -thFunc = - pure $ LitE (IntegerL 5) diff --git a/tests/integration/tests/717-sdist-test/files/stack.yaml b/tests/integration/tests/717-sdist-test/files/stack.yaml index 1f8de3e558..196e557d7b 100644 --- a/tests/integration/tests/717-sdist-test/files/stack.yaml +++ b/tests/integration/tests/717-sdist-test/files/stack.yaml @@ -1,7 +1,8 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 + packages: -- package-with-th -- package-with-working-th -- package-with-failing-test +- failing-package-with-test +- failing-package-with-th - subdirs/dependent-on-failing-packages - subdirs/failing-in-subdir +- working-package-with-th diff --git a/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/README.md b/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/README.md index 8831e9c09c..387b7303cf 100644 --- a/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/README.md +++ b/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/README.md @@ -1 +1 @@ -# thtest +# dependent-on-failing-packages diff --git a/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/Setup.hs b/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/dependent-on-failing-packages.cabal b/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/dependent-on-failing-packages.cabal deleted file mode 100644 index cb1ddff94c..0000000000 --- a/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/dependent-on-failing-packages.cabal +++ /dev/null @@ -1,23 +0,0 @@ -name: dependent-on-failing-packages -version: 0.1.0.0 -synopsis: Some package -description: Some package -homepage: https://invalid -license: BSD3 -license-file: LICENSE -author: Author name here -maintainer: example@example.com -copyright: 2000 Author name here -category: Web -build-type: Simple -extra-source-files: README.md -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: LibD - build-depends: base >= 4.7 && < 5, - template-haskell, - package-with-th, - failing-in-subdir - default-language: Haskell2010 diff --git a/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/files/file.txt b/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/files/file.txt index 72943a16fb..d95f3ad14d 100644 --- a/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/files/file.txt +++ b/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/files/file.txt @@ -1 +1 @@ -aaa +content diff --git a/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/package.yaml b/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/package.yaml new file mode 100644 index 0000000000..32ba13e69e --- /dev/null +++ b/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/package.yaml @@ -0,0 +1,16 @@ +spec-version: 0.36.0 + +name: dependent-on-failing-packages +description: A package that can be sdist that depends on packages that cannot + +extra-source-files: +- README.md + +dependencies: +- base < 5 +- template-haskell +- failing-package-with-th +- failing-in-subdir + +library: + source-dirs: src diff --git a/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/src/LibD.hs b/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/src/LibD.hs index a0c7ad615e..5967ffc1dc 100644 --- a/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/src/LibD.hs +++ b/tests/integration/tests/717-sdist-test/files/subdirs/dependent-on-failing-packages/src/LibD.hs @@ -1,9 +1,9 @@ module LibD - ( someFunc - ) where + ( someFuncD + ) where -import Lib -import LibC +import Lib ( someFunc ) +import LibC ( someFuncC ) someFuncD :: IO () someFuncD = do diff --git a/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/README.md b/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/README.md index 8831e9c09c..0533304f7f 100644 --- a/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/README.md +++ b/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/README.md @@ -1 +1 @@ -# thtest +# failing-in-subdir diff --git a/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/Setup.hs b/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/failing-in-subdir.cabal b/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/failing-in-subdir.cabal deleted file mode 100644 index 944a17a598..0000000000 --- a/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/failing-in-subdir.cabal +++ /dev/null @@ -1,22 +0,0 @@ -name: failing-in-subdir -version: 0.1.0.0 -synopsis: Some package -description: Some package -homepage: https://invalid -license: BSD3 -license-file: LICENSE -author: Author name here -maintainer: example@example.com -copyright: 2000 Author name here -category: Web -build-type: Simple -extra-source-files: README.md -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: LibC, - THInSubdir - build-depends: base >= 4.7 && < 5, - template-haskell - default-language: Haskell2010 diff --git a/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/files/file.txt b/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/files/file.txt index 72943a16fb..d95f3ad14d 100644 --- a/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/files/file.txt +++ b/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/files/file.txt @@ -1 +1 @@ -aaa +content diff --git a/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/package.yaml b/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/package.yaml new file mode 100644 index 0000000000..265fa029cd --- /dev/null +++ b/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/package.yaml @@ -0,0 +1,14 @@ +spec-version: 0.36.0 + +name: failing-in-subdir +description: A package with Template Haskell that is incomplete if sdist. + +extra-source-files: +- README.md + +dependencies: +- base < 5 +- template-haskell + +library: + source-dirs: src diff --git a/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/src/LibC.hs b/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/src/LibC.hs index f951ce4a28..bce50b4df4 100644 --- a/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/src/LibC.hs +++ b/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/src/LibC.hs @@ -1,10 +1,10 @@ {-# LANGUAGE TemplateHaskell #-} + module LibC ( someFuncC ) where -import THInSubdir -import Language.Haskell.TH +import THInSubdir ( thFuncC ) someFuncC :: IO () someFuncC = print $(thFuncC) diff --git a/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/src/THInSubdir.hs b/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/src/THInSubdir.hs index d9a3820d9d..803150f5ca 100644 --- a/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/src/THInSubdir.hs +++ b/tests/integration/tests/717-sdist-test/files/subdirs/failing-in-subdir/src/THInSubdir.hs @@ -1,6 +1,8 @@ -module THInSubdir (thFuncC) where +module THInSubdir + ( thFuncC + ) where -import Language.Haskell.TH +import Language.Haskell.TH ( Exp (..), Lit (..), Q, runIO ) thFuncC :: Q Exp thFuncC = runIO $ do diff --git a/tests/integration/tests/717-sdist-test/files/package-with-th/LICENSE b/tests/integration/tests/717-sdist-test/files/working-package-with-th/LICENSE similarity index 100% rename from tests/integration/tests/717-sdist-test/files/package-with-th/LICENSE rename to tests/integration/tests/717-sdist-test/files/working-package-with-th/LICENSE diff --git a/tests/integration/tests/717-sdist-test/files/working-package-with-th/README.md b/tests/integration/tests/717-sdist-test/files/working-package-with-th/README.md new file mode 100644 index 0000000000..c98b2279e2 --- /dev/null +++ b/tests/integration/tests/717-sdist-test/files/working-package-with-th/README.md @@ -0,0 +1 @@ +# working-package-with-th diff --git a/tests/integration/tests/717-sdist-test/files/working-package-with-th/package.yaml b/tests/integration/tests/717-sdist-test/files/working-package-with-th/package.yaml new file mode 100644 index 0000000000..660aa8f803 --- /dev/null +++ b/tests/integration/tests/717-sdist-test/files/working-package-with-th/package.yaml @@ -0,0 +1,15 @@ +spec-version: 0.36.0 + +name: working-package-with-th +version: 0.1.0.0 +description: A package with Template Haskell that can be sdist. + +extra-source-files: +- README.md + +dependencies: +- base < 5 +- template-haskell + +library: + source-dirs: src diff --git a/tests/integration/tests/717-sdist-test/files/package-with-working-th/src/Lib.hs b/tests/integration/tests/717-sdist-test/files/working-package-with-th/src/Lib.hs similarity index 58% rename from tests/integration/tests/717-sdist-test/files/package-with-working-th/src/Lib.hs rename to tests/integration/tests/717-sdist-test/files/working-package-with-th/src/Lib.hs index 26d2841b8f..dfdbfc9d08 100644 --- a/tests/integration/tests/717-sdist-test/files/package-with-working-th/src/Lib.hs +++ b/tests/integration/tests/717-sdist-test/files/working-package-with-th/src/Lib.hs @@ -1,10 +1,10 @@ {-# LANGUAGE TemplateHaskell #-} + module Lib - ( someFunc - ) where + ( someFunc + ) where -import TH -import Language.Haskell.TH +import TH ( thFunc ) someFunc :: IO () someFunc = print $(thFunc) diff --git a/tests/integration/tests/717-sdist-test/files/working-package-with-th/src/TH.hs b/tests/integration/tests/717-sdist-test/files/working-package-with-th/src/TH.hs new file mode 100644 index 0000000000..06925fbf18 --- /dev/null +++ b/tests/integration/tests/717-sdist-test/files/working-package-with-th/src/TH.hs @@ -0,0 +1,8 @@ +module TH + ( thFunc + ) where + +import Language.Haskell.TH ( Exp (..), Lit (..), Q ) + +thFunc :: Q Exp +thFunc = pure $ LitE (IntegerL 5) diff --git a/tests/integration/tests/763-buildable-false/Main.hs b/tests/integration/tests/763-buildable-false/Main.hs index 89d44c5eea..4e0cb8c2ac 100644 --- a/tests/integration/tests/763-buildable-false/Main.hs +++ b/tests/integration/tests/763-buildable-false/Main.hs @@ -1,9 +1,12 @@ -import StackTest +-- Stack reports an error if commanded to build a specific component of a +-- package that is not buildable. +-- +-- https://github.com/commercialhaskell/stack/issues/763 + +import StackTest main :: IO () main = do - stack ["build"] - stack ["build", "--flag", "*:force-enable"] - stack ["build", ":enabled"] - stackErr ["build", ":disabled"] - stack ["build", ":disabled", "--flag", "files:force-enable"] + stack ["build"] + stack ["build", ":myPackage", "--flag", "myPackage:buildable"] + stackErr ["build", ":myPackage"] diff --git a/tests/integration/tests/763-buildable-false/files/.gitignore b/tests/integration/tests/763-buildable-false/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/763-buildable-false/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/763-buildable-false/files/files.cabal b/tests/integration/tests/763-buildable-false/files/files.cabal deleted file mode 100644 index a4c6069896..0000000000 --- a/tests/integration/tests/763-buildable-false/files/files.cabal +++ /dev/null @@ -1,25 +0,0 @@ -name: files -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -flag force-enable - default: False - description: foo - -executable enabled - hs-source-dirs: app - main-is: Main.hs - build-depends: base - default-language: Haskell2010 - buildable: True - -executable disabled - hs-source-dirs: app - main-is: Main.hs - build-depends: base - default-language: Haskell2010 - if flag(force-enable) - buildable: True - else - buildable: False diff --git a/tests/integration/tests/763-buildable-false/files/package.yaml b/tests/integration/tests/763-buildable-false/files/package.yaml new file mode 100644 index 0000000000..1d512e9811 --- /dev/null +++ b/tests/integration/tests/763-buildable-false/files/package.yaml @@ -0,0 +1,23 @@ +spec-version: 0.36.0 + +name: myPackage + +flags: + buildable: + description: Make component buildable. + default: false + manual: true + +dependencies: +- base + +executables: + myPackage: + source-dirs: app + main: Main.hs + when: + - condition: flag(buildable) + then: + buildable: true + else: + buildable: false diff --git a/tests/integration/tests/763-buildable-false/files/stack.yaml b/tests/integration/tests/763-buildable-false/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/763-buildable-false/files/stack.yaml +++ b/tests/integration/tests/763-buildable-false/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/796-ghc-options/Main.hs b/tests/integration/tests/796-ghc-options/Main.hs index 25ee1e2869..4842cdc38b 100644 --- a/tests/integration/tests/796-ghc-options/Main.hs +++ b/tests/integration/tests/796-ghc-options/Main.hs @@ -1,7 +1,12 @@ -import StackTest +-- Stack can set environment variables in a project-level configuration file or +-- at the command line and cause the package to be rebuilt. +-- +-- See: https://github.com/commercialhaskell/stack/issues/796 + +import StackTest main :: IO () main = do - stack ["build"] - stackErr ["build", "--ghc-options=-DBAZ"] - stack ["build", "--ghc-options=-DQUX"] + stack ["build"] + stackErr ["build", "--ghc-options=-DVARIABLE_C"] + stack ["build", "--ghc-options=-DVARIABLE_D"] diff --git a/tests/integration/tests/796-ghc-options/files/.gitignore b/tests/integration/tests/796-ghc-options/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/796-ghc-options/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/796-ghc-options/files/ghc-options.cabal b/tests/integration/tests/796-ghc-options/files/ghc-options.cabal deleted file mode 100644 index 642090489e..0000000000 --- a/tests/integration/tests/796-ghc-options/files/ghc-options.cabal +++ /dev/null @@ -1,10 +0,0 @@ -name: ghc-options -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 diff --git a/tests/integration/tests/796-ghc-options/files/package.yaml b/tests/integration/tests/796-ghc-options/files/package.yaml new file mode 100644 index 0000000000..a7305a77cf --- /dev/null +++ b/tests/integration/tests/796-ghc-options/files/package.yaml @@ -0,0 +1,9 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src diff --git a/tests/integration/tests/796-ghc-options/files/src/Lib.hs b/tests/integration/tests/796-ghc-options/files/src/Lib.hs index cbb5c96956..5a5e96c7f0 100644 --- a/tests/integration/tests/796-ghc-options/files/src/Lib.hs +++ b/tests/integration/tests/796-ghc-options/files/src/Lib.hs @@ -1,24 +1,20 @@ {-# LANGUAGE CPP #-} -module Lib - ( someFunc - ) where -someFunc :: IO () -someFunc = putStrLn "someFunc" +module Lib where -- Avoid problems with CPP and HLint #ifndef __HLINT__ -#ifndef FOO -#error FOO isn't defined +#ifndef VARIABLE_A +#error VARIABLE_A isn't defined #endif -#ifndef BAR -#error BAR isn't defined +#ifndef VARIABLE_B +#error VARIABLE_B isn't defined #endif -#ifdef BAZ -#error BAZ is defined +#ifdef VARIABLE_C +#error VARIABLE_C is defined #endif #endif diff --git a/tests/integration/tests/796-ghc-options/files/stack.yaml b/tests/integration/tests/796-ghc-options/files/stack.yaml index f98d2f0900..3c2c041e3d 100644 --- a/tests/integration/tests/796-ghc-options/files/stack.yaml +++ b/tests/integration/tests/796-ghc-options/files/stack.yaml @@ -1,5 +1,7 @@ snapshot: ghc-9.10.3 + ghc-options: - "*": -DFOO - ghc-options: -DBAR + "*": -DVARIABLE_A + myPackage: -DVARIABLE_B + rebuild-ghc-options: true diff --git a/tests/integration/tests/allow-newer-specific-packages/Main.hs b/tests/integration/tests/allow-newer-specific-packages/Main.hs index af048e917b..af0d7407fe 100644 --- a/tests/integration/tests/allow-newer-specific-packages/Main.hs +++ b/tests/integration/tests/allow-newer-specific-packages/Main.hs @@ -1,5 +1,7 @@ -import StackTest +-- | Stack allows allow-newer to be applied to the dependencies of specified +-- packages. + +import StackTest main :: IO () -main = do - stack ["build"] +main = stack ["build"] diff --git a/tests/integration/tests/allow-newer-specific-packages/files/.gitignore b/tests/integration/tests/allow-newer-specific-packages/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/allow-newer-specific-packages/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/allow-newer-specific-packages/files/foo.cabal b/tests/integration/tests/allow-newer-specific-packages/files/foo.cabal deleted file mode 100644 index 1cd8630056..0000000000 --- a/tests/integration/tests/allow-newer-specific-packages/files/foo.cabal +++ /dev/null @@ -1,20 +0,0 @@ -cabal-version: 1.12 - --- This file has been generated from package.yaml by hpack version 0.35.0. --- --- see: https://github.com/sol/hpack - -name: foo -version: 0 -build-type: Simple - -library - exposed-modules: - Foo - other-modules: - Paths_foo - hs-source-dirs: - src - build-depends: - base ==4.13.* - default-language: Haskell2010 diff --git a/tests/integration/tests/allow-newer-specific-packages/files/package.yaml b/tests/integration/tests/allow-newer-specific-packages/files/package.yaml index c3af47cd49..9104b9bf64 100644 --- a/tests/integration/tests/allow-newer-specific-packages/files/package.yaml +++ b/tests/integration/tests/allow-newer-specific-packages/files/package.yaml @@ -1,8 +1,10 @@ -name: foo -version: 0 +spec-version: 0.36.0 + +name: myPackage dependencies: -- base >= 4.13 && < 4.14 +- base +- acme-missiles < 0.3 library: source-dirs: src diff --git a/tests/integration/tests/allow-newer-specific-packages/files/src/Foo.hs b/tests/integration/tests/allow-newer-specific-packages/files/src/Foo.hs deleted file mode 100644 index efbf93bbde..0000000000 --- a/tests/integration/tests/allow-newer-specific-packages/files/src/Foo.hs +++ /dev/null @@ -1 +0,0 @@ -module Foo where diff --git a/tests/integration/tests/allow-newer-specific-packages/files/src/Lib.hs b/tests/integration/tests/allow-newer-specific-packages/files/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/allow-newer-specific-packages/files/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/allow-newer-specific-packages/files/stack.yaml b/tests/integration/tests/allow-newer-specific-packages/files/stack.yaml index 4126c4cd28..ebf6dd48f5 100644 --- a/tests/integration/tests/allow-newer-specific-packages/files/stack.yaml +++ b/tests/integration/tests/allow-newer-specific-packages/files/stack.yaml @@ -1,5 +1,9 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 + +extra-deps: +- acme-missiles-0.3 allow-newer: true + allow-newer-deps: -- foo +- myPackage diff --git a/tests/integration/tests/basic-install/Main.hs b/tests/integration/tests/basic-install/Main.hs index b18a78a32f..659cccdb75 100644 --- a/tests/integration/tests/basic-install/Main.hs +++ b/tests/integration/tests/basic-install/Main.hs @@ -1,6 +1,8 @@ -import StackTest +-- | Stack will build packages in the package index in the absence of a Stack +-- project-level configuration file (by referring to the configuration file in +-- the global-project directory in the Stack root). + +import StackTest main :: IO () -main = do - stack [defaultSnapshotArg, "install", "acme-missiles-0.3"] - doesNotExist "stack.yaml" +main = stack ["build", "acme-missiles-0.3"] diff --git a/tests/integration/tests/build-ghc/Main.hs b/tests/integration/tests/build-ghc/Main.hs index 2d533a4c18..3a389a2b7d 100644 --- a/tests/integration/tests/build-ghc/Main.hs +++ b/tests/integration/tests/build-ghc/Main.hs @@ -1,5 +1,5 @@ -import StackTest -import System.Directory (withCurrentDirectory) +import StackTest +import System.Directory ( withCurrentDirectory ) main :: IO () main = superslow $ do diff --git a/tests/integration/tests/cabal-non-buildable-bug/Main.hs b/tests/integration/tests/cabal-non-buildable-bug/Main.hs index a1cd064333..ceaa053290 100644 --- a/tests/integration/tests/cabal-non-buildable-bug/Main.hs +++ b/tests/integration/tests/cabal-non-buildable-bug/Main.hs @@ -1,20 +1,9 @@ -import StackTest +-- | When building, Stack ignores the components of packages that are +-- not-buildable. + +import StackTest main :: IO () main = do - -- Newer Cabal: dry run and building should succeed, because they'll - -- both ignore the do-not-build - writeFile "stack.yaml" "snapshot: lts-24.24" stack ["build", "--dry-run"] stack ["build"] - - -- Older Cabal: both should fail, because they'll both try to - -- include the non-buildable component. If there's a regression, the - -- dry run will succeed (because Stack will use the proper logic) - -- and build will fail (because Cabal will be using its broken - -- logic). - writeFile "stack.yaml" "snapshot: ghc-7.10.3" - -- The '--install-ghc' flag is passed here, because IntegrationSpec.runApp - -- sets up `config.yaml` with `system-ghc: true` and `install-ghc: false`. - stackErr ["--install-ghc", "build"] - stackErr ["--install-ghc", "build", "--dry-run"] diff --git a/tests/integration/tests/cabal-non-buildable-bug/files/.gitignore b/tests/integration/tests/cabal-non-buildable-bug/files/.gitignore index 0008ca1636..b0a5a052a1 100644 --- a/tests/integration/tests/cabal-non-buildable-bug/files/.gitignore +++ b/tests/integration/tests/cabal-non-buildable-bug/files/.gitignore @@ -1,2 +1 @@ -stack.yaml -foo.cabal +myPackage.cabal diff --git a/tests/integration/tests/cabal-non-buildable-bug/files/package.yaml b/tests/integration/tests/cabal-non-buildable-bug/files/package.yaml index 67f3a25c46..47630ba295 100644 --- a/tests/integration/tests/cabal-non-buildable-bug/files/package.yaml +++ b/tests/integration/tests/cabal-non-buildable-bug/files/package.yaml @@ -1,14 +1,11 @@ -name: foo -version: "0" +spec-version: 0.36.0 + +name: myPackage dependencies: - base -library: {} - executables: - not-built: - main: Main.hs - dependencies: - - does-not-exist + myExe: + main: Main.hs # Does not exist buildable: false diff --git a/tests/integration/tests/cabal-non-buildable-bug/files/stack.yaml b/tests/integration/tests/cabal-non-buildable-bug/files/stack.yaml new file mode 100644 index 0000000000..e674eab75a --- /dev/null +++ b/tests/integration/tests/cabal-non-buildable-bug/files/stack.yaml @@ -0,0 +1 @@ +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/cabal-public-sublibraries/Main.hs b/tests/integration/tests/cabal-public-sublibraries/Main.hs deleted file mode 100644 index 987ebbfe2e..0000000000 --- a/tests/integration/tests/cabal-public-sublibraries/Main.hs +++ /dev/null @@ -1,6 +0,0 @@ -import StackTest - -main :: IO () -main = do - putStrLn "Disabled: CI doesn't have GHC 8.8.1" - --stack ["build"] diff --git a/tests/integration/tests/cabal-public-sublibraries/files/Setup.hs b/tests/integration/tests/cabal-public-sublibraries/files/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/cabal-public-sublibraries/files/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/cabal-public-sublibraries/files/files.cabal b/tests/integration/tests/cabal-public-sublibraries/files/files.cabal deleted file mode 100644 index 5255078e44..0000000000 --- a/tests/integration/tests/cabal-public-sublibraries/files/files.cabal +++ /dev/null @@ -1,17 +0,0 @@ -cabal-version: 3.0 -name: files -version: 0.1.0.0 -build-type: Simple - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 - -library sub - visibility: public - hs-source-dirs: src - exposed-modules: Sub - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 diff --git a/tests/integration/tests/cabal-public-sublibraries/files/src/Sub.hs b/tests/integration/tests/cabal-public-sublibraries/files/src/Sub.hs deleted file mode 100644 index 08c047a5a1..0000000000 --- a/tests/integration/tests/cabal-public-sublibraries/files/src/Sub.hs +++ /dev/null @@ -1,7 +0,0 @@ -module Sub - ( someFunc - ) where - -someFunc :: IO () -someFunc = do - putStrLn "hello world" diff --git a/tests/integration/tests/cabal-public-sublibraries/files/stack.yaml b/tests/integration/tests/cabal-public-sublibraries/files/stack.yaml deleted file mode 100644 index 6fdd699311..0000000000 --- a/tests/integration/tests/cabal-public-sublibraries/files/stack.yaml +++ /dev/null @@ -1,5 +0,0 @@ -snapshot: nightly-2020-01-17 -extra-deps: -- github: snoyberg/filelock - commit: 4f080496d8bf153fbe26e64d1f52cf73c7db25f6 -# - Cabal-3.0.0.0@sha256:1ba37b8d80e89213b17db7b8b9ea0108da55ca65f8c0cbb7433881a284c5cf67,26027 diff --git a/tests/integration/tests/cabal-public-sublibraries/files/stack.yaml.lock b/tests/integration/tests/cabal-public-sublibraries/files/stack.yaml.lock deleted file mode 100644 index 44b4120015..0000000000 --- a/tests/integration/tests/cabal-public-sublibraries/files/stack.yaml.lock +++ /dev/null @@ -1,23 +0,0 @@ -# This file was autogenerated by Stack. -# You should not edit this file by hand. -# For more information, please see the documentation at: -# https://docs.haskellstack.org/en/stable/lock_files - -packages: -- completed: - name: filelock - pantry-tree: - sha256: 0563d664aefb56cacfa89bc244d377c5e63597abd827a5a3f8d6be21a2b3b4d9 - size: 584 - sha256: c27641e26137f52b27e3ef9e27e7ac3f845f719ea54a12475f00f2ea7e6d9afc - size: 9228 - url: https://github.com/snoyberg/filelock/archive/4f080496d8bf153fbe26e64d1f52cf73c7db25f6.tar.gz - version: 0.1.1.2 - original: - url: https://github.com/snoyberg/filelock/archive/4f080496d8bf153fbe26e64d1f52cf73c7db25f6.tar.gz -snapshots: -- completed: - sha256: bfafe5735ccb74527d754b1f9999ded72d7c3a6c3a88529449661431ccfbd6cc - size: 649327 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/8.yaml - original: lts-20.8 diff --git a/tests/integration/tests/cabal-sublibrary-dependency/Main.hs b/tests/integration/tests/cabal-sublibrary-dependency/Main.hs index da62ff8f13..4f9ba45ac1 100644 --- a/tests/integration/tests/cabal-sublibrary-dependency/Main.hs +++ b/tests/integration/tests/cabal-sublibrary-dependency/Main.hs @@ -1,13 +1,10 @@ -import Control.Monad (unless) -import Data.List (isInfixOf) -import StackTest +-- | Stack can build a project package that depends on the public named library +-- (a sublibrary) of another project package. However, the latter package must +-- also have a main library (which may be a Stack bug). +-- +-- See: https://github.com/commercialhaskell/stack/issues/6896 --- This tests building two project packages, one of which depends on the other --- (subproject). The dependency has a library and a visible sub-library named --- sub, each of which exposes a module that exports a function. +import StackTest main :: IO () --- The '--install-ghc' flag is passed here, because IntegrationSpec.runApp sets --- up `config.yaml` with `system-ghc: true` and `install-ghc: false`. --- (See stack.yaml; using GHC 9.10.3.) -main = stack ["build", "--install-ghc"] +main = stack ["build", ":myExe"] diff --git a/tests/integration/tests/cabal-sublibrary-dependency/files/.gitignore b/tests/integration/tests/cabal-sublibrary-dependency/files/.gitignore new file mode 100644 index 0000000000..f9a6e152d2 --- /dev/null +++ b/tests/integration/tests/cabal-sublibrary-dependency/files/.gitignore @@ -0,0 +1,2 @@ +myPackageA.cabal +myPackageB.cabal diff --git a/tests/integration/tests/cabal-sublibrary-dependency/files/Setup.hs b/tests/integration/tests/cabal-sublibrary-dependency/files/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/cabal-sublibrary-dependency/files/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/cabal-sublibrary-dependency/files/files.cabal b/tests/integration/tests/cabal-sublibrary-dependency/files/files.cabal deleted file mode 100644 index 41071cf460..0000000000 --- a/tests/integration/tests/cabal-sublibrary-dependency/files/files.cabal +++ /dev/null @@ -1,11 +0,0 @@ -cabal-version: 3.8 -name: files -version: 0.1.0.0 -build-type: Simple - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5 - , subproject:{subproject, sub} - default-language: Haskell2010 diff --git a/tests/integration/tests/cabal-sublibrary-dependency/files/myPackageA/app/Main.hs b/tests/integration/tests/cabal-sublibrary-dependency/files/myPackageA/app/Main.hs new file mode 100644 index 0000000000..89ad4b3e08 --- /dev/null +++ b/tests/integration/tests/cabal-sublibrary-dependency/files/myPackageA/app/Main.hs @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = pure () diff --git a/tests/integration/tests/cabal-sublibrary-dependency/files/myPackageA/package.yaml b/tests/integration/tests/cabal-sublibrary-dependency/files/myPackageA/package.yaml new file mode 100644 index 0000000000..c7b310119d --- /dev/null +++ b/tests/integration/tests/cabal-sublibrary-dependency/files/myPackageA/package.yaml @@ -0,0 +1,12 @@ +spec-version: 0.36.0 + +name: myPackageA + +dependencies: +- base +- myPackageB:myPackageB-sub + +executables: + myExe: + source-dirs: app + main: Main.hs diff --git a/tests/integration/tests/cabal-sublibrary-dependency/files/myPackageB/package.yaml b/tests/integration/tests/cabal-sublibrary-dependency/files/myPackageB/package.yaml new file mode 100644 index 0000000000..9591417520 --- /dev/null +++ b/tests/integration/tests/cabal-sublibrary-dependency/files/myPackageB/package.yaml @@ -0,0 +1,13 @@ +spec-version: 0.36.0 + +name: myPackageB + +dependencies: +- base + +library: {} + +internal-libraries: + myPackageB-sub: + visibility: public + source-dirs: src diff --git a/tests/integration/tests/cabal-sublibrary-dependency/files/myPackageB/src/Lib.hs b/tests/integration/tests/cabal-sublibrary-dependency/files/myPackageB/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/cabal-sublibrary-dependency/files/myPackageB/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/cabal-sublibrary-dependency/files/src/Lib.hs b/tests/integration/tests/cabal-sublibrary-dependency/files/src/Lib.hs deleted file mode 100644 index 6b90650128..0000000000 --- a/tests/integration/tests/cabal-sublibrary-dependency/files/src/Lib.hs +++ /dev/null @@ -1,11 +0,0 @@ -module Lib - ( someFunc - ) where - -import Subproject.Lib ( libFunc ) -import Subproject.SubLib ( subLibFunc ) - -someFunc :: IO () -someFunc = do - libFunc - subLibFunc diff --git a/tests/integration/tests/cabal-sublibrary-dependency/files/stack.yaml b/tests/integration/tests/cabal-sublibrary-dependency/files/stack.yaml index 6282bfb76f..68891a8d7c 100644 --- a/tests/integration/tests/cabal-sublibrary-dependency/files/stack.yaml +++ b/tests/integration/tests/cabal-sublibrary-dependency/files/stack.yaml @@ -1,4 +1,5 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 + packages: -- . -- subproject +- myPackageA +- myPackageB diff --git a/tests/integration/tests/cabal-sublibrary-dependency/files/stack.yaml.lock b/tests/integration/tests/cabal-sublibrary-dependency/files/stack.yaml.lock deleted file mode 100644 index 8e0b3a647f..0000000000 --- a/tests/integration/tests/cabal-sublibrary-dependency/files/stack.yaml.lock +++ /dev/null @@ -1,12 +0,0 @@ -# This file was autogenerated by Stack. -# You should not edit this file by hand. -# For more information, please see the documentation at: -# https://docs.haskellstack.org/en/stable/lock_files - -packages: [] -snapshots: -- completed: - sha256: c4233cb7ff3bc39c1eaad6153615331c9adc624559391142a8b812248a31300d - size: 598787 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2023/3/4.yaml - original: nightly-2023-03-04 diff --git a/tests/integration/tests/cabal-sublibrary-dependency/files/subproject/src/Subproject/Lib.hs b/tests/integration/tests/cabal-sublibrary-dependency/files/subproject/src/Subproject/Lib.hs deleted file mode 100644 index 381ea5e740..0000000000 --- a/tests/integration/tests/cabal-sublibrary-dependency/files/subproject/src/Subproject/Lib.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Subproject.Lib - ( libFunc - ) where - -libFunc :: IO () -libFunc = putStrLn "libFunc" diff --git a/tests/integration/tests/cabal-sublibrary-dependency/files/subproject/src/Subproject/SubLib.hs b/tests/integration/tests/cabal-sublibrary-dependency/files/subproject/src/Subproject/SubLib.hs deleted file mode 100644 index ccf81c7278..0000000000 --- a/tests/integration/tests/cabal-sublibrary-dependency/files/subproject/src/Subproject/SubLib.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Subproject.SubLib - ( subLibFunc - ) where - -subLibFunc :: IO () -subLibFunc = putStrLn "subLibFunc" diff --git a/tests/integration/tests/cabal-sublibrary-dependency/files/subproject/subproject.cabal b/tests/integration/tests/cabal-sublibrary-dependency/files/subproject/subproject.cabal deleted file mode 100644 index f8db548fb8..0000000000 --- a/tests/integration/tests/cabal-sublibrary-dependency/files/subproject/subproject.cabal +++ /dev/null @@ -1,17 +0,0 @@ -cabal-version: 3.8 -name: subproject -version: 0.1.0.0 -build-type: Simple - -library - hs-source-dirs: src - exposed-modules: Subproject.Lib - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 - -library sub - visibility: public - hs-source-dirs: src - exposed-modules: Subproject.SubLib - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 diff --git a/tests/integration/tests/copy-bins-works/Main.hs b/tests/integration/tests/copy-bins-works/Main.hs index 038e3f1124..feafc1ba33 100644 --- a/tests/integration/tests/copy-bins-works/Main.hs +++ b/tests/integration/tests/copy-bins-works/Main.hs @@ -1,14 +1,15 @@ -import StackTest -import System.Directory -import Control.Monad (unless) +-- | Stack's build command supports the copy-bins flag. + +import StackTest +import System.Directory ( createDirectoryIfMissing ) main :: IO () main = do - let test args = do - removeDirIgnore "bin" - stackCleanFull - stack args - exists <- doesDirectoryExist "bin" - unless exists $ error $ "Failed with: " ++ show args - test ["install", "--local-bin-path", "bin"] - test ["build", "--copy-bins", "--local-bin-path", "bin"] + createDirectoryIfMissing True "bin1" + stack ["build", "--copy-bins", "--local-bin-path", "bin1"] + doesExist ("bin1/" <> myPackageExe) + createDirectoryIfMissing True "bin2" + stack ["--stack-yaml", "stack-copy-bins.yaml", "build", "--local-bin-path", "bin2"] + doesExist ("bin2/" <> myPackageExe) + where + myPackageExe = "myExe" <> exeExt diff --git a/tests/integration/tests/copy-bins-works/files/.gitignore b/tests/integration/tests/copy-bins-works/files/.gitignore index f1a8228e76..fc53374c2f 100644 --- a/tests/integration/tests/copy-bins-works/files/.gitignore +++ b/tests/integration/tests/copy-bins-works/files/.gitignore @@ -1,2 +1,3 @@ -*.cabal -/bin/ +myPackage.cabal +bin1/ +bin2/ diff --git a/tests/integration/tests/copy-bins-works/files/app/Main.hs b/tests/integration/tests/copy-bins-works/files/app/Main.hs new file mode 100644 index 0000000000..89ad4b3e08 --- /dev/null +++ b/tests/integration/tests/copy-bins-works/files/app/Main.hs @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = pure () diff --git a/tests/integration/tests/copy-bins-works/files/package.yaml b/tests/integration/tests/copy-bins-works/files/package.yaml index 34d45cd594..ee1f9f8afa 100644 --- a/tests/integration/tests/copy-bins-works/files/package.yaml +++ b/tests/integration/tests/copy-bins-works/files/package.yaml @@ -1,9 +1,11 @@ -name: foo -version: 0 +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base executables: - bar: - source-dirs: src + myExe: + source-dirs: app main: Main.hs - dependencies: - - base diff --git a/tests/integration/tests/copy-bins-works/files/stack-copy-bins.yaml b/tests/integration/tests/copy-bins-works/files/stack-copy-bins.yaml new file mode 100644 index 0000000000..4ca93380fd --- /dev/null +++ b/tests/integration/tests/copy-bins-works/files/stack-copy-bins.yaml @@ -0,0 +1,4 @@ +snapshot: ghc-9.10.3 + +build: + copy-bins: true diff --git a/tests/integration/tests/copy-bins-works/files/stack.yaml b/tests/integration/tests/copy-bins-works/files/stack.yaml index af66d8f381..abe6c1f573 100644 --- a/tests/integration/tests/copy-bins-works/files/stack.yaml +++ b/tests/integration/tests/copy-bins-works/files/stack.yaml @@ -1,2 +1,4 @@ snapshot: ghc-9.10.3 -copy-bins: true + +build: + copy-bins: false diff --git a/tests/integration/tests/cyclic-test-deps/Main.hs b/tests/integration/tests/cyclic-test-deps/Main.hs index 80dab5b758..afc53ad304 100644 --- a/tests/integration/tests/cyclic-test-deps/Main.hs +++ b/tests/integration/tests/cyclic-test-deps/Main.hs @@ -1,4 +1,4 @@ -import StackTest +import StackTest main :: IO () main = do diff --git a/tests/integration/tests/drop-packages/Main.hs b/tests/integration/tests/drop-packages/Main.hs index b16d43227b..69700c9823 100644 --- a/tests/integration/tests/drop-packages/Main.hs +++ b/tests/integration/tests/drop-packages/Main.hs @@ -1,4 +1,6 @@ -import StackTest +-- | Stack can drop packages from a snapshot. + +import StackTest main :: IO () main = stackErr ["build"] diff --git a/tests/integration/tests/drop-packages/files/.gitignore b/tests/integration/tests/drop-packages/files/.gitignore index d43d807c0d..b0a5a052a1 100644 --- a/tests/integration/tests/drop-packages/files/.gitignore +++ b/tests/integration/tests/drop-packages/files/.gitignore @@ -1 +1 @@ -*.cabal +myPackage.cabal diff --git a/tests/integration/tests/drop-packages/files/package.yaml b/tests/integration/tests/drop-packages/files/package.yaml index 1fe2825944..e4d2cd7656 100644 --- a/tests/integration/tests/drop-packages/files/package.yaml +++ b/tests/integration/tests/drop-packages/files/package.yaml @@ -1,6 +1,9 @@ -name: unimportant -version: 0 +spec-version: 0.36.0 + +name: myPackage + dependencies: - base - unliftio-core + library: {} diff --git a/tests/integration/tests/drop-packages/files/stack.yaml b/tests/integration/tests/drop-packages/files/stack.yaml index 5d6ab2f533..9d4c5b23af 100644 --- a/tests/integration/tests/drop-packages/files/stack.yaml +++ b/tests/integration/tests/drop-packages/files/stack.yaml @@ -1,3 +1,4 @@ -snapshot: lts-24.24 +snapshot: lts-24.43 + drop-packages: - unliftio-core diff --git a/tests/integration/tests/duplicate-package-ids/Main.hs b/tests/integration/tests/duplicate-package-ids/Main.hs index 88fd081bc6..38ca390b7f 100644 --- a/tests/integration/tests/duplicate-package-ids/Main.hs +++ b/tests/integration/tests/duplicate-package-ids/Main.hs @@ -1,11 +1,10 @@ -import StackTest +-- | Stack distinguises between a package in the package index and a project +-- package, even if they have the same name and version. + +import StackTest main :: IO () main = do - readFile "stack1.yaml" >>= writeFile "stack.yaml" - stack ["setup"] - stack ["build", "auto-update"] - readFile "stack2.yaml" >>= writeFile "stack.yaml" - removeDirIgnore "auto-update-0.1.2.1" - stack ["unpack", "auto-update-0.1.2.1"] - stack ["build"] + stack ["--stack-yaml", "stack1.yaml", "build", "acme-missiles"] + stack ["unpack", "acme-missiles-0.3"] + stack ["--stack-yaml", "stack2.yaml", "build"] diff --git a/tests/integration/tests/duplicate-package-ids/files/.gitignore b/tests/integration/tests/duplicate-package-ids/files/.gitignore index f39970f250..2707bad1cb 100644 --- a/tests/integration/tests/duplicate-package-ids/files/.gitignore +++ b/tests/integration/tests/duplicate-package-ids/files/.gitignore @@ -1,2 +1 @@ -stack.yaml -auto-update-0.1.2.1 +acme-missiles-0.3/ diff --git a/tests/integration/tests/duplicate-package-ids/files/mySnapshot.yaml b/tests/integration/tests/duplicate-package-ids/files/mySnapshot.yaml new file mode 100644 index 0000000000..09bb7df5ab --- /dev/null +++ b/tests/integration/tests/duplicate-package-ids/files/mySnapshot.yaml @@ -0,0 +1,6 @@ +name: mySnapshot + +snapshot: ghc-9.10.3 + +packages: +- acme-missiles-0.3 diff --git a/tests/integration/tests/duplicate-package-ids/files/stack1.yaml b/tests/integration/tests/duplicate-package-ids/files/stack1.yaml index bee6b8de03..1412b971c3 100644 --- a/tests/integration/tests/duplicate-package-ids/files/stack1.yaml +++ b/tests/integration/tests/duplicate-package-ids/files/stack1.yaml @@ -1,2 +1,3 @@ -snapshot: lts-24.24 +snapshot: mySnapshot.yaml + packages: [] diff --git a/tests/integration/tests/duplicate-package-ids/files/stack2.yaml b/tests/integration/tests/duplicate-package-ids/files/stack2.yaml index 2cefc6a490..1b7948f75a 100644 --- a/tests/integration/tests/duplicate-package-ids/files/stack2.yaml +++ b/tests/integration/tests/duplicate-package-ids/files/stack2.yaml @@ -1,3 +1,4 @@ -snapshot: lts-24.24 +snapshot: mySnapshot.yaml + packages: -- auto-update-0.1.2.1 +- acme-missiles-0.3 diff --git a/tests/integration/tests/ghc-install-hooks/Main.hs b/tests/integration/tests/ghc-install-hooks/Main.hs index 491eb11761..f4013f1eb3 100644 --- a/tests/integration/tests/ghc-install-hooks/Main.hs +++ b/tests/integration/tests/ghc-install-hooks/Main.hs @@ -1,7 +1,8 @@ -import System.Process (rawSystem) -import Control.Exception (throwIO) -import StackTest -import Control.Monad (unless) +-- | Stack supports GHC installation customisation shell scripts. + +import Control.Exception ( throwIO ) +import StackTest +import System.Process ( rawSystem ) main :: IO () main = rawSystem "sh" ["run.sh"] >>= throwIO diff --git a/tests/integration/tests/ghc-install-hooks/files/foo.hs b/tests/integration/tests/ghc-install-hooks/files/Test.hs similarity index 100% rename from tests/integration/tests/ghc-install-hooks/files/foo.hs rename to tests/integration/tests/ghc-install-hooks/files/Test.hs diff --git a/tests/integration/tests/ghc-install-hooks/files/run.sh b/tests/integration/tests/ghc-install-hooks/files/run.sh index 7fdbe39f94..beaf269b9e 100644 --- a/tests/integration/tests/ghc-install-hooks/files/run.sh +++ b/tests/integration/tests/ghc-install-hooks/files/run.sh @@ -2,7 +2,7 @@ set -exu -stack_bin=$("$STACK_EXE" path --resolver ghc-9.10.3 --compiler-bin) +stack_bin=$("$STACK_EXE" path --snapshot ghc-9.10.3 --compiler-bin) export STACK_ROOT=$(pwd)/fake-root @@ -11,5 +11,5 @@ mkdir -p "${STACK_ROOT}"/hooks echo "echo '${stack_bin}/ghc'" > "${STACK_ROOT}"/hooks/ghc-install.sh chmod +x "${STACK_ROOT}"/hooks/ghc-install.sh -"$STACK_EXE" --no-install-ghc --resolver ghc-9.10.3 ghc -- --info -"$STACK_EXE" --no-install-ghc --resolver ghc-9.10.3 runghc foo.hs +"$STACK_EXE" --no-install-ghc --snapshot ghc-9.10.3 ghc -- --info +"$STACK_EXE" --no-install-ghc --snapshot ghc-9.10.3 runghc Test.hs diff --git a/tests/integration/tests/git-submodules/Main.hs b/tests/integration/tests/git-submodules/Main.hs index 29e6cbf234..196abe7e72 100644 --- a/tests/integration/tests/git-submodules/Main.hs +++ b/tests/integration/tests/git-submodules/Main.hs @@ -1,11 +1,13 @@ -import StackTest -import System.Directory - ( createDirectoryIfMissing, withCurrentDirectory, getCurrentDirectory ) -import System.Exit ( exitFailure ) -import System.FilePath ( () ) -import Data.List ( filter ) -import System.IO ( hPutStrLn, withFile, IOMode (..) ) -import Control.Monad ( when ) +import Control.Monad ( when ) +import Data.List ( filter ) +import StackTest +import System.Directory + ( createDirectoryIfMissing, getCurrentDirectory + , withCurrentDirectory + ) +import System.Exit ( exitFailure ) +import System.FilePath ( () ) +import System.IO ( IOMode (..), hPutStrLn, withFile ) main :: IO () main = when isLinux $ do diff --git a/tests/integration/tests/haddock-options/Main.hs b/tests/integration/tests/haddock-options/Main.hs index 1c65576206..5cf2f7f412 100644 --- a/tests/integration/tests/haddock-options/Main.hs +++ b/tests/integration/tests/haddock-options/Main.hs @@ -4,12 +4,10 @@ import StackTest main :: IO () main = do - removeDirIgnore ".stack-work" - - -- BAR is defined here and FOO in stack.yaml file - stackCheckStderr ["haddock", "--haddock-arguments", "--optghc=-DBAR"] $ \s -> + -- VARIABLE_B is defined here and VARIABLE_A in stack.yaml file + stackCheckStderr ["haddock", "--haddock-arguments", "--optghc=-DVARIABLE_B"] $ \s -> unless (errorMsg `isInfixOf` s) $ - error "FOO and BAR not both defined" + error "VARIABLE_A and VARIABLE_B not both defined" stack ["clean"] -- Works just fine, test #3099 while at it. stack ["haddock", "--no-haddock-hyperlink-source"] @@ -20,5 +18,5 @@ main = do -- The error message differs by operating system errorMsg :: String errorMsg = if isLinux - then "error: #error FOO and BAR is defined" - else "error: FOO and BAR is defined" + then "error: #error VARIABLE_A and VARIABLE_B is defined" + else "error: VARIABLE_A and VARIABLE_B is defined" diff --git a/tests/integration/tests/haddock-options/files/.gitignore b/tests/integration/tests/haddock-options/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/haddock-options/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/haddock-options/files/haddock-options.cabal b/tests/integration/tests/haddock-options/files/haddock-options.cabal deleted file mode 100644 index f47b3df0b4..0000000000 --- a/tests/integration/tests/haddock-options/files/haddock-options.cabal +++ /dev/null @@ -1,10 +0,0 @@ -name: haddock-options -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base - default-language: Haskell2010 diff --git a/tests/integration/tests/haddock-options/files/package.yaml b/tests/integration/tests/haddock-options/files/package.yaml new file mode 100644 index 0000000000..a7305a77cf --- /dev/null +++ b/tests/integration/tests/haddock-options/files/package.yaml @@ -0,0 +1,9 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src diff --git a/tests/integration/tests/haddock-options/files/src/Lib.hs b/tests/integration/tests/haddock-options/files/src/Lib.hs index 2ad999dff9..4683fbf37e 100644 --- a/tests/integration/tests/haddock-options/files/src/Lib.hs +++ b/tests/integration/tests/haddock-options/files/src/Lib.hs @@ -1,11 +1,14 @@ {-# LANGUAGE CPP #-} + module Lib - ( someFunc - ) where + ( someFunc + ) where someFunc :: IO () someFunc = putStrLn "someFunc" -#if defined(FOO) && defined(BAR) -#error FOO and BAR is defined +#if defined(VARIABLE_A) && defined(VARIABLE_B) + +#error VARIABLE_A and VARIABLE_B is defined + #endif diff --git a/tests/integration/tests/haddock-options/files/stack.yaml b/tests/integration/tests/haddock-options/files/stack.yaml index 7461e4e285..69b8c2eeb2 100644 --- a/tests/integration/tests/haddock-options/files/stack.yaml +++ b/tests/integration/tests/haddock-options/files/stack.yaml @@ -1,6 +1,6 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 build: haddock-arguments: haddock-args: - - --optghc=-DFOO + - --optghc=-DVARIABLE_A diff --git a/tests/integration/tests/hpack-repo/Main.hs b/tests/integration/tests/hpack-repo/Main.hs index 9512c6cca4..58ef93df19 100644 --- a/tests/integration/tests/hpack-repo/Main.hs +++ b/tests/integration/tests/hpack-repo/Main.hs @@ -1,7 +1,9 @@ -import StackTest -import System.Directory +-- Stack supports immutable dependency packages that are described only by a +-- package.yaml file. However, this work flow is deprecated. +-- +-- See: https://github.com/commercialhaskell/stack/issues/5210 + +import StackTest main :: IO () -main = do - removeDirIgnore ".stack-work" - stack ["build"] +main = stack ["build"] diff --git a/tests/integration/tests/hpack-repo/files/.gitignore b/tests/integration/tests/hpack-repo/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/hpack-repo/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/hpack-repo/files/files.cabal b/tests/integration/tests/hpack-repo/files/files.cabal deleted file mode 100644 index e167e1ff8c..0000000000 --- a/tests/integration/tests/hpack-repo/files/files.cabal +++ /dev/null @@ -1,10 +0,0 @@ -name: files -version: 0.1.0.0 -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5, validity - default-language: Haskell2010 diff --git a/tests/integration/tests/hpack-repo/files/package.yaml b/tests/integration/tests/hpack-repo/files/package.yaml new file mode 100644 index 0000000000..498b32af5d --- /dev/null +++ b/tests/integration/tests/hpack-repo/files/package.yaml @@ -0,0 +1,10 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base +- validity + +library: + source-dirs: src diff --git a/tests/integration/tests/hpack-repo/files/src/Lib.hs b/tests/integration/tests/hpack-repo/files/src/Lib.hs index 65c2b1b231..0512f4633e 100644 --- a/tests/integration/tests/hpack-repo/files/src/Lib.hs +++ b/tests/integration/tests/hpack-repo/files/src/Lib.hs @@ -1,8 +1,3 @@ -module Lib - ( someFunc - ) where +module Lib where import Data.Validity - -someFunc :: IO () -someFunc = putStrLn "someFunc" diff --git a/tests/integration/tests/hpack-repo/files/stack.yaml b/tests/integration/tests/hpack-repo/files/stack.yaml index c566c6c997..ce50d6afd4 100644 --- a/tests/integration/tests/hpack-repo/files/stack.yaml +++ b/tests/integration/tests/hpack-repo/files/stack.yaml @@ -1,4 +1,6 @@ -snapshot: lts-24.24 +snapshot: lts-24.43 + +# At this commit, the validity package is described only by a package.yaml file extra-deps: - git: https://github.com/NorfairKing/validity.git commit: d128cc30bc886e31ea7f8161fb7708c08b162937 diff --git a/tests/integration/tests/init-omit-packages/Main.hs b/tests/integration/tests/init-omit-packages/Main.hs index 41772717d1..ef232fb00d 100644 --- a/tests/integration/tests/init-omit-packages/Main.hs +++ b/tests/integration/tests/init-omit-packages/Main.hs @@ -1,12 +1,14 @@ -import Control.Monad (unless) -import StackTest -import System.IO (readFile) +-- | Stack's init command provides an --omit-packages flag to avoid the problem +-- of bad project packages. + +import Control.Monad ( unless ) +import StackTest +import System.IO ( readFile ) main :: IO () main = do - removeFileIgnore "stack.yaml" - stackErr ["init", "--snapshot", "lts-24.24"] - stack ["init", "--snapshot", "lts-24.24", "--omit-packages"] + stackErr ["init", "--snapshot", "lts-24.43"] + stack ["init", "--snapshot", "lts-24.43", "--omit-packages"] contents <- lines <$> readFile "stack.yaml" unless ("#- bad" `elem` contents) $ error "commented out 'bad' package was expected" diff --git a/tests/integration/tests/init-omit-packages/files/.gitignore b/tests/integration/tests/init-omit-packages/files/.gitignore index 684dbffa96..74744b2dd6 100644 --- a/tests/integration/tests/init-omit-packages/files/.gitignore +++ b/tests/integration/tests/init-omit-packages/files/.gitignore @@ -1 +1,3 @@ stack.yaml +good.cabal +bad.cabal diff --git a/tests/integration/tests/init-omit-packages/files/bad/bad.cabal b/tests/integration/tests/init-omit-packages/files/bad/bad.cabal deleted file mode 100644 index 789ad7d101..0000000000 --- a/tests/integration/tests/init-omit-packages/files/bad/bad.cabal +++ /dev/null @@ -1,9 +0,0 @@ -name: bad -version: 1.0.0 -build-type: Simple -cabal-version: >= 1.8 - -library - exposed-modules: Bad - build-depends: base, not-existing-package == 666.0 - default-language: Haskell2010 \ No newline at end of file diff --git a/tests/integration/tests/init-omit-packages/files/bad/package.yaml b/tests/integration/tests/init-omit-packages/files/bad/package.yaml new file mode 100644 index 0000000000..0875dcdae1 --- /dev/null +++ b/tests/integration/tests/init-omit-packages/files/bad/package.yaml @@ -0,0 +1,9 @@ +spec-version: 0.36.0 + +name: bad + +dependencies: +- base +- non-existent-package == 666.0 + +library: {} diff --git a/tests/integration/tests/init-omit-packages/files/good/good.cabal b/tests/integration/tests/init-omit-packages/files/good/good.cabal deleted file mode 100644 index 944e5795cf..0000000000 --- a/tests/integration/tests/init-omit-packages/files/good/good.cabal +++ /dev/null @@ -1,9 +0,0 @@ -name: good -version: 1.0.0 -build-type: Simple -cabal-version: >= 1.8 - -library - exposed-modules: Good - build-depends: base - default-language: Haskell2010 \ No newline at end of file diff --git a/tests/integration/tests/init-omit-packages/files/good/package.yaml b/tests/integration/tests/init-omit-packages/files/good/package.yaml new file mode 100644 index 0000000000..9b93276a13 --- /dev/null +++ b/tests/integration/tests/init-omit-packages/files/good/package.yaml @@ -0,0 +1,8 @@ +spec-version: 0.36.0 + +name: good + +dependencies: +- base + +library: {} diff --git a/tests/integration/tests/internal-libraries/Main.hs b/tests/integration/tests/internal-libraries/Main.hs index 1f56f3ca84..c8b3b9c6be 100644 --- a/tests/integration/tests/internal-libraries/Main.hs +++ b/tests/integration/tests/internal-libraries/Main.hs @@ -1,20 +1,7 @@ -import StackTest -import Control.Monad ( unless ) +-- | Stack supports private named libraries (internal libraries) and foreign +-- libraries. + +import StackTest --- This does not work on Windows with snapshot: ghc-9.8.4 (Cabal-3.10.3.0). It --- fails witb: --- --- Preprocessing foreign library 'baz' for files-0.1.0.0.. --- Building foreign library 'baz' for files-0.1.0.0.. --- [1 of 1] Compiling Baz --- [1 of 2] Compiling Baz [Flags changed] --- [2 of 2] Linking .stack-work\dist\eebe39f7\build\baz\baz.dll --- lld: error: unknown argument: -rpath --- lld: error: unknown argument: -rpath --- clang: error: linker command failed with exit code 1 (use -v to see invocation) --- ghc-9.8.4.exe: `clang.exe' failed in phase `Linker'. (Exit code: 1) --- --- The above is a regression from snapshot: ghc-9.6.4 (Cabal-3.10.1.0). See --- https://github.com/haskell/cabal/issues/9982. main :: IO () -main = unless isWindows $ stack ["build"] +main = stack ["build"] diff --git a/tests/integration/tests/internal-libraries/files/.gitignore b/tests/integration/tests/internal-libraries/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/internal-libraries/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/internal-libraries/files/Setup.hs b/tests/integration/tests/internal-libraries/files/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/internal-libraries/files/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/internal-libraries/files/app/Main.hs b/tests/integration/tests/internal-libraries/files/app/Main.hs new file mode 100644 index 0000000000..89ad4b3e08 --- /dev/null +++ b/tests/integration/tests/internal-libraries/files/app/Main.hs @@ -0,0 +1,4 @@ +module Main where + +main :: IO () +main = pure () diff --git a/tests/integration/tests/internal-libraries/files/files.cabal b/tests/integration/tests/internal-libraries/files/files.cabal deleted file mode 100644 index 30b6c571ce..0000000000 --- a/tests/integration/tests/internal-libraries/files/files.cabal +++ /dev/null @@ -1,31 +0,0 @@ -name: files -version: 0.1.0.0 -build-type: Simple -cabal-version: 2.0 - -library - hs-source-dirs: src - exposed-modules: Files - build-depends: base - default-language: Haskell2010 - -library foo - hs-source-dirs: src-foo - exposed-modules: Foo - build-depends: base, files, stm - default-language: Haskell2010 - -executable bar - hs-source-dirs: src-bar - main-is: Main.hs - build-depends: base, files, foo - default-language: Haskell2010 - -foreign-library baz - type: native-shared - other-modules: Baz - build-depends: base, files, foo, mtl - hs-source-dirs: src-baz - default-language: Haskell2010 - if os(Windows) - options: standalone diff --git a/tests/integration/tests/internal-libraries/files/int/Internal.hs b/tests/integration/tests/internal-libraries/files/int/Internal.hs new file mode 100644 index 0000000000..d066bb085e --- /dev/null +++ b/tests/integration/tests/internal-libraries/files/int/Internal.hs @@ -0,0 +1 @@ +module Internal where diff --git a/tests/integration/tests/internal-libraries/files/package.yaml b/tests/integration/tests/internal-libraries/files/package.yaml new file mode 100644 index 0000000000..f991171fd9 --- /dev/null +++ b/tests/integration/tests/internal-libraries/files/package.yaml @@ -0,0 +1,40 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src + +internal-libraries: + internal: + source-dirs: int + dependencies: + - myPackage + - stm + +executables: + myExe: + source-dirs: app + main: Main.hs + dependencies: + - internal + - myPackage + +verbatim: | + foreign-library foreign + type: native-shared + other-modules: + Foreign + build-depends: + base + , myPackage + , internal + , mtl + hs-source-dirs: + src-foreign + default-language: Haskell2010 + if os(Windows) + options: standalone diff --git a/tests/integration/tests/internal-libraries/files/src-bar/Main.hs b/tests/integration/tests/internal-libraries/files/src-bar/Main.hs deleted file mode 100644 index cc7e42ba70..0000000000 --- a/tests/integration/tests/internal-libraries/files/src-bar/Main.hs +++ /dev/null @@ -1,11 +0,0 @@ -module Main where - -import Files -import Foo - -main :: IO () -main = do - putStrLn "files:" - print files - putStrLn "foo" - foo >>= print diff --git a/tests/integration/tests/internal-libraries/files/src-baz/Baz.hs b/tests/integration/tests/internal-libraries/files/src-baz/Baz.hs deleted file mode 100644 index 7e4e962ff3..0000000000 --- a/tests/integration/tests/internal-libraries/files/src-baz/Baz.hs +++ /dev/null @@ -1,12 +0,0 @@ -module Baz where - -import Files -import Foo -import Control.Monad.Reader - -baz :: IO () -baz = flip runReaderT () $ lift $ do - putStrLn "files:" - print files - putStrLn "foo" - foo >>= print diff --git a/tests/integration/tests/internal-libraries/files/src-foo/Foo.hs b/tests/integration/tests/internal-libraries/files/src-foo/Foo.hs deleted file mode 100644 index fba29d124c..0000000000 --- a/tests/integration/tests/internal-libraries/files/src-foo/Foo.hs +++ /dev/null @@ -1,7 +0,0 @@ -module Foo where - -import Control.Monad.STM -import Files - -foo :: IO String -foo = atomically $ pure $ "foo using " ++ files diff --git a/tests/integration/tests/internal-libraries/files/src-foreign/Foreign.hs b/tests/integration/tests/internal-libraries/files/src-foreign/Foreign.hs new file mode 100644 index 0000000000..8c00a37599 --- /dev/null +++ b/tests/integration/tests/internal-libraries/files/src-foreign/Foreign.hs @@ -0,0 +1 @@ +module Foreign where diff --git a/tests/integration/tests/internal-libraries/files/src/Files.hs b/tests/integration/tests/internal-libraries/files/src/Files.hs deleted file mode 100644 index b9c9eeac03..0000000000 --- a/tests/integration/tests/internal-libraries/files/src/Files.hs +++ /dev/null @@ -1,4 +0,0 @@ -module Files where - -files :: String -files = "files" diff --git a/tests/integration/tests/internal-libraries/files/src/Lib.hs b/tests/integration/tests/internal-libraries/files/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/internal-libraries/files/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/lock-files/Main.hs b/tests/integration/tests/lock-files/Main.hs index 8f7c89700f..84131e34f0 100644 --- a/tests/integration/tests/lock-files/Main.hs +++ b/tests/integration/tests/lock-files/Main.hs @@ -1,17 +1,16 @@ -import Control.Monad (unless, when) -import Data.List (isInfixOf) -import StackTest -import System.Directory +-- | Stack creates lock files. + +import Control.Monad ( unless, when ) +import Data.List ( isInfixOf ) +import StackTest main :: IO () main = do - copyFile "stack-2-extras" "stack.yaml" - stack ["build"] - lock1 <- readFile "stack.yaml.lock" - unless ("acme-dont" `isInfixOf` lock1) $ - error "Package acme-dont wasn't found in Stack lock file" - copyFile "stack-1-extra" "stack.yaml" - stack ["build"] - lock2 <- readFile "stack.yaml.lock" - when ("acme-dont" `isInfixOf` lock2) $ - error "Package acme-dont shouldn't be in Stack lock file anymore" + stack ["--stack-yaml", "stack1.yaml", "build"] + lock1 <- readFile "stack1.yaml.lock" + unless ("acme-box" `isInfixOf` lock1) $ + error "Package acme-box wasn't found in Stack lock file" + stack ["--stack-yaml", "stack2.yaml", "build"] + lock2 <- readFile "stack2.yaml.lock" + when ("acme-box" `isInfixOf` lock2) $ + error "Package acme-box shouldn't be in Stack lock file anymore" diff --git a/tests/integration/tests/lock-files/files/.gitignore b/tests/integration/tests/lock-files/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/lock-files/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/lock-files/files/Lib.hs b/tests/integration/tests/lock-files/files/Lib.hs deleted file mode 100644 index a3b82e6e83..0000000000 --- a/tests/integration/tests/lock-files/files/Lib.hs +++ /dev/null @@ -1,2 +0,0 @@ -foo :: Int -foo = 42 diff --git a/tests/integration/tests/lock-files/files/package.yaml b/tests/integration/tests/lock-files/files/package.yaml index 36e02ec5e7..a7305a77cf 100644 --- a/tests/integration/tests/lock-files/files/package.yaml +++ b/tests/integration/tests/lock-files/files/package.yaml @@ -1,4 +1,9 @@ -name: example +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + library: - dependencies: - - base + source-dirs: src diff --git a/tests/integration/tests/lock-files/files/src/Lib.hs b/tests/integration/tests/lock-files/files/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/lock-files/files/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/lock-files/files/stack-1-extra b/tests/integration/tests/lock-files/files/stack-1-extra deleted file mode 100644 index f2c7953baf..0000000000 --- a/tests/integration/tests/lock-files/files/stack-1-extra +++ /dev/null @@ -1,3 +0,0 @@ -resolver: lts-24.24 -extra-deps: -- acme-cuteboy-0.1.0.0 diff --git a/tests/integration/tests/lock-files/files/stack-2-extras b/tests/integration/tests/lock-files/files/stack-2-extras deleted file mode 100644 index 4d71871e66..0000000000 --- a/tests/integration/tests/lock-files/files/stack-2-extras +++ /dev/null @@ -1,4 +0,0 @@ -resolver: lts-24.24 -extra-deps: -- acme-cuteboy-0.1.0.0 -- acme-dont-1.1 diff --git a/tests/integration/tests/lock-files/files/stack1.yaml b/tests/integration/tests/lock-files/files/stack1.yaml new file mode 100644 index 0000000000..e317b1aefe --- /dev/null +++ b/tests/integration/tests/lock-files/files/stack1.yaml @@ -0,0 +1,5 @@ +snapshot: ghc-9.10.3 + +extra-deps: +- acme-missiles-0.3 +- acme-box-0.0.0.0 diff --git a/tests/integration/tests/lock-files/files/stack2.yaml b/tests/integration/tests/lock-files/files/stack2.yaml new file mode 100644 index 0000000000..37425098dd --- /dev/null +++ b/tests/integration/tests/lock-files/files/stack2.yaml @@ -0,0 +1,4 @@ +snapshot: ghc-9.10.3 + +extra-deps: +- acme-missiles-0.3 diff --git a/tests/integration/tests/module-added-multiple-times/Main.hs b/tests/integration/tests/module-added-multiple-times/Main.hs index 73cfee36f5..095b1af3fb 100644 --- a/tests/integration/tests/module-added-multiple-times/Main.hs +++ b/tests/integration/tests/module-added-multiple-times/Main.hs @@ -1,12 +1,14 @@ -import Control.Monad -import StackTest.Repl +-- | Stack can load a package into GHC's repl. + +import Control.Monad ( when ) +import StackTest.Repl main :: IO () main = stackRepl [] $ do nextPrompt replCommand ":main" line <- replGetLine - let expected = "Hello World!" + let expected = "OK" when (line /= expected) $ error $ "Main module didn't load correctly.\n" diff --git a/tests/integration/tests/module-added-multiple-times/files/.gitignore b/tests/integration/tests/module-added-multiple-times/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/module-added-multiple-times/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/module-added-multiple-times/files/LICENSE b/tests/integration/tests/module-added-multiple-times/files/LICENSE deleted file mode 100644 index d05408d876..0000000000 --- a/tests/integration/tests/module-added-multiple-times/files/LICENSE +++ /dev/null @@ -1,30 +0,0 @@ -Copyright (c) 2000 - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Your name here nor the names of other - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tests/integration/tests/module-added-multiple-times/files/Setup.hs b/tests/integration/tests/module-added-multiple-times/files/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/module-added-multiple-times/files/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/module-added-multiple-times/files/app/Main.hs b/tests/integration/tests/module-added-multiple-times/files/app/Main.hs new file mode 100644 index 0000000000..d09b7c23cd --- /dev/null +++ b/tests/integration/tests/module-added-multiple-times/files/app/Main.hs @@ -0,0 +1,6 @@ +module Main where + +import Lib.Lib ( func ) + +main :: IO () +main = putStrLn func diff --git a/tests/integration/tests/module-added-multiple-times/files/exe/Main.hs b/tests/integration/tests/module-added-multiple-times/files/exe/Main.hs deleted file mode 100644 index 504eb17dda..0000000000 --- a/tests/integration/tests/module-added-multiple-times/files/exe/Main.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Main where - -import Lib.A - -main :: IO () -main = putStrLn messageA diff --git a/tests/integration/tests/module-added-multiple-times/files/package.yaml b/tests/integration/tests/module-added-multiple-times/files/package.yaml new file mode 100644 index 0000000000..bea19d444e --- /dev/null +++ b/tests/integration/tests/module-added-multiple-times/files/package.yaml @@ -0,0 +1,16 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src + +executables: + myExe: + source-dirs: app + main: Main.hs + dependencies: + - myPackage diff --git a/tests/integration/tests/module-added-multiple-times/files/project-a.cabal b/tests/integration/tests/module-added-multiple-times/files/project-a.cabal deleted file mode 100644 index 4e230ef90b..0000000000 --- a/tests/integration/tests/module-added-multiple-times/files/project-a.cabal +++ /dev/null @@ -1,33 +0,0 @@ -name: project-a -version: 0.1.0.0 -synopsis: Simple project template from stack -description: Please see README.md -homepage: http://github.com/githubuser/project-a#readme -license: MIT -license-file: LICENSE -author: Author name here -maintainer: example@example.com -copyright: 2010 Author Here -category: Web -build-type: Simple -cabal-version: >=1.10 - -library - hs-source-dirs: src - default-language: Haskell2010 - - exposed-modules: Lib.A - - build-depends: base - - -executable project-a-exe - main-is: Main.hs - hs-source-dirs: exe - default-language: Haskell2010 - - ghc-options: -rtsopts - - build-depends: base - - , project-a \ No newline at end of file diff --git a/tests/integration/tests/module-added-multiple-times/files/src/Lib/A.hs b/tests/integration/tests/module-added-multiple-times/files/src/Lib/A.hs deleted file mode 100644 index 788d4e22d5..0000000000 --- a/tests/integration/tests/module-added-multiple-times/files/src/Lib/A.hs +++ /dev/null @@ -1,4 +0,0 @@ -module Lib.A where - -messageA :: String -messageA = "Hello World!" diff --git a/tests/integration/tests/module-added-multiple-times/files/src/Lib/Lib.hs b/tests/integration/tests/module-added-multiple-times/files/src/Lib/Lib.hs new file mode 100644 index 0000000000..3c09853b27 --- /dev/null +++ b/tests/integration/tests/module-added-multiple-times/files/src/Lib/Lib.hs @@ -0,0 +1,6 @@ +module Lib.Lib + ( func + ) where + +func :: String +func = "OK" diff --git a/tests/integration/tests/module-added-multiple-times/files/stack.yaml b/tests/integration/tests/module-added-multiple-times/files/stack.yaml index b54fd809bf..e674eab75a 100644 --- a/tests/integration/tests/module-added-multiple-times/files/stack.yaml +++ b/tests/integration/tests/module-added-multiple-times/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: ghc-9.10.3 diff --git a/tests/integration/tests/multi-test/Main.hs b/tests/integration/tests/multi-test/Main.hs deleted file mode 100644 index 56f21042ea..0000000000 --- a/tests/integration/tests/multi-test/Main.hs +++ /dev/null @@ -1,17 +0,0 @@ -import Control.Monad (unless) -import Data.List (isInfixOf) -import StackTest - -main :: IO () -main = do - -- FIXME: Make 'clean' unnecessary (see #1411) - stack ["clean"] - stackCheckStderr ["test", "--coverage"] $ \out -> do - unless ("The coverage report for multi-test-suite's test-suite multi-test-suite-test is available at" `isInfixOf` out) $ - fail "Didn't get expected report for multi-test-suite-test" - unless ("[S-6829]" `isInfixOf` out) $ - fail "Didn't get expected empty report for multi-test-suite-test-2" - -- Test then build works too. - stack ["clean"] - stack ["test"] - stack ["build"] diff --git a/tests/integration/tests/multi-test/files/LICENSE b/tests/integration/tests/multi-test/files/LICENSE deleted file mode 100644 index d05408d876..0000000000 --- a/tests/integration/tests/multi-test/files/LICENSE +++ /dev/null @@ -1,30 +0,0 @@ -Copyright (c) 2000 - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Your name here nor the names of other - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tests/integration/tests/multi-test/files/Setup.hs b/tests/integration/tests/multi-test/files/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/multi-test/files/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/multi-test/files/cyclic/Cyclic.hs b/tests/integration/tests/multi-test/files/cyclic/Cyclic.hs deleted file mode 100644 index 57c0764899..0000000000 --- a/tests/integration/tests/multi-test/files/cyclic/Cyclic.hs +++ /dev/null @@ -1,4 +0,0 @@ -module Cyclic where - -cyclic :: String -cyclic = "Hello from cyclic" diff --git a/tests/integration/tests/multi-test/files/cyclic/LICENSE b/tests/integration/tests/multi-test/files/cyclic/LICENSE deleted file mode 100644 index d05408d876..0000000000 --- a/tests/integration/tests/multi-test/files/cyclic/LICENSE +++ /dev/null @@ -1,30 +0,0 @@ -Copyright (c) 2000 - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Your name here nor the names of other - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tests/integration/tests/multi-test/files/cyclic/Setup.hs b/tests/integration/tests/multi-test/files/cyclic/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/multi-test/files/cyclic/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/multi-test/files/cyclic/Spec.hs b/tests/integration/tests/multi-test/files/cyclic/Spec.hs deleted file mode 100644 index 2a7e6b6085..0000000000 --- a/tests/integration/tests/multi-test/files/cyclic/Spec.hs +++ /dev/null @@ -1,4 +0,0 @@ -import Lib (cyclicOutput) - -main :: IO () -main = cyclicOutput diff --git a/tests/integration/tests/multi-test/files/cyclic/cyclic.cabal b/tests/integration/tests/multi-test/files/cyclic/cyclic.cabal deleted file mode 100644 index 4faef11041..0000000000 --- a/tests/integration/tests/multi-test/files/cyclic/cyclic.cabal +++ /dev/null @@ -1,33 +0,0 @@ --- Initial cyclic.cabal generated by cabal init. For further --- documentation, see http://haskell.org/cabal/users-guide/ - -name: cyclic -version: 0.1.0.0 --- synopsis: --- description: --- license: -license-file: LICENSE -author: Michael Sloan -maintainer: mgsloan@gmail.com --- copyright: --- category: -build-type: Simple --- extra-source-files: -cabal-version: >=1.10 - -library - exposed-modules: Cyclic - -- other-modules: - -- other-extensions: - build-depends: base >=4.8 && <5.0 - -- hs-source-dirs: - default-language: Haskell2010 - -test-suite cyclic-test-suite - type: exitcode-stdio-1.0 - main-is: Spec.hs - build-depends: base - -- This is cyclic because multi-test-suite depends on this package. - , multi-test-suite - ghc-options: -threaded -rtsopts -with-rtsopts=-N - default-language: Haskell2010 diff --git a/tests/integration/tests/multi-test/files/multi-test-suite.cabal b/tests/integration/tests/multi-test/files/multi-test-suite.cabal deleted file mode 100644 index deb33d3572..0000000000 --- a/tests/integration/tests/multi-test/files/multi-test-suite.cabal +++ /dev/null @@ -1,58 +0,0 @@ -name: multi-test-suite -version: 0.1.0.0 -synopsis: Initial project template from stack -description: Please see README.md -homepage: http://github.com/commercialhaskell/multi-test-suite#readme -license: BSD3 -license-file: LICENSE -author: Your name here -maintainer: your.address@example.com --- copyright: -category: Web -build-type: Simple --- extra-source-files: -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5, cyclic - default-language: Haskell2010 - -executable multi-test-suite-exe - hs-source-dirs: app - main-is: Main.hs - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: base - , multi-test-suite - default-language: Haskell2010 - -test-suite multi-test-suite-test - type: exitcode-stdio-1.0 - hs-source-dirs: test - main-is: Spec.hs - build-depends: base - , multi-test-suite - ghc-options: -threaded -rtsopts -with-rtsopts=-N - default-language: Haskell2010 - -test-suite multi-test-suite-test-2 - type: exitcode-stdio-1.0 - hs-source-dirs: test-2 - main-is: Spec.hs - build-depends: base - , multi-test-suite - ghc-options: -threaded -rtsopts -with-rtsopts=-N - default-language: Haskell2010 - -test-suite multi-test-suite-test-3 - type: exitcode-stdio-1.0 - hs-source-dirs: test-3 - main-is: Spec.hs - build-depends: base - ghc-options: -threaded -rtsopts -with-rtsopts=-N - default-language: Haskell2010 - -source-repository head - type: git - location: https://github.com/commercialhaskell/multi-test-suite diff --git a/tests/integration/tests/multi-test/files/src/Lib.hs b/tests/integration/tests/multi-test/files/src/Lib.hs deleted file mode 100644 index dc9643b828..0000000000 --- a/tests/integration/tests/multi-test/files/src/Lib.hs +++ /dev/null @@ -1,16 +0,0 @@ -module Lib - ( someFunc - , someOtherFunc - , cyclicOutput - ) where - -import Cyclic - -someFunc :: IO () -someFunc = putStrLn "someFunc" - -someOtherFunc :: IO () -someOtherFunc = putStrLn "someOtherFunc" - -cyclicOutput :: IO () -cyclicOutput = putStrLn cyclic diff --git a/tests/integration/tests/multi-test/files/stack.yaml b/tests/integration/tests/multi-test/files/stack.yaml deleted file mode 100644 index 4628a20c03..0000000000 --- a/tests/integration/tests/multi-test/files/stack.yaml +++ /dev/null @@ -1,5 +0,0 @@ -snapshot: lts-24.24 -packages: -- . -- sub-package -- cyclic diff --git a/tests/integration/tests/multi-test/files/sub-package/src/Lib2.hs b/tests/integration/tests/multi-test/files/sub-package/src/Lib2.hs deleted file mode 100644 index 92ce236d56..0000000000 --- a/tests/integration/tests/multi-test/files/sub-package/src/Lib2.hs +++ /dev/null @@ -1,4 +0,0 @@ -module Lib2 where - -lib2 :: IO () -lib2 = putStrLn "lib2" diff --git a/tests/integration/tests/multi-test/files/sub-package/src/main.hs b/tests/integration/tests/multi-test/files/sub-package/src/main.hs deleted file mode 100644 index e84bf058a8..0000000000 --- a/tests/integration/tests/multi-test/files/sub-package/src/main.hs +++ /dev/null @@ -1,3 +0,0 @@ -import Lib2 - -main = lib2 diff --git a/tests/integration/tests/multi-test/files/sub-package/sub-package.cabal b/tests/integration/tests/multi-test/files/sub-package/sub-package.cabal deleted file mode 100644 index 0e94272961..0000000000 --- a/tests/integration/tests/multi-test/files/sub-package/sub-package.cabal +++ /dev/null @@ -1,31 +0,0 @@ -name: sub-package -version: 0.1.0.0 -synopsis: Initial project template from stack -description: Please see README.md -homepage: http://github.com/commercialhaskell/multi-test-suite#readme -license: BSD3 -license-file: ../LICENSE -author: Your name here -maintainer: your.address@example.com --- copyright: -category: Web -build-type: Simple --- extra-source-files: -cabal-version: >=1.10 - -executable sub-package-exe - hs-source-dirs: src - main-is: main.hs - other-modules: Lib2 - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 - -test-suite sub-package-test - type: exitcode-stdio-1.0 - hs-source-dirs: src, test - main-is: Spec.hs - other-modules: Lib2 - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: base - , multi-test-suite - default-language: Haskell2010 diff --git a/tests/integration/tests/multi-test/files/sub-package/test/Spec.hs b/tests/integration/tests/multi-test/files/sub-package/test/Spec.hs deleted file mode 100644 index 87852a7dec..0000000000 --- a/tests/integration/tests/multi-test/files/sub-package/test/Spec.hs +++ /dev/null @@ -1,7 +0,0 @@ -import Lib -import Lib2 - -main :: IO () -main = do - someOtherFunc - lib2 diff --git a/tests/integration/tests/multi-test/files/test/OtherModule.hs b/tests/integration/tests/multi-test/files/test/OtherModule.hs deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/integration/tests/multi-test/files/test/Spec.hs b/tests/integration/tests/multi-test/files/test/Spec.hs deleted file mode 100644 index 7153edaf67..0000000000 --- a/tests/integration/tests/multi-test/files/test/Spec.hs +++ /dev/null @@ -1,4 +0,0 @@ -import Lib - -main :: IO () -main = someFunc diff --git a/tests/integration/tests/mutable-deps/Main.hs b/tests/integration/tests/mutable-deps/Main.hs index 72fd0e9ab2..2106578801 100644 --- a/tests/integration/tests/mutable-deps/Main.hs +++ b/tests/integration/tests/mutable-deps/Main.hs @@ -1,6 +1,6 @@ -import Control.Monad (forM_, unless, when) -import Data.List (isInfixOf, stripPrefix) -import StackTest +import Control.Monad ( forM_, unless, when ) +import Data.List ( isInfixOf, stripPrefix ) +import StackTest -- The package 'files' depends directly on filemanip, which depends directly on -- packages directory, filepath and unix-compat. Package directory also depends @@ -12,22 +12,22 @@ import StackTest main :: IO () main = unless isWindows $ do -- dependency issues on Windows - let isBuild package line = - case stripPrefix package line of - Just x -> "> build" `isInfixOf` line - Nothing -> False - expectRecompilation pkgs stderr = forM_ pkgs $ \p -> - unless (any (isBuild p) $ lines stderr) $ - error $ "package " ++ show p ++ " recompilation was expected" - expectNoRecompilation pkgs stderr = forM_ pkgs $ \p -> - when (any (isBuild p) $ lines stderr) $ - error $ "package " ++ show p ++ " recompilation was not expected" - mutablePackages = [ "filepath" - , "directory" - , "filemanip" - , "files" - ] - stackCheckStderr ["build"] $ expectRecompilation mutablePackages - stackCheckStderr ["build" , "--profile"] $ expectRecompilation mutablePackages - stackCheckStderr ["build"] $ expectNoRecompilation mutablePackages - stackCheckStderr ["build" , "--profile"] $ expectNoRecompilation mutablePackages + let isBuild package line = + case stripPrefix package line of + Just x -> "> build" `isInfixOf` line + Nothing -> False + expectRecompilation pkgs stderr = forM_ pkgs $ \p -> + unless (any (isBuild p) $ lines stderr) $ + error $ "package " ++ show p ++ " recompilation was expected" + expectNoRecompilation pkgs stderr = forM_ pkgs $ \p -> + when (any (isBuild p) $ lines stderr) $ + error $ "package " ++ show p ++ " recompilation was not expected" + mutablePackages = [ "filepath" + , "directory" + , "filemanip" + , "myPackage" + ] + stackCheckStderr ["build"] $ expectRecompilation mutablePackages + stackCheckStderr ["build" , "--profile"] $ expectRecompilation mutablePackages + stackCheckStderr ["build"] $ expectNoRecompilation mutablePackages + stackCheckStderr ["build" , "--profile"] $ expectNoRecompilation mutablePackages diff --git a/tests/integration/tests/mutable-deps/files/.gitignore b/tests/integration/tests/mutable-deps/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/mutable-deps/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/mutable-deps/files/app/Main.hs b/tests/integration/tests/mutable-deps/files/app/Main.hs index 5e18155cea..ecf5062557 100644 --- a/tests/integration/tests/mutable-deps/files/app/Main.hs +++ b/tests/integration/tests/mutable-deps/files/app/Main.hs @@ -1,6 +1,6 @@ module Main where -import Files +import Lib main = do cFiles <- allCFiles diff --git a/tests/integration/tests/mutable-deps/files/files.cabal b/tests/integration/tests/mutable-deps/files/files.cabal deleted file mode 100644 index f269fecb00..0000000000 --- a/tests/integration/tests/mutable-deps/files/files.cabal +++ /dev/null @@ -1,23 +0,0 @@ -cabal-version: 3.8 - -name: files -version: 1.0.0 -build-type: Simple - -library - hs-source-dirs: - src - exposed-modules: - Files - build-depends: - base - , filemanip - -executable test-exe - hs-source-dirs: - app - main-is: - Main.hs - build-depends: - base - , files diff --git a/tests/integration/tests/mutable-deps/files/package.yaml b/tests/integration/tests/mutable-deps/files/package.yaml new file mode 100644 index 0000000000..79d39d13fa --- /dev/null +++ b/tests/integration/tests/mutable-deps/files/package.yaml @@ -0,0 +1,18 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src + dependencies: + - filemanip + +executables: + myExe: + source-dirs: app + main: Main.hs + dependencies: + - myPackage diff --git a/tests/integration/tests/mutable-deps/files/src/Files.hs b/tests/integration/tests/mutable-deps/files/src/Lib.hs similarity index 82% rename from tests/integration/tests/mutable-deps/files/src/Files.hs rename to tests/integration/tests/mutable-deps/files/src/Lib.hs index 5e3452f0b5..77d29f1945 100644 --- a/tests/integration/tests/mutable-deps/files/src/Files.hs +++ b/tests/integration/tests/mutable-deps/files/src/Lib.hs @@ -1,4 +1,4 @@ -module Files where +module Lib where import System.FilePath.Glob diff --git a/tests/integration/tests/mutable-deps/files/stack.yaml b/tests/integration/tests/mutable-deps/files/stack.yaml index 96615000ff..461c9c454c 100644 --- a/tests/integration/tests/mutable-deps/files/stack.yaml +++ b/tests/integration/tests/mutable-deps/files/stack.yaml @@ -1,4 +1,5 @@ -snapshot: lts-24.24 +snapshot: lts-24.43 + extra-deps: - ./filepath-1.5.4.0 # Required, otherwise Stack reports that GHC boot library has been pruned. diff --git a/tests/integration/tests/nice-resolver-names/Main.hs b/tests/integration/tests/nice-resolver-names/Main.hs index 3e472300a1..cd87ad3af7 100644 --- a/tests/integration/tests/nice-resolver-names/Main.hs +++ b/tests/integration/tests/nice-resolver-names/Main.hs @@ -1,14 +1,18 @@ +-- | Stack's init command uses a convenience synonym for the snapshot in the +-- project-level configuration file, if that is what was specified at the +-- command line. + {-# LANGUAGE OverloadedStrings #-} -import StackTest -import Control.Exception (throwIO) -import Data.Maybe (mapMaybe) -import Data.Foldable (for_) -import Data.List (stripPrefix) +import Control.Exception ( throwIO ) +import Data.Maybe ( mapMaybe ) +import Data.Foldable ( for_ ) +import Data.List ( stripPrefix ) +import StackTest main :: IO () main = do - for_ ["lts-20.26", "lts-24.24"] $ \snapshot -> do + for_ ["lts-20.26", "lts-24.43"] $ \snapshot -> do stack ["init", "--force", "--snapshot", snapshot] str <- readFile "stack.yaml" case mapMaybe (stripPrefix "snapshot: ") $ lines str of diff --git a/tests/integration/tests/nice-resolver-names/files/.gitignore b/tests/integration/tests/nice-resolver-names/files/.gitignore index 66f418505d..82bb5452c4 100644 --- a/tests/integration/tests/nice-resolver-names/files/.gitignore +++ b/tests/integration/tests/nice-resolver-names/files/.gitignore @@ -1,2 +1,2 @@ +myPackage.cabal stack.yaml -unimportant.cabal diff --git a/tests/integration/tests/nice-resolver-names/files/package.yaml b/tests/integration/tests/nice-resolver-names/files/package.yaml index 4b60802c43..7e155848c9 100644 --- a/tests/integration/tests/nice-resolver-names/files/package.yaml +++ b/tests/integration/tests/nice-resolver-names/files/package.yaml @@ -1,3 +1,5 @@ -name: unimportant -version: 0 +spec-version: 0.36.0 + +name: myPackage + library: {} diff --git a/tests/integration/tests/no-rerun-tests/Main.hs b/tests/integration/tests/no-rerun-tests/Main.hs deleted file mode 100644 index 39d125ad1a..0000000000 --- a/tests/integration/tests/no-rerun-tests/Main.hs +++ /dev/null @@ -1,13 +0,0 @@ -import StackTest -import System.Directory -import Control.Monad - -main :: IO () -main = do - stack ["test"] - exists1 <- doesFileExist "foo" - unless exists1 $ error "exists1 should be True" - removeFile "foo" - stack ["test", "--no-rerun-tests"] - exists2 <- doesFileExist "foo" - when exists2 $ error "exists2 should be False" diff --git a/tests/integration/tests/no-rerun-tests/files/.gitignore b/tests/integration/tests/no-rerun-tests/files/.gitignore deleted file mode 100644 index 04c6af385a..0000000000 --- a/tests/integration/tests/no-rerun-tests/files/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.stack-work/ -files.cabal -*~ -foo diff --git a/tests/integration/tests/no-rerun-tests/files/package.yaml b/tests/integration/tests/no-rerun-tests/files/package.yaml deleted file mode 100644 index dcebf6d755..0000000000 --- a/tests/integration/tests/no-rerun-tests/files/package.yaml +++ /dev/null @@ -1,12 +0,0 @@ -name: files - -dependencies: -- base >= 4.7 && < 5 - -library: - source-dirs: src - -tests: - test: - main: Spec.hs - source-dirs: test diff --git a/tests/integration/tests/no-rerun-tests/files/test/Spec.hs b/tests/integration/tests/no-rerun-tests/files/test/Spec.hs deleted file mode 100644 index d030d26e0c..0000000000 --- a/tests/integration/tests/no-rerun-tests/files/test/Spec.hs +++ /dev/null @@ -1,2 +0,0 @@ -main :: IO () -main = writeFile "foo" "" diff --git a/tests/integration/tests/override-compiler/Main.hs b/tests/integration/tests/override-compiler/Main.hs index 961973e199..d7196f4e9c 100644 --- a/tests/integration/tests/override-compiler/Main.hs +++ b/tests/integration/tests/override-compiler/Main.hs @@ -1,7 +1,10 @@ -import StackTest -import Control.Monad (unless) +-- | Stack can override the compiler specified in a snapshot. + +import Control.Monad ( unless ) +import StackTest main :: IO () main = stackCheckStdout ["exec", "--", "ghc", "--numeric-version"] $ \ver -> -- get rid of the newline character - unless (concat (lines ver) == "9.10.3") $ error $ "Invalid version: " ++ show ver + unless (concat (lines ver) == "9.10.3") $ + error $ "Invalid version: " ++ show ver diff --git a/tests/integration/tests/proper-rebuilds/Main.hs b/tests/integration/tests/proper-rebuilds/Main.hs index 643f575e9a..4a12aac853 100644 --- a/tests/integration/tests/proper-rebuilds/Main.hs +++ b/tests/integration/tests/proper-rebuilds/Main.hs @@ -1,21 +1,24 @@ -import Control.Monad (unless, when) -import Data.List (isInfixOf) -import StackTest -import System.Directory +-- | Stack rebuilds an executable if profiling is enabled or disabled or if the +-- library on which it depends changes. + +import Control.Monad ( unless, when ) +import Data.List ( isInfixOf ) +import StackTest +import System.Directory ( copyFile ) main :: IO () main = do - let expectRecompilation stderr = - unless ("> build" `isInfixOf` stderr) $ + let expectRecompilation stderr = + unless ("> build" `isInfixOf` stderr) $ error "package recompilation was expected" - expectNoRecompilation stderr = - when ("> build" `isInfixOf` stderr) $ + expectNoRecompilation stderr = + when ("> build" `isInfixOf` stderr) $ error "package recompilation was not expected" - copyFile "src/Lib.hs.v1" "src/Lib.hs" - stackCheckStderr ["build"] expectRecompilation - stackCheckStderr ["build" , "--profile"] expectRecompilation - stackCheckStderr ["build" , "--profile"] expectNoRecompilation - -- changing source file to trigger recompilation - copyFile "src/Lib.hs.v2" "src/Lib.hs" - stackCheckStderr ["build" , "--profile"] expectRecompilation - stackCheckStderr ["build"] expectRecompilation + copyFile "src/Lib.v1" "src/Lib.hs" + stackCheckStderr ["build"] expectRecompilation + stackCheckStderr ["build" , "--profile"] expectRecompilation + stackCheckStderr ["build" , "--profile"] expectNoRecompilation + -- changing source file to trigger recompilation + copyFile "src/Lib.v2" "src/Lib.hs" + stackCheckStderr ["build" , "--profile"] expectRecompilation + stackCheckStderr ["build"] expectRecompilation diff --git a/tests/integration/tests/proper-rebuilds/files/.gitignore b/tests/integration/tests/proper-rebuilds/files/.gitignore index 25dffca60e..b0a5a052a1 100644 --- a/tests/integration/tests/proper-rebuilds/files/.gitignore +++ b/tests/integration/tests/proper-rebuilds/files/.gitignore @@ -1 +1 @@ -src/Lib.hs +myPackage.cabal diff --git a/tests/integration/tests/proper-rebuilds/files/app/Main.hs b/tests/integration/tests/proper-rebuilds/files/app/Main.hs index a2fa21e3ac..c081d93bae 100644 --- a/tests/integration/tests/proper-rebuilds/files/app/Main.hs +++ b/tests/integration/tests/proper-rebuilds/files/app/Main.hs @@ -1,6 +1,6 @@ module Main where -import Lib +import Lib ( func ) -main = do - putStrLn $ "Sample strings: " ++ show someStrings +main :: IO () +main = func diff --git a/tests/integration/tests/proper-rebuilds/files/files.cabal b/tests/integration/tests/proper-rebuilds/files/files.cabal deleted file mode 100644 index b04858a5fd..0000000000 --- a/tests/integration/tests/proper-rebuilds/files/files.cabal +++ /dev/null @@ -1,17 +0,0 @@ -name: files -version: 1.0.0 -build-type: Simple -cabal-version: >= 1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base - default-language: Haskell2010 - -executable test-exe - hs-source-dirs: app - main-is: Main.hs - ghc-options: -rtsopts - build-depends: base, files - default-language: Haskell2010 \ No newline at end of file diff --git a/tests/integration/tests/proper-rebuilds/files/package.yaml b/tests/integration/tests/proper-rebuilds/files/package.yaml new file mode 100644 index 0000000000..bea19d444e --- /dev/null +++ b/tests/integration/tests/proper-rebuilds/files/package.yaml @@ -0,0 +1,16 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: + source-dirs: src + +executables: + myExe: + source-dirs: app + main: Main.hs + dependencies: + - myPackage diff --git a/tests/integration/tests/proper-rebuilds/files/src/Lib.hs b/tests/integration/tests/proper-rebuilds/files/src/Lib.hs new file mode 100644 index 0000000000..412990b09b --- /dev/null +++ b/tests/integration/tests/proper-rebuilds/files/src/Lib.hs @@ -0,0 +1,6 @@ +module Lib + ( func + ) where + +func :: IO () +func = putStrLn "Version 1" diff --git a/tests/integration/tests/proper-rebuilds/files/src/Lib.hs.v1 b/tests/integration/tests/proper-rebuilds/files/src/Lib.hs.v1 deleted file mode 100644 index fc0ad60719..0000000000 --- a/tests/integration/tests/proper-rebuilds/files/src/Lib.hs.v1 +++ /dev/null @@ -1,4 +0,0 @@ -module Lib where - -someStrings :: [String] -someStrings = ["Hello", "world!"] diff --git a/tests/integration/tests/proper-rebuilds/files/src/Lib.hs.v2 b/tests/integration/tests/proper-rebuilds/files/src/Lib.hs.v2 deleted file mode 100644 index 59c5f8c548..0000000000 --- a/tests/integration/tests/proper-rebuilds/files/src/Lib.hs.v2 +++ /dev/null @@ -1,4 +0,0 @@ -module Lib where - -someStrings :: [String] -someStrings = ["Hello", "other", "world!"] diff --git a/tests/integration/tests/proper-rebuilds/files/src/Lib.v1 b/tests/integration/tests/proper-rebuilds/files/src/Lib.v1 new file mode 100644 index 0000000000..412990b09b --- /dev/null +++ b/tests/integration/tests/proper-rebuilds/files/src/Lib.v1 @@ -0,0 +1,6 @@ +module Lib + ( func + ) where + +func :: IO () +func = putStrLn "Version 1" diff --git a/tests/integration/tests/proper-rebuilds/files/src/Lib.v2 b/tests/integration/tests/proper-rebuilds/files/src/Lib.v2 new file mode 100644 index 0000000000..98438cc36e --- /dev/null +++ b/tests/integration/tests/proper-rebuilds/files/src/Lib.v2 @@ -0,0 +1,6 @@ +module Lib + ( func + ) where + +func :: IO () +func = putStrLn "Version 2" diff --git a/tests/integration/tests/relative-script-snapshots/Main.hs b/tests/integration/tests/relative-script-snapshots/Main.hs index 0a4044c6af..483add4c7d 100644 --- a/tests/integration/tests/relative-script-snapshots/Main.hs +++ b/tests/integration/tests/relative-script-snapshots/Main.hs @@ -1,4 +1,7 @@ -import StackTest +-- Stack's script interpreter supports snapshot locations that are relative +-- local file paths. + +import StackTest main :: IO () main = stack ["subdir/script.hs"] diff --git a/tests/integration/tests/relative-script-snapshots/files/subdir/snapshot.yaml b/tests/integration/tests/relative-script-snapshots/files/subdir/mySnapshot.yaml similarity index 80% rename from tests/integration/tests/relative-script-snapshots/files/subdir/snapshot.yaml rename to tests/integration/tests/relative-script-snapshots/files/subdir/mySnapshot.yaml index faccd3d5e8..3ab8bcbe35 100644 --- a/tests/integration/tests/relative-script-snapshots/files/subdir/snapshot.yaml +++ b/tests/integration/tests/relative-script-snapshots/files/subdir/mySnapshot.yaml @@ -1,5 +1,7 @@ +name: mySnapshot + snapshot: ghc-9.10.3 -name: snapshot + packages: - acme-missiles-0.3@rev:0 - stm-2.5.0.0@rev:0 diff --git a/tests/integration/tests/relative-script-snapshots/files/subdir/script.hs b/tests/integration/tests/relative-script-snapshots/files/subdir/script.hs index 21fa066ca2..582c1d7b5a 100644 --- a/tests/integration/tests/relative-script-snapshots/files/subdir/script.hs +++ b/tests/integration/tests/relative-script-snapshots/files/subdir/script.hs @@ -1,6 +1,7 @@ #!/usr/bin/env stack --- stack --snapshot snapshot.yaml script -import Acme.Missiles +-- stack --snapshot mySnapshot.yaml script + +import Acme.Missiles ( launchMissiles ) main :: IO () main = launchMissiles diff --git a/tests/integration/tests/sanity/Main.hs b/tests/integration/tests/sanity/Main.hs index cdf55e9c54..cb6f3f44bc 100644 --- a/tests/integration/tests/sanity/Main.hs +++ b/tests/integration/tests/sanity/Main.hs @@ -1,25 +1,26 @@ -import StackTest -import Control.Monad (unless) -import System.Directory (doesFileExist) +-- | Various tests of Stack's sanity. + +import Control.Monad ( unless ) +import StackTest +import System.Directory ( doesFileExist ) main :: IO () main = do - stack ["--version"] - stack ["--help"] - removeDirIgnore "acme-missiles-0.2" - removeDirIgnore "acme-missiles-0.3" - stack ["unpack", "acme-missiles-0.2"] - stack ["unpack", "acme-missiles"] - stackErr ["command-does-not-exist"] - stackErr ["unpack", "invalid-package-name-"] + stack ["--version"] + stack ["--help"] + removeDirIgnore "acme-missiles-0.2" + removeDirIgnore "acme-missiles-0.3" + stack ["unpack", "acme-missiles-0.2"] + stack ["unpack", "acme-missiles"] + stackErr ["command-does-not-exist"] + stackErr ["unpack", "invalid-package-name-"] - -- When running outside of IntegrationSpec.hs, this will use the - -- stack.yaml from Stack itself - exists <- doesFileExist "../../../../../stack.yaml" - unless exists $ stackErr ["build"] + -- When running outside of IntegrationSpec.hs, this will use the + -- stack.yaml from Stack itself + exists <- doesFileExist "../../../../../stack.yaml" + unless exists $ stackErr ["build"] - doesNotExist "stack.yaml" + doesNotExist "stack.yaml" - if isWindows - then stack [defaultSnapshotArg, "exec", "./foo.bat"] - else stack [defaultSnapshotArg, "exec", "./foo.sh"] + let scriptFile = if isWindows then "./script.bat" else "./script.sh" + stack [defaultSnapshotArg, "exec", scriptFile] diff --git a/tests/integration/tests/sanity/files/foo.bat b/tests/integration/tests/sanity/files/script.bat old mode 100755 new mode 100644 similarity index 100% rename from tests/integration/tests/sanity/files/foo.bat rename to tests/integration/tests/sanity/files/script.bat diff --git a/tests/integration/tests/sanity/files/foo.sh b/tests/integration/tests/sanity/files/script.sh similarity index 100% rename from tests/integration/tests/sanity/files/foo.sh rename to tests/integration/tests/sanity/files/script.sh diff --git a/tests/integration/tests/script-extra-dep/Main.hs b/tests/integration/tests/script-extra-dep/Main.hs index c2e9c88b99..b575ce035d 100644 --- a/tests/integration/tests/script-extra-dep/Main.hs +++ b/tests/integration/tests/script-extra-dep/Main.hs @@ -1,4 +1,6 @@ -import StackTest +-- Stack's script interpreter supports extra-deps. + +import StackTest main :: IO () main = stack ["script.hs"] diff --git a/tests/integration/tests/script-extra-dep/files/script.hs b/tests/integration/tests/script-extra-dep/files/script.hs index 47c25c808b..cbb5e52b49 100644 --- a/tests/integration/tests/script-extra-dep/files/script.hs +++ b/tests/integration/tests/script-extra-dep/files/script.hs @@ -1,6 +1,7 @@ #!/usr/bin/env stack --- stack --snapshot ghc-9.10.3 script --extra-dep acme-missiles-0.3@rev:0 --extra-dep stm-2.5.3.1@rev:1 -import Acme.Missiles +-- stack --snapshot ghc-9.10.3 script --extra-dep acme-missiles-0.3@rev:0 + +import Acme.Missiles ( launchMissiles ) main :: IO () main = launchMissiles diff --git a/tests/integration/tests/skip-unreachable-dirs/Main.hs b/tests/integration/tests/skip-unreachable-dirs/Main.hs index 08d36cec61..25983649fa 100644 --- a/tests/integration/tests/skip-unreachable-dirs/Main.hs +++ b/tests/integration/tests/skip-unreachable-dirs/Main.hs @@ -1,6 +1,8 @@ -import StackTest -import System.Directory -import Control.Exception (catch, IOException) +-- | Stack's init command skips unreachable directories. + +import Control.Exception ( IOException, catch) +import StackTest +import System.Directory main :: IO () main = do diff --git a/tests/integration/tests/skip-unreachable-dirs/files/.gitignore b/tests/integration/tests/skip-unreachable-dirs/files/.gitignore index 684dbffa96..20fdd32928 100644 --- a/tests/integration/tests/skip-unreachable-dirs/files/.gitignore +++ b/tests/integration/tests/skip-unreachable-dirs/files/.gitignore @@ -1 +1,3 @@ +myPackage.cabal stack.yaml +unreachabledir/ diff --git a/tests/integration/tests/skip-unreachable-dirs/files/foo.cabal b/tests/integration/tests/skip-unreachable-dirs/files/foo.cabal deleted file mode 100644 index 625239b18d..0000000000 --- a/tests/integration/tests/skip-unreachable-dirs/files/foo.cabal +++ /dev/null @@ -1,10 +0,0 @@ -name: foo -version: 0.0.0 -synopsis: foo -build-type: Simple -cabal-version: >=1.10 - -library - exposed-modules: Foo - build-depends: base - default-language: Haskell2010 diff --git a/tests/integration/tests/skip-unreachable-dirs/files/package.yaml b/tests/integration/tests/skip-unreachable-dirs/files/package.yaml new file mode 100644 index 0000000000..4b373ba746 --- /dev/null +++ b/tests/integration/tests/skip-unreachable-dirs/files/package.yaml @@ -0,0 +1,8 @@ +spec-version: 0.36.0 + +name: myPackage + +dependencies: +- base + +library: {} diff --git a/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/Main.hs b/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/Main.hs index d4efcc403c..60cd2526ad 100644 --- a/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/Main.hs +++ b/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/Main.hs @@ -1,6 +1,25 @@ -import StackTest +-- | The test case here is weird enough to warrant an explanation. What we +-- _really_ want to test is whether building the lts-3.12 snapshot's +-- semigroupoids package with rev-1 works. See +-- https://github.com/commercialhaskell/stackage/issues/3185. However, that test +-- requires that we use an older GHC, and as Manny commented: +-- +-- > Having integration tests with old resolvers will cause them to fail +-- > on Linux distributions with GCC with PIE enabled by default (which +-- > is the latest versions of most distributions now), since older GHC +-- > versions do not support it. I'm not sure what we should do about +-- > this, since it obviously does make sense to be able to test against +-- > old snapshots sometimes. +-- +-- So I am instead testing a totally different case here which repros the +-- same issue. If we use a custom snapshot with incompatible `stm` and +-- `async` versions, we want Stack to trust the build plan and allow a +-- `--dry-run` to succeed. But if we do this via `extra-deps`, we want it +-- to fail. + +import StackTest main :: IO () main = do - stackErr ["build", "--stack-yaml", "as-extra-dep.yaml", "--dry-run"] - stack ["build", "--stack-yaml", "as-snapshot.yaml", "--dry-run"] + stackErr ["build", "--stack-yaml", "stack1.yaml", "--dry-run"] + stack ["build", "--stack-yaml", "stack2.yaml", "--dry-run"] diff --git a/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/.gitignore b/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/.gitignore index 6a9f1098c7..b0a5a052a1 100644 --- a/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/.gitignore +++ b/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/.gitignore @@ -1 +1 @@ -/unimportant.cabal +myPackage.cabal diff --git a/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/README.md b/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/README.md deleted file mode 100644 index 141a9834f3..0000000000 --- a/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/README.md +++ /dev/null @@ -1,18 +0,0 @@ -The test case here is weird enough to warrant an explanation. What we -_really_ want to test is whether building the lts-3.12 snapshot's -semigroupoids package with rev-1 works. See -https://github.com/commercialhaskell/stackage/issues/3185. However, that test -requires that we use an older GHC, and as Manny commented: - -> Having integration tests with old resolvers will cause them to fail -> on Linux distributions with GCC with PIE enabled by default (which -> is the latest versions of most distributions now), since older GHC -> versions do not support it. I'm not sure what we should do about -> this, since it obviously does make sense to be able to test against -> old snapshots sometimes. - -So I am instead testing a totally different case here which repros the -same issue. If we use a custom snapshot with incompatible `stm` and -`async` versions, we want Stack to trust the build plan and allow a -`--dry-run` to succeed. But if we do this via `extra-deps`, we want it -to fail. diff --git a/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/as-snapshot.yaml b/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/as-snapshot.yaml deleted file mode 100644 index 1c2b12b0f1..0000000000 --- a/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/as-snapshot.yaml +++ /dev/null @@ -1 +0,0 @@ -snapshot: snapshot.yaml diff --git a/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/mySnapshot.yaml b/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/mySnapshot.yaml new file mode 100644 index 0000000000..0c602a1e79 --- /dev/null +++ b/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/mySnapshot.yaml @@ -0,0 +1,8 @@ +name: mySnapshot + +snapshot: ghc-9.10.3 + +packages: +# The Cabal file for async-2.1.1.1 specifies stm >= 2.2 +- async-2.1.1.1 +- stm-2.1.2.2 diff --git a/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/package.yaml b/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/package.yaml index f403f2761f..d04e500bd6 100644 --- a/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/package.yaml +++ b/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/package.yaml @@ -1,4 +1,6 @@ -name: unimportant +spec-version: 0.36.0 + +name: myPackage dependencies: - base diff --git a/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/snapshot.yaml b/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/snapshot.yaml deleted file mode 100644 index f3b9e8c23d..0000000000 --- a/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/snapshot.yaml +++ /dev/null @@ -1,5 +0,0 @@ -snapshot: ghc-9.10.3 -name: hackage-revisions-are-annoying -packages: -- async-2.1.1.1 -- stm-2.1.2.2 diff --git a/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/as-extra-dep.yaml b/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/stack1.yaml similarity index 52% rename from tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/as-extra-dep.yaml rename to tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/stack1.yaml index 598233f978..4813fc689c 100644 --- a/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/as-extra-dep.yaml +++ b/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/stack1.yaml @@ -1,4 +1,6 @@ snapshot: ghc-9.10.3 + extra-deps: +# The Cabal file for async-2.1.1.1 specifies stm >= 2.2 - async-2.1.1.1 - stm-2.1.2.2 diff --git a/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/stack2.yaml b/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/stack2.yaml new file mode 100644 index 0000000000..5d99800320 --- /dev/null +++ b/tests/integration/tests/stackage-3185-ignore-bounds-in-snapshot/files/stack2.yaml @@ -0,0 +1 @@ +snapshot: mySnapshot.yaml diff --git a/tests/integration/tests/upload/Main.hs b/tests/integration/tests/upload/Main.hs index 2a7e47dc38..792d75e3e4 100644 --- a/tests/integration/tests/upload/Main.hs +++ b/tests/integration/tests/upload/Main.hs @@ -1,34 +1,32 @@ -import Control.Concurrent - +import Control.Concurrent ( threadDelay ) import StackTest - -import System.Directory (createDirectoryIfMissing, - getCurrentDirectory) -import System.Environment (getEnv, setEnv) -import System.FilePath (()) -import System.Process +import System.Directory + ( createDirectoryIfMissing, getCurrentDirectory ) +import System.Environment ( getEnv, setEnv ) +import System.FilePath ( () ) +import System.Process ( proc, withCreateProcess ) main :: IO () main = - withFakeHackage $ do - stackRoot <- getEnv "STACK_ROOT" - -- Ensure there are credentials available for uploading - createDirectoryIfMissing True (stackRoot "upload") - writeFile - (stackRoot "upload" "credentials.json") - "{\"username\":\"fake\",\"password\":\"fake\"}" - stack ["upload", "."] + withFakeHackage $ do + stackRoot <- getEnv "STACK_ROOT" + -- Ensure there are credentials available for uploading + createDirectoryIfMissing True (stackRoot "upload") + writeFile + (stackRoot "upload" "credentials.json") + "{\"username\":\"fake\",\"password\":\"fake\"}" + stack ["upload", "."] -- | Start a fake Hackage server to test the upload withFakeHackage :: IO a -> IO a withFakeHackage act = do - stackEnv <- stackExe - -- Build the dependencies for the fake server - stack $ withNetworkArgs ++ ["FakeHackageStart.hs"] - -- Start the fake server - withCreateProcess (proc stackEnv $ withNetworkArgs ++ ["FakeHackage.hs"]) $ \_ _ _ _ -> do - -- Wait for the fake server to start accepting requests - threadDelay 3000000 - act - where - withNetworkArgs = ["runghc", "--package", "network"] + stackEnv <- stackExe + -- Build the dependencies for the fake server + stack $ withNetworkArgs ++ ["FakeHackageStart.hs"] + -- Start the fake server + withCreateProcess (proc stackEnv $ withNetworkArgs ++ ["FakeHackage.hs"]) $ \_ _ _ _ -> do + -- Wait for the fake server to start accepting requests + threadDelay 3000000 + act + where + withNetworkArgs = ["runghc", "--package", "network"] diff --git a/tests/integration/tests/upload/files/.gitignore b/tests/integration/tests/upload/files/.gitignore new file mode 100644 index 0000000000..b0a5a052a1 --- /dev/null +++ b/tests/integration/tests/upload/files/.gitignore @@ -0,0 +1 @@ +myPackage.cabal diff --git a/tests/integration/tests/upload/files/FakeHackage.hs b/tests/integration/tests/upload/files/FakeHackage.hs index eef4b9349b..3d39c7a445 100644 --- a/tests/integration/tests/upload/files/FakeHackage.hs +++ b/tests/integration/tests/upload/files/FakeHackage.hs @@ -1,32 +1,32 @@ {-# LANGUAGE OverloadedStrings #-} -import Control.Concurrent -import Control.Monad -import Network.Socket hiding (recv) -import Network.Socket.ByteString (recv, sendAll) -import System.Exit -import System.IO +import Control.Concurrent ( forkIO, threadDelay ) +import Control.Monad ( forever ) +import Network.Socket hiding ( recv ) +import Network.Socket.ByteString ( recv, sendAll ) +import System.Exit ( exitSuccess ) +import System.IO () -- | Fake server that always responds with HTTP OK main = - withSocketsDo $ do - _ <- forkIO serve - -- Exit after a delay to ensure the process doesn't linger around - threadDelay 10000000 - exitSuccess + withSocketsDo $ do + _ <- forkIO serve + -- Exit after a delay to ensure the process doesn't linger around + threadDelay 10000000 + exitSuccess serve :: IO () serve = do - let hints = defaultHints {addrFlags = [AI_PASSIVE], addrSocketType = Stream} - (addr:_) <- getAddrInfo (Just hints) Nothing (Just "12415") - sock <- socket (addrFamily addr) (addrSocketType addr) (addrProtocol addr) - setSocketOption sock ReuseAddr 1 - bind sock (addrAddress addr) - listen sock 10 - forever $ do - (conn, _) <- accept sock - _ <- recv conn 1024 - sendAll - conn - "HTTP/1.1 200 OK\r\nContent-Length: 1\r\nContent-Type: text/plain\r\n\r\na" - shutdown conn ShutdownSend + let hints = defaultHints {addrFlags = [AI_PASSIVE], addrSocketType = Stream} + (addr:_) <- getAddrInfo (Just hints) Nothing (Just "12415") + sock <- socket (addrFamily addr) (addrSocketType addr) (addrProtocol addr) + setSocketOption sock ReuseAddr 1 + bind sock (addrAddress addr) + listen sock 10 + forever $ do + (conn, _) <- accept sock + _ <- recv conn 1024 + sendAll + conn + "HTTP/1.1 200 OK\r\nContent-Length: 1\r\nContent-Type: text/plain\r\n\r\na" + shutdown conn ShutdownSend diff --git a/tests/integration/tests/upload/files/Foo.hs b/tests/integration/tests/upload/files/Foo.hs deleted file mode 100644 index efbf93bbde..0000000000 --- a/tests/integration/tests/upload/files/Foo.hs +++ /dev/null @@ -1 +0,0 @@ -module Foo where diff --git a/tests/integration/tests/upload/files/package.yaml b/tests/integration/tests/upload/files/package.yaml new file mode 100644 index 0000000000..75c0d254af --- /dev/null +++ b/tests/integration/tests/upload/files/package.yaml @@ -0,0 +1,11 @@ +spec-version: 0.36.0 + +name: myPackage +description: Upload test description +license: BSD-3-Clause + +dependencies: +- base < 5 + +library: + source-dirs: src diff --git a/tests/integration/tests/upload/files/src/Lib.hs b/tests/integration/tests/upload/files/src/Lib.hs new file mode 100644 index 0000000000..6d85a26fe1 --- /dev/null +++ b/tests/integration/tests/upload/files/src/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/tests/integration/tests/upload/files/stack.yaml b/tests/integration/tests/upload/files/stack.yaml index a857811614..4785f281bc 100644 --- a/tests/integration/tests/upload/files/stack.yaml +++ b/tests/integration/tests/upload/files/stack.yaml @@ -1,2 +1,3 @@ -snapshot: lts-24.24 +snapshot: lts-24.43 + hackage-base-url: http://localhost:12415/ diff --git a/tests/integration/tests/upload/files/uploadtest.cabal b/tests/integration/tests/upload/files/uploadtest.cabal deleted file mode 100644 index fbf051d525..0000000000 --- a/tests/integration/tests/upload/files/uploadtest.cabal +++ /dev/null @@ -1,13 +0,0 @@ -build-type: Simple -name: uploadtest -version: 0.0.0 -category: test -maintainer: uploadtest@example.com -cabal-version: 1.20 -synopsis: Upload test -description: Upload test description -license: BSD3 -library - build-depends: base >= 4.7 && < 5 - exposed-modules: Foo - default-language: Haskell2010 diff --git a/tests/integration/tests/variables-in-template-file-names/Main.hs b/tests/integration/tests/variables-in-template-file-names/Main.hs index e2572ef0e0..598874ea80 100644 --- a/tests/integration/tests/variables-in-template-file-names/Main.hs +++ b/tests/integration/tests/variables-in-template-file-names/Main.hs @@ -1,10 +1,13 @@ -import StackTest -import System.Directory -import Control.Monad (unless) +-- | A Stack project template can be populated with the name of the Stack +-- project. + +import Control.Monad ( unless ) +import StackTest +import System.Directory ( doesFileExist ) main :: IO () main = do - removeDirIgnore "somename" - stack ["new", "somename", "./template.hsfiles"] - exists <- doesFileExist "somename/somename.cabal" + removeDirIgnore "myPackage" + stack ["new", "myPackage", "./template.hsfiles"] + exists <- doesFileExist "myPackage/myPackage.cabal" unless exists $ error "does not exist" diff --git a/tests/integration/tests/variables-in-template-file-names/files/.gitignore b/tests/integration/tests/variables-in-template-file-names/files/.gitignore index 6d57d66dd6..761adaef96 100644 --- a/tests/integration/tests/variables-in-template-file-names/files/.gitignore +++ b/tests/integration/tests/variables-in-template-file-names/files/.gitignore @@ -1 +1 @@ -/somename/ +myPackage/ diff --git a/tests/integration/tests/watched-files/Main.hs b/tests/integration/tests/watched-files/Main.hs index d683c93a0b..3cd9840459 100644 --- a/tests/integration/tests/watched-files/Main.hs +++ b/tests/integration/tests/watched-files/Main.hs @@ -1,6 +1,8 @@ -import StackTest -import Data.Foldable (for_) -import Control.Monad (unless) +-- | Stack recompiles when a file required for compilation is dirty. + +import Control.Monad ( unless ) +import Data.Foldable ( for_ ) +import StackTest main :: IO () main = for_ (words "foo bar baz bin") $ \x -> do diff --git a/tests/integration/tests/watched-files/files/.gitignore b/tests/integration/tests/watched-files/files/.gitignore index d09ee0af48..c93a3fc3e5 100644 --- a/tests/integration/tests/watched-files/files/.gitignore +++ b/tests/integration/tests/watched-files/files/.gitignore @@ -1,2 +1,2 @@ some-text-file.txt -*.cabal +myPackage.cabal diff --git a/tests/integration/tests/watched-files/files/Main.hs b/tests/integration/tests/watched-files/files/app/Main.hs similarity index 65% rename from tests/integration/tests/watched-files/files/Main.hs rename to tests/integration/tests/watched-files/files/app/Main.hs index a462eafd73..34d36111aa 100644 --- a/tests/integration/tests/watched-files/files/Main.hs +++ b/tests/integration/tests/watched-files/files/app/Main.hs @@ -1,9 +1,10 @@ {-# LANGUAGE TemplateHaskell #-} + module Main where -import Data.FileEmbed import qualified Data.ByteString as B -import System.IO (stdout) +import Data.FileEmbed ( embedFile ) +import System.IO ( stdout ) main :: IO () main = B.hPut stdout $(embedFile "some-text-file.txt") diff --git a/tests/integration/tests/watched-files/files/package.yaml b/tests/integration/tests/watched-files/files/package.yaml index 6611f13029..2132e12b97 100644 --- a/tests/integration/tests/watched-files/files/package.yaml +++ b/tests/integration/tests/watched-files/files/package.yaml @@ -1,9 +1,13 @@ -name: watched-files +spec-version: 0.36.0 + +name: myPackage + dependencies: - base - bytestring - file-embed executables: - watched: + myExe: + source-dirs: app main: Main.hs diff --git a/tests/integration/tests/watched-files/files/stack.yaml b/tests/integration/tests/watched-files/files/stack.yaml index b54fd809bf..5490d5880f 100644 --- a/tests/integration/tests/watched-files/files/stack.yaml +++ b/tests/integration/tests/watched-files/files/stack.yaml @@ -1 +1 @@ -snapshot: lts-24.24 +snapshot: lts-24.43 diff --git a/tests/unit/Stack/ConfigSpec.hs b/tests/unit/Stack/ConfigSpec.hs index cbabbede89..d336947360 100644 --- a/tests/unit/Stack/ConfigSpec.hs +++ b/tests/unit/Stack/ConfigSpec.hs @@ -53,14 +53,15 @@ import Test.Hspec sampleConfig :: String sampleConfig = - "snapshot: lts-24.24\n" ++ + "snapshot: lts-24.43\n" ++ "packages: ['.']\n" buildOptsConfig :: String buildOptsConfig = - "snapshot: lts-24.24\n" ++ + "snapshot: lts-24.43\n" ++ "packages: ['.']\n" ++ "build:\n" ++ + " semaphore: true\n" ++ " library-profiling: true\n" ++ " executable-profiling: true\n" ++ " library-stripping: false\n" ++ @@ -89,6 +90,7 @@ buildOptsConfig = " additional-args: ['-fprof']\n" ++ " coverage: true\n" ++ " no-run-tests: true\n" ++ + " test-suite-timeout-grace: 30\n" ++ " bench: true\n" ++ " benchmark-opts:\n" ++ " benchmark-arguments: -O2\n" ++ @@ -104,7 +106,7 @@ buildOptsConfig = buildOptsHaddockForHackageConfig :: String buildOptsHaddockForHackageConfig = - "snapshot: lts-24.24\n" ++ + "snapshot: lts-24.43\n" ++ "packages: ['.']\n" ++ "build:\n" ++ " haddock: true\n" ++ @@ -120,24 +122,24 @@ buildOptsHaddockForHackageConfig = hpackConfig :: String hpackConfig = - "snapshot: lts-24.24\n" ++ + "snapshot: lts-24.43\n" ++ "with-hpack: /usr/local/bin/hpack\n" ++ "packages: ['.']\n" resolverConfig :: String resolverConfig = - "resolver: lts-24.24\n" ++ + "resolver: lts-24.43\n" ++ "packages: ['.']\n" snapshotConfig :: String snapshotConfig = - "snapshot: lts-24.24\n" ++ + "snapshot: lts-24.43\n" ++ "packages: ['.']\n" resolverSnapshotConfig :: String resolverSnapshotConfig = - "resolver: lts-24.24\n" ++ - "snapshot: lts-24.24\n" ++ + "resolver: lts-24.43\n" ++ + "snapshot: lts-24.43\n" ++ "packages: ['.']\n" stackDotYaml :: Path Rel File @@ -187,11 +189,11 @@ spec = beforeAll setup $ do it "parses snapshot using 'resolver'" $ inTempDir $ do loadProject resolverConfig $ \project -> - project.snapshot `shouldBe` RSLSynonym (LTS 24 24) + project.snapshot `shouldBe` RSLSynonym (LTS 24 43) it "parses snapshot using 'snapshot'" $ inTempDir $ do loadProject snapshotConfig $ \project -> - project.snapshot `shouldBe` RSLSynonym (LTS 24 24) + project.snapshot `shouldBe` RSLSynonym (LTS 24 43) it "throws if both 'resolver' and 'snapshot' are present" $ inTempDir $ do loadProject resolverSnapshotConfig (const (pure ())) @@ -228,6 +230,7 @@ spec = beforeAll setup $ do writeFile (toFilePath stackDotYaml) buildOptsConfig loadConfig' $ \config -> liftIO $ do let bopts = config.build + bopts.semaphore `shouldBe` True bopts.libProfile `shouldBe` True bopts.exeProfile `shouldBe` True bopts.libStrip `shouldBe` False @@ -257,6 +260,7 @@ spec = beforeAll setup $ do , coverage = True , runTests = False , maximumTimeSeconds = Nothing + , timeoutGraceSeconds = Just 30 , allowStdin = True } bopts.benchmarks `shouldBe` True