Skip to content

Commit

Permalink
Add note about how to run test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
foosel committed Nov 22, 2017
1 parent b252da4 commit 6221175
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 10 deletions.
15 changes: 14 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ See [How to open the Javascript Console in different browsers](https://webmaster
## Setting up a development environment

See [the corresponding chapter in the documentation](http://docs.octoprint.org/en/master/development/index.html#setting-up-a-development-environment).
This also includes information on how to run the test suite and how to build
the documentation.

## Pull requests

Expand Down Expand Up @@ -303,7 +305,17 @@ See [the corresponding chapter in the documentation](http://docs.octoprint.org/e
* Make sure you do not add dead code (e.g. commented out left-overs
from experiments).
8. Ensure your changes **pass the existing unit tests**. PRs that break
those cannot be accepted.
those cannot be accepted. You can run the unit tests locally (after
[initial development environment setup with "develop" dependencies](http://docs.octoprint.org/en/master/development/index.html#setting-up-a-development-environment))
by running

```
nosetests --with-doctest
```

in the OctoPrint checkout folder. A [travis build](https://travis-ci.org/foosel/OctoPrint)
is also setup so that if the tests should fail, your PR will be marked
accordingly.
9. **Test your changes thoroughly**. That also means testing with usage
scenarios you don't normally use, e.g. if you only use access control, test
without and vice versa. If you only test with your printer, test with the
Expand Down Expand Up @@ -432,6 +444,7 @@ the local version identifier to allow for an exact determination of the active c
* 2017-03-10: Reproduce bugs in safe mode to make sure they are really caused
by OctoPrint itself and not a misbehaving plugin.
* 2017-03-27: Added safe mode section to ticket template.
* 2017-11-22: Added note on how to run the unit tests

## Footnotes
* [1] - If you are wondering why, the problem is that anything that you add
Expand Down
43 changes: 34 additions & 9 deletions docs/development/environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@ below.
* `Git <https://git-scm.com>`_

* Checkout the OctoPrint sources from their Git repository: ``git clone https://github.com/foosel/OctoPrint.git``
* Create a virtual environment in the checkout folder to use for installing and running OctoPrint and its
* Enter the checked out source folder: ``cd OctoPrint``
* Create a virtual environment in the checked out source folder to use for installing and running OctoPrint and its
dependencies (this avoids potential versioning issues for the dependencies with system wide installed
instances): ``virtualenv venv``
* Activate the virtual environment: ``source venv/bin/activate`` (might differ per your platform/OS)
* Activate the virtual environment: ``source venv/bin/activate`` (Linux, MacOS) or
``source venv/Scripts/activate`` (Git Bash under Windows, see below)
* Update ``pip`` in the virtual environment: ``pip install --upgrade pip``
* Install OctoPrint in `"editable" mode <https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs>`_,
including its regular *and* development dependencies: ``pip install -e .[develop]``
including its regular *and* development and plugin development dependencies: ``pip install -e .[develop,plugins]``

When the virtual environment is activated you can then:

* run the OctoPrint server via ``octoprint serve``
* run the test suite from the checked out source folder via ``nosetests --with-doctest``
* build the documentation from the ``docs`` sub folder of the checked out sources via ``sphinx-build -b html . _build``

.. _sec-development-environment-source-linux:

Expand Down Expand Up @@ -93,9 +101,6 @@ Open the Git Bash you just installed and in that:
pip install --upgrade pip
pip install -e .[develop,plugins]
You can then start OctoPrint via ``/c/Devel/OctoPrint/venv/Scripts/octoprint`` or just ``octoprint`` if you activated the virtual
environment.

.. _sec-development-environment-mac:

Mac OS X
Expand Down Expand Up @@ -139,9 +144,6 @@ You'll need a user account with administrator privileges.
pip install --upgrade pip
pip install -e .[develop,plugins]
You can then start OctoPrint via ``~/devel/OctoPrint/venv/bin/octoprint`` or just ``octoprint`` if you activated the virtual
environment.

.. _sec-development-environment-ides:

IDE Setup
Expand Down Expand Up @@ -177,6 +179,29 @@ PyCharm
* Parameters: ``install -e .[develop,plugins]``
* Working directory: ``$ProjectFileDir$``

- Add Run/Debug Configuration, select "Python tests" and therein "Nosetests":

* Name: OctoPrint nosetests
* Target: Path, ``.``
* Project: ``OctoPrint``
* Python interpreter: the ``venv`` local virtual environment
* Working directory: the OctoPrint checkout folder (e.g. ``~/devel/OctoPrint`` or ``C:\Devel\OctoPrint``)
* Just like with the run configuration for the server you can also have the dependencies auto-update on run of
the tests, see above on how to set this up.

- Add Run/Debug Configuration, select "Python docs" and therein "Sphinx task"

* Name: OctoPrint docs
* Command: ``html``
* Input: the ``docs`` folder in the OctoPrint checkout folder (e.g. ``~/devel/OctoPrint/docs`` or
``C:\Devel\OctoPrint\docs``)
* Output: the ``docs/_build`` folder in the OctoPrint checkout folder (e.g. ``~/devel/OctoPrint/docs/_build`` or
``C:\Devel\OctoPrint\docs\_build``)
* Project: ``OctoPrint``
* Python interpreter: the ``venv`` local virtual environment
* Just like with the run configuration for the server you can also have the dependencies auto-update when building
the documentation, see above on how to set this up.

.. note::

Make sure you are running a PyCharm version of 2016.1 or later, or manually fix
Expand Down

0 comments on commit 6221175

Please sign in to comment.