From d293be0b37be09ebeebd01a68b37bc16d4d30884 Mon Sep 17 00:00:00 2001 From: Evan New-Schmidt Date: Wed, 18 Sep 2019 23:47:02 -0400 Subject: [PATCH 1/4] Point people towards released versions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d49c95a..4f53f39 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ this by cloning the source repository to somewhere on your machine and running `pip install`: ```shell -git clone https://github.com/olin/focstest.git +git clone --branch=release https://github.com/olin/focstest.git # clone a stable version pip install focstest/ ``` From 996a94dd2f2d747e66f6dbe55077e2bbc7917a94 Mon Sep 17 00:00:00 2001 From: Evan New-Schmidt Date: Fri, 27 Sep 2019 16:37:44 -0400 Subject: [PATCH 2/4] Move logging level to env var --- README.md | 9 +++++++-- focstest.py | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4f53f39..242ef91 100644 --- a/README.md +++ b/README.md @@ -138,8 +138,6 @@ optional arguments: -h, --help show this help message and exit -u URL, --url URL a url to scrape tests from -v, --verbose increase test output verbosity - --log-level {debug,info,warning} - the program log level -uc, --update-cache update cached files -U [N [N ...]], --use-suites [N [N ...]] test suites to use exclusively, indexed from 1 @@ -181,3 +179,10 @@ Run `pipenv install --dev` to install all of the dev packages. Run tests with `python -m unittest discover`. Want to use it while you hack on it? Install it with `pip install -e`. + +You can set `focstest`'s logging level with the `LOG_LEVEL` environment variable. +The possible values are all of python's usual logging levels, set it to `DEBUG` +for more output. +```shell +$ LOG_LEVEL=DEBUG focstest homework3.ml +``` diff --git a/focstest.py b/focstest.py index ec5e150..3c7353b 100755 --- a/focstest.py +++ b/focstest.py @@ -204,8 +204,6 @@ def main(): help='the ocaml file to test against') parser.add_argument('-v', '--verbose', action='store_true', help='increase test output verbosity') - parser.add_argument('--log-level', choices=['debug', 'info', 'warning'], - help='the program log level') parser.add_argument('-uc', '--update-cache', action='store_true', help='update cached files') test_selection = parser.add_mutually_exclusive_group(required=False) @@ -214,9 +212,18 @@ def main(): test_selection.add_argument('-S', '--skip-suites', metavar='N', type=int, nargs='*', help='test suites to skip, indexed from 1') args = parser.parse_args() - if args.log_level: - numeric_level = getattr(logging, args.log_level.upper(), None) - logger.setLevel(numeric_level) + + # check environment var for logging level + log_level = os.getenv('LOG_LEVEL') + if log_level is not None: + log_level = log_level.upper() + try: + numeric_level = getattr(logging, os.getenv('LOG_LEVEL')) + except AttributeError as e: + logging.warning("Found 'LOG_LEVEL' env var, but was unable to parse: {}".format(e)) + else: + logger.setLevel(numeric_level) + logger.debug('Set logging level to {!r} ({}) from env var'.format(log_level, numeric_level)) URL = args.url FILE = getattr(args, 'ocaml-file') From 25b19f117068c955a59bbfc53b5811d1796e5a1e Mon Sep 17 00:00:00 2001 From: Evan New-Schmidt Date: Fri, 27 Sep 2019 16:41:28 -0400 Subject: [PATCH 3/4] Deprecate `-u` for `--url` in favor of test selection --- focstest.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/focstest.py b/focstest.py index 3c7353b..7d0259b 100755 --- a/focstest.py +++ b/focstest.py @@ -196,10 +196,8 @@ def main(): epilog='Submit bugs to .') parser.add_argument('--version', action='version', version=__version__) input_types = parser.add_mutually_exclusive_group(required=False) - input_types.add_argument('-u', '--url', type=str, - help='a url to scrape tests from (usually automagically guessed based on ocaml-file)') - # input_types.add_argument('-f', '--file', type=str, - # help='a file to load tests from') + input_types.add_argument('--url', type=str, + help='a url to scrape tests from (usually automagically guessed from ocaml-file)') parser.add_argument('ocaml-file', type=str, help='the ocaml file to test against') parser.add_argument('-v', '--verbose', action='store_true', @@ -207,9 +205,9 @@ def main(): parser.add_argument('-uc', '--update-cache', action='store_true', help='update cached files') test_selection = parser.add_mutually_exclusive_group(required=False) - test_selection.add_argument('-U', '--use-suites', metavar='N', type=int, nargs='*', + test_selection.add_argument('-u', '--use-suites', metavar='N', type=int, nargs='*', help='test suites to use exclusively, indexed from 1') - test_selection.add_argument('-S', '--skip-suites', metavar='N', type=int, nargs='*', + test_selection.add_argument('-s', '--skip-suites', metavar='N', type=int, nargs='*', help='test suites to skip, indexed from 1') args = parser.parse_args() From fc9b2e5cb771bda0b1c107b8b3edc62562b360ef Mon Sep 17 00:00:00 2001 From: Evan New-Schmidt Date: Fri, 27 Sep 2019 16:45:42 -0400 Subject: [PATCH 4/4] Update cli documentation --- README.md | 19 +++++++++++-------- focstest.py | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 242ef91..5a6ea31 100644 --- a/README.md +++ b/README.md @@ -119,15 +119,14 @@ refresh `focstest`'s copy, use the `--update-cache` flag: focstest homework2.ml --update-cache ``` - `focstest` uses a standard python-powered command-line interface. You can always ask it for help with `--help` or `-h`. -``` +```shell $ focstest --help -usage: focstest [-h] [-u URL] [-v] [--log-level {debug,info,warning}] [-uc] - [-U [N [N ...]] | -S [N [N ...]]] - ocaml-file +usage: focstest [-h] [--version] [--url URL] [-v] [-uc] [-u [N [N ...]] | -s + [N [N ...]]] + ocaml-file Run ocaml "doctests". @@ -136,13 +135,17 @@ positional arguments: optional arguments: -h, --help show this help message and exit - -u URL, --url URL a url to scrape tests from + --version show program's version number and exit + --url URL a url to scrape tests from (usually automagically + guessed from ocaml-file) -v, --verbose increase test output verbosity -uc, --update-cache update cached files - -U [N [N ...]], --use-suites [N [N ...]] + -u [N [N ...]], --use-suites [N [N ...]] test suites to use exclusively, indexed from 1 - -S [N [N ...]], --skip-suites [N [N ...]] + -s [N [N ...]], --skip-suites [N [N ...]] test suites to skip, indexed from 1 + +Submit bugs to . ``` For most homeworks, the workflow that I've used is going question by question diff --git a/focstest.py b/focstest.py index 7d0259b..eaed45d 100755 --- a/focstest.py +++ b/focstest.py @@ -229,7 +229,7 @@ def main(): if not args.url: url_guess = infer_url(FILE) if not url_guess: # break if filename can't be matched - logger.critical('Could not infer url from filename {!r}. Try passing a url manually with the `-u`/`--url` flag.'.format(FILE)) + logger.critical('Could not infer url from filename {!r}. Try passing a url manually with the `--url` flag.'.format(FILE)) sys.exit(1) else: URL = url_guess