diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 10 | ||||
-rw-r--r-- | tests/lang.sh | 47 | ||||
-rw-r--r-- | tests/lang/eval-fail-blackhole.nix | 5 | ||||
-rw-r--r-- | tests/lang/eval-okay-let.exp | 1 | ||||
-rw-r--r-- | tests/lang/eval-okay-let.nix | 5 | ||||
-rw-r--r-- | tests/lang/eval-okay-map.exp | 1 | ||||
-rw-r--r-- | tests/lang/eval-okay-map.nix | 1 | ||||
-rw-r--r-- | tests/lang/eval-okay-scope-1.exp | 1 | ||||
-rw-r--r-- | tests/lang/eval-okay-scope-1.nix | 6 | ||||
-rw-r--r-- | tests/lang/eval-okay-scope-2.exp | 1 | ||||
-rw-r--r-- | tests/lang/eval-okay-scope-2.nix | 6 | ||||
-rw-r--r-- | tests/lang/eval-okay-scope-3.exp | 1 | ||||
-rw-r--r-- | tests/lang/eval-okay-scope-3.nix | 6 | ||||
-rw-r--r-- | tests/lang/eval-okay-string.exp | 1 | ||||
-rw-r--r-- | tests/lang/eval-okay-string.nix | 1 | ||||
-rw-r--r-- | tests/lang/parse-fail-1.nix | 1 | ||||
-rw-r--r-- | tests/lang/parse-okay-1.exp | 1 | ||||
-rw-r--r-- | tests/lang/parse-okay-1.nix | 1 | ||||
-rw-r--r-- | tests/lang/parse-okay-subversion.exp | 1 | ||||
-rw-r--r-- | tests/lang/parse-okay-subversion.nix | 43 | ||||
-rw-r--r-- | tests/lang/parse-okay-url.exp | 1 | ||||
-rw-r--r-- | tests/lang/parse-okay-url.nix | 7 |
22 files changed, 145 insertions, 3 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 5ac01aca3f4d..ae6da726b35a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -11,7 +11,7 @@ TESTS_ENVIRONMENT = TEST_ROOT=$(TEST_ROOT) \ NIX_BUILD_HOOK= \ TOP=$(shell pwd)/.. \ SHARED=$(extra1) \ - $(SHELL) -e -x + $(SHELL) -e simple.sh: simple.nix dependencies.sh: dependencies.nix @@ -22,11 +22,14 @@ substitutes.sh: substitutes.nix substituter.nix substitutes2.sh: substitutes2.nix substituter.nix substituter2.nix fallback.sh: fallback.nix -TESTS = init.sh simple.sh dependencies.sh locking.sh parallel.sh \ +TESTS = init.sh lang.sh simple.sh dependencies.sh locking.sh parallel.sh \ build-hook.sh substitutes.sh substitutes2.sh fallback.sh verify.sh XFAIL_TESTS = +foo: + $(TESTS_ENVIRONMENT) ./lang.sh + include ../substitute.mk EXTRA_DIST = $(TESTS) \ @@ -37,4 +40,5 @@ EXTRA_DIST = $(TESTS) \ build-hook.nix.in build-hook.hook.sh \ substitutes.nix.in substituter.nix.in substituter.builder.sh \ substitutes2.nix.in substituter2.nix.in substituter2.builder.sh \ - fallback.nix.in + fallback.nix.in \ + $(wildcard lang/*.nix) $(wildcard lang/*.exp) diff --git a/tests/lang.sh b/tests/lang.sh new file mode 100644 index 000000000000..55aaa46f375f --- /dev/null +++ b/tests/lang.sh @@ -0,0 +1,47 @@ +fail=0 + +for i in lang/parse-fail-*.nix; do + echo "parsing $i (should fail)"; + i=$(basename $i .nix) + if $TOP/src/nix-instantiate/nix-instantiate --parse-only - < lang/$i.nix; then + echo "FAIL: $i shouldn't parse" + fail=1 + fi +done + +for i in lang/parse-okay-*.nix; do + echo "parsing $i (should succeed)"; + i=$(basename $i .nix) + if ! $TOP/src/nix-instantiate/nix-instantiate --parse-only - < lang/$i.nix > lang/$i.ast; then + echo "FAIL: $i should parse" + fail=1 + fi + if ! cmp lang/$i.ast lang/$i.exp; then + echo "FAIL: parse tree of $i not as expected" + fail=1 + fi +done + +for i in lang/eval-fail-*.nix; do + echo "evaluating $i (should fail)"; + i=$(basename $i .nix) + if $TOP/src/nix-instantiate/nix-instantiate --eval-only - < lang/$i.nix; then + echo "FAIL: $i shouldn't evaluate" + fail=1 + fi +done + +for i in lang/eval-okay-*.nix; do + echo "evaluating $i (should succeed)"; + i=$(basename $i .nix) + if ! $TOP/src/nix-instantiate/nix-instantiate --eval-only - < lang/$i.nix > lang/$i.out; then + echo "FAIL: $i should evaluate" + fail=1 + fi + if ! cmp lang/$i.out lang/$i.exp; then + echo "FAIL: evaluation result of $i not as expected" + fail=1 + fi +done + +exit $fail \ No newline at end of file diff --git a/tests/lang/eval-fail-blackhole.nix b/tests/lang/eval-fail-blackhole.nix new file mode 100644 index 000000000000..81133b511c95 --- /dev/null +++ b/tests/lang/eval-fail-blackhole.nix @@ -0,0 +1,5 @@ +let { + body = x; + x = y; + y = x; +} diff --git a/tests/lang/eval-okay-let.exp b/tests/lang/eval-okay-let.exp new file mode 100644 index 000000000000..dddca4459bfb --- /dev/null +++ b/tests/lang/eval-okay-let.exp @@ -0,0 +1 @@ +Str("foobar") diff --git a/tests/lang/eval-okay-let.nix b/tests/lang/eval-okay-let.nix new file mode 100644 index 000000000000..fe118c5282e3 --- /dev/null +++ b/tests/lang/eval-okay-let.nix @@ -0,0 +1,5 @@ +let { + x = "foo"; + y = "bar"; + body = x + y; +} diff --git a/tests/lang/eval-okay-map.exp b/tests/lang/eval-okay-map.exp new file mode 100644 index 000000000000..ab8e7a27806c --- /dev/null +++ b/tests/lang/eval-okay-map.exp @@ -0,0 +1 @@ +List([Call(Function1("x",OpPlus(Var("x"),Str("bar")),Pos("(string)",1,7)),Str("foo")),Call(Function1("x",OpPlus(Var("x"),Str("bar")),Pos("(string)",1,7)),Str("bla")),Call(Function1("x",OpPlus(Var("x"),Str("bar")),Pos("(string)",1,7)),Str("xyzzy"))]) diff --git a/tests/lang/eval-okay-map.nix b/tests/lang/eval-okay-map.nix new file mode 100644 index 000000000000..924446657aec --- /dev/null +++ b/tests/lang/eval-okay-map.nix @@ -0,0 +1 @@ +map (x: x + "bar") [ "foo" "bla" "xyzzy" ] \ No newline at end of file diff --git a/tests/lang/eval-okay-scope-1.exp b/tests/lang/eval-okay-scope-1.exp new file mode 100644 index 000000000000..7da0e4219eee --- /dev/null +++ b/tests/lang/eval-okay-scope-1.exp @@ -0,0 +1 @@ +Int(3) diff --git a/tests/lang/eval-okay-scope-1.nix b/tests/lang/eval-okay-scope-1.nix new file mode 100644 index 000000000000..fa38a7174e03 --- /dev/null +++ b/tests/lang/eval-okay-scope-1.nix @@ -0,0 +1,6 @@ +(({x}: x: + + { x = 1; + y = x; + } +) {x = 2;} 3).y diff --git a/tests/lang/eval-okay-scope-2.exp b/tests/lang/eval-okay-scope-2.exp new file mode 100644 index 000000000000..067d2b7461e8 --- /dev/null +++ b/tests/lang/eval-okay-scope-2.exp @@ -0,0 +1 @@ +Int(1) diff --git a/tests/lang/eval-okay-scope-2.nix b/tests/lang/eval-okay-scope-2.nix new file mode 100644 index 000000000000..eb8b02bc4994 --- /dev/null +++ b/tests/lang/eval-okay-scope-2.nix @@ -0,0 +1,6 @@ +((x: {x}: + rec { + x = 1; + y = x; + } +) 2 {x = 3;}).y diff --git a/tests/lang/eval-okay-scope-3.exp b/tests/lang/eval-okay-scope-3.exp new file mode 100644 index 000000000000..65c1faee25ec --- /dev/null +++ b/tests/lang/eval-okay-scope-3.exp @@ -0,0 +1 @@ +Int(4) diff --git a/tests/lang/eval-okay-scope-3.nix b/tests/lang/eval-okay-scope-3.nix new file mode 100644 index 000000000000..10d6bc04d830 --- /dev/null +++ b/tests/lang/eval-okay-scope-3.nix @@ -0,0 +1,6 @@ +((x: as: {x}: + rec { + inherit (as) x; + y = x; + } +) 2 {x = 4;} {x = 3;}).y diff --git a/tests/lang/eval-okay-string.exp b/tests/lang/eval-okay-string.exp new file mode 100644 index 000000000000..07741d1605ce --- /dev/null +++ b/tests/lang/eval-okay-string.exp @@ -0,0 +1 @@ +Str("foobar/a/b/c/d") diff --git a/tests/lang/eval-okay-string.nix b/tests/lang/eval-okay-string.nix new file mode 100644 index 000000000000..19b60497a52d --- /dev/null +++ b/tests/lang/eval-okay-string.nix @@ -0,0 +1 @@ +"foo" + "bar" + toString (/a/b + /c/d) diff --git a/tests/lang/parse-fail-1.nix b/tests/lang/parse-fail-1.nix new file mode 100644 index 000000000000..7b63008110db --- /dev/null +++ b/tests/lang/parse-fail-1.nix @@ -0,0 +1 @@ +x: y diff --git a/tests/lang/parse-okay-1.exp b/tests/lang/parse-okay-1.exp new file mode 100644 index 000000000000..71e55d3afec4 --- /dev/null +++ b/tests/lang/parse-okay-1.exp @@ -0,0 +1 @@ +Function([NoDefFormal("x"),NoDefFormal("y"),NoDefFormal("z")],OpPlus(OpPlus(Var("x"),Var("y")),Var("z")),Pos("(string)",1,2)) diff --git a/tests/lang/parse-okay-1.nix b/tests/lang/parse-okay-1.nix new file mode 100644 index 000000000000..23a58ed109b1 --- /dev/null +++ b/tests/lang/parse-okay-1.nix @@ -0,0 +1 @@ +{x, y, z}: x + y + z diff --git a/tests/lang/parse-okay-subversion.exp b/tests/lang/parse-okay-subversion.exp new file mode 100644 index 000000000000..caf2bf29f239 --- /dev/null +++ b/tests/lang/parse-okay-subversion.exp @@ -0,0 +1 @@ +Function([DefFormal("localServer",Var("false")),DefFormal("httpServer",Var("false")),DefFormal("sslSupport",Var("false")),DefFormal("pythonBindings",Var("false")),DefFormal("javaSwigBindings",Var("false")),DefFormal("javahlBindings",Var("false")),NoDefFormal("stdenv"),NoDefFormal("fetchurl"),DefFormal("openssl",Var("null")),DefFormal("httpd",Var("null")),DefFormal("db4",Var("null")),NoDefFormal("expat"),DefFormal("swig",Var("null")),DefFormal("j2sdk",Var("null"))],Assert(OpNEq(Var("expat"),Var("null")),Assert(OpImpl(Var("localServer"),OpNEq(Var("db4"),Var("null"))),Assert(OpImpl(Var("httpServer"),OpAnd(OpNEq(Var("httpd"),Var("null")),OpEq(Select(Var("httpd"),"expat"),Var("expat")))),Assert(OpImpl(Var("sslSupport"),OpAnd(OpNEq(Var("openssl"),Var("null")),OpImpl(Var("httpServer"),OpEq(Select(Var("httpd"),"openssl"),Var("openssl"))))),Assert(OpImpl(Var("pythonBindings"),OpAnd(OpNEq(Var("swig"),Var("null")),Select(Var("swig"),"pythonSupport"))),Assert(OpImpl(Var("javaSwigBindings"),OpAnd(OpNEq(Var("swig"),Var("null")),Select(Var("swig"),"javaSupport"))),Assert(OpImpl(Var("javahlBindings"),OpNEq(Var("j2sdk"),Var("null"))),Call(Select(Var("stdenv"),"mkDerivation"),Attrs([Bind("name",Str("subversion-1.1.1"),Pos("(string)",20,7)),Bind("builder",Path("/home/eelco/nix/tests/builder.sh"),Pos("(string)",22,10)),Bind("src",Call(Var("fetchurl"),Attrs([Bind("url",Uri("http://subversion.tigris.org/tarballs/subversion-1.1.1.tar.bz2"),Pos("(string)",24,8)),Bind("md5",Str("a180c3fe91680389c210c99def54d9e0"),Pos("(string)",25,8))])),Pos("(string)",23,6)),Bind("patches",If(Var("javahlBindings"),List([Path("/home/eelco/nix/tests/javahl.patch")]),List([])),Pos("(string)",31,10)),Bind("openssl",If(Var("sslSupport"),Var("openssl"),Var("null")),Pos("(string)",33,10)),Bind("httpd",If(Var("httpServer"),Var("httpd"),Var("null")),Pos("(string)",34,8)),Bind("db4",If(Var("localServer"),Var("db4"),Var("null")),Pos("(string)",35,6)),Bind("swig",If(OpOr(Var("pythonBindings"),Var("javaSwigBindings")),Var("swig"),Var("null")),Pos("(string)",36,7)),Bind("python",If(Var("pythonBindings"),Select(Var("swig"),"python"),Var("null")),Pos("(string)",37,9)),Bind("j2sdk",If(Var("javaSwigBindings"),Select(Var("swig"),"j2sdk"),If(Var("javahlBindings"),Var("j2sdk"),Var("null"))),Pos("(string)",38,8)),Bind("expat",Var("expat"),Pos("(string)",41,10)),Bind("localServer",Var("localServer"),Pos("(string)",41,10)),Bind("httpServer",Var("httpServer"),Pos("(string)",41,10)),Bind("sslSupport",Var("sslSupport"),Pos("(string)",41,10)),Bind("pythonBindings",Var("pythonBindings"),Pos("(string)",41,10)),Bind("javaSwigBindings",Var("javaSwigBindings"),Pos("(string)",41,10)),Bind("javahlBindings",Var("javahlBindings"),Pos("(string)",41,10))])),Pos("(string)",17,7)),Pos("(string)",16,7)),Pos("(string)",15,7)),Pos("(string)",14,7)),Pos("(string)",13,7)),Pos("(string)",12,7)),Pos("(string)",11,7)),Pos("(string)",1,2)) diff --git a/tests/lang/parse-okay-subversion.nix b/tests/lang/parse-okay-subversion.nix new file mode 100644 index 000000000000..5909da88f838 --- /dev/null +++ b/tests/lang/parse-okay-subversion.nix @@ -0,0 +1,43 @@ +{ localServer ? false +, httpServer ? false +, sslSupport ? false +, pythonBindings ? false +, javaSwigBindings ? false +, javahlBindings ? false +, stdenv, fetchurl +, openssl ? null, httpd ? null, db4 ? null, expat, swig ? null, j2sdk ? null +}: + +assert expat != null; +assert localServer -> db4 != null; +assert httpServer -> httpd != null && httpd.expat == expat; +assert sslSupport -> openssl != null && (httpServer -> httpd.openssl == openssl); +assert pythonBindings -> swig != null && swig.pythonSupport; +assert javaSwigBindings -> swig != null && swig.javaSupport; +assert javahlBindings -> j2sdk != null; + +stdenv.mkDerivation { + name = "subversion-1.1.1"; + + builder = ./builder.sh; + src = fetchurl { + url = http://subversion.tigris.org/tarballs/subversion-1.1.1.tar.bz2; + md5 = "a180c3fe91680389c210c99def54d9e0"; + }; + + # This is a hopefully temporary fix for the problem that + # libsvnjavahl.so isn't linked against libstdc++, which causes + # loading the library into the JVM to fail. + patches = if javahlBindings then [./javahl.patch] else []; + + openssl = if sslSupport then openssl else null; + httpd = if httpServer then httpd else null; + db4 = if localServer then db4 else null; + swig = if pythonBindings || javaSwigBindings then swig else null; + python = if pythonBindings then swig.python else null; + j2sdk = if javaSwigBindings then swig.j2sdk else + if javahlBindings then j2sdk else null; + + inherit expat localServer httpServer sslSupport + pythonBindings javaSwigBindings javahlBindings; +} diff --git a/tests/lang/parse-okay-url.exp b/tests/lang/parse-okay-url.exp new file mode 100644 index 000000000000..fa6706e21a81 --- /dev/null +++ b/tests/lang/parse-okay-url.exp @@ -0,0 +1 @@ +List([Uri("x:x"),Uri("https://svn.cs.uu.nl:12443/repos/trace/trunk"),Uri("http://www2.mplayerhq.hu/MPlayer/releases/fonts/font-arial-iso-8859-1.tar.bz2"),Uri("http://losser.st-lab.cs.uu.nl/~armijn/.nix/gcc-3.3.4-static-nix.tar.gz"),Uri("http://fpdownload.macromedia.com/get/shockwave/flash/english/linux/7.0r25/install_flash_player_7_linux.tar.gz"),Uri("ftp://ftp.gtk.org/pub/gtk/v1.2/gtk+-1.2.10.tar.gz")]) diff --git a/tests/lang/parse-okay-url.nix b/tests/lang/parse-okay-url.nix new file mode 100644 index 000000000000..fce3b13ee64b --- /dev/null +++ b/tests/lang/parse-okay-url.nix @@ -0,0 +1,7 @@ +[ x:x + https://svn.cs.uu.nl:12443/repos/trace/trunk + http://www2.mplayerhq.hu/MPlayer/releases/fonts/font-arial-iso-8859-1.tar.bz2 + http://losser.st-lab.cs.uu.nl/~armijn/.nix/gcc-3.3.4-static-nix.tar.gz + http://fpdownload.macromedia.com/get/shockwave/flash/english/linux/7.0r25/install_flash_player_7_linux.tar.gz + ftp://ftp.gtk.org/pub/gtk/v1.2/gtk+-1.2.10.tar.gz +] |