summaryrefslogtreecommitdiffstats
path: root/test/sanity
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2018-04-07 00:48:02 +0200
committerMatt Clay <matt@mystile.com>2018-04-13 00:56:49 +0200
commit26fa3adeab44e478b1984da38619eab59b08c13d (patch)
treeb4d6495d3efd74397943fba6542e1c228ab0854b /test/sanity
parentSuppress a UserWarning about unknown dist option (diff)
downloadansible-26fa3adeab44e478b1984da38619eab59b08c13d.tar.xz
ansible-26fa3adeab44e478b1984da38619eab59b08c13d.zip
Add docs-build sanity test.
Diffstat (limited to 'test/sanity')
-rw-r--r--test/sanity/code-smell/docs-build.json4
-rwxr-xr-xtest/sanity/code-smell/docs-build.py55
2 files changed, 59 insertions, 0 deletions
diff --git a/test/sanity/code-smell/docs-build.json b/test/sanity/code-smell/docs-build.json
new file mode 100644
index 0000000000..376970e682
--- /dev/null
+++ b/test/sanity/code-smell/docs-build.json
@@ -0,0 +1,4 @@
+{
+ "always": true,
+ "output": "path-line-column-message"
+}
diff --git a/test/sanity/code-smell/docs-build.py b/test/sanity/code-smell/docs-build.py
new file mode 100755
index 0000000000..614114436d
--- /dev/null
+++ b/test/sanity/code-smell/docs-build.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+
+import os
+import re
+import subprocess
+
+
+def main():
+ base_dir = os.getcwd() + os.sep
+ docs_dir = os.path.abspath('docs/docsite')
+ cmd = ['make', 'singlehtmldocs']
+
+ sphinx = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=docs_dir)
+ stdout, stderr = sphinx.communicate()
+
+ if sphinx.returncode != 0:
+ raise subprocess.CalledProcessError(sphinx.returncode, cmd, output=stdout, stderr=stderr)
+
+ with open('docs/docsite/rst_warnings', 'r') as warnings_fd:
+ output = warnings_fd.read().strip()
+ lines = output.splitlines()
+
+ for line in lines:
+ match = re.search('^(?P<path>[^:]+):((?P<line>[0-9]+):)?((?P<column>[0-9]+):)? (?P<level>WARNING|ERROR): (?P<message>.*)$', line)
+
+ if not match:
+ path = 'docs/docsite/rst/index.rst'
+ lineno = 0
+ column = 0
+ level = 'unknown'
+ message = line
+
+ # surface unknown lines while filtering out known lines to avoid excessive output
+ print('%s:%d:%d: %s: %s' % (path, lineno, column, level, message))
+ continue
+
+ path = match.group('path')
+ lineno = int(match.group('line') or 0)
+ column = int(match.group('column') or 0)
+ level = match.group('level').lower()
+ message = match.group('message')
+
+ path = os.path.abspath(path)
+
+ if path.startswith(base_dir):
+ path = path[len(base_dir):]
+
+ if level == 'warning':
+ continue
+
+ print('%s:%d:%d: %s: %s' % (path, lineno, column, level, message))
+
+
+if __name__ == '__main__':
+ main()