script: Fix failing build_xc job
authorNoel Power <noel.power@suse.com>
Wed, 5 Dec 2018 16:37:17 +0000 (16:37 +0000)
committerNoel Power <npower@samba.org>
Mon, 10 Dec 2018 09:38:25 +0000 (10:38 +0100)
build_xc job uses compare_cc_results.py to compare cache
files, the cache files are stringified hash maps, the results
in python 3.4 don't compare well due to inconsistent order of
dict key/value pairs when the cache files are created. While
comparing the file contents works fine in python3.6 it fails
with python3.4. This patch detects problematic dict lines and
rewrites the value for comparison

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
script/compare_cc_results.py

index 570f454ca9cce34429c21081de9161da24c7e4b5..8ff7bde6564ddd1cd088aff70fe3988ac564ae28 100755 (executable)
@@ -33,8 +33,22 @@ for fname in sys.argv[1:]:
             continue
         if len(line.split('=', 1)) == 2:
             key = line.split('=', 1)[0].strip()
+            value = line.split('=', 1)[1].strip()
             if key in exceptions:
                 continue
+            # using waf with python 3.4 seems to randomly sort dict keys
+            # we can't modify the waf code but we can fake a dict value
+            # string representation as if it were sorted. python 3.6.5
+            # doesn't seem to suffer from this behaviour
+            if value.startswith('{'):
+                import ast
+                amap = ast.literal_eval(value)
+                fakeline = ""
+                for k in sorted(amap.keys()):
+                    if not len(fakeline) == 0:
+                        fakeline = fakeline + ", "
+                    fakeline = fakeline + '\'' + k + '\': \'' + amap[k] + '\''
+                line = key + ' = {' + fakeline + '}'
         lines.append(line)
     f.close()
     if base_fname: