Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
badw-it
DHParser
Commits
8473cf32
Commit
8473cf32
authored
Aug 17, 2018
by
di68kap
Browse files
- fixed error in dhparser.py script
parent
0133d6c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
DHParser/testing.py
View file @
8473cf32
...
...
@@ -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
):
...
...
dhparser.py
View file @
8473cf32
...
...
@@ -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'
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment