meson-cc-tests/freetype-pcf-long-family-names.c | 7 meson.build | 19 + test/meson.build | 27 ++ test/run-test-conf.sh | 2 test/run-test.sh | 290 ++++++++++++++---------- test/test-conf.c | 14 - test/wrapper-script.sh | 6 7 files changed, 245 insertions(+), 120 deletions(-) New commits: commit bc40c5837f3cc6321b77ccd4b71eaf8008861f17 Merge: 5a6fef6 ea3c8c4 Author: Akira TAGOH <akira@xxxxxxxxx> Date: Mon Apr 22 03:41:06 2024 +0000 Merge branch 'fix-runtestsh-on-meson' into 'main' Enable run-test.sh on meson See merge request fontconfig/fontconfig!242 commit ea3c8c4434802a5197923abfa7bd2b24bab85bb3 Author: Akira TAGOH <akira@xxxxxxxxx> Date: Mon Apr 22 11:47:22 2024 +0900 ci: normalize path to avoid miscalculation of cache name diff --git a/test/run-test.sh b/test/run-test.sh index f8fd95f..ac6b57a 100644 --- a/test/run-test.sh +++ b/test/run-test.sh @@ -29,12 +29,16 @@ case "$OSTYPE" in * ) MyPWD=$(pwd) ;; # On any other platforms, returns a Unix style path. esac +normpath() { + printf "%s" "$1" | sed -E 's,/+,/,g' +} + TESTDIR=${srcdir-"$MyPWD"} BUILDTESTDIR=${builddir-"$MyPWD"} BASEDIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX) -FONTDIR="$BASEDIR"/fonts -CACHEDIR="$BASEDIR"/cache.dir +FONTDIR=$(normpath "$BASEDIR"/fonts) +CACHEDIR=$(normpath "$BASEDIR"/cache.dir) EXPECTED=${EXPECTED-"out.expected"} FCLIST="$LOG_COMPILER $BUILDTESTDIR/../fc-list/fc-list$EXEEXT" @@ -53,8 +57,8 @@ else exit 1 fi -FONT1=$TESTDIR/4x6.pcf -FONT2=$TESTDIR/8x16.pcf +FONT1=$(normpath $TESTDIR/4x6.pcf) +FONT2=$(normpath $TESTDIR/8x16.pcf) TEST="" export TZ=UTC commit 85c3ac6c21c8a53eca1c7585dec759473d042742 Author: Akira TAGOH <akira@xxxxxxxxx> Date: Fri Apr 19 21:25:06 2024 +0900 ci: Use md5 if md5sum isn't available. diff --git a/test/run-test.sh b/test/run-test.sh index a052bc3..f8fd95f 100644 --- a/test/run-test.sh +++ b/test/run-test.sh @@ -44,6 +44,15 @@ if [ -x "$(command -v bwrap)" ]; then BWRAP="$(command -v bwrap)" fi +if [ -x "$(command -v md5sum)" ]; then + MD5SUM="$(command -v md5sum)" +elif [ -x "$(command -v md5)" ]; then + MD5SUM="$(command -v md5)" +else + echo "E: No md5sum or equivalent command" + exit 1 +fi + FONT1=$TESTDIR/4x6.pcf FONT2=$TESTDIR/8x16.pcf TEST="" @@ -401,7 +410,7 @@ cp "$BUILDTESTDIR"/fonts.conf "$BUILDTESTDIR"/sysroot/"$BUILDTESTDIR"/fonts.conf $FCCACHE -y "$BUILDTESTDIR"/sysroot dotest "creating cache file on sysroot" -md5=$(printf "%s" "$FONTDIR" | md5sum | sed 's/ .*$//') +md5=$(printf "%s" "$FONTDIR" | $MD5SUM | sed 's/ .*$//') echo "checking for cache file $md5" if ! ls "$BUILDTESTDIR/sysroot/$CACHEDIR/$md5"*; then echo "*** Test failed: $TEST" commit 48d87846487f4837d861c534dc785d24ec805460 Author: Akira TAGOH <akira@xxxxxxxxx> Date: Fri Apr 19 13:18:31 2024 +0900 Fix test case for reproducible builds diff --git a/test/run-test.sh b/test/run-test.sh index df4f90c..a052bc3 100644 --- a/test/run-test.sh +++ b/test/run-test.sh @@ -47,6 +47,43 @@ fi FONT1=$TESTDIR/4x6.pcf FONT2=$TESTDIR/8x16.pcf TEST="" +export TZ=UTC + +fdate() { + sdate=$1 + ret=0 + date -d @0 > /dev/null 2>&1 || ret=$? + if [ $ret -eq 0 ]; then + ret=$(date -u -d @${sdate} +%y%m%d%H%M.%S) + else + ret=$(date -u -j -f "%s" +%y%m%d%H%M.%S $sdate) + fi + echo $ret +} + +fstat() { + fmt=$1 + fn=$2 + ret=0 + stat -c %Y "$fn" > /dev/null 2>&1 || ret=$? + if [ $ret -eq 0 ]; then + # GNU + ret=$(stat -c "$fmt" "$fn") + else + # BSD + if [ "x$fmt" == "x%Y" ]; then + ret=$(stat -f "%m" "$fn") + elif [ "x$fmt" == "x%y" ]; then + ret=$(stat -f "%Sm" -t "%F %T %z" "$fn") + elif [ "x$fmt" == "x%n %s %y %z" ]; then + ret=$(stat -f "%SN %z %Sm %Sc" -t "%F %T %z" "$fn") + else + echo "E: Unknown format" + exit 1 + fi + fi + echo $ret +} clean_exit() { rc=$? @@ -97,7 +134,7 @@ dotest "Basic check" prep cp "$FONT1" "$FONT2" "$FONTDIR" if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then - touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR" + touch -m -t "$(fdate ${SOURCE_DATE_EPOCH})" "$FONTDIR" fi check @@ -105,7 +142,7 @@ dotest "With a subdir" prep cp "$FONT1" "$FONT2" "$FONTDIR" if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then - touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR" + touch -m -t "$(fdate ${SOURCE_DATE_EPOCH})" "$FONTDIR" fi $FCCACHE "$FONTDIR" check @@ -115,7 +152,7 @@ prep mkdir "$FONTDIR"/a cp "$FONT1" "$FONT2" "$FONTDIR"/a if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then - touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR"/a + touch -m -t "$(fdate ${SOURCE_DATE_EPOCH})" "$FONTDIR"/a fi $FCCACHE "$FONTDIR"/a check @@ -128,11 +165,11 @@ mkdir "$FONTDIR"/b mkdir "$FONTDIR"/b/a cp "$FONT1" "$FONTDIR"/a if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then - touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR"/a + touch -m -t "$(fdate ${SOURCE_DATE_EPOCH})" "$FONTDIR"/a fi cp "$FONT2" "$FONTDIR"/b/a if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then - touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR"/b/a + touch -m -t "$(fdate ${SOURCE_DATE_EPOCH})" "$FONTDIR"/b/a fi check @@ -156,10 +193,10 @@ check dotest "Keep mtime of the font directory" prep cp "$FONT1" "$FONTDIR" -touch -d @0 "$FONTDIR" -stat -c '%y' "$FONTDIR" > "$BUILDTESTDIR"/out1 -$FCCACHE "$FONTDIR" -stat -c '%y' "$FONTDIR" > "$BUILDTESTDIR"/out2 +touch -t $(fdate 0) "$FONTDIR" +fstat "%y" "$FONTDIR" > "$BUILDTESTDIR"/out1 +$FCCACHE -v "$FONTDIR" +fstat "%y" "$FONTDIR" > "$BUILDTESTDIR"/out2 if cmp "$BUILDTESTDIR"/out1 "$BUILDTESTDIR"/out2 > /dev/null ; then : ; else echo "*** Test failed: $TEST" echo "mtime was modified" @@ -171,7 +208,7 @@ dotest "Basic functionality with the bind-mounted cache dir" prep cp "$FONT1" "$FONT2" "$FONTDIR" if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then - touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR" + touch -m -t "$(fdate ${SOURCE_DATE_EPOCH})" "$FONTDIR" fi $FCCACHE "$FONTDIR" sleep 1 @@ -224,17 +261,17 @@ dotest "Different directory content between host and sandbox" prep cp "$FONT1" "$FONTDIR" if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then - touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR" + touch -m -t "$(fdate ${SOURCE_DATE_EPOCH})" "$FONTDIR" fi $FCCACHE "$FONTDIR" sleep 1 ls -1 --color=no "$CACHEDIR"/*cache*> "$BUILDTESTDIR"/out1 -stat -c '%n %s %y %z' "$(cat $BUILDTESTDIR/out1)" > "$BUILDTESTDIR"/stat1 +fstat "%n %s %y %z" "$(cat $BUILDTESTDIR/out1)" > "$BUILDTESTDIR"/stat1 TESTTMPDIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX) TESTTMP2DIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX) cp "$FONT2" "$TESTTMP2DIR" if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then - touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$TESTTMP2DIR" + touch -m -t "$(fdate ${SOURCE_DATE_EPOCH})" "$TESTTMP2DIR" fi sed "s!@FONTDIR@!$TESTTMPDIR/fonts</dir><dir salt="'"'"salt-to-make-different"'"'">$FONTDIR! s!@REMAPDIR@!<remap-dir as-path="'"'"$FONTDIR"'"'">$TESTTMPDIR/fonts</remap-dir>! @@ -251,7 +288,7 @@ fi $BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind "$TESTTMP2DIR" "$FONTDIR" --bind "$BUILDTESTDIR"/.. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/test/"$TESTEXE" | sort > "$BUILDTESTDIR"/flist1 $BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind "$TESTTMP2DIR" "$FONTDIR" --bind "$BUILDTESTDIR"/.. "$TESTTMPDIR"/build --dev-bind /dev /dev find "$TESTTMPDIR"/fonts/ -type f -name '*.pcf' | sort > "$BUILDTESTDIR"/flist2 ls -1 --color=no "$CACHEDIR"/*cache* > "$BUILDTESTDIR"/out2 -stat -c '%n %s %y %z' "$(cat $BUILDTESTDIR/out1)" > "$BUILDTESTDIR"/stat2 +fstat "%n %s %y %z" "$(cat $BUILDTESTDIR/out1)" > "$BUILDTESTDIR"/stat2 if cmp "$BUILDTESTDIR"/stat1 "$BUILDTESTDIR"/stat2 > /dev/null ; then : ; else echo "*** Test failed: $TEST" echo "cache was created/updated." @@ -285,7 +322,7 @@ prep mkdir -p "$FONTDIR"/sub cp "$FONT1" "$FONTDIR"/sub if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then - touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR"/sub + touch -m -t "$(fdate ${SOURCE_DATE_EPOCH})" "$FONTDIR"/sub fi $FCCACHE "$FONTDIR" sleep 1 @@ -315,18 +352,18 @@ dotest "Fallback to uuid" prep cp "$FONT1" "$FONTDIR" if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then - touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR" + touch -m -t "$(fdate ${SOURCE_DATE_EPOCH})" "$FONTDIR" fi -touch -d @"$(stat -c %Y "$FONTDIR")" "$FONTDIR" +touch -t "$(fdate $(fstat "%Y" "$FONTDIR"))" "$FONTDIR" $FCCACHE "$FONTDIR" sleep 1 _cache=$(ls -1 --color=no "$CACHEDIR"/*cache*) -_mtime=$(stat -c %Y "$FONTDIR") +_mtime=$(fstat "%Y" "$FONTDIR") _uuid=$(uuidgen) _newcache=$(echo "$_cache" | sed "s/\([0-9a-f]*\)\(\-.*\)/$_uuid\2/") mv "$_cache" "$_newcache" echo "$_uuid" > "$FONTDIR"/.uuid -touch -d @"$_mtime" "$FONTDIR" +touch -t "$(fdate "$_mtime")" "$FONTDIR" (cd "$CACHEDIR"; ls -1 --color=no ./*cache*) > "$BUILDTESTDIR"/out1 TESTTMPDIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX) mkdir -p "$TESTTMPDIR"/cache.dir @@ -358,7 +395,7 @@ mkdir -p "$BUILDTESTDIR"/sysroot/"$CACHEDIR" mkdir -p "$BUILDTESTDIR"/sysroot/"$BUILDTESTDIR" cp "$FONT1" "$BUILDTESTDIR"/sysroot/"$FONTDIR" if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then - touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$BUILDTESTDIR"/sysroot/"$FONTDIR" + touch -m -t "$(fdate ${SOURCE_DATE_EPOCH})" "$BUILDTESTDIR"/sysroot/"$FONTDIR" fi cp "$BUILDTESTDIR"/fonts.conf "$BUILDTESTDIR"/sysroot/"$BUILDTESTDIR"/fonts.conf $FCCACHE -y "$BUILDTESTDIR"/sysroot @@ -378,8 +415,13 @@ rm -rf "$BUILDTESTDIR"/sysroot dotest "read newer caches when multiple places are allowed to store" prep cp "$FONT1" "$FONT2" "$FONTDIR" +if [ -n "${SOURCE_DATE_EPOCH:-}" ]; then + # epoch 0 has special meaning. increase to avoid epoch 0 + old_epoch=${SOURCE_DATE_EPOCH} + SOURCE_DATE_EPOCH=$(("$SOURCE_DATE_EPOCH" + 1)) +fi if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then - touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR" + touch -m -t "$(fdate ${SOURCE_DATE_EPOCH})" "$FONTDIR" fi MYCACHEBASEDIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX) MYCACHEDIR="$MYCACHEBASEDIR"/cache.dir @@ -409,7 +451,6 @@ s!@REMAPDIR@!<include ignore_missing=\"yes\">$MYCONFIG</include>! s!@CACHEDIR@!$MYOWNCACHEDIR!" < "$TESTDIR"/fonts.conf.in > "$BUILDTESTDIR"/my-fonts.conf if [ -n "${SOURCE_DATE_EPOCH:-}" ]; then - old_epoch=${SOURCE_DATE_EPOCH} SOURCE_DATE_EPOCH=$(("$SOURCE_DATE_EPOCH" + 1)) fi FONTCONFIG_FILE="$BUILDTESTDIR"/my-fonts.conf $FCCACHE -f "$FONTDIR" @@ -451,7 +492,7 @@ if [ -x "$BUILDTESTDIR"/test-crbug1004254 ]; then curl -s -o "$FONTDIR"/noto.zip https://noto-website-2.storage.googleapis.com/pkgs/NotoSans-hinted.zip (cd "$FONTDIR"; unzip noto.zip) if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then - touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR" + touch -m -t "$(fdate ${SOURCE_DATE_EPOCH})" "$FONTDIR" fi "$BUILDTESTDIR"/test-crbug1004254 else @@ -468,7 +509,7 @@ export temp_HOME=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX) export HOME="$temp_HOME" cp "$FONT1" "$FONT2" "$FONTDIR" if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then - touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR" + touch -m -t "$(fdate ${SOURCE_DATE_EPOCH})" "$FONTDIR" fi echo "<fontconfig><dir>$FONTDIR</dir><cachedir prefix=\"xdg\">fontconfig</cachedir></fontconfig>" > "$BUILDTESTDIR"/my-fonts.conf FONTCONFIG_FILE="$BUILDTESTDIR"/my-fonts.conf $FCCACHE "$FONTDIR" || : commit 065f6e2f131690f82da6e8497fff548a23352e48 Author: Akira TAGOH <akira@xxxxxxxxx> Date: Fri Apr 15 14:09:35 2022 +0900 test-conf: Fix compiler warnings diff --git a/test/test-conf.c b/test/test-conf.c index c5ddabe..8b298ef 100644 --- a/test/test-conf.c +++ b/test/test-conf.c @@ -401,7 +401,7 @@ run_test (FcConfig *config, json_object *root) } if (method != NULL && strcmp (method, "match") == 0) { - FcPattern *match; + FcPattern *match = NULL; FcResult res; if (!query) @@ -456,12 +456,13 @@ run_test (FcConfig *config, json_object *root) } } while (FcPatternIterNext (result, &iter)); bail: - FcPatternDestroy (match); + if (match) + FcPatternDestroy (match); } else { FcPatternIter iter; - int x, vc; + int vc; FcPatternIterStart (result, &iter); vc = FcPatternIterValueCount (result, &iter); @@ -474,7 +475,7 @@ run_test (FcConfig *config, json_object *root) } else if (method != NULL && strcmp (method, "list") == 0) { - FcFontSet *fs; + FcFontSet *fs = NULL; if (!query) { @@ -544,7 +545,8 @@ run_test (FcConfig *config, json_object *root) } while (FcPatternIterNext (result_fs->fonts[i], &iter)); } bail2: - FcFontSetDestroy (fs); + if (fs) + FcFontSetDestroy (fs); } } else @@ -577,7 +579,7 @@ static FcBool run_scenario (FcConfig *config, char *file) { FcBool ret = FcTrue; - json_object *root, *scenario; + json_object *root; root = json_object_from_file (file); if (!root) commit a47bf2c0b81d75fbdbb05c1dc0e774967364dd1a Author: Akira TAGOH <akira@xxxxxxxxx> Date: Fri Apr 8 21:33:44 2022 +0900 meson: Add missing the unit testing with json-c diff --git a/meson.build b/meson.build index 78e8c07..44ed8cb 100644 --- a/meson.build +++ b/meson.build @@ -48,6 +48,8 @@ else endif endif +jsonc_dep = dependency('json-c', required: false) + xml_dep = dependency('', required: false) xmlbackend = get_option('xml-backend') xmltype = '' diff --git a/test/meson.build b/test/meson.build index 159795e..d547591 100644 --- a/test/meson.build +++ b/test/meson.build @@ -57,4 +57,14 @@ if host_machine.system() != 'windows' test('run_test_sh', find_program('run-test.sh'), timeout: 600, env: ['srcdir=@0@'.format(meson.current_source_dir()), 'builddir=@0@'.format(meson.current_build_dir()), 'EXEEXT=@0@'.format(conf.get('EXEEXT')), 'VERBOSE=1']) endif -# FIXME: jsonc test-conf +if jsonc_dep.found() + test_conf = executable('test-conf', 'test-conf.c', + dependencies: [fontconfig_dep, jsonc_dep]) + test('run_test_conf_sh', find_program('run-test-conf.sh'), + timeout: 120, + env: [ + 'srcdir=@0@'.format(meson.current_source_dir()), + 'builddir=@0@'.format(meson.current_build_dir()) + ], + depends: test_conf) +endif diff --git a/test/run-test-conf.sh b/test/run-test-conf.sh index 20b80e1..cc41185 100644 --- a/test/run-test-conf.sh +++ b/test/run-test-conf.sh @@ -31,7 +31,7 @@ esac TESTDIR=${srcdir-"$MyPWD"} BUILDTESTDIR=${builddir-"$MyPWD"} -RUNNER=../test/test-conf$EXEEXT +RUNNER=$BUILDTESTDIR/test-conf$EXEEXT if [ ! -f ${RUNNER} ]; then echo "${RUNNER} not found!\n" commit 3b35c62382ba3772e38e1b0ad7bab7b13d61c6b8 Author: Akira TAGOH <akira@xxxxxxxxx> Date: Fri Oct 28 16:07:37 2022 +0900 test/wrapper-script.sh: don't add a path when executable already has a path name. diff --git a/test/wrapper-script.sh b/test/wrapper-script.sh index 4138e4b..94add1b 100755 --- a/test/wrapper-script.sh +++ b/test/wrapper-script.sh @@ -4,7 +4,11 @@ case "$1" in *.exe) fccwd=`pwd` cd $(IFS=:;for i in $PATH; do echo $i|grep mingw> /dev/null; [ $? -eq 0 ] && echo $i; done) - /usr/bin/env wine $fccwd/$@ + if [ "x$(dirname $@)" = "x." ]; then + /usr/bin/env wine $fccwd/$@ + else + /usr/bin/env wine $@ + fi ;; *) $@ commit 22ac8384de978582ab320e9e860191d345a614cd Author: Akira TAGOH <akira@xxxxxxxxx> Date: Thu Oct 27 19:01:48 2022 +0900 meson: Enable run-test.sh for non-Win32 Fix run-test.sh script which wrongly assume the current path. That was the reason why it didn't work on meson. diff --git a/meson-cc-tests/freetype-pcf-long-family-names.c b/meson-cc-tests/freetype-pcf-long-family-names.c new file mode 100644 index 0000000..1ca6205 --- /dev/null +++ b/meson-cc-tests/freetype-pcf-long-family-names.c @@ -0,0 +1,7 @@ +#include <ft2build.h> +#include FT_CONFIG_OPTIONS_H +#ifndef PCF_CONFIG_OPTION_LONG_FAMILY_NAMES +# error "No pcf long family names support" +#endif + +int main(void) {return 0;} diff --git a/meson.build b/meson.build index a466328..78e8c07 100644 --- a/meson.build +++ b/meson.build @@ -37,6 +37,17 @@ if not freetype_dep.found() fallback: ['freetype2', 'freetype_dep'], default_options: 'werror=false') endif +if freetype_dep.type_name() == 'internal' + conf.set('FREETYPE_PCF_LONG_FAMILY_NAMES', false) +else + if cc.compiles(files('meson-cc-tests/freetype-pcf-long-family-names.c'), + dependencies: freetype_dep) + conf.set('FREETYPE_PCF_LONG_FAMILY_NAMES', true) + else + conf.set('FREETYPE_PCF_LONG_FAMILY_NAMES', false) + endif +endif + xml_dep = dependency('', required: false) xmlbackend = get_option('xml-backend') xmltype = '' @@ -162,6 +173,12 @@ conf.set_quoted('PACKAGE_STRING', '@0@ @1@'.format(meson.project_name(), meson.p conf.set_quoted('PACKAGE_BUGREPORT', 'https://gitlab.freedesktop.org/fontconfig/fontconfig/issues/new') conf.set_quoted('PACKAGE_URL', '') +if host_machine.system() == 'windows' + conf.set('EXEEXT', '.exe') +else + conf.set('EXEEXT', '') +endif + i18n = import('i18n') gettext_args = [ '--msgid-bugs-address=@0@'.format(conf.get('PACKAGE_BUGREPORT')) ] diff --git a/test/meson.build b/test/meson.build index 59de427..159795e 100644 --- a/test/meson.build +++ b/test/meson.build @@ -43,5 +43,18 @@ foreach test_data : tests test(test_name, exe, timeout: 600) endforeach -# FIXME: run-test.sh stuff +fs = import('fs') + +if host_machine.system() != 'windows' + if conf.get('FREETYPE_PCF_LONG_FAMILY_NAMES') + out_expected = fs.copyfile('out.expected-long-family-names', + 'out.expected') + else + out_expected = fs.copyfile('out.expected-no-long-family-names', + 'out.expected') + endif + + test('run_test_sh', find_program('run-test.sh'), timeout: 600, env: ['srcdir=@0@'.format(meson.current_source_dir()), 'builddir=@0@'.format(meson.current_build_dir()), 'EXEEXT=@0@'.format(conf.get('EXEEXT')), 'VERBOSE=1']) +endif + # FIXME: jsonc test-conf diff --git a/test/run-test.sh b/test/run-test.sh index c3da72a..df4f90c 100644 --- a/test/run-test.sh +++ b/test/run-test.sh @@ -37,8 +37,8 @@ FONTDIR="$BASEDIR"/fonts CACHEDIR="$BASEDIR"/cache.dir EXPECTED=${EXPECTED-"out.expected"} -FCLIST="$LOG_COMPILER ../fc-list/fc-list$EXEEXT" -FCCACHE="$LOG_COMPILER ../fc-cache/fc-cache$EXEEXT" +FCLIST="$LOG_COMPILER $BUILDTESTDIR/../fc-list/fc-list$EXEEXT" +FCCACHE="$LOG_COMPILER $BUILDTESTDIR/../fc-cache/fc-cache$EXEEXT" if [ -x "$(command -v bwrap)" ]; then BWRAP="$(command -v bwrap)" @@ -65,14 +65,14 @@ check () { $FCLIST - family pixelsize | sort; echo "="; $FCLIST - family pixelsize | sort; - } > out - tr -d '\015' <out >out.tmp; mv out.tmp out - if cmp out "$BUILDTESTDIR"/"$EXPECTED" > /dev/null ; then : ; else + } > "$BUILDTESTDIR"/out + tr -d '\015' <"$BUILDTESTDIR"/out >"$BUILDTESTDIR"/out.tmp; mv "$BUILDTESTDIR"/out.tmp "$BUILDTESTDIR"/out + if cmp "$BUILDTESTDIR"/out "$BUILDTESTDIR"/"$EXPECTED" > /dev/null ; then : ; else echo "*** Test failed: $TEST" echo "*** output is in 'out', expected output in '$EXPECTED'" exit 1 fi - rm -f out + rm -f "$BUILDTESTDIR"/out } prep() { @@ -88,9 +88,9 @@ dotest () { sed "s!@FONTDIR@!$FONTDIR! s!@REMAPDIR@!! -s!@CACHEDIR@!$CACHEDIR!" < "$TESTDIR"/fonts.conf.in > fonts.conf +s!@CACHEDIR@!$CACHEDIR!" < "$TESTDIR"/fonts.conf.in > "$BUILDTESTDIR"/fonts.conf -FONTCONFIG_FILE="$MyPWD"/fonts.conf +FONTCONFIG_FILE="$BUILDTESTDIR"/fonts.conf export FONTCONFIG_FILE dotest "Basic check" @@ -157,10 +157,10 @@ dotest "Keep mtime of the font directory" prep cp "$FONT1" "$FONTDIR" touch -d @0 "$FONTDIR" -stat -c '%y' "$FONTDIR" > out1 +stat -c '%y' "$FONTDIR" > "$BUILDTESTDIR"/out1 $FCCACHE "$FONTDIR" -stat -c '%y' "$FONTDIR" > out2 -if cmp out1 out2 > /dev/null ; then : ; else +stat -c '%y' "$FONTDIR" > "$BUILDTESTDIR"/out2 +if cmp "$BUILDTESTDIR"/out1 "$BUILDTESTDIR"/out2 > /dev/null ; then : ; else echo "*** Test failed: $TEST" echo "mtime was modified" exit 1 @@ -175,42 +175,50 @@ if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then fi $FCCACHE "$FONTDIR" sleep 1 -ls -l "$CACHEDIR" > out1 +ls -l "$CACHEDIR" > "$BUILDTESTDIR"/out1 TESTTMPDIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX) # Once font dir is remapped, we could use $FONTDIR as different one in theory. # but we don't use it here and to avoid duplicate entries, set the non-existing # directory here. sed "s!@FONTDIR@!$FONTDIR/a! s!@REMAPDIR@!<remap-dir as-path="'"'"$FONTDIR"'"'">$TESTTMPDIR/fonts</remap-dir>! -s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < "$TESTDIR"/fonts.conf.in > bind-fonts.conf -$BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/fc-match/fc-match"$EXEEXT" -f "%{file}\n" ":foundry=Misc" > xxx -$BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/test/test-bz106618"$EXEEXT" | sort > flist1 -$BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev find "$TESTTMPDIR"/fonts/ -type f -name '*.pcf' | sort > flist2 -ls -l "$CACHEDIR" > out2 -if cmp out1 out2 > /dev/null ; then : ; else +s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < "$TESTDIR"/fonts.conf.in > "$BUILDTESTDIR"/bind-fonts.conf +$BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind "$BUILDTESTDIR"/.. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/fc-match/fc-match"$EXEEXT" -f "%{file}\n" ":foundry=Misc" > "$BUILDTESTDIR"/xxx +if test -x "$BUILDTESTDIR"/test-bz106618"$EXEEXT"; then + TESTEXE=test-bz106618"$EXEEXT" +elif test -x "$BUILDTESTDIR"/test_bz106618"$EXEEXT"; then + TESTEXE=test_bz106618"$EXEEXT" +else + echo "*** Test failed: no test case for bz106618" + exit 1 +fi +$BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind "$BUILDTESTDIR"/.. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/test/"$TESTEXE" | sort > "$BUILDTESTDIR"/flist1 +$BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind "$BUILDTESTDIR"/.. "$TESTTMPDIR"/build --dev-bind /dev /dev find "$TESTTMPDIR"/fonts/ -type f -name '*.pcf' | sort > "$BUILDTESTDIR"/flist2 +ls -l "$CACHEDIR" > "$BUILDTESTDIR"/out2 +if cmp "$BUILDTESTDIR"/out1 "$BUILDTESTDIR"/out2 > /dev/null ; then : ; else echo "*** Test failed: $TEST" echo "cache was created/updated." echo "Before:" - cat out1 + cat "$BUILDTESTDIR"/out1 echo "After:" - cat out2 + cat "$BUILDTESTDIR"/out2 exit 1 fi -if [ x"$(cat xxx)" != "x$TESTTMPDIR/fonts/4x6.pcf" ]; then +if [ x"$(cat $BUILDTESTDIR/xxx)" != "x$TESTTMPDIR/fonts/4x6.pcf" ]; then echo "*** Test failed: $TEST" echo "file property doesn't point to the new place: $TESTTMPDIR/fonts/4x6.pcf" exit 1 fi -if cmp flist1 flist2 > /dev/null ; then : ; else +if cmp "$BUILDTESTDIR"/flist1 "$BUILDTESTDIR"/flist2 > /dev/null ; then : ; else echo "*** Test failed: $TEST" echo "file properties doesn't point to the new places" echo "Expected result:" - cat flist2 + cat "$BUILDTESTDIR"/flist2 echo "Actual result:" - cat flist1 + cat "$BUILDTESTDIR"/flist1 exit 1 fi -rm -rf "$TESTTMPDIR" out1 out2 xxx flist1 flist2 bind-fonts.conf +rm -rf "$TESTTMPDIR" "$BUILDTESTDIR"/out1 "$BUILDTESTDIR"/out2 "$BUILDTESTDIR"/xxx "$BUILDTESTDIR"/flist1 "$BUILDTESTDIR"/flist2 "$BUILDTESTDIR"/bind-fonts.conf dotest "Different directory content between host and sandbox" prep @@ -220,8 +228,8 @@ if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then fi $FCCACHE "$FONTDIR" sleep 1 -ls -1 --color=no "$CACHEDIR"/*cache*> out1 -stat -c '%n %s %y %z' "$(cat out1)" > stat1 +ls -1 --color=no "$CACHEDIR"/*cache*> "$BUILDTESTDIR"/out1 +stat -c '%n %s %y %z' "$(cat $BUILDTESTDIR/out1)" > "$BUILDTESTDIR"/stat1 TESTTMPDIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX) TESTTMP2DIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX) cp "$FONT2" "$TESTTMP2DIR" @@ -230,39 +238,47 @@ if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then fi sed "s!@FONTDIR@!$TESTTMPDIR/fonts</dir><dir salt="'"'"salt-to-make-different"'"'">$FONTDIR! s!@REMAPDIR@!<remap-dir as-path="'"'"$FONTDIR"'"'">$TESTTMPDIR/fonts</remap-dir>! -s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < "$TESTDIR"/fonts.conf.in > bind-fonts.conf -$BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind "$TESTTMP2DIR" "$FONTDIR" --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/fc-match/fc-match"$EXEEXT" -f "%{file}\n" ":foundry=Misc" > xxx -$BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind "$TESTTMP2DIR" "$FONTDIR" --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/test/test-bz106618"$EXEEXT" | sort > flist1 -$BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind "$TESTTMP2DIR" "$FONTDIR" --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev find "$TESTTMPDIR"/fonts/ -type f -name '*.pcf' | sort > flist2 -ls -1 --color=no "$CACHEDIR"/*cache* > out2 -stat -c '%n %s %y %z' "$(cat out1)" > stat2 -if cmp stat1 stat2 > /dev/null ; then : ; else +s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < "$TESTDIR"/fonts.conf.in > "$BUILDTESTDIR"/bind-fonts.conf +$BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind "$TESTTMP2DIR" "$FONTDIR" --bind "$BUILDTESTDIR"/.. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/fc-match/fc-match"$EXEEXT" -f "%{file}\n" ":foundry=Misc" > "$BUILDTESTDIR"/xxx +if test -x "$BUILDTESTDIR"/test-bz106618"$EXEEXT"; then + TESTEXE=test-bz106618"$EXEEXT" +elif test -x "$BUILDTESTDIR"/test_bz106618"$EXEEXT"; then + TESTEXE=test_bz106618"$EXEEXT" +else + echo "*** Test failed: no test case for bz106618" + exit 1 +fi +$BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind "$TESTTMP2DIR" "$FONTDIR" --bind "$BUILDTESTDIR"/.. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/test/"$TESTEXE" | sort > "$BUILDTESTDIR"/flist1 +$BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind "$TESTTMP2DIR" "$FONTDIR" --bind "$BUILDTESTDIR"/.. "$TESTTMPDIR"/build --dev-bind /dev /dev find "$TESTTMPDIR"/fonts/ -type f -name '*.pcf' | sort > "$BUILDTESTDIR"/flist2 +ls -1 --color=no "$CACHEDIR"/*cache* > "$BUILDTESTDIR"/out2 +stat -c '%n %s %y %z' "$(cat $BUILDTESTDIR/out1)" > "$BUILDTESTDIR"/stat2 +if cmp "$BUILDTESTDIR"/stat1 "$BUILDTESTDIR"/stat2 > /dev/null ; then : ; else echo "*** Test failed: $TEST" echo "cache was created/updated." - cat stat1 stat2 + cat "$BUILDTESTDIR"/stat1 "$BUILDTESTDIR"/stat2 exit 1 fi -if grep -v -- "$(cat out1)" out2 > /dev/null ; then : ; else +if grep -v -- "$(cat $BUILDTESTDIR/out1)" "$BUILDTESTDIR"/out2 > /dev/null ; then : ; else echo "*** Test failed: $TEST" echo "cache wasn't created for dir inside sandbox." - cat out1 out2 + cat "$BUILDTESTDIR"/out1 "$BUILDTESTDIR"/out2 exit 1 fi -if [ x"$(cat xxx)" != "x$TESTTMPDIR/fonts/4x6.pcf" ]; then +if [ x"$(cat $BUILDTESTDIR/xxx)" != "x$TESTTMPDIR/fonts/4x6.pcf" ]; then echo "*** Test failed: $TEST" echo "file property doesn't point to the new place: $TESTTMPDIR/fonts/4x6.pcf" exit 1 fi -if cmp flist1 flist2 > /dev/null ; then +if cmp "$BUILDTESTDIR"/flist1 "$BUILDTESTDIR"/flist2 > /dev/null ; then echo "*** Test failed: $TEST" echo "Missing fonts should be available on sandbox" echo "Expected result:" - cat flist2 + cat "$BUILDTESTDIR"/flist2 echo "Actual result:" - cat flist1 + cat "$BUILDTESTDIR"/flist1 exit 1 fi -rm -rf "$TESTTMPDIR" "$TESTTMP2DIR" out1 out2 xxx flist1 flist2 stat1 stat2 bind-fonts.conf +rm -rf "$TESTTMPDIR" "$TESTTMP2DIR" "$BUILDTESTDIR"/out1 "$BUILDTESTDIR"/out2 "$BUILDTESTDIR"/xxx "$BUILDTESTDIR"/flist1 "$BUILDTESTDIR"/flist2 "$BUILDTESTDIR"/stat1 "$BUILDTESTDIR"/stat2 "$BUILDTESTDIR"/bind-fonts.conf dotest "Check consistency of MD5 in cache name" prep @@ -273,7 +289,7 @@ if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then fi $FCCACHE "$FONTDIR" sleep 1 -(cd "$CACHEDIR"; ls -1 --color=no ./*cache*) > out1 +(cd "$CACHEDIR"; ls -1 --color=no ./*cache*) > "$BUILDTESTDIR"/out1 TESTTMPDIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX) mkdir -p "$TESTTMPDIR"/cache.dir # Once font dir is remapped, we could use $FONTDIR as different one in theory. @@ -281,19 +297,19 @@ mkdir -p "$TESTTMPDIR"/cache.dir # directory here. sed "s!@FONTDIR@!$FONTDIR/a! s!@REMAPDIR@!<remap-dir as-path="'"'"$FONTDIR"'"'">$TESTTMPDIR/fonts</remap-dir>! -s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < "$TESTDIR"/fonts.conf.in > bind-fonts.conf -$BWRAP --bind / / --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/fc-cache/fc-cache"$EXEEXT" "$TESTTMPDIR"/fonts -(cd "$TESTTMPDIR"/cache.dir; ls -1 --color=no ./*cache*) > out2 -if cmp out1 out2 > /dev/null ; then : ; else +s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < "$TESTDIR"/fonts.conf.in > "$BUILDTESTDIR"/bind-fonts.conf +$BWRAP --bind / / --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind "$BUILDTESTDIR"/.. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/fc-cache/fc-cache"$EXEEXT" "$TESTTMPDIR"/fonts +(cd "$TESTTMPDIR"/cache.dir; ls -1 --color=no ./*cache*) > "$BUILDTESTDIR"/out2 +if cmp "$BUILDTESTDIR"/out1 "$BUILDTESTDIR"/out2 > /dev/null ; then : ; else echo "*** Test failed: $TEST" echo "cache was created unexpectedly." echo "Before:" - cat out1 + cat "$BUILDTESTDIR"/out1 echo "After:" - cat out2 + cat "$BUILDTESTDIR"/out2 exit 1 fi -rm -rf "$TESTTMPDIR" out1 out2 bind-fonts.conf +rm -rf "$TESTTMPDIR" "$BUILDTESTDIR"/out1 "$BUILDTESTDIR"/out2 "$BUILDTESTDIR"/bind-fonts.conf dotest "Fallback to uuid" prep @@ -311,24 +327,24 @@ _newcache=$(echo "$_cache" | sed "s/\([0-9a-f]*\)\(\-.*\)/$_uuid\2/") mv "$_cache" "$_newcache" echo "$_uuid" > "$FONTDIR"/.uuid touch -d @"$_mtime" "$FONTDIR" -(cd "$CACHEDIR"; ls -1 --color=no ./*cache*) > out1 +(cd "$CACHEDIR"; ls -1 --color=no ./*cache*) > "$BUILDTESTDIR"/out1 TESTTMPDIR=$(mktemp -d "$TMPDIR"/fontconfig.XXXXXXXX) mkdir -p "$TESTTMPDIR"/cache.dir sed "s!@FONTDIR@!$TESTTMPDIR/fonts! s!@REMAPDIR@!<remap-dir as-path="'"'"$FONTDIR"'"'">$TESTTMPDIR/fonts</remap-dir>! -s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < "$TESTDIR"/fonts.conf.in > bind-fonts.conf -$BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind .. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/fc-match/fc-match"$EXEEXT" -f "" -(cd "$CACHEDIR"; ls -1 --color=no ./*cache*) > out2 -if cmp out1 out2 > /dev/null ; then : ; else +s!@CACHEDIR@!$TESTTMPDIR/cache.dir!" < "$TESTDIR"/fonts.conf.in > "$BUILDTESTDIR"/bind-fonts.conf +$BWRAP --bind / / --bind "$CACHEDIR" "$TESTTMPDIR"/cache.dir --bind "$FONTDIR" "$TESTTMPDIR"/fonts --bind "$BUILDTESTDIR"/.. "$TESTTMPDIR"/build --dev-bind /dev /dev --setenv FONTCONFIG_FILE "$TESTTMPDIR"/build/test/bind-fonts.conf "$TESTTMPDIR"/build/fc-match/fc-match"$EXEEXT" -f "" +(cd "$CACHEDIR"; ls -1 --color=no ./*cache*) > "$BUILDTESTDIR"/out2 +if cmp "$BUILDTESTDIR"/out1 "$BUILDTESTDIR"/out2 > /dev/null ; then : ; else echo "*** Test failed: $TEST" echo "cache was created unexpectedly." echo "Before:" - cat out1 + cat "$BUILDTESTDIR"/out1 echo "After:" - cat out2 + cat "$BUILDTESTDIR"/out2 exit 1 fi -rm -rf "$TESTTMPDIR" out1 out2 bind-fonts.conf +rm -rf "$TESTTMPDIR" "$BUILDTESTDIR"/out1 "$BUILDTESTDIR"/out2 "$BUILDTESTDIR"/bind-fonts.conf else echo "No bubblewrap installed. skipping..." @@ -337,27 +353,27 @@ fi # if [ x"$BWRAP" != "x" -a "x$EXEEXT" = "x" ] if [ "x$EXEEXT" = "x" ]; then dotest "sysroot option" prep -mkdir -p "$MyPWD"/sysroot/"$FONTDIR" -mkdir -p "$MyPWD"/sysroot/"$CACHEDIR" -mkdir -p "$MyPWD"/sysroot/"$MyPWD" -cp "$FONT1" "$MyPWD"/sysroot/"$FONTDIR" +mkdir -p "$BUILDTESTDIR"/sysroot/"$FONTDIR" +mkdir -p "$BUILDTESTDIR"/sysroot/"$CACHEDIR" +mkdir -p "$BUILDTESTDIR"/sysroot/"$BUILDTESTDIR" +cp "$FONT1" "$BUILDTESTDIR"/sysroot/"$FONTDIR" if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then - touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$MyPWD"/sysroot/"$FONTDIR" + touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$BUILDTESTDIR"/sysroot/"$FONTDIR" fi -cp "$MyPWD"/fonts.conf "$MyPWD"/sysroot/"$MyPWD"/fonts.conf -$FCCACHE -y "$MyPWD"/sysroot +cp "$BUILDTESTDIR"/fonts.conf "$BUILDTESTDIR"/sysroot/"$BUILDTESTDIR"/fonts.conf +$FCCACHE -y "$BUILDTESTDIR"/sysroot dotest "creating cache file on sysroot" md5=$(printf "%s" "$FONTDIR" | md5sum | sed 's/ .*$//') echo "checking for cache file $md5" -if ! ls "$MyPWD/sysroot/$CACHEDIR/$md5"*; then +if ! ls "$BUILDTESTDIR/sysroot/$CACHEDIR/$md5"*; then echo "*** Test failed: $TEST" echo "No cache for $FONTDIR ($md5)" - ls "$MyPWD"/sysroot/"$CACHEDIR" + ls "$BUILDTESTDIR"/sysroot/"$CACHEDIR" exit 1 fi -rm -rf "$MyPWD"/sysroot +rm -rf "$BUILDTESTDIR"/sysroot dotest "read newer caches when multiple places are allowed to store" prep @@ -375,9 +391,9 @@ mkdir -p "$MYOWNCACHEDIR" sed "s!@FONTDIR@!$FONTDIR! s!@REMAPDIR@!! -s!@CACHEDIR@!$MYCACHEDIR!" < "$TESTDIR"/fonts.conf.in > my-fonts.conf +s!@CACHEDIR@!$MYCACHEDIR!" < "$TESTDIR"/fonts.conf.in > "$BUILDTESTDIR"/my-fonts.conf -FONTCONFIG_FILE="$MyPWD"/my-fonts.conf $FCCACHE "$FONTDIR" +FONTCONFIG_FILE="$BUILDTESTDIR"/my-fonts.conf $FCCACHE "$FONTDIR" sleep 1 cat<<EOF>"$MYCONFIG" @@ -390,42 +406,42 @@ cat<<EOF>"$MYCONFIG" EOF sed "s!@FONTDIR@!$FONTDIR! s!@REMAPDIR@!<include ignore_missing=\"yes\">$MYCONFIG</include>! -s!@CACHEDIR@!$MYOWNCACHEDIR!" < "$TESTDIR"/fonts.conf.in > my-fonts.conf +s!@CACHEDIR@!$MYOWNCACHEDIR!" < "$TESTDIR"/fonts.conf.in > "$BUILDTESTDIR"/my-fonts.conf if [ -n "${SOURCE_DATE_EPOCH:-}" ]; then old_epoch=${SOURCE_DATE_EPOCH} SOURCE_DATE_EPOCH=$(("$SOURCE_DATE_EPOCH" + 1)) fi -FONTCONFIG_FILE="$MyPWD"/my-fonts.conf $FCCACHE -f "$FONTDIR" +FONTCONFIG_FILE="$BUILDTESTDIR"/my-fonts.conf $FCCACHE -f "$FONTDIR" if [ -n "${SOURCE_DATE_EPOCH:-}" ]; then SOURCE_DATE_EPOCH=${old_epoch} fi sed "s!@FONTDIR@!$FONTDIR! s!@REMAPDIR@!<include ignore_missing=\"yes\">$MYCONFIG</include>! -s!@CACHEDIR@!$MYCACHEDIR</cachedir><cachedir>$MYOWNCACHEDIR!" < "$TESTDIR"/fonts.conf.in > my-fonts.conf +s!@CACHEDIR@!$MYCACHEDIR</cachedir><cachedir>$MYOWNCACHEDIR!" < "$TESTDIR"/fonts.conf.in > "$BUILDTESTDIR"/my-fonts.conf { - FONTCONFIG_FILE="$MyPWD"/my-fonts.conf $FCLIST - family pixelsize | sort; + FONTCONFIG_FILE="$BUILDTESTDIR"/my-fonts.conf $FCLIST - family pixelsize | sort; echo "="; - FONTCONFIG_FILE="$MyPWD"/my-fonts.conf $FCLIST - family pixelsize | sort; + FONTCONFIG_FILE="$BUILDTESTDIR"/my-fonts.conf $FCLIST - family pixelsize | sort; echo "="; - FONTCONFIG_FILE="$MyPWD"/my-fonts.conf $FCLIST - family pixelsize | sort; -} > my-out -tr -d '\015' <my-out >my-out.tmp; mv my-out.tmp my-out -sed -e 's/pixelsize=6/pixelsize=8/g' "$BUILDTESTDIR"/"$EXPECTED" > my-out.expected + FONTCONFIG_FILE="$BUILDTESTDIR"/my-fonts.conf $FCLIST - family pixelsize | sort; +} > "$BUILDTESTDIR"/my-out +tr -d '\015' <"$BUILDTESTDIR"/my-out >"$BUILDTESTDIR"/my-out.tmp; mv "$BUILDTESTDIR"/my-out.tmp "$BUILDTESTDIR"/my-out +sed -e 's/pixelsize=6/pixelsize=8/g' "$BUILDTESTDIR"/"$EXPECTED" > "$BUILDTESTDIR"/my-out.expected -if cmp my-out my-out.expected > /dev/null ; then : ; else +if cmp "$BUILDTESTDIR"/my-out "$BUILDTESTDIR"/my-out.expected > /dev/null ; then : ; else echo "*** Test failed: $TEST" echo "*** output is in 'my-out', expected output in 'my-out.expected'" echo "Actual Result" - cat my-out + cat "$BUILDTESTDIR"/my-out echo "Expected Result" - cat my-out.expected + cat "$BUILDTESTDIR"/my-out.expected exit 1 fi -rm -rf "$MYCACHEBASEDIR" "$MYCONFIG" my-fonts.conf my-out my-out.expected +rm -rf "$MYCACHEBASEDIR" "$MYCONFIG" "$BUILDTESTDIR"/my-fonts.conf "$BUILDTESTDIR"/my-out "$BUILDTESTDIR"/my-out.expected fi # if [ "x$EXEEXT" = "x" ] @@ -454,8 +470,8 @@ cp "$FONT1" "$FONT2" "$FONTDIR" if [ -n "${SOURCE_DATE_EPOCH:-}" ] && [ ${#SOURCE_DATE_EPOCH} -gt 0 ]; then touch -m -t "$(date -d @"${SOURCE_DATE_EPOCH}" +%y%m%d%H%M.%S)" "$FONTDIR" fi -echo "<fontconfig><dir>$FONTDIR</dir><cachedir prefix=\"xdg\">fontconfig</cachedir></fontconfig>" > my-fonts.conf -FONTCONFIG_FILE="$MyPWD"/my-fonts.conf $FCCACHE "$FONTDIR" || : +echo "<fontconfig><dir>$FONTDIR</dir><cachedir prefix=\"xdg\">fontconfig</cachedir></fontconfig>" > "$BUILDTESTDIR"/my-fonts.conf +FONTCONFIG_FILE="$BUILDTESTDIR"/my-fonts.conf $FCCACHE "$FONTDIR" || : if [ -d "$HOME"/.cache ] && [ -d "$HOME"/.cache/fontconfig ]; then : ; else echo "*** Test failed: $TEST" echo "No \$HOME/.cache/fontconfig directory" @@ -465,7 +481,7 @@ if [ -d "$HOME"/.cache ] && [ -d "$HOME"/.cache/fontconfig ]; then : ; else fi export HOME="$old_HOME" -rm -rf "$temp_HOME" my-fonts.conf +rm -rf "$temp_HOME" "$BUILDTESTDIR"/my-fonts.conf unset XDG_CACHE_HOME unset old_HOME unset temp_HOME