Created
May 17, 2024 12:45
-
-
Save mpickering/353d96513ead6e319e6d8cfaaef74efa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Test.Cabal.Prelude | |
import Data.List | |
data BuildWay = StaticWay | DynWay | ProfWay | ProfDynWay | |
deriving (Eq, Ord, Show, Read, Enum) | |
-- Test building with profiling shared support | |
main = do | |
setupTest $ recordMode DoNotRecord $ do | |
let analyse_result expected r = do | |
let ls = lines (resultOutput r) | |
library_prefix = "Wanted build ways(True): " | |
executable_prefix = "Wanted build ways(False): " | |
get_ways prefix = map (drop (length prefix)) (filter (prefix `isPrefixOf`) ls) | |
library_ways = read_ways (get_ways library_prefix) | |
executable_ways = read_ways (get_ways executable_prefix) | |
read_ways raw_ways = | |
case raw_ways of | |
-- There should only be one | |
[x] -> read @[BuildWay] x | |
-- Unless there are none, when we don't built the executable for example | |
[] -> [] | |
xs -> error "Unexpected number of log lines" | |
way = (library_ways, executable_ways) | |
unless (expected == way) $ | |
assertFailure $ "Expected:" ++ show expected ++ "\n" ++ "Got:" ++ show way | |
requireSuccess r | |
let run_test args expected = do | |
setup "configure" args | |
res <- setup' "build" [] | |
analyse_result expected res | |
setup "clean" [] | |
has_shared <- hasProfiledSharedLibraries | |
run_test [] | |
([StaticWay, DynWay], [StaticWay]) | |
run_test ["--disable-library-vanilla", "--enable-executable-dynamic"] | |
([DynWay], [DynWay]) | |
run_test ["--enable-profiling-shared"] | |
(if has_shared | |
then ([StaticWay, DynWay, ProfDynWay], [StaticWay]) | |
else ([StaticWay, DynWay, ProfWay], [StaticWay])) | |
run_test ["--enable-profiling-shared", "--enable-executable-dynamic"] | |
(if has_shared | |
then ([StaticWay, DynWay, ProfDynWay], [DynWay]) | |
else ([StaticWay, DynWay, ProfWay], [DynWay])) | |
run_test ["--enable-executable-dynamic", "--disable-library-vanilla"] | |
([DynWay], [DynWay]) | |
run_test ["--enable-profiling"] | |
([StaticWay, DynWay, ProfWay], [ProfWay]) | |
run_test ["--enable-executable-profiling"] | |
([StaticWay, DynWay, ProfWay], [ProfWay]) | |
run_test ["--enable-executable-profiling", "--enable-executable-dynamic"] | |
(if has_shared | |
then | |
([StaticWay, DynWay, ProfDynWay], [ProfDynWay]) | |
else | |
([StaticWay, DynWay, ProfWay], [ProfWay])) | |
run_test ["--enable-profiling", "--enable-executable-dynamic"] | |
(if has_shared | |
then | |
([StaticWay, DynWay, ProfDynWay], [ProfDynWay]) | |
else | |
([StaticWay, DynWay, ProfWay], [ProfWay])) | |
--v dyn p (p exe) | |
run_test ["--enable-library-profiling", "--enable-executable-profiling"] | |
([StaticWay, DynWay, ProfWay], [ProfWay]) | |
run_test ["prof-shared", "--enable-profiling-shared", "--disable-library-vanilla", "--disable-shared"] | |
(if has_shared | |
then ([ProfDynWay], []) | |
else ([ProfWay], [])) | |
-- p p_dyn | |
run_test ["prof-shared", "--enable-profiling-shared", "--enable-library-profiling", "--disable-library-vanilla", "--disable-shared"] | |
(if has_shared | |
then ([ProfWay, ProfDynWay], []) | |
else ([ProfWay], [])) | |
-- v p p_dyn | |
run_test ["prof-shared","--enable-profiling-shared", "--enable-library-profiling", "--enable-library-vanilla", "--disable-shared"] | |
(if has_shared | |
then ([StaticWay, ProfWay, ProfDynWay], []) | |
else ([StaticWay, ProfWay], [])) | |
-- v dyn p p_dyn | |
run_test ["prof-shared", "--enable-profiling-shared", "--enable-library-profiling", "--enable-library-vanilla", "--enable-shared"] | |
(if has_shared | |
then ([StaticWay, DynWay, ProfWay, ProfDynWay], []) | |
else ([StaticWay, DynWay, ProfWay], [])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment