public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Akira TAGOH <akira@tagoh.org>
To: git-commits@fedoraproject.org
Subject: [tests/fonts] rhel9: generic_alias: Add a feature to read variables from file
Date: Thu, 13 Aug 2026 10:29:15 GMT	[thread overview]
Message-ID: <178661695577.1.14508370575233655500.tests-fonts-f774e88feca8@fedoraproject.org> (raw)

A new commit has been pushed.

Repo   : tests/fonts
Branch : rhel9
Commit : f774e88feca85e90079ecc99e801cb4ff679250a
Author : Akira TAGOH <akira@tagoh.org>
Date   : 2024-07-05T16:48:23+09:00
Stats  : +61/-21 in 2 file(s)
URL    : https://src.fedoraproject.org/tests/fonts/c/f774e88feca85e90079ecc99e801cb4ff679250a?branch=rhel9

Log:
generic_alias: Add a feature to read variables from file

---
diff --git a/README.rst b/README.rst
index 7ec3791..ed827ce 100644
--- a/README.rst
+++ b/README.rst
@@ -162,3 +162,11 @@ FAQ
   However, for some limitation in the implementation, it can't be done for
   TTC/OTC. So you may want to have separate plan file per faces in TTC/OTC.
   See `adobe-source-han-mono-fonts package <https://src.fedoraproject.org/rpms/adobe-source-han-mono-fonts/blob/rawhide/f/plans>`_ for example.
+
+- I saw "No space left on device" error during testing.
+- Too many sub packages. How can this be simplified?
+
+  You can put required variables into a file like the following format::
+
+  # comment
+  PACKAGE;FONT_ALIAS;FONT_LANG;FONT_WIDTH;FONT_FAMILY;

diff --git a/tests/generic_alias/test.sh b/tests/generic_alias/test.sh
index 021158b..f146329 100755
--- a/tests/generic_alias/test.sh
+++ b/tests/generic_alias/test.sh
@@ -1,5 +1,8 @@
 #!/bin/bash
 # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+
+basedir=$(pwd)
+
 . /usr/share/beakerlib/beakerlib.sh || exit 1
 
 FONT_ALIAS=${FONT_ALIAS:-"sans-serif"}
@@ -7,39 +10,68 @@ FONT_FAMILY=${FONT_FAMILY:-"family name"}
 FONT_LANG=${FONT_LANG:-"en"}
 FONT_WIDTH=${FONT_WIDTH:-"normal"}
 PACKAGE=${PACKAGE:-"blahblah-fonts"}
+VARLIST=${VARLIST:-}
 
-rlJournalStart
-    rlPhaseStartSetup
-        rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
-        rlRun "pushd $tmp"
-        rlRun "set -o pipefail"
-	rlRun "cachedir=\$(pkg-config --variable cachedir fontconfig)" 0 "Set cachedir"
-	rlRun "tmpconfd=\$(mktemp -d)" 0 "Create tmp conf.d directory"
-	rlRun "conffiles=\$(rpm -ql $PACKAGE | grep conf.d | tr '\n' ' ')"
-	rlRun "conf=\$(for i in $conffiles; do
-  echo \"<include>\$i</include>\"
-done)"
-	rlRun "cat <<_E_> $tmpconfd/fonts.conf
+function prepare_test {
+    local pkg=$1
+
+    rlRun "conffiles=\$(rpm -ql $pkg | grep conf.d | tr '\n' ' ')"
+    rlRun "conf=\$(for i in $conffiles; do echo \"  <include>\$i</include>\"; done)"
+    rlRun "cat <<_E_> $tmpconfd/$pkg.conf
 <fontconfig>
   <dir>/usr/share/fonts</dir>
-  $conf
+$conf
   <cachedir>$cachedir</cachedir>
 </fontconfig>
-_E_" 0 "Create fonts.conf"
+_E_" 0 "Create fonts.conf for $pkg"
+}
+
+function test_pkg {
+    local pkg=$1
+
+    rlPhaseStartTest "Package installation test for $pkg" #{
+        rlRun "rpm -q $pkg" 0 "Package installation test" #}
     rlPhaseEnd
+}
+
+function test_generic_alias {
+    local pkg=${1:-"unknown package"}
+    local fcfamily=${2:-"undefined family"}
+    local fclang=${3:-"en"}
+    local fcwidth=${4:-"normal"}
+    local fcresult=${5:-"unknown family"}
 
-    rlPhaseStartTest
-        rlRun "rpm -q $PACKAGE" 0 "Package installation test"
+    rlPhaseStartTest "Generic alias test for $pkg"
+        prepare_test $pkg
+        rlRun "cat $tmpconfd/$pkg.conf"
+        rlRun "FONTCONFIG_FILE=$tmpconfd/$pkg.conf fc-match -f \"%{family[0]}\\n\" \":family=$fcfamily:lang=$fclang:width=$fcwidth\" | tee output" 0 "Matching a font"
+        rlAssertGrep "^$fcresult\$" "output"
     rlPhaseEnd
+}
 
-    rlPhaseStartTest
-        rlRun "cat $tmpconfd/fonts.conf"
-	rlRun "FONTCONFIG_FILE=$tmpconfd/fonts.conf fc-match -f \"%{family[0]}\\n\" \":family=$FONT_ALIAS:lang=$FONT_LANG:width=$FONT_WIDTH\" | tee output" 0 "Matching a font"
-        rlAssertGrep "$FONT_FAMILY" "output"
+rlJournalStart
+    rlPhaseStartSetup
+        rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
+        rlRun "pushd $tmp"
+        rlRun "set -o pipefail"
+        rlRun "cachedir=\$(pkg-config --variable cachedir fontconfig)" 0 "Set cachedir"
+        rlRun "tmpconfd=\$(mktemp -d)" 0 "Create tmp conf.d directory"
     rlPhaseEnd
 
+    if [ -n "$VARLIST" ] && [ -f "$basedir/../../plans/$VARLIST" ]; then
+        rlLogInfo "Reading variables from $VARLIST"
+        cat "$basedir/../../plans/$VARLIST" | grep -E -v "^#" | while IFS=";" read -r PACKAGE FONT_ALIAS FONT_LANG FONT_WIDTH FONT_FAMILY dummy; do
+            test_pkg "$PACKAGE"
+            test_generic_alias "$PACKAGE" "$FONT_ALIAS" "$FONT_LANG" "$FONT_WIDTH" "$FONT_FAMILY"
+        done
+    else
+        test_pkg "$PACKAGE"
+        test_generic_alias "$PACKAGE" "$FONT_ALIAS" "$FONT_LANG" "$FONT_WIDTH" "$FONT_FAMILY"
+    fi
+
     rlPhaseStartCleanup
         rlRun "popd"
-        rlRun "rm -r $tmp" 0 "Remove tmp directory"
+        rlRun "rm -r $tmpconfd $tmp" 0 "Remove tmp directory"
     rlPhaseEnd
+
 rlJournalEnd

                 reply	other threads:[~2026-08-13 10:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178661695577.1.14508370575233655500.tests-fonts-f774e88feca8@fedoraproject.org \
    --to=akira@tagoh.org \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox