#39975 closed task (blessed) (fixed)
Remove direct calls to '/tmp/' in Unit Tests
Reported by: | joemcgill | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | has-patch needs-refresh |
Focuses: | Cc: |
Description
As noted by @mikeschroder in 39875, there are several places in our unit tests where we assume the temp directory is '/tmp/' and make direct calls. Instead, we should use something like wp_tempnam()
to ensure we're writing and removing files from the right place during tests.
Attachments (3)
Change History (18)
@
7 years ago
Removes symlinks from phpunit/tests/link/themeFile.php using parts of @danielhueskens patch on #40856
#4
@
7 years ago
This would greatly improve the unit test experience on Windows.
39975.2 replaces additional usages of /tmp from three files in phpunit/tests/widgets
39975.1 and 30075.2 remove 157 errors.
39975.3 replaces symlinks from phpunit/tests/link/themeFile.php using parts of @danielhuesken 's patch on #40856.
On Windows 10 with PHP 7.1.11, this removes the following warnings:
Warning: unlink(C:\laragon\www\trunk/src/wp-content\themes\theme-file-parent): Permission denied in C:\laragon\www\trunk\tests\phpunit\tests\link\themeFile.php on line 13 Warning: unlink(C:\laragon\www\trunk/src/wp-content\themes\theme-file-child): Permission denied in C:\laragon\www\trunk\tests\phpunit\tests\link\themeFile.php on line 14
and also avoids additional warnings when the tests are run again (because unlink didn't remove the symlink in the previous run) :
Warning: symlink(): Cannot create symlink, error code(183) in C:\laragon\www\trunk\tests\phpunit\tests\link\themeFile.php on line 8 Warning: symlink(): Cannot create symlink, error code(183) in C:\laragon\www\trunk\tests\phpunit\tests\link\themeFile.php on line 9
6 failures remain after 39975.3:
1) Tests_WP_Customize_Manager::test_import_theme_starter_content Expected reuse of non-auto-draft attachment. Failed asserting that an array contains 914. C:\laragon\www\trunk\tests\phpunit\tests\customize\manager.php:644 2) Tests_DB::test_mysqli_flush_sync procedure could not be created (missing privileges?) C:\laragon\www\trunk\tests\phpunit\tests\db.php:621 3) Test_Theme_File::test_theme_file_uri_returns_valid_uri with data set #0 ('parent-only.php', 'theme-file-parent', array('theme-file-parent')) Failed asserting that two strings are identical. --- Expected +++ Actual @@ @@ -'' +'C:\laragon\www\trunk\tests\phpunit\includes/../data/themedir1/default/parent-only.php' C:\laragon\www\trunk\tests\phpunit\tests\link\themeFile.php:117 4) Test_Theme_File::test_theme_file_uri_returns_valid_uri with data set #1 ('child-only.php', 'theme-file-child', array('theme-file-child')) Failed asserting that two strings are identical. --- Expected +++ Actual @@ @@ -'' +'C:\laragon\www\trunk\tests\phpunit\includes/../data/themedir1/default/child-only.php' C:\laragon\www\trunk\tests\phpunit\tests\link\themeFile.php:117 5) Test_Theme_File::test_theme_file_uri_returns_valid_uri with data set #2 ('parent-and-child.php', 'theme-file-child', array('theme-file-parent', 'theme-file-child')) Failed asserting that two strings are identical. --- Expected +++ Actual @@ @@ -'' +'C:\laragon\www\trunk\tests\phpunit\includes/../data/themedir1/default/parent-and-child.php' C:\laragon\www\trunk\tests\phpunit\tests\link\themeFile.php:117 6) Test_Theme_File::test_theme_file_uri_returns_valid_uri with data set #3 ('neither.php', 'theme-file-parent', array()) Failed asserting that two strings are identical. --- Expected +++ Actual @@ @@ -'' +'C:\laragon\www\trunk\tests\phpunit\includes/../data/themedir1/default/neither.php' C:\laragon\www\trunk\tests\phpunit\tests\link\themeFile.php:117
This ticket was mentioned in Slack in #hosting-community by desrosj. View the logs.
6 years ago
This ticket was mentioned in Slack in #core by clorith. View the logs.
5 years ago
#9
@
4 years ago
- Keywords needs-refresh added
Latest patch fails against trunk
, so marking for a refresh.
#10
@
4 years ago
- Milestone changed from Awaiting Review to Future Release
- Owner set to SergeyBiryukov
- Status changed from new to accepted
Please see 39975.01.patch which makes the requested change. There is one whitespace change (space at the end of the line) accidentally included.