Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Finder] Exclude relative to content root if prefixed / #54754

Open
wants to merge 4 commits into
base: 7.1
Choose a base branch
from

Conversation

phil-davis
Copy link
Contributor

Q A
Branch? 7.1
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #28158 #47431
License MIT

I had some test enhancements ready to be used against code for this. So this PR to the 7.1 branch has:

  • add multi-level unit test items for Finder tests - that commit adds a top/foo/file.tmp multi-level directory tree to the set of directories and files used by the Finder unit tests. That demonstrates the current behaviour, so we can ensure that the new feature does not introduce regressions. These tests pass with the existing 7.1 branch code.
  • add more comments about Finder exclude, to say that starting the excluded string with / will then only exclude that folder name at the root (top) level of the tree.
  • add test for root-level finder exclude, showing the expected behavior of the new feature
  • fix(Finder): ExcludeDirectoryFilterIterator relative to "root" if / - cherry-pick of the code provided in PR [Finder] Exclude relative to content root if prefixed / #54752

I probably have more unit test cases to add, let's see what CI thinks so far...

@phil-davis phil-davis marked this pull request as ready for review April 27, 2024 16:43
@carsonbot carsonbot added this to the 7.1 milestone Apr 27, 2024
@symfony symfony deleted a comment from carsonbot Apr 27, 2024
Comment on lines -1650 to +1767
]
]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code format checker wanted me to unindent this ], even though it is indented in the current 7.1 branch code.
I suppose that the current code in the 7.1 branch does not pass the code format checker - strange.

]), $finder->in(self::$tmpDir)->getIterator());
}

public function testExcludeTopLevelOnly()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the new test case. The top-level foo has been excluded, but top/foo and top/foo/file.tmp are still included, which is what we want the new feature to do.

@phil-davis
Copy link
Contributor Author

phil-davis commented Apr 27, 2024

https://ci.appveyor.com/project/fabpot/symfony/builds/49703585

There was 1 failure:
1) Symfony\Component\Finder\Tests\FinderTest::testRelativePath
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
     16 => 'qux'
     17 => 'qux'
     18 => 'top'
-    19 => 'top/foo'
+    19 => 'top\foo'
 )
C:\projects\symfony\src\Symfony\Component\Finder\Tests\FinderTest.php:1311
FAILURES!
Tests: 687, Assertions: 4154, Failures: 1, Skipped: 6, Incomplete: 1.
KO src\Symfony/Component/Finder

I need to adjust a unit test to cope with the directory separator being different in the appveyor build. - done

@phil-davis
Copy link
Contributor Author

https://github.com/symfony/symfony/actions/runs/8861398010/job/24333227688?pr=54754

If you did not receive a copy of the PHP license, or have any
questions about PHP licensing, please contact license@php.net.
/home/runner/work/_temp/494f96ef-04e0-4ed8-bd26-ffe291f3a7d8.sh: line 2: 24082 Segmentation fault      (core dumped) php -i
Error: Process completed with exit code 139.

Integration (8.2) failed when "Display versions" got a segmentation fault! I don't think that the changes in this PR caused that.

@phil-davis
Copy link
Contributor Author

Unit Tests (8.4) fail with various things, I suppose that PHP 8.4 support is coming, and hasn't been finished yet.

@phil-davis
Copy link
Contributor Author

https://ci.appveyor.com/project/fabpot/symfony/builds/49703627

Testing C:\projects\symfony\src\Symfony\Component\AssetMapper
....................E..........................................  63 / 287 ( 21%)
............................................................... 126 / 287 ( 43%)
............................................................... 189 / 287 ( 65%)
............................................................... 252 / 287 ( 87%)
...................................                             287 / 287 (100%)
Time: 00:42.674, Memory: 32.00 MB
There was 1 error:
1) Symfony\Component\AssetMapper\Tests\Command\AssetMapperCompileCommandTest::testAssetsAreCompiled
Symfony\Component\Filesystem\Exception\IOException: Failed to remove directory "C:\projects\symfony\src\Symfony\Component\AssetMapper\Tests\Fixtures/var": rmdir(C:\projects\symfony\src\Symfony\Component\AssetMapper\Tests\Fixtures/var): Directory not empty
C:\projects\symfony\src\Symfony\Component\Filesystem\Filesystem.php:194
C:\projects\symfony\src\Symfony\Component\Filesystem\Filesystem.php:153
C:\projects\symfony\src\Symfony\Component\AssetMapper\Tests\Command\AssetMapperCompileCommandTest.php:39
ERRORS!
Tests: 287, Assertions: 821, Errors: 1.
KO src\Symfony/Component/AssetMapper

Is that a known unit test failure?
I don't see how this PR can cause that failure.

@joshtrichards
Copy link

Thanks for digging into the tests! I'll try to take a closer look at your PR in the week ahead.

@xabbuh xabbuh modified the milestones: 7.1, 7.2 May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

There is no way to exclude path only from root directory
4 participants