Skip to content

Commit 005b2d1

Browse files
committed
Add functional test to parse all Fedora spec files
Signed-off-by: Nikola Forró <nforro@redhat.com>
1 parent c5dce21 commit 005b2d1

File tree

5 files changed

+79
-0
lines changed

5 files changed

+79
-0
lines changed

plans/functional.fmf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
summary:
2+
Functional tests
3+
discover+:
4+
filter: tier:2
5+
prepare:
6+
- how: install
7+
package: xz
8+
- how: shell
9+
script: |
10+
curl -O https://src.fedoraproject.org/lookaside/rpm-specs-latest.tar.xz
11+
tar -xf rpm-specs-latest.tar.xz -C /tmp

tests/functional.fmf

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
summary:
2+
Functional tests
3+
require:
4+
- python3-pytest
5+
- python3-specfile
6+
- redhat-rpm-config
7+
- rpmautospec-rpm-macros
8+
- MUMPS-srpm-macros
9+
- ansible-srpm-macros
10+
- blis-srpm-macros
11+
- efi-srpm-macros
12+
- folly-srpm-macros
13+
- fonts-srpm-macros
14+
- fpc-srpm-macros
15+
- ghc-srpm-macros
16+
- gnat-srpm-macros
17+
- go-srpm-macros
18+
- kernel-srpm-macros
19+
- lua-srpm-macros
20+
- nbdkit-srpm-macros
21+
- ocaml-srpm-macros
22+
- openblas-srpm-macros
23+
- package-notes-srpm-macros
24+
- perl-srpm-macros
25+
- pyproject-srpm-macros
26+
- python-srpm-macros
27+
- qt5-srpm-macros
28+
- qt6-srpm-macros
29+
- rust-srpm-macros
30+
- typelib-srpm-macros
31+
tag:
32+
- functional
33+
tier: 2
34+
duration: 1h
35+
# running from the "tests" directory prevents pytest from processing "tests/functional/conftest.py"
36+
path: /
37+
test: python3 -m pytest --verbose --specdir=/tmp/rpm-specs tests/functional

tests/functional/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Copyright Contributors to the Packit project.
2+
# SPDX-License-Identifier: MIT

tests/functional/conftest.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright Contributors to the Packit project.
2+
# SPDX-License-Identifier: MIT
3+
4+
from pathlib import Path
5+
6+
7+
def pytest_addoption(parser):
8+
parser.addoption(
9+
"--specdir",
10+
action="store",
11+
default=None,
12+
help="path to a directory containing spec files",
13+
)
14+
15+
16+
def pytest_generate_tests(metafunc):
17+
if "spec_path" in metafunc.fixturenames:
18+
specdir = metafunc.config.getoption("specdir")
19+
specs = list(Path(specdir).glob("*.spec")) if specdir else []
20+
metafunc.parametrize("spec_path", specs, ids=lambda p: p.name)

tests/functional/test_parse.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright Contributors to the Packit project.
2+
# SPDX-License-Identifier: MIT
3+
4+
from specfile import Specfile
5+
6+
7+
def test_parse(spec_path):
8+
spec = Specfile(spec_path, force_parse=True)
9+
assert spec.expanded_version

0 commit comments

Comments
 (0)