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
ed1dd638
Commit
ed1dd638
authored
Mar 27, 2019
by
di68kap
Browse files
- json: tst-script
parent
59844e1a
Changes
8
Hide whitespace changes
Inline
Side-by-side
DHParser/testing.py
View file @
ed1dd638
...
...
@@ -540,6 +540,7 @@ def grammar_suite(directory, parser_factory, transformer_factory,
with
concurrent
.
futures
.
ProcessPoolExecutor
(
multiprocessing
.
cpu_count
())
as
pool
:
results
=
[]
for
filename
in
sorted
(
os
.
listdir
(
'.'
)):
print
(
filename
)
if
any
(
fnmatch
.
fnmatch
(
filename
,
pattern
)
for
pattern
in
fn_patterns
):
parameters
=
filename
,
parser_factory
,
transformer_factory
,
report
,
verbose
results
.
append
((
filename
,
pool
.
submit
(
run_unit
,
log_dir
(),
*
parameters
)))
...
...
examples/ArithmeticSimple/ArithmeticRightRecursiveCompiler.py
View file @
ed1dd638
...
...
@@ -12,7 +12,7 @@ from functools import partial
import
os
import
sys
sys
.
path
.
app
end
(
r
'/home/eckhart/Entwicklung/DHParser'
)
sys
.
path
.
ext
end
(
[
'../../'
,
'../'
,
'./'
]
)
try
:
import
regex
as
re
...
...
examples/Tutorial/LyrikCompiler.py
View file @
ed1dd638
...
...
@@ -11,10 +11,8 @@ import collections
from
functools
import
partial
import
os
import
sys
sys
.
path
.
extend
([
'../../'
,
'../'
,
'./'
])
sys
.
path
.
app
end
(
r
'/home/eckhart/Entwicklung/DHParser'
)
sys
.
path
.
ext
end
(
[
'../../'
,
'../'
,
'./'
]
)
try
:
import
regex
as
re
...
...
examples/Tutorial/Lyrik_explicit_whitespaceCompiler.py
View file @
ed1dd638
...
...
@@ -12,7 +12,7 @@ from functools import partial
import
os
import
sys
sys
.
path
.
app
end
(
r
'/home/eckhart/Entwicklung/DHParser'
)
sys
.
path
.
ext
end
(
[
'../../'
,
'../'
,
'./'
]
)
try
:
import
regex
as
re
...
...
examples/XML/XMLCompiler.py
View file @
ed1dd638
...
...
@@ -12,7 +12,6 @@ from functools import partial
import
os
import
sys
sys
.
path
.
extend
([
'../'
,
'../../'
])
try
:
...
...
examples/json/jsonCompiler.py
View file @
ed1dd638
...
...
@@ -12,7 +12,7 @@ from functools import partial
import
os
import
sys
sys
.
path
.
app
end
(
r
'/home/eckhart/Entwicklung/DHParser'
)
sys
.
path
.
ext
end
(
[
'../../'
,
'../'
,
'./'
]
)
try
:
import
regex
as
re
...
...
examples/json/tst_json_grammar.py
View file @
ed1dd638
...
...
@@ -8,15 +8,15 @@ import sys
LOGGING
=
False
sys
.
path
.
app
end
(
r
'/home/eckhart/Entwicklung/DHParser'
)
sys
.
path
.
ext
end
(
[
'.'
,
'../..'
]
)
scriptpath
=
os
.
path
.
dirname
(
__file__
)
try
:
from
DHParser
import
dsl
import
DHParser.log
from
DHParser
import
testing
from
DHParser.toolkit
import
set_config_value
except
ModuleNotFoundError
:
print
(
'Could not import DHParser. Please adjust sys.path in file '
'"%s" manually'
%
__file__
)
...
...
@@ -37,7 +37,7 @@ def recompile_grammar(grammar_src, force):
sys
.
exit
(
1
)
def
run_grammar_tests
(
glob_pattern
):
def
run_grammar_tests
(
glob_pattern
,
get_grammar
,
get_transformer
):
with
DHParser
.
log
.
logging
(
LOGGING
):
error_report
=
testing
.
grammar_suite
(
os
.
path
.
join
(
scriptpath
,
'grammar_tests'
),
...
...
@@ -66,7 +66,8 @@ if __name__ == '__main__':
force
=
False
)
sys
.
path
.
append
(
'.'
)
from
jsonCompiler
import
get_grammar
,
get_transformer
error_report
=
run_grammar_tests
(
glob_pattern
=
arg
)
# set_config_value('test_parallelization', False)
error_report
=
run_grammar_tests
(
arg
,
get_grammar
,
get_transformer
)
if
error_report
:
print
(
'
\n
'
)
print
(
error_report
)
...
...
scripts/dhparser.py
View file @
ed1dd638
...
...
@@ -155,7 +155,7 @@ def recompile_grammar(grammar_src, force):
sys.exit(1)
def run_grammar_tests(glob_pattern):
def run_grammar_tests(glob_pattern
, get_grammar, get_transformer
):
with DHParser.log.logging(LOGGING):
error_report = testing.grammar_suite(
os.path.join(scriptpath, 'grammar_tests'),
...
...
@@ -184,7 +184,7 @@ if __name__ == '__main__':
force=False)
sys.path.append('.')
from {name}Compiler import get_grammar, get_transformer
error_report = run_grammar_tests(
glob_pattern=arg
)
error_report = run_grammar_tests(
arg, get_grammar, get_transformer
)
if error_report:
print('\n')
print(error_report)
...
...
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