Opened 5 weeks ago
Last modified 4 weeks ago
#63443 reviewing defect (bug)
ZIP tests not checking potential clean directory
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.9 | Priority: | normal |
Severity: | trivial | Version: | |
Component: | External Libraries | Keywords: | good-first-bug has-patch has-unit-tests dev-feedback |
Focuses: | tests | Cc: |
Description
During some tests, completely out of the blue, I found that the tests
test_should_apply_unzip_file_filters
test_should_apply_pre_unzip_file_filters
in both tests/phpunit/tests/filesystem/unzipFilePclzip.php
and tests/phpunit/tests/filesystem/unzipFileZiparchive.php
Were failing
For some reason, if the tests happen to fail, they leave the archive
directory undeleted, with root
as owner, and since it's not going to handle it anymore future executions of mkdir
are going to fail.
Solution: Build a test setup function to check existences and clean directories before running the tests.
Change History (10)
This ticket was mentioned in PR #8803 on WordPress/wordpress-develop by @aslamdoctor.
5 weeks ago
#1
- Keywords has-patch has-unit-tests added; needs-patch removed
#2
@
5 weeks ago
I have created a PR for this.
Instructions for testing:
- Manually create "archive" directory under
/tests/phpunit/data/filesystem
- Update the code in both files where it says
$this->assertSame( 1, $filter->get_call_count() );
to$this->assertSame( 2, $filter->get_call_count() );
. By doing this, it will intentionally fail the test. - Now run both tests one by one :
npm run test:php -- --filter=Tests_Filesystem_UnzipFilePclzip::test_should_apply_unzip_file_filters npm run test:php -- --filter=Tests_Filesystem_UnzipFileZiparchive::test_should_apply_unzip_file_filters
- Now check the "archive" directory is still there under
/tests/phpunit/data/filesystem
. - It should be removed in any case whether the test fails or passes.
@SirLouen commented on PR #8803:
5 weeks ago
#3
@aslamdoctor
Looks good to me.
But I think it will be better to add cleanup_unzip_destination
to tests/phpunit/includes/abstract-testcase.php
(always try to DRY)
@SirLouen commented on PR #8803:
5 weeks ago
#6
Ok, now things are looking good, but it seems that two tests are still failing:
1) Tests_Filesystem_UnzipFilePclzip::test_should_apply_pre_unzip_file_filters mkdir(): File exists /var/www/tests/phpunit/tests/filesystem/unzipFilePclzip.php:44 ERRORS! Tests: 4, Assertions: 3, Errors: 1.
Because we forgot to add the cleanup_unzip_destination
in the method test_should_apply_pre_unzip_file_filters
.
for both: tests/phpunit/tests/filesystem/unzipFileZiparchive.php
And: tests/phpunit/tests/filesystem/unzipFilePclzip.php
Finally, for PHPCS compliance: Inline comments must end in full-stops, exclamation marks, or question marks
(Just add a full stop by the end of each comment, like: // See #65443 for details.
And with this, I think we are done.
#8
@
5 weeks ago
- Keywords dev-feedback added; changes-requested removed
Test Report
Description
This report validates that the indicated patch works as expected.
Patch tested: https://github.com/WordPress/wordpress-develop/pull/8803.diff
Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.28
- Server: nginx/1.27.5
- Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
- Browser: Chrome 136.0.0.0
- OS: Windows 10/11
- Theme: Twenty Twenty-Five 1.2
- MU Plugins: None activated
- Plugins:
- Test Reports 1.2.0
Reproduction Steps
- Followed these steps
Actual Results
- ✅ Issue resolved with patch.
#9
@
5 weeks ago
- Milestone changed from Awaiting Review to 6.9
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
Trac ticket: https://core.trac.wordpress.org/ticket/63443