Skip to content

Instantly share code, notes, and snippets.

@felixfontein
Last active November 16, 2019 15:32
Show Gist options
  • Save felixfontein/219b19f8c39b7755b4482e3c28212d7e to your computer and use it in GitHub Desktop.
Save felixfontein/219b19f8c39b7755b4482e3c28212d7e to your computer and use it in GitHub Desktop.
Update test/sanity/ignore.txt from output.

Run bin/ansible-test sanity --test validate-modules --docker-no-pull --docker.

Put output into ignore-output.txt, and reduce to all ERROR: lines for validate-modules which inform about errors to be added or removed/ignored.

Run this script to update test/sanity/ignore.txt accordingly.

#!/usr/bin/python
import sys
remove_lines = []
add_lines = []
with open("ignore-output.txt", "rt") as f:
for line in f:
line = line.strip()
if line.startswith('ERROR: '):
err, pathlinecol, errcode, text = line.split(' ', 3)
if errcode.endswith(':'):
errcode = errcode[:-1]
path, lineno, col, _ = pathlinecol.split(':')
if text.startswith('Remove since "'):
if path == 'test/sanity/ignore.txt' and '" passes "' in text and text.endswith('" test') and errcode == 'A102':
remove_lines.append(int(lineno))
else:
raise Exception('Cannot interpret line: ' + line)
elif text.startswith("Ignoring '") and text.endswith("' is unnecessary"):
if path == 'test/sanity/ignore.txt' and errcode == 'A100':
remove_lines.append(int(lineno))
else:
raise Exception('Cannot interpret line: ' + line)
else:
add_lines.append('{0} validate-modules:{1}'.format(path, errcode))
with open("test/sanity/ignore.txt", "rt") as f:
lines = f.readlines()
for l in reversed(sorted(remove_lines)):
del lines[l - 1]
# Add new lines
lines.extend([line + '\n' for line in add_lines])
# Sort lines and remove duplicates
lines = sorted(lines)
i = 0
while i + 1 < len(lines):
if lines[i] == lines[i + 1]:
del lines[i + 1]
else:
i += 1
with open("test/sanity/ignore.txt", "wt") as f:
f.write(''.join(lines))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment