Skip to content

Commit e0f66c4

Browse files
philderbeastmergify[bot]
authored andcommitted
Add project monitoring test
- Add monitor existing and nonexistant files - Test for expected monitoring - Export mkNormalizerEnv - Don't run configure on the local project - Only show the absolute path if needed - Remove assert, explicitly disabled not available - Add only the test, note TODO and actual behaviour - Don't check for verbatim monitoring on Windows Co-Authored-By: Julian Ospald <hasufell@posteo.de> (cherry picked from commit ffc9edd) # Conflicts: # cabal-install/src/Distribution/Client/ProjectConfig.hs
1 parent 6e2464c commit e0f66c4

22 files changed

Lines changed: 279 additions & 12 deletions

cabal-install/src/Distribution/Client/ProjectConfig.hs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ import Distribution.Simple.Utils
8383
( createDirectoryIfMissingVerbose
8484
, debug
8585
, dieWithException
86+
, info
8687
, maybeExit
8788
, notice
8889
, noticeDoc
@@ -215,9 +216,6 @@ import Distribution.Utils.NubList
215216
( fromNubList
216217
)
217218
import Distribution.Verbosity
218-
( makeVerbose
219-
, modifyVerbosityFlags
220-
)
221219
import Distribution.Version
222220

223221
import qualified Codec.Archive.Tar as Tar
@@ -845,26 +843,49 @@ readProjectFileSkeletonGen :: Verbosity -> HttpTransport -> DistDirLayout -> Str
845843
readProjectFileSkeletonGen
846844
verbosity
847845
httpTransport
846+
<<<<<<< HEAD
848847
dir
849848
extensionName
850849
extensionDescription
850+
=======
851+
DistDirLayout{distProjectFile, distProjectRootDirectory}
852+
key
853+
>>>>>>> ffc9edd42 (Add project monitoring test)
851854
parseConfig =
852855
do
853856
exists <- liftIO $ doesFileExist extensionFile
854857
if exists
855858
then do
859+
monitorLog $ "Monitor existing: " ++ fileWithAbsolute extensionFile
856860
monitorFiles [monitorFileHashed extensionFile]
857861
pcs <- liftIO $ parseConfig extensionFile
858-
monitorFiles
859-
[ monitorFileHashed (projectConfigPathRoot path)
860-
| (Nothing, path) <- projectSkeletonImports pcs
861-
]
862+
let paths =
863+
[ projectConfigPathRoot path
864+
| (Nothing, path) <- projectSkeletonImports pcs
865+
]
866+
for_ paths $ \p -> do
867+
monitorLog $ "Monitor imported: " ++ fileWithAbsolute p
868+
monitorFiles $ monitorFileHashed <$> paths
862869
return pcs
863870
else do
871+
monitorLog $ "Monitor nonexistent: " ++ fileWithAbsolute extensionFile
864872
monitorFiles [monitorNonExistentFile extensionFile]
865873
return mempty
866874
where
875+
<<<<<<< HEAD
867876
extensionFile = distProjectFile dir extensionName
877+
=======
878+
monitorLog = liftIO . info verbosity
879+
extensionFile = distProjectFile key
880+
881+
fileWithAbsolute f
882+
| isAbsolute f = f
883+
| otherwise = f ++ " (" ++ makeAbsolute f ++ ")"
884+
885+
makeAbsolute f
886+
| isAbsolute f = f
887+
| otherwise = distProjectRootDirectory </> f
888+
>>>>>>> ffc9edd42 (Add project monitoring test)
868889

869890
-- There are 3 different variants of the project parsing function.
870891
-- 1. readProjectFileSkeletonLegacy: always uses the legacy parser

cabal-install/src/Distribution/Client/ProjectPlanning.hs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,6 @@ sanityCheckElaboratedConfiguredPackage
270270
== hashedInstalledPackageId
271271
(packageHashInputs sharedConfig elab)
272272
)
273-
-- the stanzas explicitly disabled should not be available
274-
. assert
275-
( optStanzaSetNull $
276-
optStanzaKeysFilteredByValue (maybe False not) elabStanzasRequested `optStanzaSetIntersection` elabStanzasAvailable
277-
)
278273
-- either a package is built inplace, or we are not attempting to
279274
-- build any test suites or benchmarks (we never build these
280275
-- for remote packages!)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Main (main) where
2+
3+
main :: IO ()
4+
main = putStrLn "Hello, Haskell!"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
cabal-version: 3.0
2+
name: cabal-project-repro
3+
version: 0.1.0.0
4+
license: BSD-3-Clause
5+
author: Julian Ospald
6+
maintainer: hasufell@posteo.de
7+
build-type: Simple
8+
9+
common warnings
10+
ghc-options: -Wall
11+
12+
executable filemonitor-test
13+
import: warnings
14+
main-is: Main.hs
15+
build-depends: base, filepath
16+
hs-source-dirs: app
17+
default-language: Haskell2010
18+
19+
test-suite cabal-project-repro-test
20+
import: warnings
21+
default-language: Haskell2010
22+
type: exitcode-stdio-1.0
23+
hs-source-dirs: test
24+
main-is: Main.hs
25+
build-depends: base
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Monitor existing: <ROOT>/cabal.freeze-only.project
2+
Monitor existing: <ROOT>/cabal.freeze-only.project.freeze
3+
Monitor imported: cabal.freeze-only.project.freeze (<ROOT>/cabal.freeze-only.project.freeze)
4+
Monitor imported: cabal.freeze-only.project.freeze (<ROOT>/cabal.freeze-only.project.freeze)
5+
Monitor imported: cabal.freeze-only.project.freeze (<ROOT>/cabal.freeze-only.project.freeze)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Monitor existing: <ROOT>/cabal.freeze-only.project
2+
Monitor existing: <ROOT>/cabal.freeze-only.project.freeze
3+
Monitor imported: nested/hop.config (<ROOT>/nested/hop.config)
4+
Monitor imported: nested/deeply-nested/hop.config (<ROOT>/nested/deeply-nested/hop.config)
5+
Monitor imported: test/tests-toggle.config (<ROOT>/test/tests-toggle.config)
6+
Monitor nonexistent: <ROOT>/cabal.freeze-only.project.local
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- NOTE: Intentionally empty as we can't specify
2+
-- --project-file=cabal.freeze-only.project when that file doesn't exist.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
packages: ./cabal-project-repro.cabal
2+
3+
package *
4+
Tests: True
5+
6+
import: nested/hop.config
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Monitor existing: <ROOT>/cabal.local-only.project
2+
Monitor nonexistent: <ROOT>/cabal.local-only.project.freeze
3+
Monitor existing: <ROOT>/cabal.local-only.project.local
4+
Monitor imported: cabal.local-only.project.local (<ROOT>/cabal.local-only.project.local)
5+
Monitor imported: cabal.local-only.project.local (<ROOT>/cabal.local-only.project.local)
6+
Monitor imported: cabal.local-only.project.local (<ROOT>/cabal.local-only.project.local)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Monitor existing: <ROOT>/cabal.local-only.project
2+
Monitor nonexistent: <ROOT>/cabal.local-only.project.freeze
3+
Monitor existing: <ROOT>/cabal.local-only.project.local
4+
Monitor imported: nested/hop.config (<ROOT>/nested/hop.config)
5+
Monitor imported: nested/deeply-nested/hop.config (<ROOT>/nested/deeply-nested/hop.config)
6+
Monitor imported: test/tests-toggle.config (<ROOT>/test/tests-toggle.config)

0 commit comments

Comments
 (0)