#212 Write pytest wrapper/engine for arcanist
Closed: Fixed Opened by jskladan.

When doing code reviews with arcanist/phabricator, it is possible to submit lint and unit test results with that code review. In order to do this, there needs to be interface code for the unit test runner.

[[https://secure.phabricator.com/book/phabricator/article/arcanist_lint_unit/|The phabricator docs for customizing workflows]] cover some of this but the existing code is limited
* [[https://github.com/facebook/arcanist/tree/master/src/unit/engine|unit test engine interfaces]]


This ticket had assigned some Differential requests:
D487
D479
D454

Well, what I found so far is that py.test wrapper is already done. However, it doesn't work out of the box, I will investigate further if we have old version, whether I should file a bug or there is problem at my side.

Quickfix for me was:
- edit /usr/share/arcanist/src/unit/engine/PytestTestEngine.php add property private $project_root; to the class.
- install package php-domxml-php4-php5.noarch

If you are working in virtualenv, you'll probably need to edit $cmd_line in buildTestFuture() so the py.test runs test from testing/ directory.

! In #364#6742, @lbrabec wrote:
If you are working in virtualenv, you'll probably need to edit $cmd_line in buildTestFuture() so the py.test runs test from testing/ directory.

Latest findings: This ^^ is not needed, if you add the following to tox.ini:

[pytest]
minversion=2.0
python_functions=test should
python_files=test_* functest_*
addopts=--functional testing/

That allows you to run py.test in the root libtaskotron directory to execute full functional testing, and when run through Phabricator it picks it up. Unfortunately, it's not possible to override the --functional argument from the cmdline, so you can't execute non-functional testing this way. For that, a different config file must exist. We can keep testing/pytest.ini and use it to run non-functional testing by default, the same way we always did: py.test testing/. But it's not completely obvious.

Another idea is to revert the meaning of the --functional argument into something like --unit or --fast. Then we can default to do full functional testing, but the user can always specify --unit/--fast to do just unit testing. And we can have just a single configuration file (tox.ini, and get rid of testing/pytest.ini).

I created tickets in phab phab:

[[ https://secure.phabricator.com/T8913 | RFE: be able to config PytestTestEngine ]]

[[ https://secure.phabricator.com/T8912 | Unable to run arc unit, PytestTestEngine throws exception]]

I've done new builds of arcanist, phabricator and libphutil which should have the upstream fixes in them.

When I try to set "unit.engine" on my local checkout and run arc unit, it still blows up looking for coverage but I could be missing some setting

Regarding the new builds thing - something is up with the phabricator build and I just noticed it. For now, I've downgraded the version, will look at it more tomorrow

OK, new builds in the repo for real this time :)

I have new things to add to my "to test" list when updating packages

I think this has been done for a while now. If there's nothing more, please close the ticket.

Seems to be done.

Metadata Update from @jskladan:
- Issue tagged with: easyfix

Metadata