-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathtest_basic.sh
More file actions
executable file
·125 lines (96 loc) · 3.66 KB
/
test_basic.sh
File metadata and controls
executable file
·125 lines (96 loc) · 3.66 KB
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
#!/bin/sh
set -ve
if [ -e COMMON ]; then
. ./COMMON
else
. "${MESON_SOURCE_ROOT}/test/COMMON"
fi
echo "== On first run, directories should get created"
$RMW_TEST_CMD_STRING
echo "$SEPARATOR"
echo "List the waste folders..."
echo "rmw should display folders on removable devices that are not mounted"
echo "$SEPARATOR"
output="$($RMW_TEST_CMD_STRING -l)"
echo "${output}"
test "${output}" = "/mnt/fs/Trash-$(id -u)
/mnt/sda10000/example_waste
"${MESON_BUILD_ROOT}"/test/rmw-tests-home/test_basic.sh_dir/.Waste
"${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"
cd "${RMW_FAKE_HOME}"
# Make some temporary files
mkdir 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}"/..
echo "\n\n == rmw should be able to operate on multiple files\n"
$RMW_TEST_CMD_STRING --verbose "${RMW_FAKE_HOME}"/tmp-files/*
test -f "${PRIMARY_WASTE_DIR}/files/1"
test -f "${PRIMARY_WASTE_DIR}/files/2"
test -f "${PRIMARY_WASTE_DIR}/files/3"
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 "rmw should append a time_string to duplicate 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)"
output="$(ls -A "$PRIMARY_WASTE_DIR"/files | wc -l | sed 's/ //g')"
test "$output" = "6"
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 || true)"
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 || true
echo "\n\n == Display contents of 1.trashinfo "
cat "$PRIMARY_WASTE_DIR"/info/1.trashinfo
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 " == 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
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
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
# Ignore dot directories
mkdir tmpdot
touch "tmpdot/.hello world"
touch "tmpdot/.hello earth"
output="$($RMW_TEST_CMD_STRING tmpdot/.*)"
cmp_substr "$output" "2 items were removed to the waste folder"
expected="0 orphans found"
output="$($RMW_TEST_CMD_STRING -o)"
test "${output}" = "${expected}"
cmp_substr "$($RMW_ALT_TEST_CMD_STRING -l)" \
"invalid option"
cmp_substr "$($RMW_TEST_CMD_STRING '')" \
"skipping"
output=$($RMW_TEST_CMD_STRING ${RMW_FAKE_HOME})
cmp_substr "$output" "Skipping"
echo "Basic tests passed"
exit 0