stbt-completion: Update config search path to match 1fc5016e

The completions offered for `stbt config` now also look in the default
config location added in commit 1fc5016e.
stbt.py: Deprecation messages should point at source location of caller

...not at the line in stbt.py with the call to `warnings.warn`.

Note that the default values for `stacklevel` is 1, and it is
interpreted as relative to the *implementation* of `warnings.warn`, not
its caller.

Changing the stacklevel to 2 makes the warning messages appear to belong
to the module of the *caller* of `wait_for_match` (etc.), not to the
`stbt` module, so with the existing `filterwarnings` specification the
warning messages wouldn't be printed at all. Hence the change to match
on the message contents instead of the module.

Unfortunately `stbt run` runs the script via `execfile`, so for scripts
executed directly via `stbt run`, the warning message will show "stbt"
for the source file (but the line number will the line number of the
offending statement in the actual script). I think that this commit is
still worthwhile because the source file will be printed correctly for
any calls to `wait_for_match` made from a *library* imported by the
top-level script. In our corpus of test scripts at YouView the vast
majority of calls to `wait_for_match` are made from such library
functions, so the source location printed by this change is of real
value.
stbt.py: Don't use object instance for `match_parameters` default value

A function's default parameter values are evaluated *once* when the
function is defined, not when the function is called; and the function
modifies this value, so subsequent calls to the same function could
get a nasty surprise if they're expecting the original default value.
For example:

(1)  def wait_for_match(..., match_parameters=MatchParameters()):
     ...

     stbt.wait_for_match("template.png", noise_threshold=0.1)
(2)  └ match_parameters.confirm_threshold = noise_threshold

     stbt.wait_for_match("template.png")
(3)  └ properties["confirmThreshold"] = match_parameters.confirm_threshold

All 3 of the numbered lines are referencing the same `MatchParameters`
instance, so the second call to `wait_for_match` sees the modification
that was made in the first call.

Thanks to Aiman Baharna for spotting this.
stbt-completion: Correction of completion of LIRC control-recorder

A modification missing from 1ccc2b1f: the new LIRC remote types haven't
been added to the completion function of '--control-recorder'.
stbt-run: Exit with different exit codes by exception type

To make interpreting test results by a test harness easier, `stbt run`
exits with exit code '0' on success, '1' if 'stbt.UITestError' is raised
indicating a test failure, and '2' if any other exception is raised
indicating a test case error or environment error.

The test execution framework shall be configured to report the two
types of failures differently, so that it's easy to distinguish between
bugs caught and other kinds of errors.
README: Document exit status
Merge branch 'different-exit-codes-by-exception-type'

* different-exit-codes-by-exception-type:
  README: Document exit status
  stbt-run: Exit with different exit codes by exception type

Closes #10.
stbt templatematch: Backwards compatibility support for `noise_threshold`

In 18a5e70e `noise_threshold` was renamed to `confirm_threshold`.

In 25d7f3a9 `confirm_threshold` was moved into a field of
`MatchParameters`, and `stbt templatematch` was updated accordingly, but
in a way that lost backwards compatibility support for
`noise_threshold`.

We'll keep `noise_threshold` for a release or two, and then we'll remove
it.
README: Update to match changes from 659f69c1

This commit is the result of running `make doc`, which keeps README.rst
in sync with the reality of the default values in the python code.
stbt.conf: Move image-matching parameters to [match] section

(From the [global] section.)

This doesn't break backwards compatibility because these parameters
(match_method, match_threshold, confirm_method, confirm_threshold,
erode_passes) were introduced (in dd44303b) more recently than the last
stb-tester release (0.12).

The need for a separate section is that in future we may want to put the
parameters for *motion* detection into stbt.conf, and those (and other
new) parameters may conflict with the image-matching parameters.
stbt.MatchParameters: Document the config file keys for default values
stbt tv: Search for `source_pipeline` in the correct config section

Since commit 9283df1f, `source_pipeline` is specified in the `[global]`
section of stbt.conf.
rpm spec file: Bump stb-tester version to 0.13
stbt.get_config works from scripts run with `python`

(not just from scripts run with `stbt run`).

Before this commit, a python script calling `stbt.config` would give
different results if it was run with `python` or with `stbt run`. When
run directly with `python`, it wouldn't read the values from
`/etc/stbt/stbt.conf` (or the appropriate location for the host-wide
config file). This was because `stbt.get_config` was expecting the
environment variable `STBT_SYSTEM_CONFIG` to be set; this was set by
`stbt` (see `stbt.in`; the correct value for `STBT_SYSTEM_CONFIG` was
hard-coded into `stbt` when you'd run `make`).

This commit changes the mechanism for finding /etc/stbt/stbt.conf: Now
this value is hard-coded (again, at `make` time) into the default
read-only config file (e.g. /usr/libexec/stbt/stbt.conf -- see
1fc5016e).

In practice, any stb-tester script that uses the video-capture or
infrared control capabilities must be run with `stbt run`; but it's
conceivable for users to write helper scripts that only use
`get_config`.

A note on the `stbt.py` implementation: According to my experiments, you
can call `ConfigParser.read` multiple times without losing the
previously-loaded values, but this isn't documented. The
documentation[1] says to load defaults with `readfp` and then make a
single call to `read` passing in multiple filenames in an array.

[1] http://docs.python.org/2/library/configparser.html#ConfigParser.RawConfigParser.read

Fixes #17.
stbt-completion: Cleanup: Refactor XDG_CONFIG_HOME default value

...into a single line. The less we mutate existing variables the better.
make check-integrationtests: Don't stop at the first failure

tests/run-tests.sh now runs all shell functions whose name begins with
"test_", instead of specifying each test function explicitly.

I hadn't done this before because I wanted the tests to be run in a
particular order (specifically, to test that GStreamer worked at all
before carrying on with any other tests). But this was causing too
much code duplication in tests/run-tests.sh.

This will also allow me to introduce parallelisation into `make check`
in a future commit.
Run self-tests in parallel

Use GNU parallel to run the various unit tests in parallel. This cuts
`make check` time in half on my dual-core Core i7:

* `make check-integrationtests` went from 80s to 40s.
* `make check-pylint` went from 5s to 3s.

The implementation takes advantage of the fact that `tests/run-tests.sh`
and `extra/pylint.sh` will run a specific test (instead of all tests) if
it is named as a command-line argument.

I can't apply the same parallelisation to `make check-nosetests` because
its output is different if you run it once per file instead of once with
a list of all files (`make check-nosetests` only takes 1.3s to run,
anyway). I didn't apply parallelisation to `make check-bashcompletion`
either, because it takes 0.1s to run.

Note that moreutils also has a tool called "parallel", but it has a
different (and less convenient) command-line API. Fedora wisely don't
provide it in their moreutils package, so that you can install GNU
parallel without conflict.

Note that this implementation falls back to running the tests serially
if you don't have GNU parallel installed.
make check: Don't use PARALLEL environment variable

Commit 42d1d8aa uses PARALLEL if it is set in the environment, copying
the way that INSTALL and TAR are handled. This wasn't a good idea
because `parallel` uses `$PARALLEL` for its default options, so users
are likely to have PARALLEL set to something like "-j8".

Using `:=` instead of `?=` won't take the value from the environment,
but you can still override it with an explicit
`make check parallel=gparallel`.
tests/run-tests.sh: Cleanup: Remove all files in $scratchdir after each test run

I was trying to avoid `rm -rf $scratchdir` out of paranoia, in case
`$scratchdir` expanded to something like "/". But I think with this
I'm being sufficiently careful.
make check: Fix intermittent failures for tests that save screenshot to disk

These tests started failing intermittently since commit 42d1d8aa where
`make check` runs these tests in parallel. Both tests were creating
`screenshot.png` in the same directory, and were occasionally trampling
on each other. Now they use `$scratchdir` which is different for each
test.