Opened 6 months ago
Closed 44 hours ago
#63443 closed defect (bug) (fixed)
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 commit |
| 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.
Attachments (1)
Change History (19)
This ticket was mentioned in PR #8803 on WordPress/wordpress-develop by @aslamdoctor.
6 months ago
#1
- Keywords has-patch has-unit-tests added; needs-patch removed
#2
@
6 months 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 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:
6 months 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:
6 months 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
@
6 months 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
@
6 months ago
- Milestone changed from Awaiting Review to 6.9
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
This ticket was mentioned in Slack in #core-test by sirlouen. View the logs.
6 months ago
#11
@
5 months ago
Test Report
Description
This report validates whether 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 137.0.0.0
- OS: macOS
- Theme: Twenty Twenty-One 2.5
- MU Plugins: None activated
- Plugins:
- Test Reports 1.2.0
Actual Results
- ✅ archive folder is deleted when test case passes
- ✅ archive folder is deleted when test case fails
Supplemental Artifacts
Screencast: https://files.catbox.moe/qgz6cb.mov
@
3 months ago
Ensures ZIP tests clean up the destination archive folder before test run. Prevents leftover dir failures.
#12
@
3 months ago
Test Report
Description
This report validates whether 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 138.0.0.0
- OS: Linux
- Theme: Twenty Twenty-Five 1.2
- MU Plugins: None activated
- Plugins:
- Test Reports 1.2.0
Actual Results
- ✅ Issue resolved with patch and archive folder is deleted even when test fails
@kalpeshh commented on PR #8803:
3 months ago
#13
I think the ticket reference number has a type, it should be // See #63443 for details instead of // See #65443 for details
@wildworks commented on PR #8803:
6 days ago
#15
@kalpeshhiran @mindctrl, 6.9 RC1 is scheduled for release next week, so I wanted to check if this pull request can be included. I have committed all of the suggested code changes myself.
#16
@
3 days ago
- Keywords commit added; dev-feedback removed
@SergeyBiryukov, The PR seems ready for a commit.
@SirLouen commented on PR #8803:
44 hours ago
#17
rmdir
Aren't we already using rmdir in the clean_up_unzip_destination
We also need delete_folders with our test case.
Maybe it's a system environment difficulty. But we tested just with rmdir and were reporting errors.
With delete_folders things were solved; this is why we added it.
Trac ticket: https://core.trac.wordpress.org/ticket/63443