summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2020-12-26 10:35:23 +0200
committerVille Skyttä <ville.skytta@iki.fi>2020-12-26 10:42:48 +0200
commitaaeb7a135a062c2fd85ed004e345cac7c267c999 (patch)
tree8e314fb9aadb7578bc129742ba29c80a149fafe8
parent5d1fc68df463f493de454f3cdcba2c9992cb4fb4 (diff)
downloadshared-mime-info-aaeb7a135a062c2fd85ed004e345cac7c267c999.tar.gz
tests: implement duplicate type check with xpath, check aliases too
-rwxr-xr-xtests/test_duplicate_mime_types.sh10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/test_duplicate_mime_types.sh b/tests/test_duplicate_mime_types.sh
index 401b383d..e7dfb150 100755
--- a/tests/test_duplicate_mime_types.sh
+++ b/tests/test_duplicate_mime_types.sh
@@ -1,9 +1,17 @@
#!/usr/bin/env bash
+set -euo pipefail
+: ${1:?filename argument missing}
xml_db_file="${1}"
+test -f ${xml_db_file} || {
+ printf "%s: no such file\n" ${xml_db_file} >&2
+ exit 1
+}
duplicated=$(
- grep '<mime-type' ${xml_db_file} | tr -d '[:blank:]' | sort | uniq -d
+ xmllint --xpath \
+ "//*[local-name()='mime-type' or local-name()='alias']/@type" \
+ ${xml_db_file} | tr ' ' '\n' | sort | uniq -d
)
if [[ -n "${duplicated}" ]]; then