~ubuntu-branches/ubuntu/intrepid/git-core/intrepid-updates

« back to all changes in this revision

Viewing changes to t/test-lib.sh

  • Committer: Package Import Robot
  • Author(s): Gerrit Pape
  • Date: 2007-04-22 13:31:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20070422133105-xg8fnm18r2cxcbg1
Tags: upstream-1.5.1.2
ImportĀ upstreamĀ versionĀ 1.5.1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
unset GIT_OBJECT_DIRECTORY
31
31
unset SHA1_FILE_DIRECTORIES
32
32
unset SHA1_FILE_DIRECTORY
 
33
GIT_MERGE_VERBOSITY=5
 
34
export GIT_MERGE_VERBOSITY
33
35
export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
34
36
export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
35
37
export EDITOR VISUAL
76
78
        -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
77
79
                verbose=t; shift ;;
78
80
        --no-python)
79
 
                no_python=t; shift ;;
 
81
                # noop now...
 
82
                shift ;;
80
83
        *)
81
84
                break ;;
82
85
        esac
95
98
 
96
99
trap 'echo >&5 "FATAL: Unexpected exit with code $?"; exit 1' exit
97
100
 
 
101
test_tick () {
 
102
        if test -z "${test_tick+set}"
 
103
        then
 
104
                test_tick=1112911993
 
105
        else
 
106
                test_tick=$(($test_tick + 60))
 
107
        fi
 
108
        GIT_COMMITTER_DATE="$test_tick -0700"
 
109
        GIT_AUTHOR_DATE="$test_tick -0700"
 
110
        export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
 
111
}
98
112
 
99
113
# You are not expected to call test_ok_ and test_failure_ directly, use
100
114
# the text_expect_* functions instead.
124
138
        return 0
125
139
}
126
140
 
 
141
test_skip () {
 
142
        this_test=$(expr "./$0" : '.*/\(t[0-9]*\)-[^/]*$')
 
143
        this_test="$this_test.$(expr "$test_count" + 1)"
 
144
        to_skip=
 
145
        for skp in $GIT_SKIP_TESTS
 
146
        do
 
147
                case "$this_test" in
 
148
                $skp)
 
149
                        to_skip=t
 
150
                esac
 
151
        done
 
152
        case "$to_skip" in
 
153
        t)
 
154
                say >&3 "skipping test: $@"
 
155
                test_count=$(expr "$test_count" + 1)
 
156
                say "skip $test_count: $1"
 
157
                : true
 
158
                ;;
 
159
        *)
 
160
                false
 
161
                ;;
 
162
        esac
 
163
}
 
164
 
127
165
test_expect_failure () {
128
166
        test "$#" = 2 ||
129
167
        error "bug in the test script: not 2 parameters to test-expect-failure"
130
 
        say >&3 "expecting failure: $2"
131
 
        test_run_ "$2"
132
 
        if [ "$?" = 0 -a "$eval_ret" != 0 -a "$eval_ret" -lt 129 ]
 
168
        if ! test_skip "$@"
133
169
        then
134
 
                test_ok_ "$1"
135
 
        else
136
 
                test_failure_ "$@"
 
170
                say >&3 "expecting failure: $2"
 
171
                test_run_ "$2"
 
172
                if [ "$?" = 0 -a "$eval_ret" != 0 -a "$eval_ret" -lt 129 ]
 
173
                then
 
174
                        test_ok_ "$1"
 
175
                else
 
176
                        test_failure_ "$@"
 
177
                fi
137
178
        fi
138
179
        echo >&3 ""
139
180
}
141
182
test_expect_success () {
142
183
        test "$#" = 2 ||
143
184
        error "bug in the test script: not 2 parameters to test-expect-success"
144
 
        say >&3 "expecting success: $2"
145
 
        test_run_ "$2"
146
 
        if [ "$?" = 0 -a "$eval_ret" = 0 ]
 
185
        if ! test_skip "$@"
147
186
        then
148
 
                test_ok_ "$1"
149
 
        else
150
 
                test_failure_ "$@"
 
187
                say >&3 "expecting success: $2"
 
188
                test_run_ "$2"
 
189
                if [ "$?" = 0 -a "$eval_ret" = 0 ]
 
190
                then
 
191
                        test_ok_ "$1"
 
192
                else
 
193
                        test_failure_ "$@"
 
194
                fi
151
195
        fi
152
196
        echo >&3 ""
153
197
}
155
199
test_expect_code () {
156
200
        test "$#" = 3 ||
157
201
        error "bug in the test script: not 3 parameters to test-expect-code"
158
 
        say >&3 "expecting exit code $1: $3"
159
 
        test_run_ "$3"
160
 
        if [ "$?" = 0 -a "$eval_ret" = "$1" ]
 
202
        if ! test_skip "$@"
161
203
        then
162
 
                test_ok_ "$2"
163
 
        else
164
 
                test_failure_ "$@"
 
204
                say >&3 "expecting exit code $1: $3"
 
205
                test_run_ "$3"
 
206
                if [ "$?" = 0 -a "$eval_ret" = "$1" ]
 
207
                then
 
208
                        test_ok_ "$2"
 
209
                else
 
210
                        test_failure_ "$@"
 
211
                fi
165
212
        fi
166
213
        echo >&3 ""
167
214
}
175
222
        repo="$1"
176
223
        mkdir "$repo"
177
224
        cd "$repo" || error "Cannot setup test environment"
178
 
        "$GIT_EXEC_PATH/git" init-db --template=$GIT_EXEC_PATH/templates/blt/ 2>/dev/null ||
179
 
        error "cannot run git init-db -- have you built things yet?"
 
225
        "$GIT_EXEC_PATH/git" init --template=$GIT_EXEC_PATH/templates/blt/ >/dev/null 2>&1 ||
 
226
        error "cannot run git init -- have you built things yet?"
180
227
        mv .git/hooks .git/hooks-disabled
181
228
        cd "$owd"
182
229
}
207
254
# t/ subdirectory and are run in trash subdirectory.
208
255
PATH=$(pwd)/..:$PATH
209
256
GIT_EXEC_PATH=$(pwd)/..
210
 
HOME=$(pwd)/trash
211
 
export PATH GIT_EXEC_PATH HOME
 
257
GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
 
258
GIT_CONFIG=.git/config
 
259
export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG
212
260
 
213
 
# Similarly use ../compat/subprocess.py if our python does not
214
 
# have subprocess.py on its own.
215
 
PYTHON=`sed -e '1{
216
 
        s/^#!//
217
 
        q
218
 
}' ../git-merge-recursive-old` || {
219
 
        error "You haven't built things yet, have you?"
220
 
}
221
 
"$PYTHON" -c 'import subprocess' 2>/dev/null || {
222
 
        PYTHONPATH=$(pwd)/../compat
223
 
        export PYTHONPATH
224
 
}
225
261
GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
226
262
export GITPERLLIB
227
263
test -d ../templates/blt || {
228
264
        error "You haven't built things yet, have you?"
229
265
}
230
266
 
 
267
if ! test -x ../test-chmtime; then
 
268
        echo >&2 'You need to build test-chmtime:'
 
269
        echo >&2 'Run "make test-chmtime" in the source (toplevel) directory'
 
270
        exit 1
 
271
fi
 
272
 
231
273
# Test repository
232
274
test=trash
233
275
rm -fr "$test"
234
276
test_create_repo $test
235
277
cd "$test"
 
278
 
 
279
this_test=$(expr "./$0" : '.*/\(t[0-9]*\)-[^/]*$')
 
280
for skp in $GIT_SKIP_TESTS
 
281
do
 
282
        to_skip=
 
283
        for skp in $GIT_SKIP_TESTS
 
284
        do
 
285
                case "$this_test" in
 
286
                $skp)
 
287
                        to_skip=t
 
288
                esac
 
289
        done
 
290
        case "$to_skip" in
 
291
        t)
 
292
                say >&3 "skipping test $this_test altogether"
 
293
                say "skip all tests in $this_test"
 
294
                test_done
 
295
        esac
 
296
done