Drupal\Tests\examples\Unit\YamlValidationTest contains the following code.

$examples_project_path = realpath(__DIR__ . '/../../..');

$paths = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($examples_project_path, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS));
foreach ($paths as $path) {
  $pathname = $path->getPathname();
  if (strpos($pathname, '.yml') !== FALSE) {
    if (strpos($pathname, '/config/') !== FALSE) {
      $yaml_paths[] = [$pathname];
    }
  }
}

It should retrieve only the files that are part of this project, but it retrieves also files contained in directories added by GitLab CI when its pipelines are executed. That is why the project tests fail with the following errors.

YAML in this file contains a uuid key:
/builds/project/examples/web/core/profiles/standard/config/install/system.site.yml
Failed asserting that an array does not have the key 'uuid'.

 

YAML in this file contains a uuid key:
/builds/project/examples/web/core/modules/config/tests/config_test/config/install/config_test.validation.yml
Failed asserting that an array does not have the key 'uuid'.

 
It also retrieves files that are not YAML files, as shown by error messages like the following ones.

2) Drupal\Tests\examples\Unit\YamlValidationTest::testNoUuidsInConfig with
data set #1102 ('/builds/project/examples/vend...l.twig')
 Symfony\Component\Yaml\Exception\ParseException: Malformed inline YAML
string: "{{machine_name }}" at line 1 (near "{{ machine_name }}.{{
entity_type_id }}_type.*:").

 

3) Drupal\Tests\examples\Unit\YamlValidationTest::testNoUuidsInConfig with
data set #1104 ('/builds/project/examples/vend...l.twig')
Symfony\Component\Yaml\Exception\ParseException: Malformed inline YAML
string: "{{machine_name }}" at line 5 (near "- {{ machine_name }}").

 
 

Issue fork examples-3458387

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

apaderno created an issue. See original summary.

avpaderno’s picture

Title: Drupal\Tests\examples\Unit\YamlValidationTest checks files outside the directory containing the project files » Drupal\Tests\examples\Unit\YamlValidationTest::provideYamls() assumes that the directory containing the project files will not contain other directories/files
Issue summary: View changes

I changed the issue summary to reflect what I discovered.

avpaderno’s picture

Title: Drupal\Tests\examples\Unit\YamlValidationTest::provideYamls() assumes that the directory containing the project files will not contain other directories/files » Avoid YamlValidationTest::provideYamls() returns .yml files that are not part of the Examples project
Status: Active » Needs review
avpaderno’s picture

Title: Avoid YamlValidationTest::provideYamls() returns .yml files that are not part of the Examples project » YamlValidationTest::provideYamls() returns .yml files that are not part of the Examples project
avpaderno’s picture

Issue summary: View changes

  • apaderno committed cdeac38f on 4.0.x
    Issue #3458387: YamlValidationTest::provideYamls() returns .yml files...
avpaderno’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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