| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
TD="$(dirname "$0")" |
| 4 |
LOGLEVEL=I |
| 5 |
USECOLORS=no |
| 6 |
. "$TD/testlib.sh" |
| 7 |
if [ -n "$PBUILDER_CHECKOUT" ]; then |
| 8 |
. "$PBUILDER_CHECKOUT/pbuilder-modules" |
| 9 |
else |
| 10 |
. "$PBUILDER_TEST_PKGLIBDIR/pbuilder-modules" |
| 11 |
fi |
| 12 |
|
| 13 |
function test_information() { |
| 14 |
log "I: test" |
| 15 |
log "W: warning" |
| 16 |
log "E: error" |
| 17 |
} |
| 18 |
expect_output "I: test |
| 19 |
W: warning |
| 20 |
E: error" test_information |
| 21 |
expect_stderr "W: warning |
| 22 |
E: error" test_information |
| 23 |
|
| 24 |
function test_log() { |
| 25 |
log.d "debug" # this should not be printed in LOGLEVEL=I (the default) |
| 26 |
log.i "info" |
| 27 |
log.w "warn" |
| 28 |
log.e "error" |
| 29 |
} |
| 30 |
expect_output "I: info |
| 31 |
W: warn |
| 32 |
E: error" test_log |
| 33 |
expect_stderr "W: warn |
| 34 |
E: error" test_log |
| 35 |
LOGLEVEL=D |
| 36 |
expect_output "D: debug |
| 37 |
I: info |
| 38 |
W: warn |
| 39 |
E: error" test_log |
| 40 |
USECOLORS=yes |
| 41 |
expect_output "$(printf "\033[0;34mD: debug\033[0m |
| 42 |
\033[0mI: info\033[0m |
| 43 |
\033[1;33mW: warn\033[0m |
| 44 |
\033[0;31mE: error\033[0m")" test_log |
| 45 |
|
| 46 |
# return to regular/stable output |
| 47 |
LOGLEVEL=I |
| 48 |
USECOLORS=no |
| 49 |
|
| 50 |
# test the non-copy case |
| 51 |
function test_conditional_cp_a() { |
| 52 |
( |
| 53 |
TEMPDIR=$(mktemp -d) |
| 54 |
cd "${TEMPDIR}" |
| 55 |
touch "hoge" |
| 56 |
outdir=$(readlink -f "${TEMPDIR}/..") |
| 57 |
conditional_cp_a "hoge" "${outdir}" echo |
| 58 |
) |
| 59 |
} |
| 60 |
expect_output "I: file hoge is already in target, not copying." \ |
| 61 |
test_conditional_cp_a |
| 62 |
|
| 63 |
# test the copy case. |
| 64 |
function test_conditional_cp_a_copy() { |
| 65 |
( |
| 66 |
cd /tmp |
| 67 |
outdir=/something-else |
| 68 |
conditional_cp_a "hoge" "${outdir}" echo |
| 69 |
) |
| 70 |
} |
| 71 |
expect_output "-a hoge /something-else" test_conditional_cp_a_copy |
| 72 |
|
| 73 |
|
| 74 |
expect_output "The foo team <[email protected]>" get822field Maintainer "$TESTDATA_DIR/srccontrol1" |
| 75 |
expect_output " |
| 76 |
Bar <[email protected]>, |
| 77 |
Foo Bar <[email protected]>," get822field Uploaders "$TESTDATA_DIR/srccontrol1" |
| 78 |
|
| 79 |
testlib_summary |