Reorganize tests
* Split out test helper functions into tools/test_functions.sh * bin/_blackbox_common_test.sh: Unit-tests for functions. * blackbox_postdeploy: Use cp_permissions instead of chmod --reference
This commit is contained in:
@@ -380,6 +380,23 @@ function md5sum_file() {
|
||||
esac
|
||||
}
|
||||
|
||||
function cp_permissions() {
|
||||
# Copy the perms of $1 onto $2 .. end.
|
||||
case $(uname -s) in
|
||||
Darwin )
|
||||
chmod $( stat -f '%p' "$1" ) "${@:2}"
|
||||
;;
|
||||
Linux | CYGWIN* )
|
||||
chmod --reference "$1" "${@:2}"
|
||||
;;
|
||||
* )
|
||||
echo 'ERROR: Unknown OS. Exiting.'
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Abstract the difference between git and hg:
|
||||
#
|
||||
|
||||
23
bin/_blackbox_common_test.sh
Executable file
23
bin/_blackbox_common_test.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# _blackbox_common_test.sh -- Unit tests of functions from _blackbox_common.sh
|
||||
#
|
||||
|
||||
set -e
|
||||
. "${0%/*}/_blackbox_common.sh"
|
||||
. tools/test_functions.sh
|
||||
|
||||
PHASE 'Test cp-permissions: TestA'
|
||||
touch TestA TestB TestC TestD
|
||||
chmod 0347 TestA
|
||||
chmod 0700 TestB
|
||||
chmod 0070 TestC
|
||||
chmod 0070 TestD
|
||||
cp_permissions TestA TestB TestC
|
||||
assert_file_perm '--wxr--rwx' TestA
|
||||
assert_file_perm '--wxr--rwx' TestB
|
||||
assert_file_perm '--wxr--rwx' TestC
|
||||
assert_file_perm '----rwx---' TestD
|
||||
|
||||
echo '========== DONE.'
|
||||
@@ -30,7 +30,7 @@ echo '========== Decrypting new/changed files: START'
|
||||
while IFS= read <&99 -r unencrypted_file; do
|
||||
encrypted_file=$(get_encrypted_filename "$unencrypted_file")
|
||||
decrypt_file_overwrite "$encrypted_file" "$unencrypted_file"
|
||||
chmod --reference "$encrypted_file" "$unencrypted_file"
|
||||
cp_permissions "$encrypted_file" "$unencrypted_file"
|
||||
if [[ ! -z "$FILE_GROUP" ]]; then
|
||||
chmod g+r "$unencrypted_file"
|
||||
chgrp "$FILE_GROUP" "$unencrypted_file"
|
||||
|
||||
Reference in New Issue
Block a user