diff options
| author | jao <jao@gnu.org> | 2026-06-27 18:49:18 +0100 |
|---|---|---|
| committer | jao <jao@gnu.org> | 2026-06-27 18:49:18 +0100 |
| commit | 3ed2f052a50731aea7bd2a538c3db898b5b15d7f (patch) | |
| tree | eb91d853351e4cf9989880fb24cc3964d0778499 /test/Xmobar/Plugins/Monitors/CpuSpec.hs | |
| parent | 618cb5c03aad37835725fce8e07d09ce0fa70c2a (diff) | |
| download | xmobar-3ed2f052a50731aea7bd2a538c3db898b5b15d7f.tar.gz xmobar-3ed2f052a50731aea7bd2a538c3db898b5b15d7f.tar.bz2 | |
better fix for CPU template for testing
Diffstat (limited to 'test/Xmobar/Plugins/Monitors/CpuSpec.hs')
| -rw-r--r-- | test/Xmobar/Plugins/Monitors/CpuSpec.hs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/test/Xmobar/Plugins/Monitors/CpuSpec.hs b/test/Xmobar/Plugins/Monitors/CpuSpec.hs index d3155ef..1af0790 100644 --- a/test/Xmobar/Plugins/Monitors/CpuSpec.hs +++ b/test/Xmobar/Plugins/Monitors/CpuSpec.hs @@ -11,6 +11,15 @@ import Data.List 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 @@ -21,9 +30,9 @@ spec = cpuValue `shouldSatisfy` (\item -> "Cpu:" `isPrefixOf` item) it "works with bar template" $ do let args = ["-L","3","-H","50","--normal","green","--high","red", "-t", "Cpu: <total>% <bar>"] - cpuArgs <- getArguments $ map (filter ('#' /=)) args + cpuArgs <- getArguments args cpuValue <- runCpu cpuArgs - cpuValue `shouldSatisfy` (all (`elem` ":#") . last . words) + cpuValue `shouldSatisfy` (all (`elem` ":#") . remtags . 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 |
