summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Piédallu <felix@piedallu.me>2020-02-20 16:08:57 +0100
committerBastien Nocera <hadess@hadess.net>2020-02-20 17:04:04 +0100
commitb4f50daac4973cf1b14a089c49c4f637506c9911 (patch)
tree3cb25536323587202fafd576d3977071559ad96e
parent872f28a4efbb4657e8f025756d138b1ad5086fab (diff)
downloadshared-mime-info-b4f50daac4973cf1b14a089c49c4f637506c9911.tar.gz
build: Add script to run the mime detection tests
Replaces the shell in Makefile.am
-rw-r--r--Makefile.am8
-rwxr-xr-xtests/test_mime.sh26
2 files changed, 27 insertions, 7 deletions
diff --git a/Makefile.am b/Makefile.am
index f4691e11..b71d7b0f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -116,13 +116,7 @@ else
echo "***************************************************************************" ; \
exit 1 ; \
else \
- mkdir -p $(top_builddir)/temp-mime-dir/mime/packages ; \
- cp -a $(top_builddir)/freedesktop.org.xml $(top_builddir)/temp-mime-dir/mime/packages/ ; \
- XDG_DATA_DIRS="$(top_builddir)/temp-mime-dir/" $(top_builddir)/update-mime-database$(EXEEXT) "$(top_builddir)/temp-mime-dir/mime/" ; \
- XDG_DATA_DIRS="$(top_builddir)/temp-mime-dir/" XDG_DATA_HOME="$(top_builddir)/temp-mime-dir/" $(XDGMIME_PATH)/src/test-mime-data$(EXEEXT) -v $(top_srcdir)/tests/mime-detection/list || exit 1; \
- XDG_DATA_DIRS="$(top_builddir)/temp-mime-dir/" XDG_DATA_HOME="$(top_builddir)/temp-mime-dir/" $(XDGMIME_PATH)/src/test-mime$(EXEEXT) || exit 1; \
- XDG_DATA_DIRS="$(top_builddir)/temp-mime-dir/" $(top_builddir)/test-tree-magic$(EXEEXT) $(top_srcdir)/tests/mime-detection/tree-list || exit 1; \
- rm -rf "$(top_builddir)/temp-mime-dir/" ; \
+ $(srcdir)/tests/test_mime.sh "$(top_srcdir)" "$(top_builddir)" "$(top_builddir)/freedesktop.org.xml" "$(top_builddir)/update-mime-database$(EXEEXT)" "$(XDGMIME_PATH)/src/test-mime-data$(EXEEXT)" "$(XDGMIME_PATH)/src/test-mime$(EXEEXT)" "$(top_builddir)/test-tree-magic$(EXEEXT)" || exit 1; \
fi; \
fi
@$(srcdir)/tests/test_duplicate_mime_types.sh $(srcdir)/data/freedesktop.org.xml.in
diff --git a/tests/test_mime.sh b/tests/test_mime.sh
new file mode 100755
index 00000000..49c531b6
--- /dev/null
+++ b/tests/test_mime.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+set -e
+
+source_root="${1}"
+build_root="${2}"
+xml_db_file="${3}"
+update_mime_database="${4}"
+xdgmime_test_mime_data="${5}"
+xdgmime_test_mime="${6}"
+test_tree_magic="${7}"
+
+tmp_dir=`mktemp -d`
+
+mkdir -p "${tmp_dir}/mime/packages"
+
+cp -a "${xml_db_file}" "${tmp_dir}/mime/packages/"
+
+export XDG_DATA_DIRS="${tmp_dir}"
+export XDG_DATA_HOME="${tmp_dir}"
+
+"${update_mime_database}" "${tmp_dir}/mime/"
+"${xdgmime_test_mime_data}" -v "${source_root}/tests/mime-detection/list"
+"${xdgmime_test_mime}"
+"${test_tree_magic}" "${source_root}/tests/mime-detection/tree-list"
+
+rm -rf "${tmp_dir}"