diff options
author | Félix Piédallu <felix@piedallu.me> | 2020-02-20 16:11:43 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2020-02-20 17:14:19 +0100 |
commit | 28350d9f2b639b2869a6c6a0e64f6dce632f49df (patch) | |
tree | 2b6852e9c01bb9dfed9cdb360ee258895044ca87 | |
parent | b4f50daac4973cf1b14a089c49c4f637506c9911 (diff) | |
download | shared-mime-info-28350d9f2b639b2869a6c6a0e64f6dce632f49df.tar.gz |
build: Add script to run the local mime detection tests
Replaces the shell in Makefile.am
-rw-r--r-- | Makefile.am | 14 | ||||
-rwxr-xr-x | tests/test_staging.sh | 30 |
2 files changed, 32 insertions, 12 deletions
diff --git a/Makefile.am b/Makefile.am index b71d7b0f..4a89a3a6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -86,18 +86,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}" |