-
Notifications
You must be signed in to change notification settings - Fork 701
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
876ff3f
commit 3da7b30
Showing
1 changed file
with
131 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import Test.Cabal.Prelude | ||
import Data.List | ||
import Data.Bifunctor | ||
|
||
data BuildWay = StaticWay | DynWay | ProfWay | ProfDynWay | ||
deriving (Eq, Ord, Show, Read, Enum) | ||
|
||
-- Test building with profiling shared support | ||
main = 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 (bimap sort sort expected == bimap sort sort way) $ | ||
assertFailure $ "Expected:" ++ show expected ++ "\n" ++ "Got:" ++ show way | ||
|
||
requireSuccess r | ||
setupTest $ recordMode DoNotRecord $ do | ||
|
||
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], [])) | ||
|
||
|
||
let run_cabal_test args expected = cabalTest $ recordMode DoNotRecord $ do | ||
res <- cabal' "v2-build" args | ||
void $ analyse_result expected res | ||
|
||
run_cabal_test ["--disable-shared"] ([StaticWay], [StaticWay]) | ||
run_cabal_test ["--disable-shared", "--disable-executable-dynamic"] ([StaticWay], [StaticWay]) | ||
run_cabal_test ["--enable-shared"] ([DynWay, StaticWay], [StaticWay]) | ||
run_cabal_test ["--enable-executable-dynamic"] ([DynWay, StaticWay], [DynWay]) | ||
run_cabal_test ["--enable-shared", "--disable-library-vanilla", "--enable-executable-dynamic"] ([DynWay], [DynWay]) | ||
|
||
run_cabal_test ["--disable-shared", "--disable-library-vanilla", "--enable-profiling"] ([ProfWay], [ProfWay]) | ||
|
||
run_cabal_test ["--disable-shared", "--enable-profiling"] ([ProfWay, StaticWay], [ProfWay]) |