Skip to content

Commit

Permalink
Test content generation with git diff return value
Browse files Browse the repository at this point in the history
Rather than trying to parse output of subprocess, just check the return
value.

Fix #3042
  • Loading branch information
copperchin committed Sep 16, 2022
1 parent 2a7e691 commit e77f810
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions pelican/tests/test_pelican.py
Expand Up @@ -55,27 +55,15 @@ def tearDown(self):
super().tearDown()

def assertDirsEqual(self, left_path, right_path):
out, err = subprocess.Popen(
proc = 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
assert not err, err
proc.wait()
assert proc.returncode == 0

def test_order_of_generators(self):
# StaticGenerator must run last, so it can identify files that
Expand Down

0 comments on commit e77f810

Please sign in to comment.