On 5/27/20 7:50 PM, Martin Liška wrote:
We'll need here a skip based on version of unidiff. So something like:
@pytest.mark.skipif
?
I believe something like:
diff --git a/contrib/gcc-changelog/git_email.py
b/contrib/gcc-changelog/git_email.py
index 6e42629cf07..afa6771c7fe 100755
--- a/contrib/gcc-changelog/git_email.py
+++ b/contrib/gcc-changelog/git_email.py
@@ -54,7 +54,7 @@ class GitEmail(GitCommit):
t = 'A'
elif f.is_removed_file:
t = 'D'
- elif f.is_rename:
+ elif hasattr(f, 'is_rename') and f.is_rename:
# Consider that renamed files are two operations: the deletion
# of the original name and the addition of the new one.
modified_files.append((f.target_file[2:], 'A'))
diff --git a/contrib/gcc-changelog/test_email.py
b/contrib/gcc-changelog/test_email.py
index c188fe9b276..f174f08d15b 100755
--- a/contrib/gcc-changelog/test_email.py
+++ b/contrib/gcc-changelog/test_email.py
@@ -22,10 +22,15 @@ import unittest
from git_email import GitEmail
+import unidiff
+
script_path = os.path.dirname(os.path.realpath(__file__))
+unidiff_supports_renaming = hasattr(unidiff.PatchedFile, 'is_rename')
+
+
class TestGccChangelog(unittest.TestCase):
def setUp(self):
self.patches = {}
@@ -296,6 +301,8 @@ class TestGccChangelog(unittest.TestCase):
'sem_ch8.adb', 'sem_elab.adb', 'sem_type.adb',
'sem_util.adb'])
+ @unittest.skipIf(not unidiff_supports_renaming,
+ 'Newer version of unidiff is needed (0.6.0+)')
def test_renamed_file(self):
email = self.from_patch_glob(
'0001-Ada-Add-support-for-XDR-streaming-in-the-default-run.patch')