From 12548bae3d8feecce6a322162d91b827289ae824 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 5 Dec 2015 17:52:43 -0400 Subject: UncheckedProperty for cmdProperty et al * Properties that run an arbitrary command, such as cmdProperty and scriptProperty are converted to use UncheckedProperty, since they cannot tell on their own if the command truely made a change or not. (API Change) Transition guide: - When GHC complains about an UncheckedProperty, add: `assume` MadeChange - Since these properties used to always return MadeChange, that change is always safe to make. - Or, if you know that the command should modifiy a file, use: `changesFile` filename * A few properties have had their Result improved, for example Apt.buldDep and Apt.autoRemove now check if a change was made or not. --- src/Propellor/Types/ResultCheck.hs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/Propellor/Types/ResultCheck.hs') diff --git a/src/Propellor/Types/ResultCheck.hs b/src/Propellor/Types/ResultCheck.hs index 6c2e1453..590d4ab9 100644 --- a/src/Propellor/Types/ResultCheck.hs +++ b/src/Propellor/Types/ResultCheck.hs @@ -5,6 +5,7 @@ module Propellor.Types.ResultCheck ( unchecked, checkResult, Checkable, + assume, ) where import Propellor.Types @@ -51,3 +52,15 @@ instance Checkable Property i where instance Checkable UncheckedProperty i where checkedProp (UncheckedProperty p) = p + +-- | Sometimes it's not practical to test if a property made a change. +-- In such a case, it's often fine to say: +-- +-- > someprop `assume` MadeChange +-- +-- However, beware assuming `NoChange`, as that will make combinators +-- like `onChange` not work. +assume :: UncheckedProperty i -> Result -> Property i +assume (UncheckedProperty p) result = adjustPropertySatisfy (checkedProp p) $ \satisfy -> do + r <- satisfy + return (r <> result) -- cgit v1.2.3