summaryrefslogtreecommitdiffhomepage
path: root/test/Xmobar/Plugins/Monitors/CpuSpec.hs
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2026-06-27 19:02:45 +0100
committerjao <jao@gnu.org>2026-06-27 19:02:45 +0100
commitde4f90a255e6b5f0034f7c380a034a695b77ea70 (patch)
tree020e51fae2ba974cc617a79b872359038149444b /test/Xmobar/Plugins/Monitors/CpuSpec.hs
parent3ed2f052a50731aea7bd2a538c3db898b5b15d7f (diff)
downloadxmobar-de4f90a255e6b5f0034f7c380a034a695b77ea70.tar.gz
xmobar-de4f90a255e6b5f0034f7c380a034a695b77ea70.tar.bz2
even better fix for CPU template test
Diffstat (limited to 'test/Xmobar/Plugins/Monitors/CpuSpec.hs')
-rw-r--r--test/Xmobar/Plugins/Monitors/CpuSpec.hs13
1 files changed, 3 insertions, 10 deletions
diff --git a/test/Xmobar/Plugins/Monitors/CpuSpec.hs b/test/Xmobar/Plugins/Monitors/CpuSpec.hs
index 1af0790..c8d7867 100644
--- a/test/Xmobar/Plugins/Monitors/CpuSpec.hs
+++ b/test/Xmobar/Plugins/Monitors/CpuSpec.hs
@@ -6,20 +6,13 @@ module Xmobar.Plugins.Monitors.CpuSpec
import Test.Hspec
import Xmobar.Plugins.Monitors.Common
import Xmobar.Plugins.Monitors.Cpu
+
import Data.List
+import Text.Regex.TDFA((=~))
main :: IO ()
main = hspec spec
-remove :: String -> String -> String
-remove w "" = ""
-remove w s@(c:cs)
- | w `isPrefixOf` s = remove w (drop (length w) s)
- | otherwise = c : remove w cs
-
-remtags :: String -> String
-remtags = remove "<fc=red>" . remove "<fc=green>" . remove "</fc>"
-
spec :: Spec
spec =
describe "CPU Spec" $ do
@@ -32,7 +25,7 @@ spec =
do let args = ["-L","3","-H","50","--normal","green","--high","red", "-t", "Cpu: <total>% <bar>"]
cpuArgs <- getArguments args
cpuValue <- runCpu cpuArgs
- cpuValue `shouldSatisfy` (all (`elem` ":#") . remtags . last . words)
+ cpuValue `shouldSatisfy` ((=~ "((<fc=(green|red)>)?#+(</fc>)?)?:*") . last . words)
it "works with no icon pattern template" $
do let args = ["-L","3","-H","50","--normal","green","--high","red", "-t", "Cpu: <total>% <bar>", "--", "--load-icon-pattern", "<icon=bright_%%.xpm/>"]
cpuArgs <- getArguments args