Add a test for the fetchurl function

This commit is contained in:
Eelco Dolstra 2012-07-09 15:41:43 -04:00
parent 035aa11403
commit 51f9f9924b
3 changed files with 17 additions and 1 deletions

View file

@ -9,7 +9,7 @@ TESTS = init.sh hash.sh lang.sh add.sh simple.sh dependencies.sh \
gc-runtime.sh install-package.sh check-refs.sh filter-source.sh \
remote-store.sh export.sh export-graph.sh negative-caching.sh \
binary-patching.sh timeout.sh secure-drv-outputs.sh nix-channel.sh \
multiple-outputs.sh import-derivation.sh
multiple-outputs.sh import-derivation.sh fetchurl.sh
XFAIL_TESTS =
@ -38,6 +38,7 @@ EXTRA_DIST = $(TESTS) \
secure-drv-outputs.nix \
multiple-outputs.nix \
import-derivation.nix \
fetchurl.nix \
$(wildcard lang/*.nix) $(wildcard lang/*.exp) $(wildcard lang/*.exp.xml) $(wildcard lang/*.flags) $(wildcard lang/dir*/*.nix) \
common.sh.in

6
tests/fetchurl.nix Normal file
View file

@ -0,0 +1,6 @@
{ filename, sha256 }:
import <nix/fetchurl.nix> {
url = "file://${filename}";
inherit sha256;
}

9
tests/fetchurl.sh Normal file
View file

@ -0,0 +1,9 @@
source common.sh
clearStore
hash=$(nix-hash --flat --type sha256 ./fetchurl.nix)
outPath=$(nix-build ./fetchurl.nix --argstr filename $(pwd)/fetchurl.nix --argstr sha256 $hash)
cmp $outPath fetchurl.nix