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

Only show files within the directory #118

Closed
xsawyerx opened this issue Jan 31, 2022 · 2 comments
Closed

Only show files within the directory #118

xsawyerx opened this issue Jan 31, 2022 · 2 comments
Labels
bug Something isn't working cPanel Test Suite

Comments

@xsawyerx
Copy link
Contributor

xsawyerx commented Jan 31, 2022

UPDATED

use Test::MockFile ();
use DDP;

my $d1 = Test::MockFile->dir('/foo/bar');
my $d2 = Test::MockFile->dir('/foo');
mkdir $d1->path();
mkdir $d2->path();

my $f = Test::MockFile->file( '/foo/bar/baz', '' );

opendir my $dh, '/foo' or die $!;
my @contents = readdir $dh;
closedir $dh or die $!;

p @contents;

The output is currently:

$>perl -Ilib t/tmp.t 
[
    [0] ".",
    [1] "..",
    [2] "bar",
    [3] "bar/baz"
]

it should be

$>perl -Ilib t/tmp.t 
[
    [0] ".",
    [1] "..",
    [2] "bar",
]
@xsawyerx xsawyerx added bug Something isn't working cPanel Test Suite labels Jan 31, 2022
xsawyerx added a commit to xsawyerx/Test-MockFile that referenced this issue Jan 31, 2022
We would grab all files in the directory recursively, but directory
listing should only show the directories inside it, not the files
within those directories.

In other words:

    foo/
        bar/
            baz.txt

`readdir($path_to_foo)` should show `bar`, not `bar/baz.txt`.

Resolves GH cpanel#118
@atoomic
Copy link
Contributor

atoomic commented Jan 31, 2022

maybe reverse $d1 and $d2 mkdir order?

xsawyerx added a commit to xsawyerx/Test-MockFile that referenced this issue Jan 31, 2022
We would grab all files in the directory recursively, but directory
listing should only show the directories inside it, not the files
within those directories.

In other words:

    foo/
        bar/
            baz.txt

`readdir($path_to_foo)` should show `bar`, not `bar/baz.txt`.

Resolves GH cpanel#118
xsawyerx added a commit to xsawyerx/Test-MockFile that referenced this issue Jan 31, 2022
We would grab all files in the directory recursively, but directory
listing should only show the directories inside it, not the files
within those directories.

In other words:

    foo/
        bar/
            baz.txt

`readdir($path_to_foo)` should show `bar`, not `bar/baz.txt`.

Resolves GH cpanel#118

Unfortunately, because of our naive structure types (an array of string),
we may find both a directory and a file within that directory, so we also
need to uniq'ify the results.
toddr pushed a commit that referenced this issue Jan 31, 2022
We would grab all files in the directory recursively, but directory
listing should only show the directories inside it, not the files
within those directories.

In other words:

    foo/
        bar/
            baz.txt

`readdir($path_to_foo)` should show `bar`, not `bar/baz.txt`.

Resolves GH #118

Unfortunately, because of our naive structure types (an array of string),
we may find both a directory and a file within that directory, so we also
need to uniq'ify the results.
@toddr
Copy link
Member

toddr commented Jan 31, 2022

this is working correctly now.

@toddr toddr closed this as completed Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cPanel Test Suite
Development

No branches or pull requests

3 participants