blob: dcc696e48633351a701383d9ea7eee23ee607dfd (
plain)
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
|
#!/bin/bash
set -eu
THIS="$(realpath "$0")"
THISDIR="$(dirname "${THIS}")"
SUT="$(dirname "${THISDIR}")/makeself.sh"
testWhiteSpaceLicense() {
# for each license file: its canonical path is identical to its content
local license_dir="$(mktemp -dt license_dir.XXXXXX)"
(
cd "${license_dir}"
cat >"$(printf "_\x09_character_tabulation.txt")" <<EOF
$(printf "_\x09_character_tabulation.txt")
EOF
cat >"$(printf "_\x0b_line_tabulation.txt")" <<EOF
$(printf "_\x0b_line_tabulation.txt")
EOF
cat >"$(printf "_\x0c_form_feed.txt")"<<EOF
$(printf "_\x0c_form_feed.txt")
EOF
cat >"$(printf "_\x0d_carriage_return.txt")"<<EOF
$(printf "_\x0d_carriage_return.txt")
EOF
cat >"$(printf "_\x20_space.txt")"<<EOF
$(printf "_\x20_space.txt")
EOF
)
# The extraction progress diagnostics are buggy on empty archives, so give
# it something to extract
local archive_dir="$(mktemp -dt archive_dir.XXXXXX)"
(
cd "${archive_dir}"
touch foo bar qux
)
local file_name="$(mktemp -t file_name.XXXXXX)"
local label=""
local license_text=""
find "${license_dir}" -type f | while read license_file; do
"${SUT}" \
--license "${license_file}" \
"${archive_dir}" \
"${file_name}" \
"Label" \
ls -lah
assertEquals "$?" 0
# Assumes the license text is the first line of output
license_text="$("${file_name}" --accept --nox11 | head -n1)"
# This doesn't work for character tabulation...
#assertEquals "${license_text}" "${license_file}"
# ...so do this instead:
assertEquals \
"$(cat "${license_file}" | md5sum | cut -d' ' -f1)" \
"$(echo "${license_text}" | md5sum | cut -d' ' -f1)"
done
rm -rf "${license_dir}" "${archive_dir}" "${file_name}"
}
# Load and run shUnit2.
source "./shunit2/shunit2"
|