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

test_cli.py: test_find_files_recursively() breaks when build directory sorts before /etc #373

Open
siriobalmelli opened this issue Apr 2, 2021 · 1 comment

Comments

@siriobalmelli
Copy link

see

yamllint/tests/test_cli.py

Lines 152 to 158 in 0fff4e2

items = [os.path.join(self.wd, 'sub'),
os.path.join(self.wd, '/etc/another/file')]
self.assertEqual(
sorted(cli.find_files_recursively(items, conf)),
[os.path.join(self.wd, '/etc/another/file'),
os.path.join(self.wd, 'sub/directory.yaml/empty.yml'),
os.path.join(self.wd, 'sub/ok.yaml')],

The semantics of os.path.join are such that:

import os
pwd = '/an/inconvenient/dir'
absolute = os.path.join(pwd, '/etc/another/file')
relative = os.path.join(pwd, 'sub/directory.yaml/empty.yml')
absolute < relative  # False
pwd = '/home/user'
relative = os.path.join(pwd, 'sub/directory.yaml/empty.yml')
absolute < relative  # True

Recommend turning /etc/another/file into a relative path.

@siriobalmelli
Copy link
Author

Thank you to @dotlambda for linking to the proper lines in test_cli.py

siriobalmelli added a commit to siriobalmelli/nixpkgs that referenced this issue Apr 2, 2021
Fix Darwin build: disable broken tests on BSDs;
see adrienverge/yamllint#307.

Report failure of test_find_files_recursively upstream;
see adrienverge/yamllint#373.

Signed-off-by: Sirio Balmelli <sirio@b-ad.ch>
Co-authored-by: Robert Schütz <dev@schuetz-co.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant