The font tests
Find a file
2024-11-15 18:42:40 +09:00
.fmf Initial commit 2024-06-19 17:28:47 +09:00
tests lang_coverage: fix shellcheck error 2024-11-15 18:42:40 +09:00
README.rst Add examples for *_EXCLUDE_FILES 2024-11-07 15:45:08 +09:00

Fonts Tests
===========

Common test repository for Fedora fonts packages.
Use ``tmt`` to run tests easily:

        tmt run

How to create
-------------

1. ``tmt init`` at a package repository
2. ``tmt plan create -t mini /plans/<sub package name>``
3. Create ``plans/<sub package name>.fmf`` with the following template

or

1. ``dnf install fontrpmspec``
2. ``fontrpmspec-gentmt <path to package repository>``
3. Review generated fmf plan files under ``<path to package repository>/plans``

Template
--------

::

  summary: Fonts related tests
  discover:
    how: fmf
    url: https://src.fedoraproject.org/tests/fonts
  execute:
    how: tmt
  environment:
    PACKAGE: <package name to test>
    FONT_ALIAS: <generic alias to test such as sans-serif, serif, monospace>
    FONT_FAMILY: <family name for this font>
    FONT_LANG: <comma-separated list of language identifier>
    FONT_WIDTH: <width name to test>

Available test cases
--------------------

- Default fonts

  A test case to check if the targeted font package affects various default
  generic alias selection.
  The following parameters are used in this test:

  - DEFAULT_SANS (optional)

    default value is ``0``. set ``1`` if the targeted font package is supposed to
    be a default font for sans-serif on a certain language.
    set ``2`` if the result isn't yet determined. it may be helpful to deal with
    minor languages.

  - DEFAULT_SERIF (optional)

    default value is ``0``. set ``1`` if the targeted font package is supposed to
    be a default font for serif on a certain language.
    set ``2`` if the result isn't yet determined. it may be helpful to deal with
    minor languages.

  - DEFAULT_MONO (optional)

    default value is ``0``. set ``1`` if the targeted font package is supposed to
    be a default font for monospace on a certain language.
    set ``2`` if the result isn't yet determined. it may be helpful to deal with
    minor languages.

  - DEFAULT_EMOJI (optional)

    default value is ``0``. set ``1`` if the targeted font package is supposed to
    be a default font for emoji.

  - DEFAULT_MATH (optional)

    default value is ``0``. set ``1`` if the targeted font package is supposed to
    be a default font for math.

  - FONT_FAMILY
  - FONT_LANG (optional)

    default value is ``en``. en will be used for ``und-zsye`` (emoji) and ``und-zmth`` (math).
    If you set ``-`` (hyphen) as a language, ``en`` will be used instead.

- Generic alias

  A test case to check if the expected generic alias is properly assigned.
  The following parameters are used in this test:

  - PACKAGE
  - FONT_ALIAS (optional)

    default value is ``sans-serif``

  - FONT_FAMILY
  - FONT_LANG (optional)

    default value is ``en``.
    If you set ``-`` (hyphen) as a language, this test will be skipped.
    This may be somewhat useful when you don't want to test a specific font only.

  - FONT_WIDTH (optional)

    default value is ``normal``.

  - FONT_CONF_EXCLUDE_FILES (optional)

    Set a regular expression [1]_ to skip some bogus fontconfig config files::

      Example

        FONT_CONF_EXCLUDE_FILES: .*-bad  # to skip all fontconfig files containing -bad word

- Language coverage

  A test case to check if a font in PACKAGE has sufficient coverage for FONT_LANG.
  The following parameters are used in this test:

  - PACKAGE
  - FONT_LANG (optional)

    default value is ``en``.
    If you set ``-`` (hyphen) as a language, this test will be skipped.
    This may be somewhat useful when you don't want to test a specific font only.

  - FONT_LANG_EXCLUDE_FILES (optional)

    Set a regular expression [1]_ to skip some bogus font files::

      Example

        FONT_LANG_EXCLUDE_FILES: .*-Bold  # to skip all font files containing -Bold word

- Validate family name

  A test case to check if a given FONT_FAMILY is really valid for this package.
  This is to prevent some human error.
  The following parameters are used in this test:

  - PACKAGE
  - FONT_FAMILY
  - FONT_VALIDATE_EXCLUDE_FILES (optional)

    Set a regular expression [1]_ to skip some bogus font files::

      Example

        FONT_VALIDATE_EXCLUDE_FILES: .*-Bold  # to skip all font files containing -Bold word

.. [1] compatible with Extended Regular Expression in grep. see grep(1) for more details.

FAQ
---

- My font package doesn't have an own config.

  You can add ``generic_alias`` into ``exclude`` at ``discover`` section like::

    discover:
      how: fmf
      url: https://src.fedoraproject.org/tests/fonts
      exclude:
        - generic_alias

- My font package doesn't have particular language coverage.

  You can add ``lang_coverage`` and ``default_fonts`` into ``exclude`` at ``discover`` section like::

    discover:
      how: fmf
      url: https://src.fedoraproject.org/tests/fonts
      exclude:
        - lang_coverage
        - default_fonts

- Unable to run ``tmt run`` locally.

  You may want to add the following snippet into your fmf plan file.
  Please note that a package set to ``package:`` will be pulled from
  the official repo. it may not contains any changes you may made in
  your repo::

    prepare:
      name: tmt
      how: install
      package: <package name to test>

  or ``fontrpmspec-gentmt -a`` if you use fontrpmspec to generate.

- How to deal with TrueType/OpenType Collection format?

  This test sets are basically supposed to have one plan per sub-packages.
  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 on plans directory like the following format::

    # comment
    PACKAGE;FONT_ALIAS;FONT_LANG;FONT_WIDTH;FONT_FAMILY;DEFAULT_SANS;DEFAULT_SERIF;DEFAULT_MONO;DEFAULT_EMOJI;DEFAULT_MATH;FONT_LANG_EXCLUDE_FILES;FONT_VALIDATE_EXCLUDE_FILES;FONT_CONF_EXCLUDE_FILES;
    ...

  And then set a filename to VARLIST like::

    environment:
      - VARLIST: <srpm-name>.list