diff options
| author | hisham <hisham@9ca3f7c1-7366-0410-b1a3-b5c78f85698c> | 2009-04-01 17:11:57 +0000 |
|---|---|---|
| committer | hisham <hisham@9ca3f7c1-7366-0410-b1a3-b5c78f85698c> | 2009-04-01 17:11:57 +0000 |
| commit | a88d6f2eeba2b3355c33fac6d736cf6086342f47 (patch) | |
| tree | 03ebfa0ced0186e091609cf337e290580fab8c11 /test | |
| download | luarocks-0.1.tar.gz luarocks-0.1.tar.bz2 luarocks-0.1.zip | |
Import latest revision from CVS at luaforge.netv1.0v0.5.2v0.5.1v0.5v0.4.3v0.4.2v0.4.1v0.4v0.3.2v0.3.1v0.3v0.2v0.1
git-svn-id: http://luarocks.org/svn/luarocks/trunk@1 9ca3f7c1-7366-0410-b1a3-b5c78f85698c
Diffstat (limited to 'test')
| -rwxr-xr-x | test/run_tests.sh | 76 | ||||
| -rw-r--r-- | test/test_deps.lua | 67 | ||||
| -rwxr-xr-x | test/test_require.lua | 25 |
3 files changed, 168 insertions, 0 deletions
diff --git a/test/run_tests.sh b/test/run_tests.sh new file mode 100755 index 00000000..aa06854f --- /dev/null +++ b/test/run_tests.sh | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | if [ -e ./run_tests.sh ] | ||
| 4 | then | ||
| 5 | cd ../src | ||
| 6 | elif [ -d src ] | ||
| 7 | then | ||
| 8 | cd src | ||
| 9 | elif ! [ -d luarocks ] | ||
| 10 | then | ||
| 11 | echo "Go to the src directory and run this." | ||
| 12 | exit 1 | ||
| 13 | fi | ||
| 14 | |||
| 15 | if [ ! -d ../rocks ] | ||
| 16 | then | ||
| 17 | echo "Downloading entire rocks repository for tests" | ||
| 18 | cd .. | ||
| 19 | wget -r -nH -np -R"index.*" http://luarocks.luaforge.net/rocks/ | ||
| 20 | cd src | ||
| 21 | fi | ||
| 22 | |||
| 23 | rocks=( | ||
| 24 | `ls ../rocks/*.rockspec | grep -v luacom` | ||
| 25 | `ls ../rocks/*.src.rock | grep -v luacom` | ||
| 26 | ) | ||
| 27 | |||
| 28 | bin/luarocks-admin make-manifest ../rocks || exit 1 | ||
| 29 | |||
| 30 | [ "$1" ] && rocks=("$1") | ||
| 31 | |||
| 32 | TRY() { | ||
| 33 | "$@" || { | ||
| 34 | echo "Failed running: $@" | ||
| 35 | exit 1 | ||
| 36 | } | ||
| 37 | } | ||
| 38 | |||
| 39 | list_search() { | ||
| 40 | bin/luarocks list $name | grep $version | ||
| 41 | } | ||
| 42 | |||
| 43 | for rock in "${rocks[@]}" | ||
| 44 | do | ||
| 45 | base=`basename $rock` | ||
| 46 | baserockspec=`basename $rock .rockspec` | ||
| 47 | basesrcrock=`basename $rock .src.rock` | ||
| 48 | if [ "$base" != "$baserockspec" ] | ||
| 49 | then | ||
| 50 | base=$baserockspec | ||
| 51 | name=`echo $base | sed 's/\(.*\)-[^-]*-[^-]*$/\1/'` | ||
| 52 | version=`echo $base | sed 's/.*-\([^-]*-[^-]*\)$/\1/'` | ||
| 53 | TRY bin/luarocks pack $rock | ||
| 54 | TRY bin/luarocks build $base.src.rock | ||
| 55 | TRY rm $base.src.rock | ||
| 56 | else | ||
| 57 | base=$basesrcrock | ||
| 58 | name=`echo $base | sed 's/\(.*\)-[^-]*-[^-]*$/\1/'` | ||
| 59 | version=`echo $base | sed 's/.*-\([^-]*-[^-]*\)$/\1/'` | ||
| 60 | TRY bin/luarocks build $rock | ||
| 61 | fi | ||
| 62 | TRY bin/luarocks pack $name $version | ||
| 63 | TRY bin/luarocks install $base.*.rock | ||
| 64 | TRY rm $base.*.rock | ||
| 65 | TRY list_search $name $version | ||
| 66 | bin/luarocks remove $name $version | ||
| 67 | # TODO: differentiate between error and dependency block. | ||
| 68 | done | ||
| 69 | |||
| 70 | if bin/luarocks install nonexistant | grep "No results" | ||
| 71 | then echo "OK, got expected error." | ||
| 72 | else exit 1 | ||
| 73 | fi | ||
| 74 | |||
| 75 | TRY ../test/test_deps.lua | ||
| 76 | TRY ../test/test_require.lua | ||
diff --git a/test/test_deps.lua b/test/test_deps.lua new file mode 100644 index 00000000..7236273c --- /dev/null +++ b/test/test_deps.lua | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | #!/usr/bin/env lua | ||
| 2 | |||
| 3 | deps = require "luarocks.deps" | ||
| 4 | |||
| 5 | print(deps.show_dep(deps.parse_dep("lfs 2.1.9pre5"), true)) | ||
| 6 | print(deps.show_dep(deps.parse_dep("cgilua cvs-2"), true)) | ||
| 7 | print(deps.show_dep(deps.parse_dep("foobar 0.0.1beta"), true)) | ||
| 8 | print(deps.show_dep(deps.parse_dep("foobar 0.0.1a"), true)) | ||
| 9 | |||
| 10 | print(deps.show_dep(deps.parse_dep("foobar 1"), true)) | ||
| 11 | print(deps.show_dep(deps.parse_dep("foobar 2.0"), true)) | ||
| 12 | print(deps.show_dep(deps.parse_dep("foobar 3.5a4"), true)) | ||
| 13 | print(deps.show_dep(deps.parse_dep("foobar 1.1pre2"), true)) | ||
| 14 | print(deps.show_dep(deps.parse_dep("foobar 2.0-beta3"), true)) | ||
| 15 | print(deps.show_dep(deps.parse_dep("foobar 5.3"), true)) | ||
| 16 | print(deps.show_dep(deps.parse_dep("foobar 3.5rc2"), true)) | ||
| 17 | print(deps.show_dep(deps.parse_dep("foobar 4.19p"), true)) | ||
| 18 | |||
| 19 | print() | ||
| 20 | comparisons = { | ||
| 21 | -- first second eq le | ||
| 22 | {"Vista", "XP", false, true}, | ||
| 23 | {"XP", "3.1", false, true}, | ||
| 24 | {"1.0", "1.0", true, false}, | ||
| 25 | {"2.2.10", "2.2-10", false, false}, | ||
| 26 | {"2.2", "2.2-10", true, false}, | ||
| 27 | {"1.0beta1", "1.0rc3", false, true}, | ||
| 28 | {"2.0beta3", "2.0", false, true}, | ||
| 29 | {"2.0beta", "2.0beta2", false, true}, | ||
| 30 | {"2.0beta4", "2.0beta3", false, false}, | ||
| 31 | {"2.1alpha1", "2.0beta1", false, false}, | ||
| 32 | {"1.5p3", "1.5.1", false, true}, | ||
| 33 | {"1.1.3", "1.1.3a", false, true}, | ||
| 34 | {"1.5a100", "1.5b1", false, true}, | ||
| 35 | {"2.0alpha100", "2.0beta1", false, true}, | ||
| 36 | {"2.0.0beta3", "2.0beta2", false, false}, | ||
| 37 | {"2.0-1", "2.0-2", false, true}, | ||
| 38 | {"2.0-2", "2.0-1", false, false}, | ||
| 39 | --[[ | ||
| 40 | -- Corner cases I don't wish to handle by now. | ||
| 41 | {"2.0.0beta2", "2.0beta2", true, true}, | ||
| 42 | {"2.0.0beta2", "2.0beta3", false, true}, | ||
| 43 | ]] | ||
| 44 | } | ||
| 45 | |||
| 46 | local v1, v2 | ||
| 47 | |||
| 48 | err = false | ||
| 49 | |||
| 50 | function result(test, expected) | ||
| 51 | if test == expected then | ||
| 52 | print(test, "OK") | ||
| 53 | else | ||
| 54 | print(test, "ERROR", deps.show_version(v1, true), deps.show_version(v2, true)) | ||
| 55 | err = true | ||
| 56 | end | ||
| 57 | end | ||
| 58 | |||
| 59 | for _, c in ipairs(comparisons) do | ||
| 60 | v1, v2 = deps.parse_version(c[1]), deps.parse_version(c[2]) | ||
| 61 | print(c[1].." == "..c[2].." ?") | ||
| 62 | result(v1 == v2, c[3]) | ||
| 63 | print(c[1].." < "..c[2].." ?") | ||
| 64 | result(v1 < v2, c[4]) | ||
| 65 | end | ||
| 66 | |||
| 67 | if err then os.exit(1) end | ||
diff --git a/test/test_require.lua b/test/test_require.lua new file mode 100755 index 00000000..2a652d29 --- /dev/null +++ b/test/test_require.lua | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | #!/usr/bin/env lua | ||
| 2 | |||
| 3 | local luarocks = require("luarocks.require") | ||
| 4 | |||
| 5 | luarocks.set_context("cgilua", "cvs-2") | ||
| 6 | |||
| 7 | print(package.path) | ||
| 8 | |||
| 9 | print(package.cpath) | ||
| 10 | |||
| 11 | local socket = require("socket") | ||
| 12 | if not socket then os.exit(1) end | ||
| 13 | print(socket, socket._VERSION) | ||
| 14 | |||
| 15 | local socket2 = require("socket") | ||
| 16 | if not socket2 then os.exit(1) end | ||
| 17 | print(socket2, socket2._VERSION) | ||
| 18 | |||
| 19 | local mime = require("mime") | ||
| 20 | if not mime then os.exit(1) end | ||
| 21 | print(mime, mime._VERSION) | ||
| 22 | |||
| 23 | local socket = require("lfs") | ||
| 24 | if not lfs then os.exit(1) end | ||
| 25 | print(lfs, lfs._VERSION) | ||
