Skip to content

Commit 63d21a9

Browse files
committed
Add functional test to parse all Fedora spec files
Signed-off-by: Nikola Forró <[email protected]>
1 parent c5dce21 commit 63d21a9

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed

plans/functional.fmf

+11
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

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
summary:
2+
Functional tests
3+
require:
4+
- python3-pytest
5+
- python3-specfile
6+
tag:
7+
- functional
8+
tier: 2
9+
duration: 1h
10+
# running from the "tests" directory prevents pytest from processing "tests/functional/conftest.py"
11+
path: /
12+
test: python3 -m pytest --verbose --specdir=/tmp/rpm-specs tests/functional

tests/functional/__init__.py

+2
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

+20
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

+9
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)