From 8bb89c3bf82a976caa7f102f628514c531e3adc4 Mon Sep 17 00:00:00 2001 From: Karolina Surma Date: Wed, 31 Jul 2024 13:18:26 +0200 Subject: [PATCH] CI: Run upstream unit tests for hatchling --- .fmf/version | 1 + plan.fmf | 4 ++++ tests/unit/main.fmf | 18 ++++++++++++++++++ tests/unit/runtest.sh | 20 ++++++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 .fmf/version create mode 100644 plan.fmf create mode 100644 tests/unit/main.fmf create mode 100755 tests/unit/runtest.sh diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/plan.fmf b/plan.fmf new file mode 100644 index 0000000..e6427de --- /dev/null +++ b/plan.fmf @@ -0,0 +1,4 @@ +discover: + how: fmf +execute: + how: tmt diff --git a/tests/unit/main.fmf b/tests/unit/main.fmf new file mode 100644 index 0000000..dcaab7b --- /dev/null +++ b/tests/unit/main.fmf @@ -0,0 +1,18 @@ +summary: run upstream unit tests +test: ./runtest.sh +require: + - cargo + - git-core + - python3-click + - python3-filelock + - python3-hatchling + - python3-httpx + - python3-packaging + - python3-pathspec + - python3-platformdirs + - python3-pytest + - python3-pytest-mock + - python3-rich + - python3-tomli-w + - python3-virtualenv +duration: 10m diff --git a/tests/unit/runtest.sh b/tests/unit/runtest.sh new file mode 100755 index 0000000..4dda9f8 --- /dev/null +++ b/tests/unit/runtest.sh @@ -0,0 +1,20 @@ +#!/bin/bash -eux + +# Get the version of our installed component +VERSION=$(rpm -q --queryformat="%{VERSION}" python3-hatchling) + +# The hatch's source code contains the tests for hatchling in tests/backend +git clone --depth 1 --branch hatchling-v$VERSION https://github.com/pypa/hatch/ +cd hatch + +# Delete the hatchling sources from the repository - we want to test the RPM package +rm -r backend/ + +# Work around tests wanting a proper Hatch installation +echo '__version__ = "(bogus)"' > src/hatch/_version.py + +# test_extra_met and test_unknown_extra try to pip install requests[security]==2.25.1 +# which is too old to be compiled for Python 3.13 - skip them +k="not test_extra_met and not test_unknown_extra" + +PYTHONPATH="$PWD/src" python3 -m pytest tests/backend -k "${k}" -v