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

Safe Loader: a second, more abstract and reusable implementation [v0] #996

Closed
wants to merge 5 commits into from

Conversation

clebergnu
Copy link
Contributor

When the safe(r) test loader mechanism was introduced in the avocado.core.loader module, it was written specifically to address Avocado's own needs (that is, avocado.Test based test classes).

Now, we want to:

  • Allow the safe test loader to be optional, that is, allow the user to run $ avocado list --unsafe or similar
  • Increase the scope of tests that can be run by Avocado, and that includes standard Python unittests

The first step is to abstract and isolate the original safe loader code, which is done and this PR in the form of the avocado.core.safeloader module. Then, as a PoC, we deliver a contrib script that makes use of this new module and finds unittests on Python source code files.

This brings us to an interesting situation, where, although not without flaws or limitations, Avocado can test itself, which was one of the original goals of the project. A sample session / command line would look like this:

$ cd avocado/selftests/unit
$ avocado run `../../contrib/avocado-find-unittests *.py | xargs` --external-runner '/usr/bin/python -m unittest'

Currently, this reveals a number of (simple) bugs in our unittests, mostly related to to file paths, and brings the following results:

RESULTS    : PASS 117 | ERROR 0 | FAIL 24 | SKIP 0 | WARN 0 | INTERRUPT 0

For functional tests, it brings the following results:

RESULTS    : PASS 120 | ERROR 0 | FAIL 12 | SKIP 0 | WARN 0 | INTERRUPT 0

The idea is to hold utilities that are used to implement the safe,
AKA ast-based, test loader.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
Signed-off-by: Cleber Rosa <crosa@redhat.com>
This little utility function is going to be used in the safe loader
module, so it's a good idea to just put it into our collection of
utility modules.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
Signed-off-by: Cleber Rosa <crosa@redhat.com>
Using the safe loader features, this scripts looks for unittests in
the given Python source code values, retuning them one per line.

The main goal is to allow Avocado to run unittests (including its
own) by means of the external runner. A sample session / command line
would look like this:

 $ cd avocado/selftests/unit
 $ avocado run `../../contrib/avocado-find-unittests *.py` \
   --external-runner '/usr/bin/python -m unittest'

Signed-off-by: Cleber Rosa <crosa@redhat.com>
@lmr lmr added the in progress label Feb 2, 2016
@clebergnu
Copy link
Contributor Author

Closing in favor of #1020

@clebergnu clebergnu closed this Feb 15, 2016
@lmr lmr removed the in progress label Feb 15, 2016
@clebergnu clebergnu deleted the safeloader branch May 4, 2016 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants