Remove the logic that compares the expected and actual output.
Also split out reading of the file - letting regroup_caps
deal with just the lines for now.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
scripts/group-qemu-caps.py | 51 ++++++++++++++++++++++----------------
1 file changed, 29 insertions(+), 22 deletions(-)
diff --git a/scripts/group-qemu-caps.py b/scripts/group-qemu-caps.py
index 29ab268c4c..dce25099b8 100755
--- a/scripts/group-qemu-caps.py
+++ b/scripts/group-qemu-caps.py
@@ -61,14 +61,9 @@ def load_caps_flags(lines):
return capsflags
-def regroup_caps(check, filename, start_regex, end_regex,
+def regroup_caps(original, start_regex, end_regex,
trailing_newline, counter_prefix, capsflags):
step = 5
-
- original = []
- with open(filename, "r") as fh:
- original = fh.read().splitlines()
-
fixed = []
game_on = False
counter = 0
@@ -108,6 +103,10 @@ def regroup_caps(check, filename, start_regex, end_regex,
fixed.append(line)
+ return fixed
+
+
+def check_wrapping(filename, original, fixed, check):
if check:
orig = "\n".join(original) + "\n"
new = "\n".join(fixed) + "\n"
@@ -142,28 +141,36 @@ header_path = args.prefix + 'src/qemu/qemu_capabilities.h'
source_path = args.prefix + 'src/qemu/qemu_capabilities.c'
header_lines = load_file(header_path)
+source_lines = load_file(source_path)
(start, end) = find_markers(header_lines,
'virQEMUCapsFlags grouping marker',
'QEMU_CAPS_LAST /* this must')
capsflags = load_caps_flags(header_lines[start:end])
-if not regroup_caps(args.check,
- source_path,
- r'virQEMUCaps grouping marker',
- r'\);',
- 0,
- " ",
- capsflags):
- errs = True
+header_fixed = regroup_caps(header_lines,
+ r'virQEMUCapsFlags grouping marker',
+ r'QEMU_CAPS_LAST \/\* this must',
+ 1,
+ " ",
+ None)
+source_fixed = regroup_caps(source_lines,
+ r'virQEMUCaps grouping marker',
+ r'\);',
+ 0,
+ " ",
+ capsflags)
-if not regroup_caps(args.check,
- header_path,
- r'virQEMUCapsFlags grouping marker',
- r'QEMU_CAPS_LAST \/\* this must',
- 1,
- " ",
- None):
- errs = True
+if not check_wrapping(header_path,
+ header_lines,
+ header_fixed,
+ args.check):
+ ret = False
+
+if not check_wrapping(source_path,
+ source_lines,
+ source_fixed,
+ args.check):
+ ret = False
if errs:
sys.exit(1)
--
2.31.1