From 147fd319bac02198886be8bec16844f877899a9b Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 11 Mar 2013 15:34:59 +0100 Subject: [PATCH] Expand TestHelper to allow non-underscore prefixes HLint 1.8.28 requires us to always add "ignore CamelCase", which can be problematic sometimes (e.g. when using OverloadedStrings). Let's expand TestHelper to also support less-standard 'caseFooBar' names, so that we can remove the annotations. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Helga Velroyen <helgav@google.com> --- test/hs/Test/Ganeti/TestHelper.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/hs/Test/Ganeti/TestHelper.hs b/test/hs/Test/Ganeti/TestHelper.hs index 4f3020587..e600026c4 100644 --- a/test/hs/Test/Ganeti/TestHelper.hs +++ b/test/hs/Test/Ganeti/TestHelper.hs @@ -6,7 +6,7 @@ {- -Copyright (C) 2011, 2012 Google Inc. +Copyright (C) 2011, 2012, 2013 Google Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -48,6 +48,10 @@ propPrefix = "prop_" casePrefix :: String casePrefix = "case_" +-- | Test case prefix without underscore. +case2Pfx :: String +case2Pfx = "case" + -- | Tries to drop a prefix from a string. simplifyName :: String -> String -> String simplifyName pfx string = fromMaybe string (stripPrefix pfx string) @@ -70,6 +74,8 @@ run name = in case () of _ | propPrefix `isPrefixOf` str -> [| runProp $strE $nameE |] | casePrefix `isPrefixOf` str -> [| runCase $strE $nameE |] + | case2Pfx `isPrefixOf` str -> + [| (testCase . simplifyName case2Pfx) $strE $nameE |] | otherwise -> fail $ "Unsupported test function name '" ++ str ++ "'" -- | Convert slashes in a name to underscores. -- GitLab