diff options
author | Robert Hensing <robert@roberthensing.nl> | 2022-10-15 17:24:09 +0200 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2022-10-27 14:06:38 +0200 |
commit | e20a362908fa6d4393efb05390e7dd38a64237da (patch) | |
tree | 37f40c77337a6c1126f9ae2cf3372736c36c7f81 /doc | |
parent | 44d0f3783387cdd7dfe05a32ff9c623eeebd0b57 (diff) |
testers.testEqualContents: init
Diffstat (limited to 'doc')
-rw-r--r-- | doc/builders/testers.chapter.md | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/doc/builders/testers.chapter.md b/doc/builders/testers.chapter.md index 57f66a428482d..58bb06f231378 100644 --- a/doc/builders/testers.chapter.md +++ b/doc/builders/testers.chapter.md @@ -75,6 +75,30 @@ environment to a minimum, some small changes are inevitable. `buildPackages.coreutils` and possibly more. These are not added to `PATH` or any other environment variable, so they should be hard to observe. +## `testEqualContents` {#tester-equalContents} + +Check that two paths have the same contents. + +Example: + +```nix +testers.testEqualContents { + assertion = "sed -e performs replacement"; + expected = writeText "expected" '' + foo baz baz + ''; + actual = runCommand "actual" { + # not really necessary for a package that's in stdenv + nativeBuildInputs = [ gnused ]; + base = writeText "base" '' + foo bar baz + ''; + } '' + sed -e 's/bar/baz/g' $base >$out + ''; +} +``` + ## `testEqualDerivation` {#tester-testEqualDerivation} Checks that two packages produce the exact same build instructions. |