mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-31 14:49:56 +00:00
fix: fix pkgbuild parsing in case if comment mark is followed by token
without whitespaces In this case, the next line was ignored
This commit is contained in:
@ -199,6 +199,52 @@ def test_parse_token_comment() -> None:
|
||||
]
|
||||
|
||||
|
||||
def test_read_comment() -> None:
|
||||
"""
|
||||
must read comment correctly
|
||||
"""
|
||||
io = StringIO("# comment\nnew line")
|
||||
io.seek(2)
|
||||
|
||||
PkgbuildParser(io)._read_comment()
|
||||
assert io.tell() == 10
|
||||
|
||||
|
||||
def test_read_comment_skip() -> None:
|
||||
"""
|
||||
must skip reading new line if comment ends with new line
|
||||
"""
|
||||
io = StringIO("#comment\nnew line")
|
||||
io.seek(7)
|
||||
|
||||
PkgbuildParser(io)._read_comment()
|
||||
assert io.tell() == 9
|
||||
|
||||
|
||||
def test_read_last() -> None:
|
||||
"""
|
||||
must read last symbol from current position
|
||||
"""
|
||||
io = StringIO("mock")
|
||||
io.seek(2)
|
||||
assert PkgbuildParser(io)._read_last() == (1, "o")
|
||||
|
||||
|
||||
def test_read_last_starting() -> None:
|
||||
"""
|
||||
must raise exception if it reads from starting position
|
||||
"""
|
||||
with pytest.raises(PkgbuildParserError):
|
||||
assert PkgbuildParser(StringIO("mock"))._read_last()
|
||||
|
||||
|
||||
def test_read_last_from_position() -> None:
|
||||
"""
|
||||
must read last symbol from the specified position
|
||||
"""
|
||||
assert PkgbuildParser(StringIO("mock"))._read_last(2) == (2, "c")
|
||||
|
||||
|
||||
def test_parse(resource_path_root: Path) -> None:
|
||||
"""
|
||||
must parse complex file
|
||||
@ -278,4 +324,6 @@ def test_parse(resource_path_root: Path) -> None:
|
||||
mv "$pkgdir"/usr/share/fonts/站酷小薇体 "$pkgdir"/usr/share/fonts/zcool-xiaowei-regular
|
||||
mv "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE.站酷小薇体 "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE.zcool-xiaowei-regular
|
||||
}"""),
|
||||
PkgbuildPatch("var", "value"),
|
||||
PkgbuildPatch("array", ["first", "second", "third"]),
|
||||
]
|
||||
|
@ -471,6 +471,7 @@ def test_walk(resource_path_root: Path) -> None:
|
||||
resource_path_root / "models" / "package_ahriman_pkgbuild",
|
||||
resource_path_root / "models" / "package_gcc10_pkgbuild",
|
||||
resource_path_root / "models" / "package_jellyfin-ffmpeg6-bin_pkgbuild",
|
||||
resource_path_root / "models" / "package_python-pytest-loop_pkgbuild",
|
||||
resource_path_root / "models" / "package_tpacpi-bat-git_pkgbuild",
|
||||
resource_path_root / "models" / "package_vim-youcompleteme-git_pkgbuild",
|
||||
resource_path_root / "models" / "package_yay_pkgbuild",
|
||||
|
@ -449,3 +449,41 @@ def test_parse_vim_youcompleteme_git(resource_path_root: Path) -> None:
|
||||
"9a5bee818a4995bc52e91588059bef42728d046808206bfb93977f4e3109e50c",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def test_parse_python_pytest_loop(resource_path_root: Path) -> None:
|
||||
"""
|
||||
must parse real PKGBUILDs correctly (python-pytest-loop)
|
||||
"""
|
||||
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_python-pytest-loop_pkgbuild")
|
||||
values = {key: value.value for key, value in pkgbuild.fields.items() if not value.is_function}
|
||||
assert values == {
|
||||
"pkgbase": "python-pytest-loop",
|
||||
"_pname": "${pkgbase#python-}",
|
||||
"_pyname": "${_pname//-/_}",
|
||||
"pkgname": [
|
||||
"python-${_pname}",
|
||||
],
|
||||
"pkgver": "1.0.13",
|
||||
"pkgrel": "1",
|
||||
"pkgdesc": "Pytest plugin for looping test execution.",
|
||||
"arch": ["any"],
|
||||
"url": "https://github.com/anogowski/pytest-loop",
|
||||
"license": ["MPL-2.0"],
|
||||
"makedepends": [
|
||||
"python-hatchling",
|
||||
"python-versioningit",
|
||||
"python-wheel",
|
||||
"python-build",
|
||||
"python-installer",
|
||||
],
|
||||
"checkdepends": [
|
||||
"python-pytest",
|
||||
],
|
||||
"source": [
|
||||
"https://files.pythonhosted.org/packages/source/${_pyname:0:1}/${_pyname}/${_pyname}-${pkgver}.tar.gz",
|
||||
],
|
||||
"md5sums": [
|
||||
"98365f49606d5068f92350f1d2569a5f",
|
||||
],
|
||||
}
|
||||
|
Reference in New Issue
Block a user