summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Piédallu <felix@piedallu.me>2020-02-20 16:00:10 +0100
committerBastien Nocera <hadess@hadess.net>2020-02-20 18:00:16 +0100
commit6fb21a2046d93f66f4625c0bcddfc5fbef27c501 (patch)
tree8359bfe48546d80aa111ba8609f148c54ef53bdf
parentb1662f0ca3d3f68ff1b7a1a5ebeafd915c1f7820 (diff)
downloadshared-mime-info-6fb21a2046d93f66f4625c0bcddfc5fbef27c501.tar.gz
build: Add script to check for duplicated mime-types
Replaces the shell in Makefile.am
-rw-r--r--Makefile.am10
-rwxr-xr-xtests/test_duplicate_mime_types.sh15
2 files changed, 18 insertions, 7 deletions
diff --git a/Makefile.am b/Makefile.am
index 1eaf72e1..8c1bd0f7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -38,7 +38,8 @@ EXTRA_DIST = \
shared-mime-info.pc.in \
data/freedesktop_generate.sh \
po/check_translations.sh \
- tests/test_generic_icons.sh
+ tests/test_generic_icons.sh \
+ tests/test_duplicate_mime_types.sh
CLEANFILES = freedesktop.org.xml po/stamp-it
@@ -128,12 +129,7 @@ else
rm -rf "$(top_builddir)/temp-mime-dir/" ; \
fi; \
fi
- @if test x`grep '<mime-type' $(srcdir)/data/freedesktop.org.xml.in | tr -d '[:blank:]' | sort | uniq -d` != "x"; then \
- echo "*************************************************************" ; \
- echo "*** Some mime-types are duplicated, fix before committing ***" ; \
- echo "*************************************************************" ; \
- exit 1 ; \
- fi
+ @$(srcdir)/tests/test_duplicate_mime_types.sh $(srcdir)/data/freedesktop.org.xml.in
@$(srcdir)/tests/test_generic_icons.sh $(srcdir)/data/freedesktop.org.xml.in
endif
diff --git a/tests/test_duplicate_mime_types.sh b/tests/test_duplicate_mime_types.sh
new file mode 100755
index 00000000..401b383d
--- /dev/null
+++ b/tests/test_duplicate_mime_types.sh
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+
+xml_db_file="${1}"
+
+duplicated=$(
+ grep '<mime-type' ${xml_db_file} | tr -d '[:blank:]' | sort | uniq -d
+)
+
+if [[ -n "${duplicated}" ]]; then
+ echo "*************************************************************"
+ echo "** Some mime-types are duplicated, fix before committing: **"
+ echo "${duplicated}"
+ echo "*************************************************************"
+ exit 1
+fi