2.12.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 8473cf32 authored by di68kap's avatar di68kap
Browse files

- fixed error in dhparser.py script

parent 0133d6c9
......@@ -215,12 +215,12 @@ def unit_from_file(filename):
return test_unit
def all_match_tests(tests):
"""Returns all match tests from ``tests``, This includes match tests
marked with an asterix for CST-output as well as unmarked match-tests.
"""
return itertools.chain(tests.get('match', dict()).items(),
tests.get('match*', dict()).items())
# def all_match_tests(tests):
# """Returns all match tests from ``tests``, This includes match tests
# marked with an asterix for CST-output as well as unmarked match-tests.
# """
# return itertools.chain(tests.get('match', dict()).items(),
# tests.get('match*', dict()).items())
def get_report(test_unit):
......
......@@ -119,6 +119,8 @@ GRAMMAR_TEST_TEMPLATE = r'''#!/usr/bin/python3
import os
import sys
LOGGING = False
sys.path.append(r'{dhparserdir}')
scriptpath = os.path.dirname(__file__)
......@@ -135,7 +137,7 @@ except ModuleNotFoundError:
def recompile_grammar(grammar_src, force):
with DHParser.log.logging(False):
with DHParser.log.logging(LOGGING):
# recompiles Grammar only if it has changed
if not dsl.recompile_grammar(grammar_src, force=force):
print('\nErrors while recompiling "%s":' % grammar_src +
......@@ -146,7 +148,7 @@ def recompile_grammar(grammar_src, force):
def run_grammar_tests(glob_pattern):
with DHParser.log.logging(False):
with DHParser.log.logging(LOGGING):
error_report = testing.grammar_suite(
os.path.join(scriptpath, 'grammar_tests'),
get_grammar, get_transformer,
......@@ -155,11 +157,15 @@ def run_grammar_tests(glob_pattern):
if __name__ == '__main__':
if (len(sys.argv) == 2 and (arg.endswith('.ebnf') or (os.path.isfile(sys.argv[1]) and
os.path.splitext(sys.argv[1])[1].lower() in testing.TEST_READERS.keys()))):
argv = sys.argv[:]
if len(argv) > 1 and sys.argv[1] == "--debug":
LOGGING = True
del argv[1]
if (len(argv) >= 2 and (argv[1].endswith('.ebnf') or
os.path.splitext(argv[1])[1].lower() in testing.TEST_READERS.keys())):
# if called with a single filename that is either an EBNF file or a known
# test file type then use the given argument
arg = sys.argv[1]
arg = argv[1]
else:
# otherwise run all tests in the test directory
arg = '*_test_*.ini'
......
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