aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.sh
blob: f8f1adad5e1c18198bc93316a44bb854b7ecd8d4 (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash

if [ -e ./run_tests.sh ]
then
   cd ../src
elif [ -d src ]
then
   cd src
elif ! [ -d luarocks ]
then
   echo "Go to the src directory and run this."
   exit 1
fi

if [ ! -d ../rocks ]
then
   echo "Downloading entire rocks repository for tests"
   cd ..
   wget -r -nH -np -R"index.*" http://luarocks.org/repositories/rocks/
   cd src
fi

rocks=(
   `ls ../rocks/*.rockspec | grep -v luacom`
   `ls ../rocks/*.src.rock | grep -v luacom`
)

bin/luarocks-admin make-manifest ../rocks || exit 1

[ "$1" ] && rocks=("$1")

TRY() {
   "$@" || {
      echo "Failed running: $@"
      exit 1
   }
}

list_search() {
   bin/luarocks list $name | grep $version
}

for rock in "${rocks[@]}"
do
   base=`basename $rock`
   baserockspec=`basename $rock .rockspec`
   basesrcrock=`basename $rock .src.rock`
   if [ "$base" != "$baserockspec" ]
   then
      base=$baserockspec
      name=`echo $base | sed 's/\(.*\)-[^-]*-[^-]*$/\1/'`
      version=`echo $base | sed 's/.*-\([^-]*-[^-]*\)$/\1/'`
      TRY bin/luarocks pack $rock
      TRY bin/luarocks build $base.src.rock
      TRY rm $base.src.rock
   else
      base=$basesrcrock
      name=`echo $base | sed 's/\(.*\)-[^-]*-[^-]*$/\1/'`
      version=`echo $base | sed 's/.*-\([^-]*-[^-]*\)$/\1/'`
      TRY bin/luarocks build $rock
   fi
   TRY bin/luarocks pack $name $version
   TRY bin/luarocks install $base.*.rock
   TRY rm $base.*.rock
   TRY list_search $name $version
   bin/luarocks remove $name $version
   # TODO: differentiate between error and dependency block.
done

if bin/luarocks install nonexistant | grep "No results"
then echo "OK, got expected error."
else exit 1
fi

TRY ../test/test_deps.lua
TRY ../test/test_require.lua