summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Piédallu <felix@piedallu.me>2020-02-20 16:11:43 +0100
committerBastien Nocera <hadess@hadess.net>2020-02-20 18:00:53 +0100
commitbf8b2e770e2523827a1f13dcb8146e7b407cdb67 (patch)
tree8c031cdd7945c6a94f56d67140fee1c01f45df64
parenta37cb4db553eb25c7b02813680533fcfbb961fc8 (diff)
downloadshared-mime-info-bf8b2e770e2523827a1f13dcb8146e7b407cdb67.tar.gz
build: Add script to run the local mime detection tests
Replaces the shell in Makefile.am
-rw-r--r--Makefile.am17
-rwxr-xr-xtests/test_staging.sh30
2 files changed, 34 insertions, 13 deletions
diff --git a/Makefile.am b/Makefile.am
index 36762a78..7af058e5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -40,7 +40,8 @@ EXTRA_DIST = \
po/check_translations.sh \
tests/test_generic_icons.sh \
tests/test_duplicate_mime_types.sh \
- tests/test_mime.sh
+ tests/test_mime.sh \
+ tests/test_staging.sh
CLEANFILES = freedesktop.org.xml po/stamp-it
@@ -91,18 +92,8 @@ local-test: po/shared-mime-info.pot freedesktop.org.xml update-mime-database$(EX
if CROSS_COMPILING
@echo "Cross compiling: Skipping checks"
else
- @if ! test -d staging-tests/ ; then \
- echo "***************************************************************************" ; \
- echo "*** Add your file to process to staging-tests/ and run local-test again ***" ; \
- echo "***************************************************************************" ; \
- exit 1 ; \
- fi
- if test -d $(top_srcdir)/.git/ ; then \
- 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/print-mime-data$(EXEEXT) staging-tests/; \
- rm -rf "$(top_builddir)/temp-mime-dir/" ; \
+ @if test -d $(top_srcdir)/.git/ ; then \
+ $(srcdir)/tests/test_staging.sh "$(top_srcdir)" "$(top_builddir)" "$(top_builddir)/freedesktop.org.xml" "$(top_builddir)/update-mime-database$(EXEEXT)" "$(XDGMIME_PATH)/src/print-mime-data$(EXEEXT)"; \
fi
endif
diff --git a/tests/test_staging.sh b/tests/test_staging.sh
new file mode 100755
index 00000000..db6d919b
--- /dev/null
+++ b/tests/test_staging.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+set -e
+
+source_root="${1}"
+build_root="${2}"
+xml_db_file="${3}"
+update_mime_database="${4}"
+xdgmime_print_mime_data="${5}"
+
+tmp_dir=`mktemp -d`
+
+if [ ! -d "${source_root}/staging-tests" ]; then
+ echo "***************************************************************************"
+ echo "*** Add your file to process to staging-tests/ and run local-test again ***"
+ echo "***************************************************************************"
+ exit 1
+fi
+
+rm -rf "${tmp_dir}"
+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_print_mime_data}" "${source_root}/staging-tests"
+
+rm -rf "${tmp_dir}"