Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve running tests locally #1352

Merged
merged 3 commits into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Docker image for the rdflib test-runner.

# Use the lowest supported Python version to run tests.
FROM python:3.6

COPY requirements.dev.txt .
COPY requirements.txt .

RUN pip install --no-cache -r requirements.dev.txt
RUN pip install --no-cache -r requirements.txt

WORKDIR /rdflib
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
tests:
docker compose up test-runner --exit-code-from test-runner

build:
docker compose build

coverage:
docker compose up test-runner-coverage --exit-code-from test-runner-coverage
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,43 @@ You can also raise issues here:
* <https://github.com/RDFLib/rdflib/issues>


## Running tests

### Running the tests on the host

Run the test suite with `nose`.
```shell
nosetests
```

### Running test coverage on the host with coverage report

Run the test suite and generate a HTML coverage report with `nose` and `coverage`.
```shell
nosetests --with-timer --timer-top-n 42 --with-coverage --cover-tests --cover-package=rdflib
```

### Running the tests in a Docker container

Run the test suite inside a Docker container for cross-platform support. This resolves issues such as installing BerkeleyDB on Windows and avoids the host and port issues on macOS.
```shell
make tests
```

Tip: If the underlying Dockerfile for the test runner changes, use `make build`.

### Running the tests in a Docker container with coverage report

Run the test suite inside a Docker container with HTML coverage report.

### Viewing test coverage

Once tests have produced HTML output of the coverage report, view it by running:
```shell
python -m http.server --directory=cover
```


## Contacts
If you want to contact the rdflib maintainers, please do so via the rdflib-dev mailing list:

Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
test-runner:
build: .
volumes:
- .:/rdflib
command: ["/rdflib/run_tests.sh"]

test-runner-coverage:
build: .
volumes:
- .:/rdflib
command: ["/rdflib/run_tests_with_coverage_report.sh"]
9 changes: 9 additions & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

cd /rdflib
pip install -e .

test_command="nosetests --with-timer --timer-top-n 42 --with-coverage --cover-tests --cover-package=rdflib"
echo "Running tests..."
echo "Test command: $test_command"
$test_command
9 changes: 9 additions & 0 deletions run_tests_with_coverage_report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

cd /rdflib
pip install -e .

test_command="nosetests --with-timer --timer-top-n 42 --with-coverage --cover-tests --cover-package=rdflib --cover-html"
echo "Running tests..."
echo "Test command: $test_command"
$test_command