- Issue created by @jonathan1055
- π¬π§United Kingdom jonathan1055
TypeError: Drupal\Tests\scheduler\Functional\SchedulerDrushTest::convertKeyValueToFlag() Argument #2 ($value) must be of type ?string, bool given called in /builds/project/scheduler/vendor/drush/drush/src/TestTraits/DrushTestTrait.php on line 74
DrushTestTraits has the following in Drush 12
/** * Given an option key / value pair, convert to a * "--key=value" string. * * @param string $key The option name * @param string $value The option value (or empty) * @return string */ protected function convertKeyValueToFlag(string $key, ?string $value)
Fixed by changing
- $this->drush('sch:cron', [], ['nomsg' => TRUE]); + $this->drush('sch:cron', [], ['nomsg' => '1']);
This also runs OK on drupal.org CI with Drush 11.5
- π¬π§United Kingdom jonathan1055
No change on 8.x-1.x but the error is different, and earlier in the testl
// Run the plain command using the full scheduler:cron command name, and // check that all of the output messages are shown. $this->drush('scheduler:cron'); $messages = $this->getErrorOutput(); $this->assertStringContainsString('Lightweight cron run activated by drush command', $messages, 'Starting dblog message not found', TRUE);
The error is
1) Drupal\Tests\scheduler\Functional\SchedulerDrushTest::testDrushCronMessages Starting dblog message not found Failed asserting that '[notice] Message: Scheduler lightweight cron completed.' contains "Lightweight cron run activated by drush command". /builds/project/scheduler/tests/src/Functional/SchedulerDrushTest.php:24
It seems that the default message "Lightweight cron run activated by drush command" is no longer being displayed. This could be due to this recent change on drush ?
- π¬π§United Kingdom jonathan1055
Using Drush 12 locally I can replicate the test failure. Using Drush 11 locally the tests pass.
Messages written in the Scheduler Drush command definition, via
$this->messenger->addMessage()
are shown and found in phpunit test using$messages = $this->getErrorOutput()
But the 'activated' messages are written in other places in the code via
$this->logger->notice()
and these are not now created during phpunit test. But they displayed in the terminal when the command is run manually.Tests on GitLab passed OK on 11 May 23:00 UTC using Drush 12.x-dev. But they were failing by 12 May 15:00 UTC with no source code changes.
- π¬π§United Kingdom jonathan1055
I have isolated the Drush commit that caused the test failures, by running locally, and removing commits until the tests pass. The last commit which allows the tests to pass is
047a3eb87 Thu May 11 21:48:15 2023 Handle bool option values in Test trait (#5560)
https://github.com/drush-ops/drush/pull/5560/filesThe next commit after this causes the test failures
ce1042ae8 Thu May 11 23:51:44 2023 Create a service adapter for drush.services.yml (#5553)
https://github.com/drush-ops/drush/pull/5553/filesIt may be that the Drush changes are fine, and the Scheduler tests were doing things wrongly, and getting away with it. But either way this needs resolving.
- π¬π§United Kingdom jonathan1055
Update IS to explain the two separate problems.
- π¬π§United Kingdom jonathan1055
The solution will either be to get Drush 12 fixed, or change the way the Scheduler phpunit test assertions are done, or both. In the meantime, now that we have GitLab pipelines running, as a temporary fix we can skip the Drush tests. This will allow the pipeline to pass, and contributors will not get confused/distracted by failing tests.
-
jonathan1055 β
committed b90cae05 on 2.x
Issue #3359998 by jonathan1055: Temporarily skip Drush tests in GitLab...
-
jonathan1055 β
committed b90cae05 on 2.x
-
jonathan1055 β
committed cc700863 on 8.x-1.x
Issue #3359998 by jonathan1055: Temporarily skip Drush tests in GitLab...
-
jonathan1055 β
committed cc700863 on 8.x-1.x
- π¬π§United Kingdom jonathan1055
I have raised a Drush issue here https://github.com/drush-ops/drush/issues/5572
-
jonathan1055 β
committed aa8cca20 on 8.x-1.x
Issue #3359998 by jonathan1055: Temporarily skip Drush tests in drupalci...
-
jonathan1055 β
committed aa8cca20 on 8.x-1.x
-
jonathan1055 β
committed d25e2cc8 on 2.x
Issue #3359998 by jonathan1055: Temporarily skip Drush tests in drupalci...
-
jonathan1055 β
committed d25e2cc8 on 2.x
- πΊπΈUnited States kwfinken Lansing, MI
getting similar error:
ArgumentCountError: Too few arguments to function Drupal\scheduler\SchedulerManager::__construct(), 7 passed in /opt/drupal/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 and exactly 9 expected in Drupal\scheduler\SchedulerManager->__construct() (line 96 of /opt/drupal/web/modules/contrib/scheduler/src/SchedulerManager.php).
- π¬π§United Kingdom jonathan1055
getting similar error
??? That's not a similar error at all! It has nothing to do with this problem in Drush tests. Please can you open a separate issue.
- π¬π§United Kingdom jonathan1055
For the record, here is the gitlab log from 14 May 2023 (logs are not kept forever on GitLab)
There were 5 failures: 1) Drupal\Tests\scheduler\Functional\SchedulerDrushTest::testDrushCronMessages Starting dblog message not found Failed asserting that '[notice] Message: Scheduler lightweight cron completed.' contains "Lightweight cron run activated by drush command". 2) Drupal\Tests\scheduler\Functional\SchedulerDrushTest::testDrushCronPublishing with data set "#node" ('node', 'testpage') Scheduled publishing message not found Failed asserting that '[notice] Message: Scheduler lightweight cron completed.' contains "Test Page: scheduled publishing of m2rAcHWd91VaWrJYgiMY for publishing". 3) Drupal\Tests\scheduler\Functional\SchedulerDrushTest::testDrushCronPublishing with data set "#media" ('media', 'test_video') Scheduled publishing message not found Failed asserting that '[notice] Message: Scheduler lightweight cron completed.' contains "Test Video: scheduled publishing of f3hJU8EiAITPBPgD11wL for publishing". 4) Drupal\Tests\scheduler\Functional\SchedulerDrushTest::testDrushCronPublishing with data set "#commerce_product" ('commerce_product', 'test_product') Scheduled publishing message not found Failed asserting that '[notice] Message: Scheduler lightweight cron completed.' contains "Test Product: scheduled publishing of s96Y5PVeEZW2CrXHJx8L for publishing". 5) Drupal\Tests\scheduler\Functional\SchedulerDrushTest::testDrushCronPublishing with data set "#taxonomy_term" ('taxonomy_term', 'test_vocab') Scheduled publishing message not found Failed asserting that '[notice] Message: Scheduler lightweight cron completed.' contains "Test Vocabulary: scheduled publishing of jRJPWX1pgqpTDE4jeFvU for publishing". FAILURES! Tests: 6, Assertions: 68, Failures: 5.
- π¬π§United Kingdom jonathan1055
This is a drush bug, reported here https://github.com/drush-ops/drush/issues/5862
There is a PR to fix it https://github.com/drush-ops/drush/pull/5863
This solves the problem locally. Before,[notice] Message: Scheduler lightweight cron completed.
With the fixed code we get the two mising messages
[notice] Lightweight cron run activated by drush command. [notice] Lightweight cron run completed. [notice] Message: Scheduler lightweight cron completed.
- π¬π§United Kingdom jonathan1055
This pipeline from 17 March still fails. It is using Drush 12.4.4
- last update
8 months ago 227 pass - π¬π§United Kingdom jonathan1055
Drush 12.5 has been released, the latest pipeline uses Drush 12.5.1 and it still fails.