Problem/Motivation

Drupal\Tests\field\Functional\EntityReference\EntityReferenceAdminTest has failed twice in 8.6.x HEAD in the past two weeks:
https://www.drupal.org/pift-ci-job/1179392
https://www.drupal.org/pift-ci-job/1184261

The fail is kind of odd:

Drupal\Tests\field\Functional\EntityReference\EntityReferenceAdminTest
fail: [Other] Line 0 of sites/default/files/simpletest/phpunit-264.xml:
PHPunit Test failed to complete; Error: PHPUnit 6.5.13 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\field\Functional\EntityReference\EntityReferenceAdminTest
...                                                                 3 / 3 (100%)

Time: 54.47 seconds, Memory: 4.00MB

OK (3 tests, 135 assertions)
HTML output was generated
http://php-apache-jenkins-php7-mysql5-5-6660/subdirectory/sites/simpletest/browser_output/Drupal_Tests_field_Functional_EntityReference_EntityReferenceAdminTest-1-90970228.html
(...etc...)

Remaining deprecation notices (2)

  2x: Passing an escaped locator to the named selector is deprecated as of 1.7 and will be removed in 2.0. Pass the raw value instead.
    2x in EntityReferenceAdminTest::testAvailableFormatters from Drupal\Tests\field\Functional\EntityReference

1.7 and 2.0 of what, you ask? Passing an escaped locator to what, and on what line? I grepped the codebase and found:
vendor/behat/mink/src/Selector/NamedSelector.php: 'Passing an escaped locator to the named selector is deprecated as of 1.7 and will be removed in 2.0.'

Which has:

    private function escapeLocator($locator)
    {
        // If the locator looks like an escaped one, don't escape it again for BC reasons.                                                                     
        if (
            preg_match('/^\'[^\']*+\'$/', $locator)
            || (false !== strpos($locator, '\'') && preg_match('/^"[^"]*+"$/', $locator))
            || ((8 < $length = strlen($locator)) && 'concat(' === substr($locator, 0, 7) && ')' === $locator[$length - 1])
        ) {
            @trigger_error(
                'Passing an escaped locator to the named selector is deprecated as of 1.7 and will be removed in 2.0.'
                .' Pass the raw value instead.',
                E_USER_DEPRECATED
            );

            return $locator;
        }

So it looks like somewhere in that test, a random string is somehow being passed to the above method, and if it matches the regex, BOOM, random fail. I read the test method though and the only variables in it are machine names, so that's as far as I got.

Proposed resolution

?

Remaining tasks

TBD

User interface changes

N/A

API changes

TBD

Data model changes

N/A

Release notes snippet

Comments

xjm created an issue. See original summary.

krzysztof domański’s picture

Status: Active » Needs review
StatusFileSize
new922 bytes
new1.08 KB
public function fieldUIAddNewField($bundle_path, $field_name, $label = NULL, $field_type = 'test_field', array $storage_edit = [], array $field_edit = []) {
  $label = $label ?: $this->randomString();
  $initial_edit = [
    'new_storage_type' => $field_type,
    'label' => $label,
    'field_name' => $field_name,
  ];

In fieldUIAddNewField() the label is randomly generated, so 'ZQ!!>&' is possible.

if (
    preg_match('/^\'[^\']*+\'$/', $locator)
    || (false !== strpos($locator, '\'') && preg_match('/^"[^"]*+"$/', $locator))
    || ((8 < $length = strlen($locator)) && 'concat(' === substr($locator, 0, 7) && ')' === $locator[$length - 1])
) {
    @trigger_error(
        'Passing an escaped locator to the named selector is deprecated as of 1.7 and will be removed in 2.0.'

The last submitted patch, 2: 3030902-test-only.patch, failed testing. View results

amateescu’s picture

Component: entity system » field_ui.module
Status: Needs review » Needs work

I think it would be better to have this fix in \Drupal\Tests\field_ui\Traits\FieldUiTestTrait::fieldUIAddNewField() itself, otherwise every code that calls it needs to be aware of this problem.

krzysztof domański’s picture

Version: 8.6.x-dev » 8.7.x-dev
Status: Needs work » Needs review
StatusFileSize
new687 bytes
new870 bytes
amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Looks great now!

The last submitted patch, 5: 3030902-test-only.patch, failed testing. View results

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 8d89da6 and pushed to 8.8.x. Thanks! (and backported to 8.7.x)

  • catch committed 21011ec on 8.7.x
    Issue #3030902 by Krzysztof Domański, amateescu, xjm: Random fail in...

  • catch committed d297e23 on 8.8.x
    Issue #3030902 by Krzysztof Domański, amateescu, xjm: Random fail in...
krzysztof domański’s picture

There are more identical random test failures caused by the vendor error.

#3041318: [random test failure] Various fails when a random string is used in an xpath selector

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.