Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
ufebl
mjtest
Commits
06151285
Commit
06151285
authored
Nov 28, 2016
by
Johannes Bechberger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge `compile-firm` and `exec` folder
parent
a546fdae
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
10 deletions
+25
-10
mjtest/cli.py
mjtest/cli.py
+2
-0
mjtest/environment.py
mjtest/environment.py
+16
-4
mjtest/test/exec_tests.py
mjtest/test/exec_tests.py
+2
-2
mjtest/test/tests.py
mjtest/test/tests.py
+5
-4
No files found.
mjtest/cli.py
View file @
06151285
...
@@ -40,6 +40,8 @@ if True:#__name__ == '__main__':
...
@@ -40,6 +40,8 @@ if True:#__name__ == '__main__':
# help="Directory that contains all test cases, default is the 'tests' directory")
# help="Directory that contains all test cases, default is the 'tests' directory")
parser
.
add_argument
(
"--only_incorrect_tests"
,
action
=
"store_true"
,
default
=
False
,
parser
.
add_argument
(
"--only_incorrect_tests"
,
action
=
"store_true"
,
default
=
False
,
help
=
"Only run the tests that were incorrect the last run"
)
help
=
"Only run the tests that were incorrect the last run"
)
parser
.
add_argument
(
"--all_exec_tests"
,
action
=
"store_true"
,
default
=
False
,
help
=
"Run all exec (compile-firm...) tests, not only the small ones"
)
parser
.
add_argument
(
"--produce_no_reports"
,
action
=
"store_true"
,
default
=
False
,
parser
.
add_argument
(
"--produce_no_reports"
,
action
=
"store_true"
,
default
=
False
,
help
=
"Produce no long reports besides the command line output"
)
help
=
"Produce no long reports besides the command line output"
)
parser
.
add_argument
(
"--produce_all_reports"
,
action
=
"store_true"
,
default
=
False
,
parser
.
add_argument
(
"--produce_all_reports"
,
action
=
"store_true"
,
default
=
False
,
...
...
mjtest/environment.py
View file @
06151285
...
@@ -25,7 +25,7 @@ class TestMode:
...
@@ -25,7 +25,7 @@ class TestMode:
semantic
=
"semantic"
semantic
=
"semantic"
comile_firm
=
"compile-firm"
com
p
ile_firm
=
"compile-firm"
exec
=
"exec"
exec
=
"exec"
...
@@ -34,7 +34,17 @@ class TestMode:
...
@@ -34,7 +34,17 @@ class TestMode:
}
}
""" All 'success' tests of the n.th mode can used as 'success' tests for the n-1.th mode"""
""" All 'success' tests of the n.th mode can used as 'success' tests for the n-1.th mode"""
TEST_MODES
=
[
TestMode
.
lexer
,
TestMode
.
syntax
,
TestMode
.
ast
,
TestMode
.
semantic
,
TestMode
.
comile_firm
,
TestMode
.
exec
]
TEST_MODES
=
[
TestMode
.
lexer
,
TestMode
.
syntax
,
TestMode
.
ast
,
TestMode
.
semantic
,
TestMode
.
compile_firm
,
TestMode
.
exec
]
def
get_test_dirname
(
mode
:
str
)
->
str
:
d
=
{
TestMode
.
compile_firm
:
"exec"
}
if
mode
not
in
d
:
return
mode
return
d
[
mode
]
class
Environment
:
class
Environment
:
...
@@ -50,7 +60,8 @@ class Environment:
...
@@ -50,7 +60,8 @@ class Environment:
timeout
:
int
=
30
,
report_dir
:
str
=
""
,
log_level
:
str
=
"warn"
,
timeout
:
int
=
30
,
report_dir
:
str
=
""
,
log_level
:
str
=
"warn"
,
produce_no_reports
:
bool
=
True
,
output_no_incorrect_reports
:
bool
=
False
,
produce_no_reports
:
bool
=
True
,
output_no_incorrect_reports
:
bool
=
False
,
produce_all_reports
:
bool
=
False
,
report_subdir
:
str
=
None
,
produce_all_reports
:
bool
=
False
,
report_subdir
:
str
=
None
,
ci_testing
:
bool
=
False
,
color
:
bool
=
False
):
ci_testing
:
bool
=
False
,
color
:
bool
=
False
,
all_exec_tests
:
bool
=
True
):
if
color
:
if
color
:
force_colored_output
()
force_colored_output
()
self
.
mode
=
mode
self
.
mode
=
mode
...
@@ -97,6 +108,7 @@ class Environment:
...
@@ -97,6 +108,7 @@ class Environment:
self
.
_tmp_file_ctr
=
0
self
.
_tmp_file_ctr
=
0
self
.
_already_preprocessed_files
=
set
()
self
.
_already_preprocessed_files
=
set
()
self
.
_pid_tmpdirs
=
{}
# type: Dict[int, str]
self
.
_pid_tmpdirs
=
{}
# type: Dict[int, str]
self
.
only_small_exec_tests
=
not
all_exec_tests
def
create_tmpfile
(
self
)
->
str
:
def
create_tmpfile
(
self
)
->
str
:
self
.
_tmp_file_ctr
+=
1
self
.
_tmp_file_ctr
+=
1
...
@@ -130,7 +142,7 @@ class Environment:
...
@@ -130,7 +142,7 @@ class Environment:
TestMode
.
syntax
:
"--parsetest"
,
TestMode
.
syntax
:
"--parsetest"
,
TestMode
.
ast
:
"--print-ast"
,
TestMode
.
ast
:
"--print-ast"
,
TestMode
.
semantic
:
"--check"
,
TestMode
.
semantic
:
"--check"
,
TestMode
.
comile_firm
:
"--compile-firm"
TestMode
.
com
p
ile_firm
:
"--compile-firm"
}[
mode
]
}[
mode
]
cmd
=
[
self
.
mj_run_cmd
,
mode_flag
]
+
list
(
args
)
cmd
=
[
self
.
mj_run_cmd
,
mode_flag
]
+
list
(
args
)
return
execute
(
cmd
,
timeout
=
self
.
timeout
)
return
execute
(
cmd
,
timeout
=
self
.
timeout
)
...
...
mjtest/test/exec_tests.py
View file @
06151285
...
@@ -16,7 +16,7 @@ class JavaExecTest(BasicSyntaxTest):
...
@@ -16,7 +16,7 @@ class JavaExecTest(BasicSyntaxTest):
FILE_ENDINGS
=
[
".java"
]
FILE_ENDINGS
=
[
".java"
]
OUTPUT_FILE_ENDING
=
".out"
OUTPUT_FILE_ENDING
=
".out"
MODE
=
TestMode
.
comile_firm
MODE
=
TestMode
.
com
p
ile_firm
def
__init__
(
self
,
env
:
Environment
,
type
:
str
,
file
:
str
,
preprocessed_file
:
str
):
def
__init__
(
self
,
env
:
Environment
,
type
:
str
,
file
:
str
,
preprocessed_file
:
str
):
super
().
__init__
(
env
,
type
,
file
,
preprocessed_file
)
super
().
__init__
(
env
,
type
,
file
,
preprocessed_file
)
...
@@ -85,4 +85,4 @@ class JavaExecTest(BasicSyntaxTest):
...
@@ -85,4 +85,4 @@ class JavaExecTest(BasicSyntaxTest):
return
1
return
1
return
0
return
0
TestCase
.
TEST_CASE_CLASSES
[
TestMode
.
comile_firm
].
append
(
JavaExecTest
)
TestCase
.
TEST_CASE_CLASSES
[
TestMode
.
compile_firm
].
append
(
JavaExecTest
)
\ No newline at end of file
\ No newline at end of file
mjtest/test/tests.py
View file @
06151285
...
@@ -2,7 +2,7 @@ from collections import namedtuple
...
@@ -2,7 +2,7 @@ from collections import namedtuple
import
shutil
import
shutil
from
typing
import
Optional
,
List
,
Tuple
,
T
,
Union
,
Dict
from
typing
import
Optional
,
List
,
Tuple
,
T
,
Union
,
Dict
import
collections
import
collections
from
mjtest.environment
import
Environment
,
TestMode
,
TEST_MODES
from
mjtest.environment
import
Environment
,
TestMode
,
TEST_MODES
,
get_test_dirname
from
os.path
import
join
,
exists
,
basename
from
os.path
import
join
,
exists
,
basename
import
logging
import
logging
import
os
import
os
...
@@ -39,9 +39,10 @@ class TestSuite:
...
@@ -39,9 +39,10 @@ class TestSuite:
for
type
in
types
:
for
type
in
types
:
self
.
_load_test_case_type
(
type
)
self
.
_load_test_case_type
(
type
)
def
_load_test_case_type
(
self
,
type
:
str
):
def
_load_test_case_type
(
self
,
type
:
str
):
dir
=
join
(
self
.
env
.
test_dir
,
type
)
dir
=
join
(
self
.
env
.
test_dir
,
get_test_dirname
(
type
))
if
get_test_dirname
(
type
)
==
"exec"
and
self
.
env
.
only_small_exec_tests
:
dir
=
join
(
dir
,
"small"
)
if
exists
(
dir
):
if
exists
(
dir
):
self
.
_load_test_case_dir
(
type
,
dir
)
self
.
_load_test_case_dir
(
type
,
dir
)
else
:
else
:
...
@@ -95,7 +96,7 @@ class TestSuite:
...
@@ -95,7 +96,7 @@ class TestSuite:
del
self
.
test_cases
[
m
]
del
self
.
test_cases
[
m
]
def
_log_file_for_type
(
self
,
type
:
str
):
def
_log_file_for_type
(
self
,
type
:
str
):
return
join
(
self
.
env
.
test_dir
,
type
,
".mjtest_correct_testcases_"
+
self
.
env
.
mode
)
return
join
(
self
.
env
.
test_dir
,
get_test_dirname
(
type
)
,
".mjtest_correct_testcases_"
+
self
.
env
.
mode
)
def
_add_correct_test_case
(
self
,
test_case
:
'TestCase'
):
def
_add_correct_test_case
(
self
,
test_case
:
'TestCase'
):
self
.
correct_test_cases
[
test_case
.
type
].
add
(
basename
(
test_case
.
file
))
self
.
correct_test_cases
[
test_case
.
type
].
add
(
basename
(
test_case
.
file
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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