2

I'm QAing https://github.com/civicrm/civicrm-core/pull/9255 and trying to run a couple of relevant test locally:

~/src/civicrm-buildkit/build/qa/sites/all/modules/civicrm$ tools/scripts/phpunit api_v3_JobProcessMailingTest --filter testConcurrency

I'm getting the following error output from each time the test uses CiviUnitTestCase::createExternalAPI to call the API:

[is_error] => 1
[error_message] => External API returned malformed response.
[trace] => Array
    (
        [code] => 127
        [stdout] => 
        [stderr] => sh: 1: cv: not found

    )

cv api Contact.get works as expected from the same directory.

Any ideas on what to do next to debug? I get why the test wants to do things concurrently, but my eyes start glazing over (only a little!) when I start looking at civicrm/Civi/API/ExternalBatch.php and I'm hoping I might have overlooked something 'obvious'.

  • I tried doing a bit of troubleshooting, mainly in tests/phpunit/CiviTest/bootstrap.php, but I'm not convinced that's the right place. In any case, this DOES work for me. – Jon G - Megaphone Tech Dec 15 '16 at 20:58
  • Hmm, this SO answer was brought to us by the letter ^A, which might be relevant (CiviCRM uses this character as a value separator). Asker closes with "I would encourage anyone with a similar problem to look for hidden characters in the string used with popen()." – Chris Burgess Dec 17 '16 at 17:55
2

The error message says sh: 1: cv not found, so the symptom here is that the proc_open() call is unable to find the executable cv.

It looked like the place to check this should be cv() function in tests/phpunit/CiviTest/bootstrap.php ... but I wasn't able to get that to work.

Having investigated, I suspect that this may be an issue in \Civi\API\ExternalBatch. In that class's constructor,

$this->env = $_ENV;

At this point in the tests, $_ENV = ['CIVICRM_UF' => 'UnitTests']. There is no path here, and the call to cv fails. Manually inserting a PATH into $_ENV here does restore the ability to call cv, but then fails with a further "malformed response" error, "Failed to determine INI file path.".

This must be working on tests.civicrm.org, so perhaps it's a configuration issue that affects both our test environments?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.