Skip to content

Commit e48386c

Browse files
authored
Merge pull request #8763 from haskell/Show-TestEnv
cabal-testsuite: new `instance Show TestEnv`
2 parents 90a2f33 + 6885fa7 commit e48386c

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@ runTestM mode m = withSystemTempDirectory "cabal-testsuite" $ \tmp_dir -> do
336336
testPlan = Nothing,
337337
testRecordDefaultMode = DoNotRecord,
338338
testRecordUserMode = Nothing,
339-
testRecordNormalizer = id,
340339
testSourceCopyRelativeDir = "source"
341340
}
342341
let go = do cleanup
@@ -527,12 +526,11 @@ data TestEnv = TestEnv
527526
, testRecordDefaultMode :: RecordMode
528527
-- | User explicitly set record mode. Not implemented ATM.
529528
, testRecordUserMode :: Maybe RecordMode
530-
-- | Function to normalize recorded output
531-
, testRecordNormalizer :: String -> String
532529
-- | Name of the subdirectory we copied the test's sources to,
533530
-- relative to 'testSourceDir'
534531
, testSourceCopyRelativeDir :: FilePath
535532
}
533+
deriving Show
536534

537535
testRecordMode :: TestEnv -> RecordMode
538536
testRecordMode env = fromMaybe (testRecordDefaultMode env) (testRecordUserMode env)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,27 @@ import Control.Monad
1919

2020
-- TODO: index this
2121
data Plan = Plan { planInstallPlan :: [InstallItem] }
22+
deriving Show
2223

2324
data InstallItem
2425
= APreExisting
2526
| AConfiguredGlobal ConfiguredGlobal
2627
| AConfiguredInplace ConfiguredInplace
28+
deriving Show
2729

2830
-- local or inplace package
2931
data ConfiguredInplace = ConfiguredInplace
3032
{ configuredInplaceDistDir :: FilePath
3133
, configuredInplaceBuildInfo :: Maybe FilePath
3234
, configuredInplacePackageName :: PackageName
3335
, configuredInplaceComponentName :: Maybe ComponentName }
36+
deriving Show
3437

3538
data ConfiguredGlobal = ConfiguredGlobal
3639
{ configuredGlobalBinFile :: Maybe FilePath
3740
, configuredGlobalPackageName :: PackageName
3841
, configuredGlobalComponentName :: Maybe ComponentName }
42+
deriving Show
3943

4044
instance FromJSON Plan where
4145
parseJSON (Object v) = fmap Plan (v .: "install-plan")

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ recordHeader args = do
679679
env <- getTestEnv
680680
let mode = testRecordMode env
681681
str_header = "# " ++ intercalate " " args ++ "\n"
682-
header = C.pack (testRecordNormalizer env str_header)
682+
header = C.pack str_header
683683
case mode of
684684
DoNotRecord -> return ()
685685
_ -> do
@@ -696,7 +696,7 @@ recordLog res = do
696696
liftIO $ C.appendFile (testWorkDir env </> "test.log")
697697
(C.pack $ "+ " ++ resultCommand res ++ "\n"
698698
++ resultOutput res ++ "\n\n")
699-
liftIO . C.appendFile (testActualFile env) . C.pack . testRecordNormalizer env $
699+
liftIO . C.appendFile (testActualFile env) . C.pack $
700700
case mode of
701701
RecordAll -> unlines (lines (resultOutput res))
702702
RecordMarked -> getMarkedOutput (resultOutput res)
@@ -787,10 +787,6 @@ recordMode mode = withReaderT (\env -> env {
787787
testRecordUserMode = Just mode
788788
})
789789

790-
recordNormalizer :: (String -> String) -> TestM a -> TestM a
791-
recordNormalizer f =
792-
withReaderT (\env -> env { testRecordNormalizer = testRecordNormalizer env . f })
793-
794790
assertOutputContains :: MonadIO m => WithCallStack (String -> Result -> m ())
795791
assertOutputContains needle result =
796792
withFrozenCallStack $

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ data ScriptEnv = ScriptEnv
3737
, runnerPackages :: [(OpenUnitId, ModuleRenaming)]
3838
, runnerWithSharedLib :: Bool
3939
}
40+
deriving Show
4041

4142
{-
4243

0 commit comments

Comments
 (0)