Commit 2d5b7027 authored by Johannes Bechberger's avatar Johannes Bechberger

Remove all dependencies and add run script

parent c04aa203
......@@ -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 `mjtest --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)
```
......
#!/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
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())
......
......@@ -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
......
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
......@@ -24,9 +24,5 @@ setup(name='mjtest',
entry_points='''
[console_scripts]
mjtest=mjtest.cli
''',
install_requires=[
'termcolor',
'rainbow_logging_handler'
]
'''
)
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