-
Notifications
You must be signed in to change notification settings - Fork 86
/
Cabal2201-allow-test-wrapper.patch
72 lines (68 loc) · 3.56 KB
/
Cabal2201-allow-test-wrapper.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
diff --git a/Distribution/Simple/Setup.hs b/Distribution/Simple/Setup.hs
index 5fa0e99..fc429b6 100644
--- a/Distribution/Simple/Setup.hs
+++ b/Distribution/Simple/Setup.hs
@@ -1919,6 +1919,7 @@ data TestFlags = TestFlags {
testMachineLog :: Flag PathTemplate,
testShowDetails :: Flag TestShowDetails,
testKeepTix :: Flag Bool,
+ testWrapper :: Flag FilePath,
-- TODO: think about if/how options are passed to test exes
testOptions :: [PathTemplate]
} deriving (Generic)
@@ -1931,6 +1932,7 @@ defaultTestFlags = TestFlags {
testMachineLog = toFlag $ toPathTemplate $ "$pkgid.log",
testShowDetails = toFlag Failures,
testKeepTix = toFlag False,
+ testWrapper = NoFlag,
testOptions = []
}
@@ -1991,6 +1993,11 @@ testCommand = CommandUI
"keep .tix files for HPC between test runs"
testKeepTix (\v flags -> flags { testKeepTix = v})
trueArg
+ , option [] ["test-wrapper"]
+ "Run test through a wrapper."
+ testWrapper (\v flags -> flags { testWrapper = v })
+ (reqArg' "FILE" (toFlag :: FilePath -> Flag FilePath)
+ (pure . fromFlag :: Flag FilePath -> [FilePath]))
, option [] ["test-options"]
("give extra options to test executables "
++ "(name templates can use $pkgid, $compiler, "
diff --git a/Distribution/Simple/Test/ExeV10.hs b/Distribution/Simple/Test/ExeV10.hs
index 707ab74..87bfefe 100644
--- a/Distribution/Simple/Test/ExeV10.hs
+++ b/Distribution/Simple/Test/ExeV10.hs
@@ -98,7 +98,12 @@ runTest pkg_descr lbi clbi flags suite = do
return (addLibraryPath os paths shellEnv)
else return shellEnv
- exit <- rawSystemIOWithEnv verbosity cmd opts Nothing (Just shellEnv')
+ exit <- case testWrapper flags of
+ Flag path -> rawSystemIOWithEnv verbosity path (cmd:opts) Nothing (Just shellEnv')
+ -- these handles are automatically closed
+ Nothing (Just wOut) (Just wErr)
+
+ NoFlag -> rawSystemIOWithEnv verbosity cmd opts Nothing (Just shellEnv')
-- these handles are automatically closed
Nothing (Just wOut) (Just wErr)
diff --git a/Distribution/Simple/Test/LibV09.hs b/Distribution/Simple/Test/LibV09.hs
index 861e91a..66316fa 100644
--- a/Distribution/Simple/Test/LibV09.hs
+++ b/Distribution/Simple/Test/LibV09.hs
@@ -99,9 +99,14 @@ runTest pkg_descr lbi clbi flags suite = do
cpath <- canonicalizePath $ LBI.componentBuildDir lbi clbi
return (addLibraryPath os (cpath : paths) shellEnv)
else return shellEnv
- createProcessWithEnv verbosity cmd opts Nothing (Just shellEnv')
- -- these handles are closed automatically
- CreatePipe (UseHandle wOut) (UseHandle wOut)
+ case testWrapper flags of
+ Flag path -> createProcessWithEnv verbosity path (cmd:opts) Nothing (Just shellEnv')
+ -- these handles are closed automatically
+ CreatePipe (UseHandle wOut) (UseHandle wOut)
+
+ NoFlag -> createProcessWithEnv verbosity cmd opts Nothing (Just shellEnv')
+ -- these handles are closed automatically
+ CreatePipe (UseHandle wOut) (UseHandle wOut)
hPutStr wIn $ show (tempLog, PD.testName suite)
hClose wIn