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 ...@@ -45,20 +45,19 @@ Test runner
### Requirements ### Requirements
The following programs are required (and executable by simply calling their names). The following programs are required (and executable by simply calling their names).
- `python3` (at least Python3.3) - `python3` (at least Python3.3)
- `javac` and `java` - `javac` and `java` (for `.java` test cases)
### Installation ### Installation
Just clone `mjtest` and install it via `pip3`. Just clone this repository and you're done:
```sh ```sh
git clone https://github.com/mj3-16/mjtest git clone https://github.com/mj3-16/mjtest
cd mjtest cd mjtest
sudo pip3 -e install .
``` ```
### Usage ### Usage
Output of the `mjtest --help` Output of the `./mjt.py --help`
``` ```
usage: mjtest [-h] [--tmp_dir] [--test_dir] [--only_incorrect_tests] usage: mjtest [-h] [--tmp_dir] [--test_dir] [--only_incorrect_tests]
...@@ -76,15 +75,9 @@ positional arguments: ...@@ -76,15 +75,9 @@ positional arguments:
optional arguments: optional arguments:
-h, --help show this help message and exit -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_incorrect_tests
Only run the tests that were incorrect the last run Only run the tests that were incorrect the last run
--parallel Run the tests in parallel --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) --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 logging
import os import os
from pprint import pprint
import sys import sys
from os.path import dirname
sys.path.append(dirname(__file__))
import util.utils
import argparse import argparse
from environment import TestMode, Environment, TEST_MODES from mjtest.environment import TestMode, Environment, TEST_MODES
from mjtest.test.tests import TestSuite from mjtest.test.tests import TestSuite
# adapted from http://stackoverflow.com/a/8527629 # adapted from http://stackoverflow.com/a/8527629
...@@ -34,18 +30,18 @@ if True:#__name__ == '__main__': ...@@ -34,18 +30,18 @@ if True:#__name__ == '__main__':
metavar="MJ_RUN", metavar="MJ_RUN",
help="Command to run your MiniJava implementation, e.g. `mj/run`, " help="Command to run your MiniJava implementation, e.g. `mj/run`, "
"can be omitted by assigning the environment variable MJ_RUN") "can be omitted by assigning the environment variable MJ_RUN")
parser.add_argument("--tmp_dir", action="store_const", default="", const="tmp_dir", #parser.add_argument("--tmp_dir", action="store_const", default="", const="tmp_dir",
help="Used temporary directory") # help="Used temporary directory")
parser.add_argument("--test_dir", action="store_const", default="", const="test_dir", #parser.add_argument("--test_dir", action="store_const", default="", const="test_dir",
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("--parallel", action="store_true", default=False, parser.add_argument("--parallel", action="store_true", default=False,
help="Run the tests in parallel") help="Run the tests in parallel")
parser.add_argument("--timeout", action="store_const", default=30, const="timeout", #parser.add_argument("--timeout", action="store_const", default=30, const="timeout",
help="Abort a program after TIMEOUT seconds") # help="Abort a program after TIMEOUT seconds")
parser.add_argument("--report_dir", action="store_const", default="", const="report_dir", #parser.add_argument("--report_dir", action="store_const", default="", const="report_dir",
help="Directory to store the reports in, default is 'reports'") # help="Directory to store the reports in, default is 'reports'")
parser.add_argument("--log_level", action=LogLevelChoices, default="warn", const="log_level", parser.add_argument("--log_level", action=LogLevelChoices, default="warn", const="log_level",
help="Logging level (error, warn, info or debug)") help="Logging level (error, warn, info or debug)")
args = vars(parser.parse_args()) args = vars(parser.parse_args())
......
...@@ -7,7 +7,7 @@ import logging ...@@ -7,7 +7,7 @@ import logging
import os import os
import multiprocessing import multiprocessing
from mjtest.util.parallelism import available_cpu_count from mjtest.util.parallelism import available_cpu_count
from termcolor import cprint, colored from mjtest.util.utils import cprint, colored
from pprint import pprint from pprint import pprint
import shutil import shutil
......
import logging import logging
from os import path from os import path
from rainbow_logging_handler import RainbowLoggingHandler
import sys import sys
def get_mjtest_basedir() -> str: def get_mjtest_basedir() -> str:
return path.dirname(path.dirname(path.dirname(path.realpath(__file__)))) return path.dirname(path.dirname(path.dirname(path.realpath(__file__))))
""" Colored logging handler that is used for the root logger """ def colored(text: str, *args, **kwargs):
handler = RainbowLoggingHandler(sys.stderr, color_funcName=('black', 'yellow', True)) """
handler.setFormatter(logging.Formatter("[%(asctime)s] %(message)s")) Wrapper around termcolor.colored (if it's loadable)
logging.getLogger().addHandler(handler) """
\ No newline at end of file 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', ...@@ -24,9 +24,5 @@ setup(name='mjtest',
entry_points=''' entry_points='''
[console_scripts] [console_scripts]
mjtest=mjtest.cli 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