Problem/Motivation

In #3063704-20: Deprecate \Drupal\Component\FileSystem\FileSystem::getOsTemporaryDirectory() and replace with sys_get_temp_dir() I found that tests using OS temporary directory instead of one defined by file_system service.
It may cause to use /tmp even if settings.php overrides it (it possible that OS does not allow to use common directory - systemd PrivateTmp=true)

Proposed resolution

Use \Drupal\Core\File\FileSystemInterface::getTempDirectory() inside of tests

Remaining tasks

agree, patch, commit

User interface changes

no

API changes

no

Data model changes

no

Release notes snippet

no

Issue fork drupal-3225473

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

andypost created an issue. See original summary.

andypost’s picture

Title: Use \Drupal\Core\File\FileSystemInterface::getTempDirectory() instead of sys_get_temp_dir() in tests » Use \Drupal\Core\File\FileSystemInterface::getTempDirectory() instead of sys_get_temp_dir() where possible
Status: Active » Needs review
StatusFileSize
new3.49 KB

Not all places allow use overridden directory

Status: Needs review » Needs work

The last submitted patch, 2: 3225473-2.patch, failed testing. View results

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new640 bytes
new2.86 KB

theme generator can't use container

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new143 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Bhanu951 made their first commit to this issue’s fork.

bhanu951’s picture

Status: Needs work » Needs review
StatusFileSize
new4.71 KB

Rerolled #4 against 10.1.x and raised MR.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

MR has failures it seems

bhanu951’s picture

Seems Random test failures. Re-initiated Tests.

bhanu951’s picture

Status: Needs work » Needs review

Back to need review after tests green.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Change looks good now.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Not sure that we can change only one call in \Drupal\KernelTests\Core\Theme\TwigEnvironmentTest - if they do return different values (which is possible) then the test will fail.

I'm not convinced that this issue is worth it - we have calls to sys_get_temp_dir() in unit tests that cannot be replaced here so I think we have an expectation that for testing sys_get_temp_dir() works and is writeable.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.