avocado: Fix bug where an exception.TestError reports PASS

An oversight happened when writing the output plugins made
the ERROR status to be ignored and reported as PASS.
This patch fixes this problem.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado: Introduce handling of non existent tests

When tests don't exist, current avocado breaks on
a very spectacular fashion:

Traceback (most recent call last):
  File "scripts/avocado", line 29, in <module>
    sys.exit(app.run())
  File "/home/lmr/Code/avocado2/avocado/cli/app.py", line 72, in run
    return self.args.func(self.args)
  File "/home/lmr/Code/avocado2/avocado/plugins/runner.py", line 106, in
run_tests
    return job_instance.run()
  File "/home/lmr/Code/avocado2/avocado/job.py", line 111, in run
    test_instance = self.run_test(url)
  File "/home/lmr/Code/avocado2/avocado/job.py", line 76, in run_test
    test_instance = self._load_test_instance(url)
  File "/home/lmr/Code/avocado2/avocado/job.py", line 63, in
_load_test_instance
    f, p, d = imp.find_module(url, [test_module_dir])
ImportError: No module named bogustest

We should be of course more classy when such a problem happens.
Introduce a NonExistentTest class to handle such problems,
and use it when the ImportError happens. The end result is
a lot better:

DEBUG LOG: /home/lmr/avocado/logs/run-2014-04-29-13.12.34/debug.log
TOTAL TESTS: 1
(1/1) bogustest.1:  ERROR (0.10 s)
TOTAL PASSED: 0
TOTAL ERROR: 1
TOTAL FAILED: 0
TOTAL SKIPPED: 0
TOTAL WARNED: 0
ELAPSED TIME: 0.10 s

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado.core.status: TEST_NA status is not a failure

When we skip a test, that is not a failure. Only the
test was not applicable for the given test environment.
Therefore, we should not report those as failures.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado.core.exceptions: Introduce JobError

For the (yet non existing) cases where we want to throw
a specific JobError, that will be managed by the runner
plugin.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado.core: Add a mapping of avocado error codes

Add a mapping of possible return codes for avocado,
to the meaning of them. We need to differentiate
simple jobs from tests failed, jobs that failed, and
avocado crashes.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
avocado.job: Refactor and introduce new error codes for job

We have to tell apart 'expected' avocado error from
plain crashes. Refactor the Job.run() method, separating
it to an unhandled exception auxiliary method, and a
handled one, that properly sets the following return
codes for avocado execution:

* AVOCADO_ALL_OK (0)
    Both job and tests PASSed
* AVOCADO_TESTS_FAIL (1)
    Job went fine, but some tests FAILed or ERRORed
* AVOCADO_JOB_FAIL (2)
    Something went wrong with the Job itself, by explicit
    :class:`avocado.core.exceptions.JobError` exception.
* AVOCADO_CRASH (3)
    Something else went wrong and avocado plain crashed.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
.travis.yml: Functional test for non existent tests

Avocado should handle gracefully and not crash.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>