Skip to content

Commit

Permalink
Add functional test to parse all Fedora spec files
Browse files Browse the repository at this point in the history
Signed-off-by: Nikola Forró <nforro@redhat.com>
  • Loading branch information
nforro committed Jun 11, 2023
1 parent c5dce21 commit 005b2d1
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 0 deletions.
11 changes: 11 additions & 0 deletions plans/functional.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
summary:
Functional tests
discover+:
filter: tier:2
prepare:
- how: install
package: xz
- how: shell
script: |
curl -O https://src.fedoraproject.org/lookaside/rpm-specs-latest.tar.xz
tar -xf rpm-specs-latest.tar.xz -C /tmp
37 changes: 37 additions & 0 deletions tests/functional.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
summary:
Functional tests
require:
- python3-pytest
- python3-specfile
- redhat-rpm-config
- rpmautospec-rpm-macros
- MUMPS-srpm-macros
- ansible-srpm-macros
- blis-srpm-macros
- efi-srpm-macros
- folly-srpm-macros
- fonts-srpm-macros
- fpc-srpm-macros
- ghc-srpm-macros
- gnat-srpm-macros
- go-srpm-macros
- kernel-srpm-macros
- lua-srpm-macros
- nbdkit-srpm-macros
- ocaml-srpm-macros
- openblas-srpm-macros
- package-notes-srpm-macros
- perl-srpm-macros
- pyproject-srpm-macros
- python-srpm-macros
- qt5-srpm-macros
- qt6-srpm-macros
- rust-srpm-macros
- typelib-srpm-macros
tag:
- functional
tier: 2
duration: 1h
# running from the "tests" directory prevents pytest from processing "tests/functional/conftest.py"
path: /
test: python3 -m pytest --verbose --specdir=/tmp/rpm-specs tests/functional
2 changes: 2 additions & 0 deletions tests/functional/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT
20 changes: 20 additions & 0 deletions tests/functional/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT

from pathlib import Path


def pytest_addoption(parser):
parser.addoption(
"--specdir",
action="store",
default=None,
help="path to a directory containing spec files",
)


def pytest_generate_tests(metafunc):
if "spec_path" in metafunc.fixturenames:
specdir = metafunc.config.getoption("specdir")
specs = list(Path(specdir).glob("*.spec")) if specdir else []
metafunc.parametrize("spec_path", specs, ids=lambda p: p.name)
9 changes: 9 additions & 0 deletions tests/functional/test_parse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT

from specfile import Specfile


def test_parse(spec_path):
spec = Specfile(spec_path, force_parse=True)
assert spec.expanded_version

0 comments on commit 005b2d1

Please sign in to comment.