Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
IPDSnelting
mjtest
Commits
2d5b7027
Commit
2d5b7027
authored
Oct 30, 2016
by
Johannes Bechberger
Browse files
Remove all dependencies and add run script
parent
c04aa203
Changes
6
Hide whitespace changes
Inline
Side-by-side
README.mdwn
View file @
2d5b7027
...
...
@@ -45,20 +45,19 @@ Test runner
### Requirements
The following programs are required (and executable by simply calling their names).
- `python3` (at least Python3.3)
- `javac` and `java`
- `javac` and `java`
(for `.java` test cases)
### Installation
Just clone
`mjtest` and install it via `pip3`.
Just clone
this repository and you're done:
```sh
git clone https://github.com/mj3-16/mjtest
cd mjtest
sudo pip3 -e install .
```
### Usage
Output of the `mjt
est
--help`
Output of the `
./
mjt
.py
--help`
```
usage: mjtest [-h] [--tmp_dir] [--test_dir] [--only_incorrect_tests]
...
...
@@ -76,15 +75,9 @@ positional arguments:
optional arguments:
-h, --help show this help message and exit
--tmp_dir Used temporary directory
--test_dir Directory that contains all test cases, default is the
'tests' directory
--only_incorrect_tests
Only run the tests that were incorrect the last run
--parallel Run the tests in parallel
--timeout Abort a program after TIMEOUT seconds
--report_dir Directory to store the reports in, default is
'reports'
--log LOG Logging level (error, warn, info or debug)
```
...
...
mjt.py
0 → 100755
View file @
2d5b7027
#!/usr/bin/python3
import
sys
from
os.path
import
dirname
,
realpath
p
=
dirname
(
realpath
(
__file__
))
sys
.
path
.
append
(
p
)
import
mjtest.cli
\ No newline at end of file
mjtest/cli.py
View file @
2d5b7027
import
logging
import
os
from
pprint
import
pprint
import
sys
from
os.path
import
dirname
sys
.
path
.
append
(
dirname
(
__file__
))
import
util.utils
import
argparse
from
environment
import
TestMode
,
Environment
,
TEST_MODES
from
mjtest.
environment
import
TestMode
,
Environment
,
TEST_MODES
from
mjtest.test.tests
import
TestSuite
# adapted from http://stackoverflow.com/a/8527629
...
...
@@ -34,18 +30,18 @@ if True:#__name__ == '__main__':
metavar
=
"MJ_RUN"
,
help
=
"Command to run your MiniJava implementation, e.g. `mj/run`, "
"can be omitted by assigning the environment variable MJ_RUN"
)
parser
.
add_argument
(
"--tmp_dir"
,
action
=
"store_const"
,
default
=
""
,
const
=
"tmp_dir"
,
help
=
"Used temporary directory"
)
parser
.
add_argument
(
"--test_dir"
,
action
=
"store_const"
,
default
=
""
,
const
=
"test_dir"
,
help
=
"Directory that contains all test cases, default is the 'tests' directory"
)
#
parser.add_argument("--tmp_dir", action="store_const", default="", const="tmp_dir",
#
help="Used temporary directory")
#
parser.add_argument("--test_dir", action="store_const", default="", const="test_dir",
#
help="Directory that contains all test cases, default is the 'tests' directory")
parser
.
add_argument
(
"--only_incorrect_tests"
,
action
=
"store_true"
,
default
=
False
,
help
=
"Only run the tests that were incorrect the last run"
)
parser
.
add_argument
(
"--parallel"
,
action
=
"store_true"
,
default
=
False
,
help
=
"Run the tests in parallel"
)
parser
.
add_argument
(
"--timeout"
,
action
=
"store_const"
,
default
=
30
,
const
=
"timeout"
,
help
=
"Abort a program after TIMEOUT seconds"
)
parser
.
add_argument
(
"--report_dir"
,
action
=
"store_const"
,
default
=
""
,
const
=
"report_dir"
,
help
=
"Directory to store the reports in, default is 'reports'"
)
#
parser.add_argument("--timeout", action="store_const", default=30, const="timeout",
#
help="Abort a program after TIMEOUT seconds")
#
parser.add_argument("--report_dir", action="store_const", default="", const="report_dir",
#
help="Directory to store the reports in, default is 'reports'")
parser
.
add_argument
(
"--log_level"
,
action
=
LogLevelChoices
,
default
=
"warn"
,
const
=
"log_level"
,
help
=
"Logging level (error, warn, info or debug)"
)
args
=
vars
(
parser
.
parse_args
())
...
...
mjtest/test/tests.py
View file @
2d5b7027
...
...
@@ -7,7 +7,7 @@ import logging
import
os
import
multiprocessing
from
mjtest.util.parallelism
import
available_cpu_count
from
termcolor
import
cprint
,
colored
from
mjtest.util.utils
import
cprint
,
colored
from
pprint
import
pprint
import
shutil
...
...
mjtest/util/utils.py
View file @
2d5b7027
import
logging
from
os
import
path
from
rainbow_logging_handler
import
RainbowLoggingHandler
import
sys
def
get_mjtest_basedir
()
->
str
:
return
path
.
dirname
(
path
.
dirname
(
path
.
dirname
(
path
.
realpath
(
__file__
))))
""" Colored logging handler that is used for the root logger """
handler
=
RainbowLoggingHandler
(
sys
.
stderr
,
color_funcName
=
(
'black'
,
'yellow'
,
True
))
handler
.
setFormatter
(
logging
.
Formatter
(
"[%(asctime)s] %(message)s"
))
logging
.
getLogger
().
addHandler
(
handler
)
\ No newline at end of file
def
colored
(
text
:
str
,
*
args
,
**
kwargs
):
"""
Wrapper around termcolor.colored (if it's loadable)
"""
try
:
from
termcolor
import
colored
return
colored
(
text
,
*
args
,
**
kwargs
)
except
ImportError
:
return
text
def
cprint
(
text
:
str
,
*
args
,
**
kwargs
):
"""
Wrapper around termcolor.cprint (if it's loadable)
"""
try
:
from
termcolor
import
cprint
cprint
(
text
,
*
args
,
**
kwargs
)
except
ImportError
:
print
(
text
)
\ No newline at end of file
setup.py
View file @
2d5b7027
...
...
@@ -24,9 +24,5 @@ setup(name='mjtest',
entry_points
=
'''
[console_scripts]
mjtest=mjtest.cli
'''
,
install_requires
=
[
'termcolor'
,
'rainbow_logging_handler'
]
'''
)
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