Skip to content

Commit

Permalink
Always have the project itself sort first
Browse files Browse the repository at this point in the history
- Use with-ghc.config with woops project
  • Loading branch information
philderbeast committed Dec 1, 2024
1 parent cc54913 commit 7f9ea4d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ newtype ProjectConfigPath = ProjectConfigPath (NonEmpty FilePath)
instance Ord ProjectConfigPath where
compare pa@(ProjectConfigPath (NE.toList -> as)) pb@(ProjectConfigPath (NE.toList -> bs)) =
case (as, bs) of
-- There should only ever be one root project path, only one path
-- with length 1. Comparing it to itself should be EQ. Don't assume
-- this though, do a comparison anyway when both sides have length
-- 1. The root path, the project itself, should always be the first
-- path in a sorted listing.
([a], [b]) -> compare a b
([_], _) -> LT
(_, [_]) -> GT

(a:_, b:_) -> case (parseAbsoluteURI a, parseAbsoluteURI b) of
(Just ua, Just ub) -> compare ua ub P.<> compare aImporters bImporters
(Just _, Nothing) -> GT
Expand Down
13 changes: 5 additions & 8 deletions cabal-testsuite/PackageTests/ConditionalAndImport/cabal.out
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ cyclical import of cyclical-2-out-out-self-b.config;
# checking that cyclical check doesn't false-positive on same file names in different folders; hoping within a folder and then into a subfolder
# cabal v2-build
Configuration is affected by the following files:
- noncyclical-same-filename-a.project
- noncyclical-same-filename-a.config
imported by: noncyclical-same-filename-a.project
- noncyclical-same-filename-a.project
- same-filename/noncyclical-same-filename-a.config
imported by: noncyclical-same-filename-a.config
imported by: noncyclical-same-filename-a.project
Expand All @@ -83,10 +83,10 @@ Building library for my-0.1...
# checking that cyclical check doesn't false-positive on same file names in different folders; hoping into a subfolder and then back out again
# cabal v2-build
Configuration is affected by the following files:
- noncyclical-same-filename-b.project
- noncyclical-same-filename-b.config
imported by: same-filename/noncyclical-same-filename-b.config
imported by: noncyclical-same-filename-b.project
- noncyclical-same-filename-b.project
- same-filename/noncyclical-same-filename-b.config
imported by: noncyclical-same-filename-b.project
Up to date
Expand Down Expand Up @@ -383,6 +383,8 @@ Up to date
# cabal v2-build
Configuration is affected by the following files:
- woops-0.project
- with-ghc.config
imported by: woops-0.project
- woops-2.config
imported by: woops/woops-1.config
imported by: woops-0.project
Expand Down Expand Up @@ -649,12 +651,7 @@ Configuration is affected by the following files:
imported by: woops/woops-1.config
imported by: woops-0.project
Resolving dependencies...
Build profile: -w ghc-9.4.8 -O1
In order, the following will be built:
- my-0.1 (lib:my) (first run)
Configuring my-0.1...
Preprocessing library for my-0.1...
Building library for my-0.1...
Up to date
# checking "using config from message" without URI imports
# cabal v2-build
# checking "using config from message" with URI imports
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do
"Project configuration with URI imports is listed in full"
"When using configuration from:(\n|\r\n) \
\ .*woops-0\\.project(\n|\r\n) \
\ .*with-ghc\\.config(\n|\r\n) \
\ .*woops-2\\.config(\n|\r\n) \
\ .*woops-4\\.config(\n|\r\n) \
\ .*woops-6\\.config(\n|\r\n) \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- WARNING: Override the `with-compiler: ghc-x.y.z` of the stackage import, of
-- https://www.stackage.org/nightly-yyyy-mm-dd/cabal.config. Otherwise tests
-- will fail with:
-- -Error: [Cabal-5490]
-- -Cannot find the program 'ghc'. User-specified path 'ghc-x.y.z' does not
-- refer to an executable and the program is not on the system path.
with-compiler: ghc
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ import: woops/woops-3.config
import: woops/woops-5.config
import: woops/woops-7.config
import: woops/woops-9.config

import: with-ghc.config

0 comments on commit 7f9ea4d

Please sign in to comment.