[diffoscope] 01/01: test_dtb.py: Only parse the version number, not any "-dirty" suffix. (Closes: #880279)

Chris Lamb chris at chris-lamb.co.uk
Fri Nov 3 09:01:54 UTC 2017


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository diffoscope.

commit d4ce05062e0368549ffe34276233f48f9ab68900
Author: Chris Lamb <lamby at debian.org>
Date:   Fri Nov 3 10:01:39 2017 +0100

    test_dtb.py: Only parse the version number, not any "-dirty" suffix. (Closes: #880279)
---
 tests/comparators/test_dtb.py | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/tests/comparators/test_dtb.py b/tests/comparators/test_dtb.py
index 635ff30..eeb5db6 100644
--- a/tests/comparators/test_dtb.py
+++ b/tests/comparators/test_dtb.py
@@ -18,6 +18,7 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
 
+import re
 import pytest
 import subprocess
 
@@ -35,14 +36,16 @@ dtb2 = load_fixture('devicetree2.dtb')
 
 
 def fdtdump_version():
-    out = subprocess.check_output(('fdtdump', '--version'), stderr=subprocess.STDOUT)
-    # We are looking for a line like
-    #   Version: DTC 1.4.5
-    # that usually is placed last
-    for line in reversed(out.decode().splitlines()):
-        if line.startswith('Version: '):
-            return line.split()[2]
-    raise ValueError('Error parsing `fdtdump --version` output')
+    out = subprocess.check_output(
+        ('fdtdump', '--version'),
+        stderr=subprocess.STDOUT,
+    ).decode('utf-8')
+
+    m = re.search(r'Version: DTC (?P<version>\d+\.\d+\.\d+)', out)
+    if m is None:
+        raise ValueError("Error parsing `fdtdump --version` output")
+
+    return m.group('version')
 
 
 def test_identification(dtb1):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git



More information about the Reproducible-commits mailing list