Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 8c25efce authored by Eckhart Arnold's avatar Eckhart Arnold
Browse files

further LaTeX-tests

parent 7803dedb
......@@ -731,11 +731,12 @@ class Grammar:
def write_log(history, log_name):
path = os.path.join(log_dir(), log_name + "_parser.log")
if os.path.exists(path):
os.remove(path)
print('WARNING: Log-file "%s" already existed and was deleted.' % path)
if history:
with open(path, "w", encoding="utf-8") as f:
f.write("\n".join(history))
elif os.path.exists(path):
os.remove(path)
if is_logging():
assert self.history__, \
......
......@@ -497,11 +497,13 @@ class Node:
def log(self, log_file_name):
if is_logging():
with open(os.path.join(log_dir(), log_file_name), "w", encoding="utf-8") as f:
path = os.path.join(log_dir(), log_file_name)
if os.path.exists(path):
print('WARNING: Log-file "%s" already exists and will be overwritten!' % path)
with open(path, "w", encoding="utf-8") as f:
f.write(self.as_sxpr())
def mock_syntax_tree(sxpr):
"""
Generates a tree of nodes from an S-expression.
......
......@@ -26,7 +26,7 @@ try:
except ImportError:
import re
from DHParser import error_messages
from DHParser.toolkit import is_logging, clear_logs, error_messages
from DHParser.syntaxtree import mock_syntax_tree, flatten_sxpr
__all__ = ('unit_from_configfile',
......@@ -149,13 +149,13 @@ def grammar_unit(test_unit, parser_factory, transformer_factory, report=True, ve
infostr = ' match-test "' + test_name + '" ... '
errflag = len(errata)
cst = parser(test_code, parser_name)
cst.log("%s_match_%s_%s.cst" % (unit_name, parser_name, test_name))
cst.log("match_%s_%s.cst" % (parser_name, test_name))
tests.setdefault('__cst__', {})[test_name] = cst
if "ast" in tests or report:
ast = copy.deepcopy(cst)
transform(ast)
tests.setdefault('__ast__', {})[test_name] = ast
ast.log("%s_match_%s_%s.ast" % (unit_name, parser_name, test_name))
ast.log("match_%s_%s.ast" % (parser_name, test_name))
if cst.error_flag:
errata.append('Match test "%s" for parser "%s" failed:\n\tExpr.: %s\n\n\t%s\n\n' %
(test_name, parser_name, '\n\t'.join(test_code.split('\n')),
......@@ -217,6 +217,7 @@ def grammar_suite(directory, parser_factory, transformer_factory, ignore_unknown
print("\nScanning test-directory: " + directory)
save_cwd = os.getcwd()
os.chdir(directory)
if is_logging(): clear_logs()
for filename in sorted(os.listdir()):
if filename.lower().find("test") >= 0:
try:
......
......@@ -133,6 +133,23 @@ def is_logging() -> bool:
return False
def clear_logs(logfile_types={'.cst', '.ast', '.log'}):
"""Removes all logs from the log-directory and removes the
log-directory if it is empty.
"""
log_dirname = log_dir()
files = os.listdir(log_dirname)
only_log_files = True
for file in files:
path = os.path.join(log_dirname, file)
if os.path.splitext(file)[1] in logfile_types or file == 'info.txt':
os.remove(path)
else:
only_log_files = False
if only_log_files:
os.rmdir(log_dirname)
# def repr_call(f, parameter_list) -> str:
# """Turns a list of items into a string resembling the parameter
# list of a function call by omitting default values at the end:
......
......@@ -6,7 +6,7 @@
latexdoc = preamble document
preamble = { command }+
preamble = { [WSPC] command }+
document = [WSPC] "\begin{document}" [WSPC]
frontpages [WSPC]
......@@ -23,16 +23,16 @@ frontpages = sequence
#######################################################################
Chapters = { Chapter [WSPC] }+
Chapter = "\Chapter" block [WSPC] { sequence | Sections }
Chapter = "\chapter" block [WSPC] { sequence | Sections }
Sections = { Section [WSPC] }+
Section = "\Section" block [WSPC] { sequence | SubSections }
Section = "\section" block [WSPC] { sequence | SubSections }
SubSections = { SubSection [WSPC] }+
SubSection = "\SubSection" block [WSPC] { sequence | SubSubSections }
SubSection = "\subsection" block [WSPC] { sequence | SubSubSections }
SubSubSections = { SubSubSection [WSPC] }+
SubSubSection = "\SubSubSection" block [WSPC] { sequence | Paragraphs }
SubSubSection = "\subsubsection" block [WSPC] { sequence | Paragraphs }
Paragraphs = { Paragraph [WSPC] }+
Paragraph = "\paragraph" block [WSPC] { sequence | SubParagraphs }
......
......@@ -72,16 +72,16 @@ class LaTeXGrammar(Grammar):
#######################################################################
Chapters = { Chapter [WSPC] }+
Chapter = "\Chapter" block [WSPC] { sequence | Sections }
Chapter = "\chapter" block [WSPC] { sequence | Sections }
Sections = { Section [WSPC] }+
Section = "\Section" block [WSPC] { sequence | SubSections }
Section = "\section" block [WSPC] { sequence | SubSections }
SubSections = { SubSection [WSPC] }+
SubSection = "\SubSection" block [WSPC] { sequence | SubSubSections }
SubSection = "\subsection" block [WSPC] { sequence | SubSubSections }
SubSubSections = { SubSubSection [WSPC] }+
SubSubSection = "\SubSubSection" block [WSPC] { sequence | Paragraphs }
SubSubSection = "\subsubsection" block [WSPC] { sequence | Paragraphs }
Paragraphs = { Paragraph [WSPC] }+
Paragraph = "\paragraph" block [WSPC] { sequence | SubParagraphs }
......@@ -210,7 +210,7 @@ class LaTeXGrammar(Grammar):
end_generic_block = Forward()
paragraph = Forward()
text_element = Forward()
source_hash__ = "529c853d5829c3016605e4ee7ed69ddb"
source_hash__ = "c77c91d639f2898ac2a58e1bfdf7e608"
parser_initialization__ = "upon instantiation"
COMMENT__ = r'%.*(?:\n|$)'
WSP__ = mixin_comment(whitespace=r'[ \t]*(?:\n(?![ \t]*\n)[ \t]*)?', comment=r'%.*(?:\n|$)')
......@@ -274,13 +274,13 @@ class LaTeXGrammar(Grammar):
SubParagraphs = OneOrMore(Series(SubParagraph, Optional(WSPC)))
Paragraph = Series(Token("\\paragraph"), block, Optional(WSPC), ZeroOrMore(Alternative(sequence, SubParagraphs)))
Paragraphs = OneOrMore(Series(Paragraph, Optional(WSPC)))
SubSubSection = Series(Token("\\SubSubSection"), block, Optional(WSPC), ZeroOrMore(Alternative(sequence, Paragraphs)))
SubSubSection = Series(Token("\\subsubsection"), block, Optional(WSPC), ZeroOrMore(Alternative(sequence, Paragraphs)))
SubSubSections = OneOrMore(Series(SubSubSection, Optional(WSPC)))
SubSection = Series(Token("\\SubSection"), block, Optional(WSPC), ZeroOrMore(Alternative(sequence, SubSubSections)))
SubSection = Series(Token("\\subsection"), block, Optional(WSPC), ZeroOrMore(Alternative(sequence, SubSubSections)))
SubSections = OneOrMore(Series(SubSection, Optional(WSPC)))
Section = Series(Token("\\Section"), block, Optional(WSPC), ZeroOrMore(Alternative(sequence, SubSections)))
Section = Series(Token("\\section"), block, Optional(WSPC), ZeroOrMore(Alternative(sequence, SubSections)))
Sections = OneOrMore(Series(Section, Optional(WSPC)))
Chapter = Series(Token("\\Chapter"), block, Optional(WSPC), ZeroOrMore(Alternative(sequence, Sections)))
Chapter = Series(Token("\\chapter"), block, Optional(WSPC), ZeroOrMore(Alternative(sequence, Sections)))
Chapters = OneOrMore(Series(Chapter, Optional(WSPC)))
frontpages = Synonym(sequence)
document = Series(Optional(WSPC), Token("\\begin{document}"), Optional(WSPC), frontpages, Optional(WSPC), Alternative(Chapters, Sections), Optional(WSPC), Optional(Bibliography), Optional(Index), Optional(WSPC), Token("\\end{document}"), Optional(WSPC), Required(EOF))
......
......@@ -31,6 +31,13 @@
and \textbackslash text-commands or other commands like this
\footnote{footnote}
10: """\begin{generic}inline environment\end{generic}
"""
11: """\begin{generic}inline environment
\end{generic}
"""
[fail:paragraph]
1 : \begin{enumerate}
......
......@@ -47,14 +47,6 @@
invalid enivronment \end{generic}
"""
[match:paragraph]
1 : """\begin{generic}inline environment\end{generic}
"""
2 : """\begin{generic}inline environment
\end{generic}
"""
[match:itemize]
1 : \begin{itemize}
\item Items doe not need to be
......
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