summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Peveler <matt.peveler@gmail.com>2020-08-13 11:54:55 -0400
committerGitHub <noreply@github.com>2020-08-13 11:54:55 -0400
commit3d0f94be2999edd4ab38fc3018e01613b8de582a (patch)
tree22cf0efb467b38c171d8f7e3069fe1cdf0f37f5e
parent1c9ad5b7c607cfca25ea9f23b60c9c7f1526482e (diff)
downloadasciidoc-py3-3d0f94be2999edd4ab38fc3018e01613b8de582a.tar.gz
auto clean-up generated artifacts from test suite (#135)
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
-rw-r--r--.gitignore8
-rw-r--r--doc/slidy-example.txt6
-rw-r--r--doc/testasciidoc.txt10
-rw-r--r--tests/data/graphviz1.pngbin10680 -> 0 bytes
-rw-r--r--tests/data/graphviz2.pngbin16952 -> 0 bytes
-rw-r--r--tests/data/music1.md51
-rw-r--r--tests/data/music1.pngbin12301 -> 0 bytes
-rw-r--r--tests/data/music2.md51
-rw-r--r--tests/data/music2.pngbin1157 -> 0 bytes
-rw-r--r--tests/data/open-block-test__1.md51
-rw-r--r--tests/data/open-block-test__1.pngbin933 -> 0 bytes
-rw-r--r--tests/data/open-block-test__2.pngbin10680 -> 0 bytes
-rw-r--r--tests/data/open-block-test__3.md51
-rw-r--r--tests/data/open-block-test__3.pngbin1157 -> 0 bytes
-rw-r--r--tests/data/slidy-example.txt174
-rw-r--r--tests/testasciidoc.conf16
-rwxr-xr-xtests/testasciidoc.py11
17 files changed, 209 insertions, 20 deletions
diff --git a/.gitignore b/.gitignore
index b7210e7..1c34a0e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,14 +5,6 @@
*.pyc
__pycache__/
-# ignore test products
-#tests/data/*.html
-#tests/data/*.xml
-#tests/data/*.ly
-#tests/data/*.abc
-#tests/data/*.md5
-#tests/data/*.png
-
# ignore doc products
doc/*.md5
doc/*.ly
diff --git a/doc/slidy-example.txt b/doc/slidy-example.txt
index cfac62b..aab2dd3 100644
--- a/doc/slidy-example.txt
+++ b/doc/slidy-example.txt
@@ -152,11 +152,6 @@ def sub_word(mo):
return word
---------------------------------------------------------------------
-////
-The music generation block is ignored for testing as it generates a PNG
-that is unique to the combination of lilypond and libpng used, which is
-easily different from environment to environment
-
[music]
.Music
---------------------------------------------------------------------
@@ -170,4 +165,3 @@ easily different from environment to environment
c2 e4 g2. f4 e d c2 r4
}
---------------------------------------------------------------------
-////
diff --git a/doc/testasciidoc.txt b/doc/testasciidoc.txt
index 68f0e12..632f592 100644
--- a/doc/testasciidoc.txt
+++ b/doc/testasciidoc.txt
@@ -174,12 +174,17 @@ AsciiDoc source file name.
% backends
Optional list of backends to be tested(default is all backends).
+
% options
Optional list of command-line option tuples.
% attributes
Optional dictionary of attribute values.
+% artifacts
+Optional list of artifacts that get generated from test, and which
+will get cleaned up.
+
---------------------------------------------------------------------
Example test spec:
@@ -224,6 +229,11 @@ configuration file that comes with AsciiDoc.
- The `requires` directive data specifies a Python list of strings
which correspond to the command line program specified by filters
in that test.
+- The `artifacts` directive data specifies a Python list of strings
+ which corresponds to the list of files (usually image or other such
+ files) that get generated when asciidoc is run over the input file.
+ The files are deleted after the test is for a given source file is
+ run for all backends.
globals directive
~~~~~~~~~~~~~~~~~
diff --git a/tests/data/graphviz1.png b/tests/data/graphviz1.png
deleted file mode 100644
index 24a8448..0000000
--- a/tests/data/graphviz1.png
+++ /dev/null
Binary files differ
diff --git a/tests/data/graphviz2.png b/tests/data/graphviz2.png
deleted file mode 100644
index c693750..0000000
--- a/tests/data/graphviz2.png
+++ /dev/null
Binary files differ
diff --git a/tests/data/music1.md5 b/tests/data/music1.md5
deleted file mode 100644
index 7f3f30b..0000000
--- a/tests/data/music1.md5
+++ /dev/null
@@ -1 +0,0 @@
-ԧxgWA\ZwA- \ No newline at end of file
diff --git a/tests/data/music1.png b/tests/data/music1.png
deleted file mode 100644
index a205947..0000000
--- a/tests/data/music1.png
+++ /dev/null
Binary files differ
diff --git a/tests/data/music2.md5 b/tests/data/music2.md5
deleted file mode 100644
index 30dcf44..0000000
--- a/tests/data/music2.md5
+++ /dev/null
@@ -1 +0,0 @@
- (״X \ No newline at end of file
diff --git a/tests/data/music2.png b/tests/data/music2.png
deleted file mode 100644
index bb33a52..0000000
--- a/tests/data/music2.png
+++ /dev/null
Binary files differ
diff --git a/tests/data/open-block-test__1.md5 b/tests/data/open-block-test__1.md5
deleted file mode 100644
index 0d3f62a..0000000
--- a/tests/data/open-block-test__1.md5
+++ /dev/null
@@ -1 +0,0 @@
--^5bU \ No newline at end of file
diff --git a/tests/data/open-block-test__1.png b/tests/data/open-block-test__1.png
deleted file mode 100644
index 5622d61..0000000
--- a/tests/data/open-block-test__1.png
+++ /dev/null
Binary files differ
diff --git a/tests/data/open-block-test__2.png b/tests/data/open-block-test__2.png
deleted file mode 100644
index 24a8448..0000000
--- a/tests/data/open-block-test__2.png
+++ /dev/null
Binary files differ
diff --git a/tests/data/open-block-test__3.md5 b/tests/data/open-block-test__3.md5
deleted file mode 100644
index 30dcf44..0000000
--- a/tests/data/open-block-test__3.md5
+++ /dev/null
@@ -1 +0,0 @@
- (״X \ No newline at end of file
diff --git a/tests/data/open-block-test__3.png b/tests/data/open-block-test__3.png
deleted file mode 100644
index bb33a52..0000000
--- a/tests/data/open-block-test__3.png
+++ /dev/null
Binary files differ
diff --git a/tests/data/slidy-example.txt b/tests/data/slidy-example.txt
new file mode 100644
index 0000000..f5d0363
--- /dev/null
+++ b/tests/data/slidy-example.txt
@@ -0,0 +1,174 @@
+Slidy Example Slideshow
+=======================
+:author: Joe Bloggs
+:copyright: Foobar Inc.
+:backend: slidy
+:max-width: 45em
+:data-uri:
+:icons:
+
+
+This preamble will appear on a separate slide.
+
+
+AsciiDoc Elements
+-----------------
+Sagittis in vestibulum. Habitasse ante nulla enim bibendum nulla. Odio
+sed pede litora.
+
+[float]
+=== Titles inside delimited blocks must be floated
+Porta nisl metus. Justo porttitor vel. Cras consequat tincidunt id sed
+conubia. Feugiat felis justo. Nunc amet nulla. Eu ac orci mollis.
+
+.Tiger
+image::images/tiger.png[]
+
+
+Incremental Elements
+--------------------
+The remaining elements on this page are incremental, press the space
+bar to reveal them.
+
+[role="incremental"]
+- Rhoncus pede justo.
+- Velit pede dolor.
+- Iaculis commodo et.
+- Volutpat tristique nec.
+
+[role="incremental"]
+--
+Sagittis in vestibulum. Habitasse ante nulla enim bibendum nulla. Odio
+sed pede litora.
+--
+
+[role="incremental"]
+. Rhoncus pede justo.
+. Velit pede dolor.
+. Iaculis commodo et.
+. Volutpat tristique nec.
+
+
+Outline Elements
+----------------
+The following list is a Slidy 'outline' list -- nested bulleted or
+numbered lists are expanded when the enclosing list item (the ones
+with blue bullet points or numbers) are clicked.
+
+[role="outline"]
+- Rhoncus pede justo.
+ * Rhoncus pede justo.
+ * Velit pede dolor.
+
+- Velit pede dolor.
+ * Iaculis commodo et.
++
+NOTE: 'Note' admonition paragraph.
+
+ * Volutpat tristique nec.
++
+image::images/tiger.png[]
+ * Iaculis commodo et.
+ * Volutpat tristique nec.
+
+- Iaculis commodo et.
+[role="outline"]
+ . Rhoncus pede justo.
+ ** Velit pede dolor.
+ ** Iaculis commodo et.
+ . Volutpat tristique nec.
+
+- Volutpat tristique nec.
+
+
+AsciiDoc Elements
+-----------------
+NOTE: 'Note' admonition paragraph.
+
+IMPORTANT: 'Important' admonition paragraph.
+
+.Sidebar
+*********************************************************************
+Faucibus sagittis commodo sed et eu. Quam nullam ornare. Sed vel est.
+Mauris urna lobortis interdum placerat per id magnis enim.
+*********************************************************************
+
+
+AsciiDoc Elements
+-----------------
+A quote block:
+
+[quote, Bertrand Russell, The World of Mathematics (1956)]
+____________________________________________________________________
+A good notation has subtlety and suggestiveness which at times makes
+it almost seem like a live teacher.
+____________________________________________________________________
+
+A verse block:
+
+[verse, William Blake, from Auguries of Innocence]
+__________________________________________________
+To see a world in a grain of sand,
+And a heaven in a wild flower,
+Hold infinity in the palm of your hand,
+And eternity in an hour.
+__________________________________________________
+
+
+AsciiDoc Elements
+-----------------
+.Horizontal and vertical source data
+[width="80%",cols="3,^2,^2,10",options="header"]
+|=========================================================
+|Date |Duration |Avg HR |Notes
+
+|22-Aug-08 |10:24 | 157 |
+Worked out MSHR (max sustainable heart rate) by going hard
+for this interval.
+
+|22-Aug-08 |23:03 | 152 |
+Back-to-back with previous interval.
+
+|24-Aug-08 |40:00 | 145 |
+Moderately hard interspersed with 3x 3min intervals (2min
+hard + 1min really hard taking the HR up to 160).
+
+|=========================================================
+
+
+Filters
+-------
+[source,python]
+.Python source
+---------------------------------------------------------------------
+''' A multi-line
+ comment.'''
+def sub_word(mo):
+ ''' Single line comment.'''
+ word = mo.group('word') # Inline comment
+ if word in keywords[language]:
+ return quote + word + quote
+ else:
+ return word
+---------------------------------------------------------------------
+
+////
+The music generation block is ignored for testing as it generates a PNG
+that is unique to the combination of lilypond and libpng used, which is
+easily different from environment to environment
+
+[music]
+.Music
+---------------------------------------------------------------------
+\version "2.10.0"
+\paper {
+ ragged-right = ##t
+}
+{
+ \time 3/4
+ \clef bass
+ c2 e4 g2. f4 e d c2 r4
+}
+---------------------------------------------------------------------
+
+////
diff --git a/tests/testasciidoc.conf b/tests/testasciidoc.conf
index a2adc91..84fc36f 100644
--- a/tests/testasciidoc.conf
+++ b/tests/testasciidoc.conf
@@ -21,6 +21,9 @@ Filters
% source
data/filters-test.txt
+% artifacts
+['data/graphviz1.png', 'data/graphviz2.png', 'data/music1.md5', 'data/music1.png', 'data/music2.md5', 'data/music2.png']
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Tables
@@ -132,10 +135,13 @@ Example slideshow
['source-highlight']
% attributes
-{'imagesdir': '../', 'iconsdir': '../images/icons'}
+{'imagesdir': '../../', 'iconsdir': '../../images/icons'}
% source
-../doc/slidy-example.txt
+data/slidy-example.txt
+
+% artifacts
+['../slidy-example__1.md5','../slidy-example__1.png']
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ASCIIMathML
@@ -179,6 +185,9 @@ LaTeX Filter
% source
../doc/latex-filter.txt
+% artifacts
+['../doc/latex-filter__1.md5','../doc/latex-filter__1.svg','../doc/latex-filter__2.md5','../doc/latex-filter__2.svg','../doc/latex1.md5','../doc/latex1.svg','../doc/latex2.md5','../doc/latex2.png','../doc/latex3.md5','../doc/latex3.svg']
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
!User Guide
@@ -203,6 +212,9 @@ Additional Open Block and Paragraph styles
% source
data/open-block-test.txt
+% artifacts
+['data/open-block-test__1.md5','data/open-block-test__1.png','data/open-block-test__2.png','data/open-block-test__3.md5','data/open-block-test__3.png']
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
English language file (article)
diff --git a/tests/testasciidoc.py b/tests/testasciidoc.py
index 4d2605a..c3426c4 100755
--- a/tests/testasciidoc.py
+++ b/tests/testasciidoc.py
@@ -77,6 +77,7 @@ class AsciiDocTest(object):
self.options = []
self.attributes = {'asciidoc-version': 'test'}
self.backends = BACKENDS
+ self.artifacts = [] # list of generated artifacts to delete
self.requires = [] # list of dependencies to check for for the test
self.confdir = None
self.datadir = None # Where output files are stored.
@@ -134,6 +135,8 @@ class AsciiDocTest(object):
self.name = data[0].strip()
elif directive == 'requires':
self.requires = eval(' '.join(data))
+ elif directive == 'artifacts':
+ self.artifacts = eval(' '.join(data))
else:
raise ValueError
if not self.title:
@@ -155,6 +158,12 @@ class AsciiDocTest(object):
os.path.getmtime(self.source)
> os.path.getmtime(self.backend_filename(backend)))
+ def clean_artifacts(self):
+ for artifact in self.artifacts:
+ loc = os.path.join(self.confdir, artifact)
+ if os.path.exists(loc):
+ os.unlink(loc)
+
def get_expected(self, backend):
"""
Return expected test data output for backend.
@@ -200,6 +209,7 @@ class AsciiDocTest(object):
for backend in backends:
if force or self.is_missing_or_outdated(backend):
self.update_expected(backend)
+ self.clean_artifacts()
def run(self, backend=None):
"""
@@ -246,6 +256,7 @@ class AsciiDocTest(object):
else:
self.skipped += 1
print(('SKIPPED: %s: %s' % (backend, fromfile)))
+ self.clean_artifacts()
else:
self.skipped += len(backends)
if self.source: