/usr/share/doc/libghc-tasty-golden-doc/html/Test-Tasty-Golden.html is in libghc-tasty-golden-doc 2.3.1.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Test.Tasty.Golden</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="file:///usr/share/javascript/mathjax/MathJax.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Test-Tasty-Golden.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Test-Tasty-Golden.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">tasty-golden-2.3.1.2: Golden tests support for tasty</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><p class="caption">Test.Tasty.Golden</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>To get started with golden testing and this library, see
<a href="https://ro-che.info/articles/2017-12-04-golden-tests">Introduction to golden testing</a>.</p><p>This module provides a simplified interface. If you want more, see
<a href="Test-Tasty-Golden-Advanced.html">Test.Tasty.Golden.Advanced</a>.</p><p>Note about filenames. They are looked up in the usual way, thus relative
names are relative to the processes current working directory.
It is common to run tests from the package's root directory (via <code>cabal
test</code> or <code>cabal install --enable-tests</code>), so if your test files are under
the <code>tests/</code> subdirectory, your relative file names should start with
<code>tests/</code> (even if your <code>test.hs</code> is itself under <code>tests/</code>, too).</p><p>Note about line endings. The best way to avoid headaches with line endings
(when running tests both on UNIX and Windows) is to treat your golden files
as binary, even when they are actually textual.</p><p>This means:</p><ul><li>When writing output files from Haskell code, open them in binary mode
(see <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/GHC-IO-Handle-FD.html#v:openBinaryFile">openBinaryFile</a></code>, <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#v:withBinaryFile">withBinaryFile</a></code> and <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/GHC-IO-Handle.html#v:hSetBinaryMode">hSetBinaryMode</a></code>). This will
disable automatic <code>\n -> \r\n</code> conversion on Windows. For convenience, this
module exports <code><a href="Test-Tasty-Golden.html#v:writeBinaryFile">writeBinaryFile</a></code> which is just like <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#v:writeFile">writeFile</a></code> but opens
the file in binary mode. When using <code>ByteString</code>s note that
<a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString.html">Data.ByteString</a> and <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString-Lazy.html">Data.ByteString.Lazy</a> use binary mode for
<code>writeFile</code>, while <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString-Char8.html">Data.ByteString.Char8</a> and <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString-Lazy-Char8.html">Data.ByteString.Lazy.Char8</a>
use text mode.</li><li>Tell your VCS not to do any newline conversion for golden files. For
git check in a <code>.gitattributes</code> file with the following contents (assuming
your golden files have <code>.golden</code> extension):</li></ul><pre>*.golden -text</pre><p>On its side, tasty-golden reads and writes files in binary mode, too.</p><p>Why not let Haskell/git do automatic conversion on Windows? Well, for
instance, <code>tar</code> will not do the conversion for you when unpacking a release
tarball, so when you run <code>cabal install your-package --enable-tests</code>, the
tests will be broken.</p><p>As a last resort, you can strip all <code>\r</code>s from both arguments in your
comparison function when necessary. But most of the time treating the files
as binary does the job.</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><a href="#v:goldenVsFile">goldenVsFile</a> :: <a href="file:///usr/share/doc/libghc-tasty-doc/html/Test-Tasty-Providers.html#t:TestName">TestName</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> () -> <a href="file:///usr/share/doc/libghc-tasty-doc/html/Test-Tasty-Providers.html#t:TestTree">TestTree</a></li><li class="src short"><a href="#v:goldenVsString">goldenVsString</a> :: <a href="file:///usr/share/doc/libghc-tasty-doc/html/Test-Tasty-Providers.html#t:TestName">TestName</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString-Lazy.html#t:ByteString">ByteString</a> -> <a href="file:///usr/share/doc/libghc-tasty-doc/html/Test-Tasty-Providers.html#t:TestTree">TestTree</a></li><li class="src short"><a href="#v:goldenVsFileDiff">goldenVsFileDiff</a> :: <a href="file:///usr/share/doc/libghc-tasty-doc/html/Test-Tasty-Providers.html#t:TestName">TestName</a> -> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>]) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> () -> <a href="file:///usr/share/doc/libghc-tasty-doc/html/Test-Tasty-Providers.html#t:TestTree">TestTree</a></li><li class="src short"><a href="#v:goldenVsStringDiff">goldenVsStringDiff</a> :: <a href="file:///usr/share/doc/libghc-tasty-doc/html/Test-Tasty-Providers.html#t:TestName">TestName</a> -> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>]) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString-Lazy.html#t:ByteString">ByteString</a> -> <a href="file:///usr/share/doc/libghc-tasty-doc/html/Test-Tasty-Providers.html#t:TestTree">TestTree</a></li><li class="src short"><a href="#v:writeBinaryFile">writeBinaryFile</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> ()</li><li class="src short"><a href="#v:findByExtension">findByExtension</a> :: [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a>] -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a>]</li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><a id="v:goldenVsFile" class="def">goldenVsFile</a> <a href="src/Test-Tasty-Golden.html#goldenVsFile" class="link">Source</a> <a href="#v:goldenVsFile" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/share/doc/libghc-tasty-doc/html/Test-Tasty-Providers.html#t:TestName">TestName</a></td><td class="doc"><p>test name</p></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>path to the «golden» file (the file that contains correct output)</p></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>path to the output file</p></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> ()</td><td class="doc"><p>action that creates the output file</p></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/libghc-tasty-doc/html/Test-Tasty-Providers.html#t:TestTree">TestTree</a></td><td class="doc"><p>the test verifies that the output file contents is the same as the golden file contents</p></td></tr></table></div><div class="doc"><p>Compare a given file contents against the golden file contents</p></div></div><div class="top"><p class="src"><a id="v:goldenVsString" class="def">goldenVsString</a> <a href="src/Test-Tasty-Golden.html#goldenVsString" class="link">Source</a> <a href="#v:goldenVsString" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/share/doc/libghc-tasty-doc/html/Test-Tasty-Providers.html#t:TestName">TestName</a></td><td class="doc"><p>test name</p></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>path to the «golden» file (the file that contains correct output)</p></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString-Lazy.html#t:ByteString">ByteString</a></td><td class="doc"><p>action that returns a string</p></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/libghc-tasty-doc/html/Test-Tasty-Providers.html#t:TestTree">TestTree</a></td><td class="doc"><p>the test verifies that the returned string is the same as the golden file contents</p></td></tr></table></div><div class="doc"><p>Compare a given string against the golden file contents</p></div></div><div class="top"><p class="src"><a id="v:goldenVsFileDiff" class="def">goldenVsFileDiff</a> <a href="src/Test-Tasty-Golden.html#goldenVsFileDiff" class="link">Source</a> <a href="#v:goldenVsFileDiff" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/share/doc/libghc-tasty-doc/html/Test-Tasty-Providers.html#t:TestName">TestName</a></td><td class="doc"><p>test name</p></td></tr><tr><td class="src">-> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>])</td><td class="doc"><p>function that constructs the command line to invoke the diff
command.</p><p>E.g.</p><pre>\ref new -> ["diff", "-u", ref, new]</pre></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>path to the golden file</p></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>path to the output file</p></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> ()</td><td class="doc"><p>action that produces the output file</p></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/libghc-tasty-doc/html/Test-Tasty-Providers.html#t:TestTree">TestTree</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Same as <code><a href="Test-Tasty-Golden.html#v:goldenVsFile">goldenVsFile</a></code>, but invokes an external diff command.</p></div></div><div class="top"><p class="src"><a id="v:goldenVsStringDiff" class="def">goldenVsStringDiff</a> <a href="src/Test-Tasty-Golden.html#goldenVsStringDiff" class="link">Source</a> <a href="#v:goldenVsStringDiff" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/share/doc/libghc-tasty-doc/html/Test-Tasty-Providers.html#t:TestName">TestName</a></td><td class="doc"><p>test name</p></td></tr><tr><td class="src">-> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a>])</td><td class="doc"><p>function that constructs the command line to invoke the diff
command.</p><p>E.g.</p><pre>\ref new -> ["diff", "-u", ref, new]</pre></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>path to the golden file</p></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/bytestring-0.10.8.1/Data-ByteString-Lazy.html#t:ByteString">ByteString</a></td><td class="doc"><p>action that returns a string</p></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/libghc-tasty-doc/html/Test-Tasty-Providers.html#t:TestTree">TestTree</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Same as <code><a href="Test-Tasty-Golden.html#v:goldenVsString">goldenVsString</a></code>, but invokes an external diff command.</p></div></div><div class="top"><p class="src"><a id="v:writeBinaryFile" class="def">writeBinaryFile</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-String.html#t:String">String</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> () <a href="src/Test-Tasty-Golden.html#writeBinaryFile" class="link">Source</a> <a href="#v:writeBinaryFile" class="selflink">#</a></p><div class="doc"><p>Like <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#v:writeFile">writeFile</a></code>, but uses binary mode</p></div></div><div class="top"><p class="src"><a id="v:findByExtension" class="def">findByExtension</a> <a href="src/Test-Tasty-Golden.html#findByExtension" class="link">Source</a> <a href="#v:findByExtension" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a>]</td><td class="doc"><p>extensions</p></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a></td><td class="doc"><p>directory</p></td></tr><tr><td class="src">-> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:IO">IO</a> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/System-IO.html#t:FilePath">FilePath</a>]</td><td class="doc"><p>paths</p></td></tr></table></div><div class="doc"><p>Find all files in the given directory and its subdirectories that have
the given extensions.</p><p>It is typically used to find all test files and produce a golden test
per test file.</p><p>The returned paths use forward slashes to separate path components,
even on Windows. Thus if the file name ends up in a golden file, it
will not differ when run on another platform.</p><p>The semantics of extensions is the same as in <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/filepath-1.4.1.1/System-FilePath-Posix.html#v:takeExtension">takeExtension</a></code>. In
particular, non-empty extensions should have the form <code>".ext"</code>.</p><p>This function may throw any exception that <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/directory-1.3.0.0/System-Directory.html#v:getDirectoryContents">getDirectoryContents</a></code> may
throw.</p><p>It doesn't do anything special to handle symlinks (in particular, it
probably won't work on symlink loops).</p><p>Nor is it optimized to work with huge directory trees (you'd probably
want to use some form of coroutines for that).</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.3</p></div></body></html>
|