summaryrefslogtreecommitdiff
path: root/sandbox/infrastructure/release-test.sh
blob: a28516614bc9be37907e142877335839660bd739 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash

# testing of a release tarball extracted from release.sh
# because if this breaks release.sh exits
# and running tests again 2.4 to 2.7 automatic never worked for me
# and 3.x is not included

# Author: Lea Wiemann
# Contact: grubert@users.sourceforge.net
# Revision: $Revision: 7548 $
# Date: $Date: 2012-12-13 10:08:17 +0100 (Don, 13 Dez 2012) $
# Copyright: This script has been placed in the public domain.

USAGE="USAGE $0 python-version docutils-version"

py_ver=$1

docutils_ver=$2

if [  -z "`which python$py_ver`" ] ; then
    echo "ERROR python$py_ver not found."
    echo $USAGE
    exit 1
fi

tarball=docutils-${docutils_ver}.tar.gz

if [ ! -e $tarball ] ; then
    echo "ERROR $tarball not found."
    echo $USAGE
    exit 1
fi

function print_command()
{
    # Print "$@", quoting parameters containing spaces.
    echo -n $
    for param in "$@"; do
        echo "$param" | grep -Fq ' ' && echo -n " '$param'" || echo -n " $param"
    done
}

function run()
{
    # Print and run "$@".
    print_command "$@"
    echo
    "$@"
}

echo "Testing the release tarball: docutils-${docutils_ver} under python$py_ver."

echo "ATTENTION: some parts must be run as root/sudo to be able to remove/install into site-packages."

START_DIR=`pwd`

test_dir=tarball_test
run rm -rf $test_dir
run mkdir -p $test_dir
cd $test_dir

py_ver_maj=${py_ver:0:1}
echo "Deleting and installing Docutils on Python $py_ver ($py_ver_maj)."
echo "Press enter."
read

if [ $py_ver_maj = "2" ] ; then
    docutils_install_dir=$(python$py_ver -c 'import docutils, os.path; print os.path.dirname(docutils.__file__)')
else
    docutils_install_dir=$(python$py_ver -c 'import docutils, os.path; print(os.path.dirname(docutils.__file__))')
fi

if [ -z "$docutils_install_dir" ] ; then
    echo "No docutils installation found"
else
    echo "docutils installation found: $docutils_install_dir"
    echo "remove docutils installation (sudo). Ctrl-C to abort"
    read
    sudo rm -rfv $docutils_install_dir
fi

echo "build and install (sudo). Ctrl-C to abort"
read
run tar xzf ../$tarball

cd docutils-"$docutils_ver"

python$py_ver setup.py build
sudo python$py_ver setup.py install
echo
echo "Remove __init__.py from docutils code directory to make sure it is not used.."
read
rm -rf docutils/__init__.py

# BUG test-dependecies.py
# * breaks on record.txt access if not run as root
# * fails missing dependencies to files in docutils/docs.

echo "run alltests.py"

if [ ${py_ver_maj} = "2" ] ; then
    TESTD=test
else
    TESTD=test3
fi

python$py_ver -u ${TESTD}/alltests.py

echo "remove test directory Ctrl C to abort"
read
cd $START_DIR
rm -rfv $test_dir