pelican icon indicating copy to clipboard operation
pelican copied to clipboard

Generation tests on master branch fail due to differing filemodes

Open copperchin opened this issue 2 years ago • 1 comments

  • [x] I have read the Filing Issues and subsequent “How to Get Help” sections of the documentation.

  • [x] I have searched the issues (including closed ones) and believe that this is not a duplicate.

  • OS version and name: Ubuntu 18.04.4 LTS (Bionic) ; via WSL on Windows 10

  • Python version: 3.8.0

  • Pelican version: 4.8.0

  • git version: 2.17.1

Issue

Doesn't appear to be a duplicate, despite similar culprits as #2846:

FAILED pelican/tests/test_pelican.py::TestPelican::test_basic_generation_works
FAILED pelican/tests/test_pelican.py::TestPelican::test_custom_generation_works
================== 2 failed, 237 passed, 24 skipped in 12.78s ==================

Appears to be due to changed filemodes this time:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <pelican.tests.test_pelican.TestPelican testMethod=test_custom_generation_works>
left_path = '/tmp/pelicantests._1clgfn6'
right_path = '/mnt/s/dev/projects/Python/pelican/pelican/tests/output/custom'

    def assertDirsEqual(self, left_path, right_path):
        out, err = subprocess.Popen(
            ['git', '--no-pager', 'diff', '--no-ext-diff', '--exit-code',
             '-w', left_path, right_path],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE
        ).communicate()

        def ignorable_git_crlf_errors(line):
            # Work around for running tests on Windows
            for msg in [
                    "LF will be replaced by CRLF",
                    "CRLF will be replaced by LF",
                    "The file will have its original line endings"]:
                if msg in line:
                    return True
            return False
        if err:
            err = '\n'.join([line for line in err.decode('utf8').splitlines()
                             if not ignorable_git_crlf_errors(line)])
>       assert not out, out
E       AssertionError: b'diff --git a/tmp/pelicantests._1clgfn6/a-markdown-powered-article.html b/mnt/s/dev/projects/Python/pelican/pelican/t... b/mnt/s/dev/projects/Python/pelican/pelican/tests/output/custom/unbelievable.html
E         old mode 100644
E         new mode 100755
E         '
E       assert not b'diff --git a/tmp/pelicantests._1clgfn6/a-markdown-powered-article.html b/mnt/s/dev/projects/Python/pelican/pelican/t... b/mnt/s/dev/projects/Python/pelican/pelican/tests/output/custom/unbelievable.html\nold mode 100644\nnew mode 100755\n'

pelican/tests/test_pelican.py:77: AssertionError

The git config seems to be set alright:

$ git config --local core.filemode
false

Right now it looks like the test is based on whether there's any output from the git diff subprocess (assert not out, out). Rather than check the output/err streams, would it be enough to just assert the subprocess had return value of 0 ?

copperchin avatar Sep 15 '22 22:09 copperchin

The real question is: why is this executable?

/mnt/s/dev/projects/Python/pelican/pelican/tests/output/custom/unbelievable.html

avaris avatar Sep 16 '22 02:09 avaris