-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP: moves functionality to Python Eliminates all but a bash shim file, restructures more in line with the python-representer and python-anaylzer repos. To run just `sh bin/run.sh SLUG EXERCISE_DIR OUTPUT_DIR * update Dockerfile to use new scripts * Update runner/__init__.py Co-Authored-By: Corey McCandless <[email protected]> * Update runner/utils.py Co-Authored-By: Corey McCandless <[email protected]> * Refactor and self testing Significant refactor of the main structure, now working on a test suite for the runner itself; only problem here is it's not sufficiently isolated, yet, from the programtically run pytest. * adds output capture and tests Updates to add output capturing from stdout. Also many more tests, including some examples of the various stylings available for us to choose from for traceback. * add tests demonstrating truncation Now demonstrating truncation of stdout output at 500 chars. * updates Docker container testing Updates the Dockerfile to use requirements.txt, just to be consistent and in case we ever add more dependencies. Moves the run-in-docker script and eliminates its use in the Github CI action. Adds some documentation of the current state of things. * Force Action run * Fix formatting. * Fix issue with missing Python... hopefully * Updates bin/runs.sh to find the correct python * sanitizes messages more completely This _should_ make the `message` field more sensible for the students.
- Loading branch information
Showing
39 changed files
with
854 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
name: Run Example | ||
--- | ||
name: CI | ||
|
||
on: [push] | ||
on: | ||
push: | ||
paths-ignore: | ||
- '.gitignore' | ||
- 'LICENSE' | ||
- '**.md' | ||
|
||
jobs: | ||
build: | ||
name: Test Runner | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Run python-test-runner on example files | ||
run: sh run-in-docker.sh example test/example/ test/output/example | ||
- name: Verify that results.json is created | ||
run: test -f test/output/example/results.json && cat test/output/example/results.json | ||
- name: Verify that test case order in results.json | ||
run: bash verify_test_order.sh example test/example test/output/example/ | ||
- name: Verify exercise with multiple words in name | ||
run: sh run-in-docker.sh example-with-longer-name test/example-with-longer-name/ test/output/longer-example | ||
|
||
- name: Build Docker Image | ||
run: docker build -f Dockerfile -t python-test-runner . | ||
|
||
- name: Run Tests | ||
run: docker run --entrypoint "pytest" python-test-runner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
FROM python:3.7-alpine | ||
|
||
RUN pip install pytest | ||
COPY requirements.txt /requirements.txt | ||
|
||
WORKDIR /opt/test-runner | ||
RUN pip install -r /requirements.txt | ||
|
||
COPY ./run.sh ./bin/ | ||
COPY ./process_results.py ./ | ||
COPY . /opt/test-runner | ||
|
||
# Necessary to apply to tests run in bound directory /solution/ | ||
COPY ./conftest.py / | ||
WORKDIR /opt/test-runner | ||
|
||
ENTRYPOINT [ "sh", "/opt/test-runner/bin/run.sh" ] | ||
ENTRYPOINT [ "sh", "/bin/run.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0
run-in-docker.sh → bin/run-in-docker.sh
100644 → 100755
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#! /usr/bin/env python3 | ||
""" | ||
CLI for the test runner for the Python track on Exercism.io. | ||
""" | ||
from argparse import ArgumentParser, ArgumentTypeError, REMAINDER | ||
|
||
import runner | ||
import runner.utils | ||
|
||
|
||
def _slug(arg): | ||
try: | ||
return runner.utils.slug(arg) | ||
except ValueError as err: | ||
raise ArgumentTypeError(str(err)) | ||
|
||
|
||
def _directory(arg): | ||
try: | ||
return runner.utils.directory(arg) | ||
except (FileNotFoundError, PermissionError) as err: | ||
raise ArgumentTypeError(str(err)) | ||
|
||
|
||
def main(): | ||
""" | ||
Parse CLI arguments and run the tests. | ||
""" | ||
parser = ArgumentParser(description="Run the tests of a Python exercise.") | ||
|
||
parser.add_argument( | ||
"slug", metavar="SLUG", type=_slug, help="name of the exercise to process", | ||
) | ||
|
||
parser.add_argument( | ||
"input", | ||
metavar="IN", | ||
type=_directory, | ||
help="directory where the [EXERCISE.py] file is located", | ||
) | ||
|
||
parser.add_argument( | ||
"output", | ||
metavar="OUT", | ||
type=_directory, | ||
help="directory where the results.json will be written", | ||
) | ||
|
||
parser.add_argument("pytest_args", nargs=REMAINDER) | ||
|
||
args = parser.parse_args() | ||
runner.run(args.slug, args.input, args.output, args.pytest_args) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#! /bin/sh | ||
root="$( dirname "$( cd "$( dirname "$0" )" >/dev/null 2>&1 && pwd )" )" | ||
export PYTHONPATH="$root:$PYTHONPATH" | ||
/usr/bin/env python3 bin/run.py "$@" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[pytest] | ||
norecursedirs = .git .github example* traceback-styles* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pytest>=5.3.1 |
Oops, something went wrong.