-
Notifications
You must be signed in to change notification settings - Fork 102
/
test.sh
executable file
·147 lines (119 loc) · 3.93 KB
/
test.sh
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
set -e
# setup tests
## remove old build results
rm -rf deb_dist
# setup paths
if [ "${PYEXE}" == "" ]; then
PYEXE=`which python`;
fi
echo "using Python at ${PYEXE}"
PY2DSC_LOC=`which py2dsc`
PY2DSC_DEB_LOC=`which py2dsc-deb`
PYPI_DOWNLOAD_LOC=`which pypi-download`
PYPI_INSTALL_LOC=`which pypi-install`
PY2DSC="${PYEXE} ${PY2DSC_LOC}"
PY2DSC_DEB="${PYEXE} ${PY2DSC_DEB_LOC}"
PYPI_DOWNLOAD="${PYEXE} ${PYPI_DOWNLOAD_LOC}"
PYPI_INSTALL="${PYEXE} ${PYPI_INSTALL_LOC}"
# Run tests
## Test some basic tests. Just make sure these don't fail.
${PY2DSC} --help > /dev/null
${PY2DSC_DEB} --help > /dev/null
${PYPI_DOWNLOAD} --help > /dev/null
${PYPI_INSTALL} --help > /dev/null
## Run test cases on each of the following packages
# Set an upper bound on the size of the compressed deb_specific. We are not
# applying any patches here so this should be pretty small.
MAX_DEB_SPECIFIC_SIZE=5000
for i in `seq 1 3`; do
if [ $i -eq "1" ]; then
SOURCE_PACKAGE=requests
SOURCE_RELEASE=2.6.0
SOURCE_TARBALL_DIR=${SOURCE_PACKAGE}-${SOURCE_RELEASE}
SOURCE_TARBALL=${SOURCE_TARBALL_DIR}.tar.gz
DEBSOURCE=${SOURCE_TARBALL_DIR}
elif [ $i -eq "2" ]; then
SOURCE_PACKAGE=Reindent
SOURCE_RELEASE=0.1.1
SOURCE_TARBALL_DIR=${SOURCE_PACKAGE}-${SOURCE_RELEASE}
SOURCE_TARBALL=${SOURCE_TARBALL_DIR}.tar.gz
DEBSOURCE=reindent-${SOURCE_RELEASE}
elif [ $i -eq "3" ]; then
SOURCE_PACKAGE=psycopg2
SOURCE_RELEASE=2.9.9
SOURCE_TARBALL_DIR=${SOURCE_PACKAGE}-${SOURCE_RELEASE}
SOURCE_TARBALL=${SOURCE_TARBALL_DIR}.tar.gz
DEBSOURCE=${SOURCE_TARBALL_DIR}
else
echo "unknown case"
exit 1
fi
export DEB_BUILD_OPTIONS=nocheck # psycopg2 tests fail
# get a file to work with
# ==============================================================
${PYPI_DOWNLOAD} ${SOURCE_PACKAGE} --release ${SOURCE_RELEASE}
# case 1: build from pre-existing source tarball with py2dsc
# ==============================================================
${PY2DSC} $SOURCE_TARBALL
cd deb_dist/$DEBSOURCE
dpkg-buildpackage -rfakeroot -uc -us
cd ../..
for DEBFILE in deb_dist/*.deb; do
echo "contents of $DEBFILE from $SOURCE_TARBALL in case 1:"
dpkg --contents $DEBFILE
done
DEB_SPECIFIC_SIZE=$(stat -c '%s' deb_dist/*.debian.tar.?z)
if ((${DEB_SPECIFIC_SIZE}>${MAX_DEB_SPECIFIC_SIZE})); then
echo "ERROR: debian specific file larger than expected"
exit 1
else
echo "${SOURCE_PACKAGE} case 1: deb_specific size ${DEB_SPECIFIC_SIZE}"
fi
#cleanup case 1
rm -rf deb_dist
# case 2: build from pre-existing source tarball using distutils
# ==============================================================
tar xzf $SOURCE_TARBALL
cd $SOURCE_TARBALL_DIR
which python3
python3 -c "import sys; print('sys.version',sys.version)"
python3 setup.py --command-packages=stdeb.command sdist_dsc
cd deb_dist/$DEBSOURCE
dpkg-buildpackage -rfakeroot -uc -us
cd ../..
for DEBFILE in deb_dist/*.deb; do
echo "contents of $DEBFILE from $SOURCE_TARBALL in case 2:"
dpkg --contents $DEBFILE
done
DEB_SPECIFIC_SIZE=$(stat -c '%s' deb_dist/*.debian.tar.?z)
if ((${DEB_SPECIFIC_SIZE}>${MAX_DEB_SPECIFIC_SIZE})); then
echo "ERROR: debian specific file larger than expected"
exit 1
else
echo "${SOURCE_PACKAGE} case 2: deb_specific size ${DEB_SPECIFIC_SIZE}"
fi
cd ..
#cleanup case 2
# ==============================================================
rm -rf $SOURCE_TARBALL_DIR
# case 3: build from pre-existing source tarball with py2dsc
# ==============================================================
${PY2DSC_DEB} $SOURCE_TARBALL
for DEBFILE in deb_dist/*.deb; do
echo "contents of $DEBFILE from $SOURCE_TARBALL in case 3:"
dpkg --contents $DEBFILE
done
DEB_SPECIFIC_SIZE=$(stat -c '%s' deb_dist/*.debian.tar.?z)
if ((${DEB_SPECIFIC_SIZE}>${MAX_DEB_SPECIFIC_SIZE})); then
echo "ERROR: debian specific file larger than expected"
exit 1
else
echo "${SOURCE_PACKAGE} case 3: deb_specific size ${DEB_SPECIFIC_SIZE}"
fi
#cleanup case 3
rm -rf deb_dist
#cleanup original tarball
rm -rf $SOURCE_TARBALL
done
echo "All tests passed."