Repository: asciidoc-py/asciidoc-py (language: python)

Issue:
tests/test_plugin.py block error
Thank you for the new release, I thought I would try it so quickly modified the PKGBUILD:
```
$ diff -u asciidoc/PKGBUILD PKGBUILD 
--- asciidoc/PKGBUILD	2022-02-20 21:24:38.824079823 +0000
+++ PKGBUILD	2022-02-20 21:09:38.297490583 +0000
@@ -10,8 +10,8 @@
 # Contributor: Daniel J Griffiths <ghost1227@archlinux.us>
 
 pkgname=asciidoc
-pkgver=10.1.2
-pkgrel=2
+pkgver=10.1.3
+pkgrel=1
 pkgdesc='Text document format for short documents, articles, books and UNIX man pages'
 arch=('any')
 url='https://asciidoc.org/'
@@ -28,17 +28,18 @@
             'w3m: text generation'
             'lynx: alternative text generation')
 source=("https://github.com/asciidoc-py/asciidoc-py/releases/download/$pkgver/$pkgname-$pkgver.tar.gz")
-sha256sums=('0bfcebf4d0419323c8b4903676b05259847e6534c82a2629a0c852e621de7c47')
-b2sums=('a00ade1a849ffed98d10ddbbca5300e6f9fca9fc60663ff6e59979613a013b408829d35d9362cdf830ef08cd494ca4a47dab919ce29ce7111ee0fdaa3e301f24')
+sha256sums=('SKIP')
+#sha256sums=('0bfcebf4d0419323c8b4903676b05259847e6534c82a2629a0c852e621de7c47')
+#b2sums=('a00ade1a849ffed98d10ddbbca5300e6f9fca9fc60663ff6e59979613a013b408829d35d9362cdf830ef08cd494ca4a47dab919ce29ce7111ee0fdaa3e301f24')
 
 prepare() {
-  cd ${pkgname}-py-${pkgver}
+  cd ${pkgname}-${pkgver}
   # https://github.com/asciidoc-py/asciidoc-py/issues/234
   autoconf
 }
 
 build() {
-  cd ${pkgname}-py-${pkgver}
+  cd ${pkgname}-${pkgver}
   # https://github.com/asciidoc-py/asciidoc-py/issues/234#issuecomment-1045970138
   ./configure \
       --docdir /usr/share/doc/$pkgname \
@@ -48,12 +49,12 @@
 }
 
 check() {
-  cd ${pkgname}-py-${pkgver}
+  cd ${pkgname}-${pkgver}
   make test
 }
 
 package() {
-  cd ${pkgname}-py-${pkgver}
+  cd ${pkgname}-${pkgver}
   make DESTDIR="${pkgdir}" install
   make DESTDIR="${pkgdir}" docs
   install -Dm0644 -t "$pkgdir/usr/share/man/man1/" doc/*.1

```

But anyway, the build fails on the tests with another block error, when I ran the test from the cmdline it said this:

```
/tmp/asciidoc/src/asciidoc-10.1.3$ python tests/test_plugin.py
Traceback (most recent call last):
  File "/tmp/asciidoc/src/asciidoc-10.1.3/tests/test_plugin.py", line 3, in <module>
    from asciidoc.message import Message
  File "/usr/lib/python3.10/site-packages/asciidoc/__init__.py", line 11, in <module>
    from .api import AsciiDocAPI
  File "/usr/lib/python3.10/site-packages/asciidoc/api.py", line 1, in <module>
    from . import asciidoc
  File "/usr/lib/python3.10/site-packages/asciidoc/asciidoc.py", line 35, in <module>
    from .blocks.table import parse_table_span_spec, Cell, Column
ModuleNotFoundError: No module named 'asciidoc.blocks'
```
Possibly I needed to make more mods to the PKGBUILD, apologies in advance if that is the case!


Discussion / hints:
I'm not sure `python tests/test_plugin.py` will work directly, it relies on pytest handling adding the asciidoc module to the syspath for imports, and so you'd need to do `python -m pytest tests/test_plugin.py`.
It fails like that too, and with "make test" which is what caused the PKGBUILD to quit, that's your test in this package, the above was just me trying to run it individually afterwards, but obviously incorrectly!
```
/tmp/asciidoc/asciidoc-10.1.3$ autoconf
/tmp/asciidoc/asciidoc-10.1.3$ ./configure
checking for a sed that does not truncate output... /usr/bin/sed
checking whether ln -s works... yes
checking for a BSD-compatible install... /usr/bin/install -c
configure: creating ./config.status
config.status: creating Makefile
/tmp/asciidoc/asciidoc-10.1.3$ make
make: Nothing to be done for 'all'.
/tmp/asciidoc/asciidoc-10.1.3$ make test
python3 -m asciidoc.asciidoc --doctest
asciidoc: All doctests passed
python3 -m pytest
============================================================================= test session starts ==============================================================================
platform linux -- Python 3.10.2, pytest-6.2.5, py-1.11.0, pluggy-0.13.1
rootdir: /tmp/asciidoc/asciidoc-10.1.3
plugins: mock-3.7.0
collected 59 items                                                                                                                                                             

tests/test_a2x.py ...                                                                                                                                                    [  5%]
tests/test_asciidoc.py ..........                                                                                                                                        [ 22%]
tests/test_collections.py ...                                                                                                                                            [ 27%]
tests/test_plugin.py F                                                                                                                                                   [ 28%]
tests/test_utils.py ..........................................                                                                                                           [100%]

=================================================================================== FAILURES ===================================================================================
_______________________________________________________________________________ test_plugin_list _______________________________________________________________________________

capsys = <_pytest.capture.CaptureFixture object at 0x7fa5b92b1db0>

    def test_plugin_list(capsys) -> None:
        plugin = Plugin('backend', Message(None, None, CONFIG, None), CONFIG)
        plugin.list([])
        captured = capsys.readouterr()
        backend_dir = PLUGIN_DIR / 'backends'
>       assert captured.out == "{}\n{}\n".format(backend_dir / 'bar', backend_dir / 'foo')
E       AssertionError: assert '' == '/tmp/asciido...ackends/foo\n'
E         - /tmp/asciidoc/asciidoc-10.1.3/tests/__test_data__/plugin/backends/bar
E         - /tmp/asciidoc/asciidoc-10.1.3/tests/__test_data__/plugin/backends/foo

tests/test_plugin.py:17: AssertionError
=============================================================================== warnings summary ===============================================================================
asciidoc/a2x.py:289
  /tmp/asciidoc/asciidoc-10.1.3/asciidoc/a2x.py:289: DeprecationWarning: invalid escape sequence '\A'
    mo = re.search(b'\A<\?xml.* encoding="(.*?)"', contents)

asciidoc/a2x.py:376
  /tmp/asciidoc/asciidoc-10.1.3/asciidoc/a2x.py:376: DeprecationWarning: invalid escape sequence '\s'
    mo = re.search(b'^//\s*a2x:', line)

tests/test_asciidoc.py: 20 warnings
  <unknown>:1: DeprecationWarning: invalid escape sequence '\S'

tests/test_asciidoc.py::test_ignore_attribute[link:\\{attach}file\\{0}.txt[file\\{bar}too\\{1}]-<div class="paragraph"><p><a href="{attach}file{0}.txt">file{bar}too{1}</a></p></div>\r\n]
tests/test_asciidoc.py::test_ignore_attribute[link:\\{attach}file\\{0}.txt[file\\{bar}too\\{1}]-<div class="paragraph"><p><a href="{attach}file{0}.txt">file{bar}too{1}</a></p></div>\r\n]
tests/test_asciidoc.py::test_ignore_attribute[image:\\{attach}file.jpg[\\{bar}?]-<div class="paragraph"><p><span class="image">\r\n<img src="{attach}file.jpg" alt="{bar}?" />\r\n</span></p></div>\r\n]
tests/test_asciidoc.py::test_ignore_attribute[image:\\{attach}file.jpg[\\{bar}?]-<div class="paragraph"><p><span class="image">\r\n<img src="{attach}file.jpg" alt="{bar}?" />\r\n</span></p></div>\r\n]
  <unknown>:1: DeprecationWarning: invalid escape sequence '\{'

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================================================================== short test summary info ============================================================================
FAILED tests/test_plugin.py::test_plugin_list - AssertionError: assert '' == '/tmp/asciido...ackends/foo\n'
================================================================== 1 failed, 58 passed, 26 warnings in 1.21s ===================================================================
make: *** [Makefile:144: test] Error 1

```
This is with all the build deps installed as per the PKGBUILD list. It seemed suspicious this test fails when it also involves "blocks" but perhaps there is some other reason.
If the tests are not run, the resulting package does seem to build the pakku man pages sucessfully though.

Fix patch:
diff --git a/Makefile.in b/Makefile.in
index 7f3ac3cd..35861db2 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -120,8 +120,8 @@ uninstall:
 clean:
 	rm -f $(manp)
 
-MANIFEST: MANIFEST.in build_manifest.sh
-	bash build_manifest.sh
+MANIFEST: build_manifest.py
+	python3 build_manifest.py
 
 ##.
 ##   dist: creates the zip and tarball for release
diff --git a/build_manifest.py b/build_manifest.py
new file mode 100644
index 00000000..7464d9bc
--- /dev/null
+++ b/build_manifest.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python3
+
+import os
+from os import path
+import glob
+
+
+def sort_files(files):
+    return sorted(files, key=lambda v: v.lower())
+
+
+def get_files(basedir):
+    return_files = []
+
+    entries = os.listdir(basedir)
+    files = sort_files(
+        filter(
+            lambda x: path.isfile(path.join(basedir, x)) and not x.endswith('.pyc'),
+            entries
+        ),
+    )
+    dirs = sort_files(
+        filter(
+            lambda x: path.isdir(path.join(basedir, x)) and
+            (x != '__pycache__' or
+                '.gitkeep' in os.listdir(path.join(basedir, x))),
+            entries,
+        )
+    )
+    for dir in dirs:
+        return_files += get_files(path.join(basedir, dir))
+    return_files += [path.join(basedir, f) for f in files]
+    return return_files
+
+
+manifest_list = []
+
+manifest_list += get_files('asciidoc')
+
+doc_glob = [
+    'doc/*.1',
+    'doc/*.txt',
+]
+
+doc_files = [
+    'doc/article-docinfo.xml',
+    'doc/asciidoc.conf',
+    'doc/asciidoc.dict',
+    'doc/customers.csv',
+]
+
+for entry in doc_glob:
+    doc_files += glob.glob(entry)
+
+manifest_list += sort_files(doc_files)
+
+manifest_list += sort_files(glob.glob('images/*'))
+
+manifest_list += get_files('tests')
+
+manifest_list += sort_files([
+    'BUGS.adoc',
+    'build_manifest.py',
+    'CHANGELOG.adoc',
+    'configure.ac',
+    'COPYRIGHT',
+    'Dockerfile',
+    'install-sh',
+    'INSTALL.adoc',
+    'LICENSE',
+    'Makefile.in',
+    'MANIFEST',
+    'MANIFEST.in',
+    'README.md',
+    'setup.py',
+])
+
+with open('MANIFEST', 'w') as open_file:
+    open_file.write("\n".join(manifest_list) + "\n")
diff --git a/build_manifest.sh b/build_manifest.sh
deleted file mode 100644
index 78243789..00000000
--- a/build_manifest.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/env bash
-
-cat > MANIFEST.tmp <<- EOM
-asciidoc/*.py
-asciidoc/**/*.py
-asciidoc/resources/**/*
-asciidoc/resources/*.conf
-doc/asciidoc.conf
-doc/article-docinfo.xml
-doc/customers.csv
-doc/*.1
-doc/*.txt
-doc/asciidoc.dict
-images/*
-tests/data/*
-tests/inputs/*
-tests/*.py
-tests/testasciidoc.conf
-*.sh
-BUGS.adoc
-CHANGELOG.adoc
-configure.ac
-COPYRIGHT
-Dockerfile
-install-sh
-INSTALL.adoc
-LICENSE
-MANIFEST.in
-Makefile.in
-README.md
-setup.py
-EOM
-
-rm -f MANIFEST
-while read in; do
-    if [ ! -z "${in}" ]; then
-        ls -1Ad ${in} | grep -v ".pyc" | grep -v "__pycache__" >> MANIFEST
-    fi
-done < MANIFEST.tmp
-echo "MANIFEST" >> MANIFEST
-rm -f MANIFEST.tmp


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index cc62ecab..4599f56a 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -136,3 +136,61 @@ jobs:
 
       - run: asciidoc --version
       - run: asciidoc --filter list
+
+  make-dist:
+    needs: lint
+    runs-on: ubuntu-latest
+    env:
+      python-version: 3.5
+
+    steps:
+      - uses: actions/checkout@v2
+
+      - name: Set up Python ${{ env.python-version }}
+        uses: actions/setup-python@v2
+        with:
+          python-version: ${{ matrix.python-version }}
+
+      - name: Install apt dependencies
+        run: |
+          sudo apt-get install -y --no-install-recommends \
+            docbook-xml \
+            docbook-xsl \
+            dvipng \
+            dvisvgm \
+            graphviz \
+            imagemagick \
+            libxml2-utils \
+            lilypond \
+            source-highlight \
+            texlive-latex-base \
+            xsltproc
+
+      - run: pip install -U pytest pytest-mock
+
+      - name: Configure make
+        run: |
+          autoconf
+          ./configure
+
+      - run: make dist
+
+      - run: mkdir dist
+
+      - run: tar -xvf build/asciidoc-*.tar.gz -C dist --strip-components=1
+
+      - run: |
+          autoconf
+          ./configure
+        working-directory: dist
+
+      - run: python3 -m pytest
+        working-directory: dist
+
+      - run: python3 tests/testasciidoc.py run --number 1
+        working-directory: dist
+
+      - run: make install
+        working-directory: dist
+
+      - run: asciidoc --version