Skip to content

Commit

Permalink
shellcheck: fix some double-quoting warning
Browse files Browse the repository at this point in the history
  • Loading branch information
andy5995 committed Dec 2, 2024
1 parent c69b73c commit 29be738
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 103 deletions.
1 change: 1 addition & 0 deletions packaging/appimage/pre-appimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set -ev

# Set default workspace if not provided
WORKSPACE=${WORKSPACE:-$(pwd)}
echo $WORKSPACE
# Check if the workspace path is absolute
if [[ "$WORKSPACE" != /* ]]; then
echo "The workspace path must be absolute"
Expand Down
4 changes: 2 additions & 2 deletions test/COMMON
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if test -z "${MESON_BUILD_ROOT}" || test -z "${RMW_FAKE_HOME}"; then
exit 1
fi

RMW_FAKE_HOME=${RMW_FAKE_HOME}/$(basename $0)_dir
RMW_FAKE_HOME="${RMW_FAKE_HOME}"/$(basename $0)_dir
TESTS_DIR="${MESON_SOURCE_ROOT}/test"
CONFIG="${MESON_SOURCE_ROOT}/test/conf/rmw.testrc"
ALT_CONFIG="${MESON_SOURCE_ROOT}/test/conf/rmw.alt.testrc"
Expand All @@ -43,7 +43,7 @@ fi

RMW_TEST_CMD_STRING="${BIN_DIR}/rmw -c $CONFIG"

PRIMARY_WASTE_DIR=${RMW_FAKE_HOME}/.Waste
PRIMARY_WASTE_DIR="${RMW_FAKE_HOME}"/.Waste

RMW_ALT_TEST_CMD_STRING="${BIN_DIR}/rmw -c ${ALT_CONFIG}"
RMW_PURGE_DISABLED_CMD="${BIN_DIR}/rmw -c ${PURGE_DISABLED_CONFIG}"
Expand Down
54 changes: 27 additions & 27 deletions test/test_basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ fi
echo "== On first run, directories should get created"
$RMW_TEST_CMD_STRING

echo $SEPARATOR
echo "$SEPARATOR"
echo "List the waste folders..."
echo "rmw should display folders on removable devices that are not mounted"
echo $SEPARATOR
echo "$SEPARATOR"
output="$($RMW_TEST_CMD_STRING -l)"
echo "${output}"
test "${output}" = "/mnt/fs/Trash-$(id -u)
Expand All @@ -22,21 +22,21 @@ test "${output}" = "/mnt/fs/Trash-$(id -u)
"${MESON_BUILD_ROOT}"/test/rmw-tests-home/test_basic.sh_dir/.local/share/Waste-2
"${MESON_BUILD_ROOT}"/test/rmw-tests-home/test_basic.sh_dir/.local/share/Waste-3"

echo $SEPARATOR
echo "$SEPARATOR"

cd "${RMW_FAKE_HOME}"
# Make some temporary files
mkdir tmp-files
cd "${RMW_FAKE_HOME}/tmp-files"
cd "${RMW_FAKE_HOME}"/tmp-files

echo "\n\n == creating temporary files to be deleted"
for file in 1 2 3; do
touch $file
done
cd ${RMW_FAKE_HOME}/..
cd "${RMW_FAKE_HOME}"/..

echo "\n\n == rmw should be able to operate on multiple files\n"
$RMW_TEST_CMD_STRING --verbose ${RMW_FAKE_HOME}/tmp-files/*
$RMW_TEST_CMD_STRING --verbose "${RMW_FAKE_HOME}"/tmp-files/*

test -f "${PRIMARY_WASTE_DIR}/files/1"
test -f "${PRIMARY_WASTE_DIR}/files/2"
Expand All @@ -45,60 +45,60 @@ test -f "${PRIMARY_WASTE_DIR}/info/1.trashinfo"
test -f "${PRIMARY_WASTE_DIR}/info/2.trashinfo"
test -f "${PRIMARY_WASTE_DIR}/info/3.trashinfo"

echo $SEPARATOR
echo "$SEPARATOR"
echo "rmw should append a time_string to duplicate files..."
cd ${RMW_FAKE_HOME}/tmp-files
cd "${RMW_FAKE_HOME}"/tmp-files
for file in 1 2 3; do
touch $file
done
$RMW_TEST_CMD_STRING 1 2 3

echo "\n\n == Show contents of the files and info directories"

test -n "$(ls -A $PRIMARY_WASTE_DIR/files)"
test -n "$(ls -A $PRIMARY_WASTE_DIR/info)"
test -n "$(ls -A "$PRIMARY_WASTE_DIR"/files)"
test -n "$(ls -A "$PRIMARY_WASTE_DIR"/info)"

output="$(ls -A $PRIMARY_WASTE_DIR/files | wc -l | sed 's/ //g')"
output="$(ls -A "$PRIMARY_WASTE_DIR"/files | wc -l | sed 's/ //g')"
test "$output" = "6"

echo $SEPARATOR
echo "$SEPARATOR"
echo " == rmw should refuse to move a waste folder or a file that resides within a waste folder"
output="$($RMW_TEST_CMD_STRING $PRIMARY_WASTE_DIR/info)"
test "${output}" = " :warning: $PRIMARY_WASTE_DIR/info resides within a waste folder and has been ignored
output="$($RMW_TEST_CMD_STRING "$PRIMARY_WASTE_DIR"/info)"
test "${output}" = " :warning: "$PRIMARY_WASTE_DIR"/info resides within a waste folder and has been ignored
0 items were removed to the waste folder"

# If the file gets removed (which it shouldn't), then the test that follows it will fail
$RMW_TEST_CMD_STRING $PRIMARY_WASTE_DIR/info/1.trashinfo
$RMW_TEST_CMD_STRING "$PRIMARY_WASTE_DIR"/info/1.trashinfo

echo "\n\n == Display contents of 1.trashinfo "
cat $PRIMARY_WASTE_DIR/info/1.trashinfo
cat "$PRIMARY_WASTE_DIR"/info/1.trashinfo

echo $SEPARATOR
echo "$SEPARATOR"
echo " == Test -m option"
output=$($RMW_TEST_CMD_STRING --verbose -m)
cmp_substr "$output" ".Waste/files/1_"
cmp_substr "$output" ".Waste/files/2_"
cmp_substr "$output" ".Waste/files/3_"

echo $SEPARATOR
echo "$SEPARATOR"
echo " == test undo/restore feature"

$RMW_TEST_CMD_STRING --verbose -u
$RMW_TEST_CMD_STRING --verbose -z $PRIMARY_WASTE_DIR/files/1
$RMW_TEST_CMD_STRING --verbose -z $PRIMARY_WASTE_DIR/files/2
$RMW_TEST_CMD_STRING --verbose -z $PRIMARY_WASTE_DIR/files/3
$RMW_TEST_CMD_STRING --verbose -z "$PRIMARY_WASTE_DIR"/files/1
$RMW_TEST_CMD_STRING --verbose -z "$PRIMARY_WASTE_DIR"/files/2
$RMW_TEST_CMD_STRING --verbose -z "$PRIMARY_WASTE_DIR"/files/3

echo "\n\n == test that the files are restored to their previous locations"

test -f ${RMW_FAKE_HOME}/tmp-files/1
test -f ${RMW_FAKE_HOME}/tmp-files/2
test -f ${RMW_FAKE_HOME}/tmp-files/3
test -f "${RMW_FAKE_HOME}"/tmp-files/1
test -f "${RMW_FAKE_HOME}"/tmp-files/2
test -f "${RMW_FAKE_HOME}"/tmp-files/3

echo "\n\n == test that the .trashinfo files have been removed"

test ! -f $PRIMARY_WASTE_DIR/info/1.trashinfo
test ! -f $PRIMARY_WASTE_DIR/info/2.trashinfo
test ! -f $PRIMARY_WASTE_DIR/info/3.trashinfo
test ! -f "$PRIMARY_WASTE_DIR"/info/1.trashinfo
test ! -f "$PRIMARY_WASTE_DIR"/info/2.trashinfo
test ! -f "$PRIMARY_WASTE_DIR"/info/3.trashinfo

# Ignore dot directories
mkdir tmpdot
Expand Down
84 changes: 42 additions & 42 deletions test/test_purging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ echo "== On first run, directories should get created"
$RMW_TEST_CMD_STRING

# Make some temporary files using a fake-year
mkdir ${RMW_FAKE_HOME}/tmp-files
cd ${RMW_FAKE_HOME}/tmp-files
mkdir "${RMW_FAKE_HOME}"/tmp-files
cd "${RMW_FAKE_HOME}"/tmp-files


create_temp_files() {
cd ${RMW_FAKE_HOME}/tmp-files
cd "${RMW_FAKE_HOME}"/tmp-files

echo "\n\n == creating temporary files to be rmw'ed"

Expand All @@ -41,17 +41,17 @@ create_temp_files() {
echo
echo
echo " Creating some files for testing..."
cd ${RMW_FAKE_HOME}
cd "${RMW_FAKE_HOME}"
create_some_files

echo
echo
echo " == rmw --empty command should completely purge the waste folders,"
echo " == no matter when they were deleted"

$RMW_TEST_CMD_STRING --verbose ${RMW_FAKE_HOME}/somefiles/*
$RMW_TEST_CMD_STRING --verbose "${RMW_FAKE_HOME}"/somefiles/*

echo $SEPARATOR
echo "$SEPARATOR"
echo ' == purging disabled should output a message that purging is disabled'
output=`$RMW_PURGE_DISABLED_CMD --empty -f`
expected=`echo "purging is disabled ('expire_age' is set to '0')" | cut -b1-20`
Expand All @@ -73,99 +73,99 @@ echo "n" | $RMW_TEST_CMD_STRING --purge --empty
echo "Nqer" | $RMW_TEST_CMD_STRING --purge --empty

echo " == (files should still be present)"
test -e $PRIMARY_WASTE_DIR/files/read_only_file
test -e $PRIMARY_WASTE_DIR/files/topdir
test -e "$PRIMARY_WASTE_DIR"/files/read_only_file
test -e "$PRIMARY_WASTE_DIR"/files/topdir

echo $SEPARATOR
echo "$SEPARATOR"
echo " == Make sure the correct string (filename) is displayed when using -vvg"
output="$($RMW_TEST_CMD_STRING -vvg)"
echo $output
cmp_substr "$output" "'read_only_file' will be purged in 90$(locale decimal_point)"
cmp_substr "$output" "'topdir' will be purged in 90$(locale decimal_point)"

echo $SEPARATOR
echo "$SEPARATOR"
echo " == Empty works with force empty (-fe)"
echo "y" | $RMW_TEST_CMD_STRING -v --empty -ff
test ! -e $PRIMARY_WASTE_DIR/files/read_only_file
test ! -e $PRIMARY_WASTE_DIR/files/topdir
test ! -e $PRIMARY_WASTE_DIR/info/read_only_file.trashinfo
test ! -e $PRIMARY_WASTE_DIR/info/topdir.trashinfo
test ! -e "$PRIMARY_WASTE_DIR"/files/read_only_file
test ! -e "$PRIMARY_WASTE_DIR"/files/topdir
test ! -e "$PRIMARY_WASTE_DIR"/info/read_only_file.trashinfo
test ! -e "$PRIMARY_WASTE_DIR"/info/topdir.trashinfo

echo " == Should work with 'Y' or 'y'"
create_temp_files
$RMW_TEST_CMD_STRING --verbose ${RMW_FAKE_HOME}/tmp-files/* && echo "y" | $RMW_TEST_CMD_STRING --empty
$RMW_TEST_CMD_STRING --verbose "${RMW_FAKE_HOME}"/tmp-files/* && echo "y" | $RMW_TEST_CMD_STRING --empty

create_temp_files
$RMW_TEST_CMD_STRING --verbose ${RMW_FAKE_HOME}/tmp-files/*
test -e $PRIMARY_WASTE_DIR/files/abc
test -e $PRIMARY_WASTE_DIR/files/123
test -e $PRIMARY_WASTE_DIR/files/xyz
$RMW_TEST_CMD_STRING --verbose "${RMW_FAKE_HOME}"/tmp-files/*
test -e "$PRIMARY_WASTE_DIR"/files/abc
test -e "$PRIMARY_WASTE_DIR"/files/123
test -e "$PRIMARY_WASTE_DIR"/files/xyz
echo "Y" | $RMW_TEST_CMD_STRING --empty

echo
echo
echo " == Test that the files are really gone"

test ! -e $PRIMARY_WASTE_DIR/files/abc
test ! -e $PRIMARY_WASTE_DIR/info/abc.trashinfo
test ! -e $PRIMARY_WASTE_DIR/files/123
test ! -e $PRIMARY_WASTE_DIR/info/123.trashinfo
test ! -e $PRIMARY_WASTE_DIR/files/xyz
test ! -e $PRIMARY_WASTE_DIR/info/xyz.trashinfo
test ! -e "$PRIMARY_WASTE_DIR"/files/abc
test ! -e "$PRIMARY_WASTE_DIR"/info/abc.trashinfo
test ! -e "$PRIMARY_WASTE_DIR"/files/123
test ! -e "$PRIMARY_WASTE_DIR"/info/123.trashinfo
test ! -e "$PRIMARY_WASTE_DIR"/files/xyz
test ! -e "$PRIMARY_WASTE_DIR"/info/xyz.trashinfo

create_temp_files

cd ${RMW_FAKE_HOME}/..
cd "${RMW_FAKE_HOME}"/..
echo "\n\n == use a built-in environmental variable to write a"
echo " == fake year to the .trashinfo files when running rmw"
echo "-----------------------------------------------------\n"

RMW_FAKE_YEAR=true $RMW_TEST_CMD_STRING --verbose ${RMW_FAKE_HOME}/tmp-files/*
cmp_substr "$(cat $PRIMARY_WASTE_DIR/info/abc.trashinfo)" \
RMW_FAKE_YEAR=true $RMW_TEST_CMD_STRING --verbose "${RMW_FAKE_HOME}"/tmp-files/*
cmp_substr "$(cat "$PRIMARY_WASTE_DIR"/info/abc.trashinfo)" \
"DeletionDate=1999"

echo
echo
echo " == The trashinfo records that these files were rmw'ed in 1999"
echo " == So they will be purged now."
$RMW_TEST_CMD_STRING --verbose --purge
test ! -e $PRIMARY_WASTE_DIR/files/abc
test ! -e $PRIMARY_WASTE_DIR/info/abc.trashinfo
test ! -e $PRIMARY_WASTE_DIR/files/123
test ! -e $PRIMARY_WASTE_DIR/info/123.trashinfo
test ! -e $PRIMARY_WASTE_DIR/files/xyz
test ! -e $PRIMARY_WASTE_DIR/info/xyz.trashinfo
test ! -e "$PRIMARY_WASTE_DIR"/files/abc
test ! -e "$PRIMARY_WASTE_DIR"/info/abc.trashinfo
test ! -e "$PRIMARY_WASTE_DIR"/files/123
test ! -e "$PRIMARY_WASTE_DIR"/info/123.trashinfo
test ! -e "$PRIMARY_WASTE_DIR"/files/xyz
test ! -e "$PRIMARY_WASTE_DIR"/info/xyz.trashinfo

echo
echo
echo " Creating some files for testing..."
cd ${RMW_FAKE_HOME}
cd "${RMW_FAKE_HOME}"
create_some_files

echo $SEPARATOR
echo "$SEPARATOR"
echo " == rmw should be able to purge directories and subdirectories"
echo " == even if some of the dirs are read-only"

echo $SEPARATOR
echo "$SEPARATOR"

RMW_FAKE_YEAR=True $RMW_TEST_CMD_STRING --verbose ${RMW_FAKE_HOME}/somefiles
RMW_FAKE_YEAR=True $RMW_TEST_CMD_STRING --verbose "${RMW_FAKE_HOME}"/somefiles

echo $SEPARATOR
echo "$SEPARATOR"
echo " == 1 f, this should pass"
$RMW_TEST_CMD_STRING -f --purge

echo
echo
echo " == Show that the files are really gone"

test ! -e $PRIMARY_WASTE_DIR/files/somefiles
test ! -e $PRIMARY_WASTE_DIR/info/somefiles.trashinfo
test ! -e "$PRIMARY_WASTE_DIR"/files/somefiles
test ! -e "$PRIMARY_WASTE_DIR"/info/somefiles.trashinfo

$RMW_TEST_CMD_STRING -o

echo " == Test 'show_purge_stats' == "
create_temp_files
RMW_FAKE_YEAR=True $RMW_TEST_CMD_STRING ${RMW_FAKE_HOME}/tmp-files/*
RMW_FAKE_YEAR=True $RMW_TEST_CMD_STRING "${RMW_FAKE_HOME}"/tmp-files/*
output=$($RMW_TEST_CMD_STRING -g)
echo $output
cmp_substr "$output" "Purging files based"
Expand Down
Loading

0 comments on commit 29be738

Please sign in to comment.