Commit 6f928a65 authored by admuc's avatar admuc

rearrange more_tests cont. i

parents d5029cbc d7fdf459
#!/usr/bin/env python3
"""produces testcases of current version AsciiDoc3 using multiprocessing.
Writes output to /dev/shm/current/*.* (that means: in memory)
Needs configuration of testcases already pickled; see
'./pickled_data/' and './pickled_data/testconf3pickle.dat'
We have to set 'imagesdir' explicitly.
Sample of testconf-item:
{'options': (('--doctype', 'book'),),
'attributes': (('toc', True),),
'outfile': '/dev/shm/current/lang-it-book-test-html5.html',
'backend': 'html5',
'inputfile': '~/asciidoc3/tests/data/lang-it-test.txt'}
(c) 2018 Berthold Gehrke <>
Free use is granted under the terms of GPLv2+
from concurrent import futures
import os.path
import pickle
......@@ -8,42 +25,28 @@ from sys import platform
from shutil import rmtree
import subprocess
"""Produces testcases of current version AsciiDoc3 using multiprocessing,
'current version' uses ../../
Output is written to /dev/shm/current/*.* (that means: only in memory and fast).
Needs pickled configuration of testcases, see './pickled_data/'.
def remove_old_files_and_mkdir_dev_shm_current():
"""Removes all remainder (if any) of previous testing in /dev/shm/current,
and creates an empty directory /dev/shm/current."""
def remove_and_mkdir_shm_current():
"""all remainder (if any) of previous testing in /dev/shm/current are removed,
and a new directory is created"""
if os.path.exists("/dev/shm/current") and os.path.isdir("/dev/shm/current"):
print("remove_old_files_and_mkdir_dev_shm_current() ... done")
print("remove_and_mkdir_shm_current() ... done")
def reading_testconf():
"""compute tuple(testtuple). Every item in testtuple
is a dict.
Sample of item:
{'options': (('--doctype', 'book'),),
'attributes': (('toc', True),),
'outfile': '/dev/shm/current/lang-it-book-test-html5.html',
'backend': 'html5',
'inputfile': '~/.asciidoc3/tests/data/lang-it-test.txt'}
is a dict. """
testconf3pickle = os.path.abspath('./pickled_data/testconf3pickle.dat')
with open(testconf3pickle, 'rb', 3) as f:
testtuple = tuple(pickle.load(f))
print("unpickle testtuple ... done")
with open(testconf3pickle, 'rb', 3) as test_conf_file:
testtuple = tuple(pickle.load(test_conf_file))
#print("len(testtuple): ", len(testtuple))
print("unpickle testtuple ... done")
return testtuple
def run_testcases(itemrow):
"""reads one testconf, runs the test, and writes output"""
# compute 'optionslist'
def create_testcases(itemrow):
"""text here"""
inputfile = itemrow['inputfile']
optionslist = list()
......@@ -55,49 +58,40 @@ def run_testcases(itemrow):
if itemrow['attributes']:
for attrpair in itemrow['attributes']:
if attrpair[1] == None:
if attrpair[1] is None:
attr = attrpair[0] + '="None"'
elif attrpair[1] == True:
elif attrpair[1] is True:
attr = attrpair[0] + '="True"'
attr = attrpair[0] + '=' + attrpair[1]
outputfile = itemrow['outfile']
optionslist.extend(["-o", outputfile])
# sample of 'optionslist':
# ['-b', 'xhtml11', '--doctype', 'article', '-a', 'toc="True"', \
# '-o', '/dev/shm/current/lang-en-article-test-xhtml11.html']
# compute 'commandline'
#set imagedir
explicit_imagedir = os.path.abspath('../../images')
optionslist.extend(["-a", "imagesdir=" + explicit_imagedir])
commandline = list()
asciidoc3_executable = os.path.abspath('../../')
ad3_executable = os.path.abspath("../../")
inputfile = itemrow['inputfile']
#print("subprocess starts with the following commadline: ")
# sample of 'commandline':
# ['python3', '~/asciidoc3/', '-b', 'docbook', '--doctype', 'article', \
# '-a', 'toc="True"', '-o', '/dev/shm/current/lang-it-article-test-docbook.xml', \
# '/home/bge/gitlabad3/asciidoc3/tests/data/lang-it-test.txt']
# ... produces the test-output
p =, stderr=subprocess.PIPE)
# If something goes wrong, print warning
if p.returncode:
print("!!! --> WARNING Returncode =", p.returncode, "item:", itemrow['inputfile'])
subprocess_testcase =, stderr=subprocess.PIPE)
if subprocess_testcase.returncode:
print("[WARNING] Returncode =", subprocess_testcase.returncode, \
"processing inputfile", itemrow['inputfile'])
if __name__ == "__main__":
# do not start as imported module
# do not run as an imported module or using an IDE like IDLE
if not platform.lower().startswith('linux'):
exit("Sorry, at this time only Linux!")
testtuple = reading_testconf()
exit("Sorry, at this time only GNU/Linux!")
TUPLE_TEST = reading_testconf()
with futures.ProcessPoolExecutor(max_workers=4) as e:
for item in testtuple:
e.submit(run_testcases, item)
for item in TUPLE_TEST:
e.submit(create_testcases, item)
print("writing testcases ... done")
......@@ -163,15 +163,17 @@ LaTeX Filter
% source
User Guide
% options
% source
# User Guide only in AsciiDoc3, see README
#User Guide
#% options
#% source
UTF-8 Examples
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment