Add a test for HPC with a literate source file in a subdirectory
authorSimon Marlow <marlowsd@gmail.com>
Thu, 24 Nov 2011 13:55:20 +0000 (13:55 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Thu, 24 Nov 2011 14:08:06 +0000 (14:08 +0000)
tests/function/subdir/tough.lhs [new file with mode: 0644]
tests/function/subdir/tough2.lhs [new file with mode: 0644]
tests/function/subdir/tough2.stdout [new file with mode: 0644]
tests/function/test.T
tests/hpcrun.pl

diff --git a/tests/function/subdir/tough.lhs b/tests/function/subdir/tough.lhs
new file mode 100644 (file)
index 0000000..248bfe9
--- /dev/null
@@ -0,0 +1,49 @@
+\begin{code}
+import Control.Exception as E
+
+-- This test shows what hpc can really do.
+
+main = do
+  print ("Hello")
+  foo "Hello"
+  E.catch (print (badCase 22 44))
+          (\ e -> print (e :: E.ErrorCall))
+  E.catch (print (badCase 22 (error "Foo")))
+          (\ e -> print (e :: E.ErrorCall))
+  E.catch (print "Bark")
+          (\ e -> print (e :: E.ErrorCall))
+  (_,_) <- return $ ("Hello","World")
+  return ()
+  () <- return ()
+  t <- case () of
+    _ | otherwoz -> return "Hello"
+    _             -> error "Bad Thing Happened"
+  t <- case () of
+    _ | otherwise -> return "Hello"
+    _              -> error "Bad Thing Happened"
+  t <- case () of
+    _ | otherwise 
+      , False      -> error "Bad Thing Happened"
+    _              -> return "Hello"
+  print t
+  print foo2
+
+foo x = do
+  print x
+  return ()
+
+unused_ a = a
+
+badCase :: Int -> Int -> Int
+badCase a b = 
+        if a > 100 
+        then error "badCase" 
+        else if a > 1000 
+             then 1 
+             else badCase (a + 1) (b - 1)
+
+
+foo2 = (1,2, if True then 3 else 4)
+
+otherwoz = True
+\end{code}
diff --git a/tests/function/subdir/tough2.lhs b/tests/function/subdir/tough2.lhs
new file mode 100644 (file)
index 0000000..248bfe9
--- /dev/null
@@ -0,0 +1,49 @@
+\begin{code}
+import Control.Exception as E
+
+-- This test shows what hpc can really do.
+
+main = do
+  print ("Hello")
+  foo "Hello"
+  E.catch (print (badCase 22 44))
+          (\ e -> print (e :: E.ErrorCall))
+  E.catch (print (badCase 22 (error "Foo")))
+          (\ e -> print (e :: E.ErrorCall))
+  E.catch (print "Bark")
+          (\ e -> print (e :: E.ErrorCall))
+  (_,_) <- return $ ("Hello","World")
+  return ()
+  () <- return ()
+  t <- case () of
+    _ | otherwoz -> return "Hello"
+    _             -> error "Bad Thing Happened"
+  t <- case () of
+    _ | otherwise -> return "Hello"
+    _              -> error "Bad Thing Happened"
+  t <- case () of
+    _ | otherwise 
+      , False      -> error "Bad Thing Happened"
+    _              -> return "Hello"
+  print t
+  print foo2
+
+foo x = do
+  print x
+  return ()
+
+unused_ a = a
+
+badCase :: Int -> Int -> Int
+badCase a b = 
+        if a > 100 
+        then error "badCase" 
+        else if a > 1000 
+             then 1 
+             else badCase (a + 1) (b - 1)
+
+
+foo2 = (1,2, if True then 3 else 4)
+
+otherwoz = True
+\end{code}
diff --git a/tests/function/subdir/tough2.stdout b/tests/function/subdir/tough2.stdout
new file mode 100644 (file)
index 0000000..b840932
--- /dev/null
@@ -0,0 +1,160 @@
+"Hello"\r
+"Hello"\r
+badCase\r
+badCase\r
+"Bark"\r
+"Hello"\r
+(1,2,3)\r
+\r
+\r
+ 71% expressions used (68/95)\r
+ 14% boolean coverage (1/7)\r
+       0% guards (0/4), 3 always True, 1 always False\r
+      33% 'if' conditions (1/3), 1 always True, 1 always False\r
+     100% qualifiers (0/0)\r
+ 58% alternatives used (7/12)\r
+100% local declarations used (0/0)\r
+ 83% top-level declarations used (5/6)\r
+\r
+\r
+-----<module Main>-----\r
+ 71% expressions used (68/95)\r
+ 14% boolean coverage (1/7)\r
+       0% guards (0/4), 3 always True, 1 always False\r
+      33% 'if' conditions (1/3), 1 always True, 1 always False\r
+     100% qualifiers (0/0)\r
+ 58% alternatives used (7/12)\r
+100% local declarations used (0/0)\r
+ 83% top-level declarations used (5/6)\r
+\r
+\r
+Writing: Main.hs.html\r
+<html><style type="text/css">\r
+span.lineno { color: white; background: #aaaaaa; border-right: solid white 12px }\r
+span.nottickedoff { background: yellow}\r
+span.istickedoff { background: white }\r
+span.tickonlyfalse { margin: -1px; border: 1px solid #f20913; background: #f20913 }\r
+span.tickonlytrue  { margin: -1px; border: 1px solid #60de51; background: #60de51 }\r
+span.funcount { font-size: small; color: orange; z-index: 2; position: absolute; right: 20 }\r
+span.decl { font-weight: bold }\r
+span.spaces    { background: white }\r
+</style>\r
+<pre>\r
+<span class="lineno">    1 </span>\begin{code}\r
+<span class="lineno">    2 </span>import Control.Exception as E\r
+<span class="lineno">    3 </span>\r
+<span class="lineno">    4 </span>-- This test shows what hpc can really do.\r
+<span class="lineno">    5 </span>\r
+<span class="lineno">    6 </span><span class="decl"><span class="istickedoff">main = do</span>\r
+<span class="lineno">    7 </span><span class="spaces">  </span><span class="istickedoff">print (&quot;Hello&quot;)</span>\r
+<span class="lineno">    8 </span><span class="spaces">  </span><span class="istickedoff">foo &quot;Hello&quot;</span>\r
+<span class="lineno">    9 </span><span class="spaces">  </span><span class="istickedoff">E.catch (print (badCase 22 <span class="nottickedoff">44</span>))</span>\r
+<span class="lineno">   10 </span><span class="spaces">          </span><span class="istickedoff">(\ e -&gt; print (e :: E.ErrorCall))</span>\r
+<span class="lineno">   11 </span><span class="spaces">  </span><span class="istickedoff">E.catch (print (badCase 22 <span class="nottickedoff">(error &quot;Foo&quot;)</span>))</span>\r
+<span class="lineno">   12 </span><span class="spaces">          </span><span class="istickedoff">(\ e -&gt; print (e :: E.ErrorCall))</span>\r
+<span class="lineno">   13 </span><span class="spaces">  </span><span class="istickedoff">E.catch (print &quot;Bark&quot;)</span>\r
+<span class="lineno">   14 </span><span class="spaces">          </span><span class="istickedoff"><span class="nottickedoff">(\ e -&gt; print (e :: E.ErrorCall))</span></span>\r
+<span class="lineno">   15 </span><span class="spaces">  </span><span class="istickedoff">(_,_) &lt;- return $ (<span class="nottickedoff">&quot;Hello&quot;</span>,<span class="nottickedoff">&quot;World&quot;</span>)</span>\r
+<span class="lineno">   16 </span><span class="spaces">  </span><span class="istickedoff">return <span class="nottickedoff">()</span></span>\r
+<span class="lineno">   17 </span><span class="spaces">  </span><span class="istickedoff">() &lt;- return ()</span>\r
+<span class="lineno">   18 </span><span class="spaces">  </span><span class="istickedoff">t &lt;- case <span class="nottickedoff">()</span> of</span>\r
+<span class="lineno">   19 </span><span class="spaces">    </span><span class="istickedoff">_ | <span class="tickonlytrue">otherwoz</span> -&gt; return <span class="nottickedoff">&quot;Hello&quot;</span></span>\r
+<span class="lineno">   20 </span><span class="spaces">    </span><span class="istickedoff">_             -&gt; <span class="nottickedoff">error &quot;Bad Thing Happened&quot;</span></span>\r
+<span class="lineno">   21 </span><span class="spaces">  </span><span class="istickedoff">t &lt;- case <span class="nottickedoff">()</span> of</span>\r
+<span class="lineno">   22 </span><span class="spaces">    </span><span class="istickedoff">_ | <span class="tickonlytrue">otherwise</span> -&gt; return <span class="nottickedoff">&quot;Hello&quot;</span></span>\r
+<span class="lineno">   23 </span><span class="spaces">    </span><span class="istickedoff">_              -&gt; <span class="nottickedoff">error &quot;Bad Thing Happened&quot;</span></span>\r
+<span class="lineno">   24 </span><span class="spaces">  </span><span class="istickedoff">t &lt;- case <span class="nottickedoff">()</span> of</span>\r
+<span class="lineno">   25 </span><span class="spaces">    </span><span class="istickedoff">_ | <span class="tickonlytrue">otherwise</span> </span>\r
+<span class="lineno">   26 </span><span class="spaces">      </span><span class="istickedoff">, <span class="tickonlyfalse">False</span>      -&gt; <span class="nottickedoff">error &quot;Bad Thing Happened&quot;</span></span>\r
+<span class="lineno">   27 </span><span class="spaces">    </span><span class="istickedoff">_              -&gt; return &quot;Hello&quot;</span>\r
+<span class="lineno">   28 </span><span class="spaces">  </span><span class="istickedoff">print t</span>\r
+<span class="lineno">   29 </span><span class="spaces">  </span><span class="istickedoff">print foo2</span></span>\r
+<span class="lineno">   30 </span>\r
+<span class="lineno">   31 </span><span class="decl"><span class="istickedoff">foo x = do</span>\r
+<span class="lineno">   32 </span><span class="spaces">  </span><span class="istickedoff">print x</span>\r
+<span class="lineno">   33 </span><span class="spaces">  </span><span class="istickedoff">return <span class="nottickedoff">()</span></span></span>\r
+<span class="lineno">   34 </span>\r
+<span class="lineno">   35 </span><span class="decl"><span class="nottickedoff">unused_ a = a</span></span>\r
+<span class="lineno">   36 </span>\r
+<span class="lineno">   37 </span>badCase :: Int -&gt; Int -&gt; Int\r
+<span class="lineno">   38 </span><span class="decl"><span class="istickedoff">badCase a b = </span>\r
+<span class="lineno">   39 </span><span class="spaces">        </span><span class="istickedoff">if a &gt; 100 </span>\r
+<span class="lineno">   40 </span><span class="spaces">        </span><span class="istickedoff">then error &quot;badCase&quot; </span>\r
+<span class="lineno">   41 </span><span class="spaces">        </span><span class="istickedoff">else if <span class="tickonlyfalse">a &gt; 1000</span> </span>\r
+<span class="lineno">   42 </span><span class="spaces">             </span><span class="istickedoff">then <span class="nottickedoff">1</span> </span>\r
+<span class="lineno">   43 </span><span class="spaces">             </span><span class="istickedoff">else badCase (a + 1) <span class="nottickedoff">(b - 1)</span></span></span>\r
+<span class="lineno">   44 </span>\r
+<span class="lineno">   45 </span>\r
+<span class="lineno">   46 </span><span class="decl"><span class="istickedoff">foo2 = (1,2, if <span class="tickonlytrue">True</span> then 3 else <span class="nottickedoff">4</span>)</span></span>\r
+<span class="lineno">   47 </span>\r
+<span class="lineno">   48 </span><span class="decl"><span class="istickedoff">otherwoz = True</span></span>\r
+<span class="lineno">   49 </span>\end{code}\r
+\r
+</pre>\r
+</html>\r
+Writing: hpc_index.html\r
+<html><style type="text/css">table.bar { background-color: #f25913; }\r
+td.bar { background-color: #60de51;  }\r
+td.invbar { background-color: #f25913;  }\r
+table.dashboard { border-collapse: collapse  ; border: solid 1px black }\r
+.dashboard td { border: solid 1px black }\r
+.dashboard th { border: solid 1px black }\r
+</style>\r
+<table class="dashboard" width="100%" border=1>\r
+<tr><th rowspan=2><a href="hpc_index.html">module</a></th><th colspan=3><a href="hpc_index_fun.html">Top Level Definitions</a></th><th colspan=3><a href="hpc_index_alt.html">Alternatives</a></th><th colspan=3><a href="hpc_index_exp.html">Expressions</a></th></tr><tr><th>%</th><th colspan=2>covered / total</th><th>%</th><th colspan=2>covered / total</th><th>%</th><th colspan=2>covered / total</th></tr><tr>\r
+<td>&nbsp;&nbsp;<tt>module <a href="Main.hs.html">Main</a></tt></td>\r
+<td align="right">83%</td><td>5/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="83%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">58%</td><td>7/12</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="58%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">71%</td><td>68/95</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="71%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>\r
+<tr></tr><tr style="background: #e0e0e0">\r
+<th align=left>&nbsp;&nbsp;Program Coverage Total</tt></th>\r
+<td align="right">83%</td><td>5/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="83%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">58%</td><td>7/12</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="58%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">71%</td><td>68/95</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="71%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>\r
+</table></html>\r
+Writing: hpc_index_fun.html\r
+<html><style type="text/css">table.bar { background-color: #f25913; }\r
+td.bar { background-color: #60de51;  }\r
+td.invbar { background-color: #f25913;  }\r
+table.dashboard { border-collapse: collapse  ; border: solid 1px black }\r
+.dashboard td { border: solid 1px black }\r
+.dashboard th { border: solid 1px black }\r
+</style>\r
+<table class="dashboard" width="100%" border=1>\r
+<tr><th rowspan=2><a href="hpc_index.html">module</a></th><th colspan=3><a href="hpc_index_fun.html">Top Level Definitions</a></th><th colspan=3><a href="hpc_index_alt.html">Alternatives</a></th><th colspan=3><a href="hpc_index_exp.html">Expressions</a></th></tr><tr><th>%</th><th colspan=2>covered / total</th><th>%</th><th colspan=2>covered / total</th><th>%</th><th colspan=2>covered / total</th></tr><tr>\r
+<td>&nbsp;&nbsp;<tt>module <a href="Main.hs.html">Main</a></tt></td>\r
+<td align="right">83%</td><td>5/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="83%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">58%</td><td>7/12</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="58%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">71%</td><td>68/95</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="71%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>\r
+<tr></tr><tr style="background: #e0e0e0">\r
+<th align=left>&nbsp;&nbsp;Program Coverage Total</tt></th>\r
+<td align="right">83%</td><td>5/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="83%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">58%</td><td>7/12</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="58%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">71%</td><td>68/95</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="71%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>\r
+</table></html>\r
+Writing: hpc_index_alt.html\r
+<html><style type="text/css">table.bar { background-color: #f25913; }\r
+td.bar { background-color: #60de51;  }\r
+td.invbar { background-color: #f25913;  }\r
+table.dashboard { border-collapse: collapse  ; border: solid 1px black }\r
+.dashboard td { border: solid 1px black }\r
+.dashboard th { border: solid 1px black }\r
+</style>\r
+<table class="dashboard" width="100%" border=1>\r
+<tr><th rowspan=2><a href="hpc_index.html">module</a></th><th colspan=3><a href="hpc_index_fun.html">Top Level Definitions</a></th><th colspan=3><a href="hpc_index_alt.html">Alternatives</a></th><th colspan=3><a href="hpc_index_exp.html">Expressions</a></th></tr><tr><th>%</th><th colspan=2>covered / total</th><th>%</th><th colspan=2>covered / total</th><th>%</th><th colspan=2>covered / total</th></tr><tr>\r
+<td>&nbsp;&nbsp;<tt>module <a href="Main.hs.html">Main</a></tt></td>\r
+<td align="right">83%</td><td>5/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="83%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">58%</td><td>7/12</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="58%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">71%</td><td>68/95</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="71%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>\r
+<tr></tr><tr style="background: #e0e0e0">\r
+<th align=left>&nbsp;&nbsp;Program Coverage Total</tt></th>\r
+<td align="right">83%</td><td>5/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="83%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">58%</td><td>7/12</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="58%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">71%</td><td>68/95</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="71%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>\r
+</table></html>\r
+Writing: hpc_index_exp.html\r
+<html><style type="text/css">table.bar { background-color: #f25913; }\r
+td.bar { background-color: #60de51;  }\r
+td.invbar { background-color: #f25913;  }\r
+table.dashboard { border-collapse: collapse  ; border: solid 1px black }\r
+.dashboard td { border: solid 1px black }\r
+.dashboard th { border: solid 1px black }\r
+</style>\r
+<table class="dashboard" width="100%" border=1>\r
+<tr><th rowspan=2><a href="hpc_index.html">module</a></th><th colspan=3><a href="hpc_index_fun.html">Top Level Definitions</a></th><th colspan=3><a href="hpc_index_alt.html">Alternatives</a></th><th colspan=3><a href="hpc_index_exp.html">Expressions</a></th></tr><tr><th>%</th><th colspan=2>covered / total</th><th>%</th><th colspan=2>covered / total</th><th>%</th><th colspan=2>covered / total</th></tr><tr>\r
+<td>&nbsp;&nbsp;<tt>module <a href="Main.hs.html">Main</a></tt></td>\r
+<td align="right">83%</td><td>5/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="83%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">58%</td><td>7/12</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="58%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">71%</td><td>68/95</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="71%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>\r
+<tr></tr><tr style="background: #e0e0e0">\r
+<th align=left>&nbsp;&nbsp;Program Coverage Total</tt></th>\r
+<td align="right">83%</td><td>5/6</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="83%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">58%</td><td>7/12</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="58%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td><td align="right">71%</td><td>68/95</td><td width=100><table cellpadding=0 cellspacing=0 width="100" class="bar"><tr><td><table cellpadding=0 cellspacing=0 width="71%"><tr><td height=12 class="bar"></td></tr></table></td></tr></table></td></tr>\r
+</table></html>\r
+\r
+\r
index ef89161..2243b6b 100644 (file)
@@ -6,3 +6,9 @@ hpc_prefix = "perl ../hpcrun.pl --clear --exeext=" + config.exeext + " --hpc='"
 
 test('tough', cmd_prefix(hpc_prefix), compile_and_run, ['-fhpc'])
 
+# Test that -fhpc still works when (a) the source file is in a
+# subdirectory and (b) it is a literate file.  We had a bug in this
+# area caused by the handling of line pragmas in the preprocessed
+# source file.
+test('subdir/tough2', [ literate, cmd_prefix(hpc_prefix) ], compile_and_run, ['-fhpc'])
+
index 77e4830..1cd955b 100644 (file)
@@ -22,6 +22,9 @@ die "no option --hpc=* provided\n" if (!defined($HPC));
         
 $binary = $ARGV[0] . $exeext;
 
+# get the basename: needed for the test function/subdir/tough2
+$binary =~ s/^.*\/([^\/]*)$/$1/;
+
 unlink "$binary.tix" if (defined($CLEAR));
 
 system @ARGV;