Skip to content

Commit

Permalink
doc: --config-override, PANTS_ environment vars
Browse files Browse the repository at this point in the history
Wrote a blurb --config-override, since I'd guessed wrong about the behavior of PANTS_CONFIG_OVERRIDE back in the day.

Wrote about PANTS_... environment variables.
Made some guesses about which parts to write about.
Linked to options.py for folks who want the whole story.

Bugs closed: 661, 847

Reviewed at https://rbcommons.com/s/twitter/r/1640/
  • Loading branch information
lahosken authored and lahosken committed Jan 30, 2015
1 parent edb63c0 commit 3d044cd
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions src/docs/invoking.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,79 @@ passthrough args to tools called by all of `test`, not just `test.pytest`.
This gets tricky. We happen to know we can pass `-k list` here, that `pytest` accepts passthrough
args, and that this `test` invocation upon `tests/python/...` won't invoke any other tools
(assuming nobody hid a `junit` test in the `python` directory).

`PANTS_...` Environment Variables
---------------------------------

Each goal option also has a corresponding environment variable. For example, either of these
commands opens a coverage report in your browser:

:::bash
$ ./pants test.junit --coverage-html-open examples/tests/java/com/pants/examples::

$ PANTS_TEST_JUNIT_COVERAGE_HTML_OPEN=1 ./pants test examples/tests/java/com/pants/examples::

Pants checks for an environment variable whose name is `PANTS` + the goal name (or goal+task name)
+ the option name; all of these in all-caps, joined by underscores (instead of dots or hyphens).

If an environment variable and a --command-line option both specify a value for some option, the
command-line option "wins".

For a complete, precedence-ordered list of places Pants looks for option values, see the
`Options` docstring in
[src/python/pants/option/options.py](https://github.com/pantsbuild/pants/blob/master/src/python/pants/option/options.py).

Pants checks some environment variables that don't correspond to command-line options.
E.g., though Pants uses the `PANTS_VERBOSE` environment variable, there's no `--verbose` flag
to Pants.

* `PANTS_BUILD_ROOT`
* `PANTS_IVY_CACHE_DIR`
* `PANTS_IVY_SETTINGS_XML`
* `PANTS_LEAVE_CHROOT`
* `PANTS_PY_COVERAGE`
* `PANTS_PYTHON_TEST_FAILSOFT`
* `PANTS_VERBOSE`

`pants.ini` Settings File
-------------------------

Pants can also read command-line options (and other options) from an `.ini` file. For example, if
your `pants.ini` file contains

[test.junit]
coverage_html_open: True

...then whenever Pants carries out the `test.junit` task, it will behave as if you passed
`test.junit --coverage-html-open`. If an environment variable and an `.ini` configuration both
specify a value for some option, the environment variable "wins".

Pants also checks some `.ini` settings that don't correspond to any command-line option.
For example, though Pants uses the `PANTS_VERBOSE` environment variable, there's no `--verbose`
flag to Pants.

### Overlay `.ini` Files with `--config-overrides`

Sometimes it's convenient to keep `.ini` settings in more than one file. Perhaps you usually
operate Pants in one "mode", but occasionally need to use a tweaked set of settings.

Use the `--config-overrides` command-line option to specify a second `.ini` file. Each of
this `.ini` file's values override the corresponding value in `pants.ini`, if any.
For example, if your `pants.ini` contains the section

[test.junit]
coverage_html_open: True
debug: False

...and you invoke `--config-overrides=quick.ini` and your `quick.ini` says

[test.junit]
coverage_html_open: False
skip: True

...then Pants will act as if you specified

[test.junit]
coverage_html_open: False
skip: True
debug: False

0 comments on commit 3d044cd

Please sign in to comment.