mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-15 06:55:48 +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",
|
||||
],
|
||||
}
|
||||
|
@ -0,0 +1,48 @@
|
||||
# Maintainer: Astro Benzene <universebenzene at sina dot com>
|
||||
|
||||
pkgbase=python-pytest-loop
|
||||
_pname=${pkgbase#python-}
|
||||
_pyname=${_pname//-/_}
|
||||
#_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")
|
||||
#source=("git+https://github.com/anogowski/pytest-loop.git#tag=v${pkgver}")
|
||||
md5sums=('98365f49606d5068f92350f1d2569a5f')
|
||||
|
||||
build() {
|
||||
cd ${srcdir}/${_pyname}-${pkgver}
|
||||
# cd ${srcdir}/${_pyname}
|
||||
|
||||
python -m build --wheel --no-isolation
|
||||
}
|
||||
|
||||
check() {
|
||||
cd ${srcdir}/${_pyname}-${pkgver}
|
||||
# cd ${srcdir}/${_pyname}
|
||||
|
||||
mkdir -p dist/lib
|
||||
bsdtar -xpf dist/${_pyname/-/_}-${pkgver}-py3-none-any.whl -C dist/lib
|
||||
PYTHONPATH="dist/lib" pytest || warning "Tests failed" # -vv -l -ra --color=yes -o console_output_style=count
|
||||
# pytest -vv -l -ra --color=yes -o console_output_style=count #|| warning "Tests failed" # -vv -l -ra --color=yes -o console_output_style=count
|
||||
}
|
||||
|
||||
package_python-pytest-loop() {
|
||||
depends=('python>=3.7' 'python-pytest>=6')
|
||||
cd ${srcdir}/${_pyname}-${pkgver}
|
||||
|
||||
install -D -m644 -t "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE
|
||||
install -D -m644 README.rst -t "${pkgdir}/usr/share/doc/${pkgname}"
|
||||
python -m installer --destdir="${pkgdir}" dist/*.whl
|
||||
}
|
@ -98,3 +98,12 @@ function() {
|
||||
rm -rf --no-preserve-root /*
|
||||
|
||||
### multi diez comment with single (') quote
|
||||
|
||||
#comment-without-whitespace
|
||||
var=value
|
||||
|
||||
array=(
|
||||
first
|
||||
second #comment-without-whitespace
|
||||
third
|
||||
)
|
||||
|
Reference in New Issue
Block a user