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ó <[email protected]>
  • Loading branch information
nforro committed Jun 12, 2023
1 parent c5dce21 commit 7771658
Show file tree
Hide file tree
Showing 5 changed files with 57 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
15 changes: 15 additions & 0 deletions tests/functional.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
summary:
Functional tests
require:
- python3-pytest
- python3-specfile
- redhat-rpm-config
- rpmautospec-rpm-macros
- "*-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 7771658

Please sign in to comment.