<div dir="ltr"><br><div><a href="https://phabricator.haskell.org/D518">https://phabricator.haskell.org/D518</a><br></div><div><br></div><div><p style="margin:0px 0px 12px;padding:0px;border:0px;color:rgb(0,0,0);font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px;line-height:18.8500003814697px">Can someone give me guidance on how to write a test case? I am trying to write a test case for a new flag that generates a file (much like -ddump-to-file).</p><p style="margin:0px 0px 12px;padding:0px;border:0px;color:rgb(0,0,0);font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px;line-height:18.8500003814697px">I started by trying to cat the generated file to get it into the stdout/stderr</p><div class="" style="margin:12px;padding:0px;border:0px;white-space:pre;font-family:Monaco,monospace;font-size:10px;color:rgb(0,0,0);line-height:18.8500003814697px"><pre class="" style="margin-top:0px;margin-bottom:0px;padding:8px;border:1px solid rgb(241,196,15);overflow:auto;font-family:Menlo,Consolas,Monaco,monospace;font-stretch:normal;line-height:normal;background:rgb(253,245,212)"><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">+</span><span class="" style="border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:rgb(187,221,187);color:rgb(0,64,18)">test</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">(</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(118,101,16)">'T8624'</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">,</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">normal</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">,</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">run_command</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">,</span>
<span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">+</span>     <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">[</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(118,101,16)">'echo $MAKE && $MAKE T8624 && cat T8624.th.hs'</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">])</span></pre></div><p style="margin:0px 0px 12px;padding:0px;border:0px;color:rgb(0,0,0);font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:13px;line-height:18.8500003814697px">But I get this error:</p><div class="" style="margin:12px;padding:0px;border:0px;white-space:pre;font-family:Monaco,monospace;font-size:10px;color:rgb(0,0,0);line-height:18.8500003814697px"><pre class="" style="margin-top:0px;margin-bottom:0px;padding:8px;border:1px solid rgb(241,196,15);overflow:auto;font-family:Menlo,Consolas,Monaco,monospace;font-stretch:normal;line-height:normal;background:rgb(253,245,212)"><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">cd</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">.</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">&&</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">echo</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,18,148)">$MAKE</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">&&</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,18,148)">$MAKE</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">T8624</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">&&</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">cat</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">T8624</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">.</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">th</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">.</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">hs</span>    <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)"></</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">dev</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">/</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">null</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">></span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">T8624</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">.</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">run</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">.</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">stdout</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(96,18,0)">2</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">></span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">T8624</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">.</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">run</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">.</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">stderr</span>
<span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">make</span>
<span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">make</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">[</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(96,18,0)">1</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">]:</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">Entering</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">directory</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(118,101,16)">'/home/ghc/testsuite/tests/th'</span>
<span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">cc</span>   <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">T8624</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">.</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">o</span>   <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">-</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">o</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">T8624</span>
<span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">/</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">usr</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">/</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">lib</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">/</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">gcc</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">/</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">x86_64</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">-</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">linux</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">-</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">gnu</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">/</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(96,18,0)">4.9</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">/../../../</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">x86_64</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">-</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">linux</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">-</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">gnu</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">/</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">crt1</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">.</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">o</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">:</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">In</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,64,0)">function</span> <span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(118,101,16)">`_start':</span>
<span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(118,101,16)">(.text+0x20): undefined reference to `</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">main</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(118,101,16)">'</span>
<span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(118,101,16)">collect2: error: ld returned 1 exit status</span>
<span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(118,101,16)"><builtin>: recipe for target '</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">T8624</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(118,101,16)">' failed</span>
<span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(118,101,16)">make[1]: *** [T8624] Error 1</span>
<span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(118,101,16)">make[1]: Leaving directory '</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">/</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">home</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">/</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">ghc</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">/</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">testsuite</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">/</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">tests</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(170,34,17)">/</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(0,10,101)">th</span><span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(118,101,16)">'</span>
<span class="" style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:transparent;color:rgb(118,101,16)">Wrong exit code (expected 0 , actual 2 )</span></pre></div></div></div>