Skip to content

Commit dac8124

Browse files
authored
Merge pull request #10683 from cabalism/add/fourmolu-on-off
Add `make style-todo` and fourmolu on off comments
2 parents 5ac2f87 + a28fbcf commit dac8124

File tree

8 files changed

+54
-3
lines changed

8 files changed

+54
-3
lines changed

Cabal-described/src/Distribution/Utils/CharSet.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ member c (CS m) = go (IM.toList m)
114114
i = ord c
115115

116116
-- | Insert 'Char' into 'CharSet'.
117+
{- FOURMOLU_DISABLE -}
117118
insert :: Char -> CharSet -> CharSet
119+
{- FOURMOLU_ENABLE -}
118120
insert c (CS m) = normalise (IM.insert (ord c) (ord c) m)
119121

120122
-- | Union of two 'CharSet's.

Cabal-tests/tests/HackageTests.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ roundtripTest testFieldsTransform fpath bs = do
301301
putStrLn bs'
302302
exitFailure
303303

304+
{- FOURMOLU_DISABLE -}
304305
parse phase c = do
305306
let (_, x') = Parsec.runParseResult $
306307
Parsec.parseGenericPackageDescription c
@@ -311,6 +312,7 @@ roundtripTest testFieldsTransform fpath bs = do
311312
traverse_ print errs
312313
B.putStr c
313314
fail "parse error"
315+
{- FOURMOLU_ENABLE -}
314316

315317
-------------------------------------------------------------------------------
316318
-- Main

Cabal-tests/tests/ParserTests.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,14 @@ regressionTests = testGroup "regressions"
200200

201201
regressionTest :: FilePath -> TestTree
202202
regressionTest fp = testGroup fp
203+
{- FOURMOLU_DISABLE -}
203204
[ formatGoldenTest fp
204205
, formatRoundTripTest fp
205206
#ifdef MIN_VERSION_tree_diff
206207
, treeDiffGoldenTest fp
207208
#endif
208209
]
210+
{- FOURMOLU_ENABLE -}
209211

210212
formatGoldenTest :: FilePath -> TestTree
211213
formatGoldenTest fp = cabalGoldenTest "format" correct $ do
@@ -248,6 +250,7 @@ formatRoundTripTest fp = testCase "roundtrip" $ do
248250
y <- parse (toUTF8BS contents')
249251
-- previously we mangled licenses a bit
250252
let y' = y
253+
{- FOURMOLU_DISABLE -}
251254
unless (x == y') $
252255
#ifdef MIN_VERSION_tree_diff
253256
assertFailure $ unlines
@@ -273,6 +276,7 @@ formatRoundTripTest fp = testCase "roundtrip" $ do
273276
void $ assertFailure $ unlines (map (showPError fp) $ NE.toList errs)
274277
fail "failure"
275278
input = "tests" </> "ParserTests" </> "regressions" </> fp
279+
{- FOURMOLU_ENABLE -}
276280

277281
-------------------------------------------------------------------------------
278282
-- InstalledPackageInfo regressions
@@ -287,13 +291,15 @@ ipiTests = testGroup "ipis"
287291
]
288292

289293
ipiTest :: FilePath -> TestTree
294+
{- FOURMOLU_DISABLE -}
290295
ipiTest fp = testGroup fp $
291296
#ifdef MIN_VERSION_tree_diff
292297
[ ipiTreeDiffGoldenTest fp ] ++
293298
#endif
294299
[ ipiFormatGoldenTest fp
295300
, ipiFormatRoundTripTest fp
296301
]
302+
{- FOURMOLU_ENABLE -}
297303

298304
ipiFormatGoldenTest :: FilePath -> TestTree
299305
ipiFormatGoldenTest fp = cabalGoldenTest "format" correct $ do

Cabal-tests/tests/custom-setup/CabalDoctestSetup.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ addDoctestsUserHook testsuiteName uh = uh
283283

284284
-- | Convert only flags used by 'generateBuildModule'.
285285
haddockToBuildFlags :: HaddockFlags -> BuildFlags
286+
{- FOURMOLU_DISABLE -}
286287
haddockToBuildFlags f =
287288
#if MIN_VERSION_Cabal(3,11,0)
288289
emptyBuildFlags
@@ -293,6 +294,7 @@ haddockToBuildFlags f =
293294
, buildDistPref = haddockDistPref f
294295
}
295296
#endif
297+
{- FOURMOLU_ENABLE -}
296298

297299
data Name = NameLib (Maybe String) | NameExe String deriving (Eq, Show)
298300

@@ -331,6 +333,7 @@ data Component = Component Name [String] [String] [String]
331333
generateBuildModule
332334
:: String -- ^ doctests test-suite name
333335
-> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
336+
{- FOURMOLU_DISABLE -}
334337
generateBuildModule testSuiteName flags pkg lbi = do
335338
let verbosity = fromFlag (buildVerbosity flags)
336339
let distPref = fromFlag (buildDistPref flags)
@@ -581,6 +584,7 @@ generateBuildModule testSuiteName flags pkg lbi = do
581584
#else
582585
executableName = exeName
583586
#endif
587+
{- FOURMOLU_ENABLE -}
584588

585589
-- | In compat settings it's better to omit the type-signature
586590
testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo

Cabal-tests/tests/custom-setup/IdrisSetup.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,14 @@ idrisCmd local = Px.joinPath $ splitDirectories $ ".." Px.</> ".." Px.</> bd Px.
9292
#else
9393
idrisCmd local = ".." </> ".." </> bd </> "idris" </> "idris"
9494
#endif
95+
{- FOURMOLU_DISABLE -}
9596
where
9697
bd =
9798
#if MIN_VERSION_Cabal(3,11,0)
9899
getSymbolicPath $
99100
#endif
100101
buildDir local
102+
{- FOURMOLU_ENABLE -}
101103

102104
-- -----------------------------------------------------------------------------
103105
-- Make Commands
@@ -223,6 +225,7 @@ generateToolchainModule verbosity srcDir toolDir = do
223225
createDirectoryIfMissingVerbose verbosity True srcDir
224226
rewriteFileEx verbosity toolPath (commonContent ++ toolContent)
225227

228+
{- FOURMOLU_DISABLE -}
226229
idrisConfigure _ flags pkgdesc local = do
227230
configureRTS
228231
withLibLBI pkgdesc local $ \_ libcfg -> do
@@ -256,6 +259,7 @@ idrisConfigure _ flags pkgdesc local = do
256259
#if !(MIN_VERSION_Cabal(2,0,0))
257260
autogenComponentModulesDir lbi _ = autogenModulesDir lbi
258261
#endif
262+
{- FOURMOLU_ENABLE -}
259263

260264
#if !MIN_VERSION_Cabal(3,0,0)
261265
idrisPreSDist args flags = do
@@ -372,6 +376,7 @@ idrisInstall verbosity copy pkg local
372376
-- We want it to be the install directory where we put the idris libraries.
373377
fixPkg pkg target = pkg { dataDir = target }
374378

379+
{- FOURMOLU_DISABLE -}
375380
idrisTestHook args pkg local hooks flags = do
376381
let target =
377382
#if MIN_VERSION_Cabal(3,11,0)
@@ -403,3 +408,4 @@ main = defaultMainWithHooks $ simpleUserHooks
403408
#endif
404409
, testHook = idrisTestHook
405410
}
411+
{- FOURMOLU_ENABLE -}

Makefile

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,45 @@ init: ## Set up git hooks and ignored revisions.
2727
@git config core.hooksPath .githooks
2828
## TODO
2929

30+
# NOTE: Keep this in sync with `.github/workflows/format.yml`.
31+
FORMAT_DIRS := \
32+
Cabal \
33+
Cabal-syntax \
34+
cabal-install \
35+
cabal-validate
36+
37+
FORMAT_DIRS_TODO := \
38+
Cabal-QuickCheck \
39+
Cabal-described \
40+
Cabal-hooks \
41+
Cabal-tests \
42+
Cabal-tree-diff \
43+
bootstrap \
44+
buildinfo-reference-generator \
45+
cabal-benchmarks \
46+
cabal-dev-scripts \
47+
cabal-install-solver \
48+
cabal-testsuite/main \
49+
cabal-testsuite/src \
50+
cabal-testsuite/static \
51+
solver-benchmarks
52+
53+
.PHONY: style-todo
54+
style-todo: ## Configured for fourmolu, avoiding GHC parser failures
55+
@fourmolu -q $(FORMAT_DIRS_TODO) > /dev/null
56+
3057
.PHONY: style
3158
style: ## Run the code styler.
32-
@fourmolu -q -i Cabal Cabal-syntax cabal-install cabal-validate
59+
@fourmolu -q -i $(FORMAT_DIRS)
3360

3461
.PHONY: style-modified
3562
style-modified: ## Run the code styler on modified files.
36-
@git ls-files --modified Cabal Cabal-syntax cabal-install cabal-validate \
63+
@git ls-files --modified $(FORMAT_DIRS) \
3764
| grep '.hs$$' | xargs -P $(PROCS) -I {} fourmolu -q -i {}
3865

3966
.PHONY: style-commit
4067
style-commit: ## Run the code styler on the previous commit.
41-
@git diff --name-only HEAD $(COMMIT) Cabal Cabal-syntax cabal-install cabal-validate \
68+
@git diff --name-only HEAD $(COMMIT) -- $(FORMAT_DIRS) \
4269
| grep '.hs$$' | xargs -P $(PROCS) -I {} fourmolu -q -i {}
4370

4471
.PHONY: whitespace

cabal-install-solver/src/Distribution/Solver/Modular/Solver.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ solve sc cinfo idx pkgConfigDB userPrefs userConstraints userGoals =
171171
--
172172
-- This only does something if the @debug-tracetree@ configure argument was
173173
-- given; otherwise this is just the identity function.
174+
{- FOURMOLU_DISABLE -}
174175
traceTree ::
175176
#ifdef DEBUG_TRACETREE
176177
GSimpleTree a =>
@@ -183,6 +184,7 @@ traceTree = gtraceJson
183184
#else
184185
traceTree _ _ = id
185186
#endif
187+
{- FOURMOLU_ENABLE -}
186188

187189
#ifdef DEBUG_TRACETREE
188190
instance GSimpleTree (Tree d c) where

cabal-testsuite/src/Test/Cabal/Server.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ startServer chan senv = do
253253

254254
-- | Unmasked initialization for the server
255255
initServer :: Server -> IO Server
256+
{- FOURMOLU_DISABLE -}
256257
initServer s0 = do
257258
-- NB: withProcessHandle reads an MVar and is interruptible
258259

@@ -275,6 +276,7 @@ initServer s0 = do
275276
write s ":set prompt \"\""
276277
write s "System.IO.hSetBuffering System.IO.stdout System.IO.LineBuffering"
277278
return s
279+
{- FOURMOLU_ENABLE -}
278280

279281
-- | Stop a GHCi session.
280282
stopServer :: Server -> IO ()

0 commit comments

Comments
 (0)