From 8dd79fbbd229b3d29dad80f3cbbe7fc3d982d322 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Wed, 28 Aug 2019 17:34:12 -0400 Subject: [PATCH] Show doc URL for sanity test failures --- test/lib/ansible_test/_internal/test.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/lib/ansible_test/_internal/test.py b/test/lib/ansible_test/_internal/test.py index 9a26f48714d..e31a6f0dc22 100644 --- a/test/lib/ansible_test/_internal/test.py +++ b/test/lib/ansible_test/_internal/test.py @@ -4,11 +4,13 @@ __metaclass__ = type import datetime import os +import re from . import types as t from .util import ( display, + get_ansible_version, ) from .util_common import ( @@ -276,6 +278,10 @@ class TestFailure(TestResult): for message in self.messages: display.error(message.format(show_confidence=True)) + doc_url = self.find_docs() + if doc_url: + display.info('See documentation for help: %s' % doc_url) + def write_lint(self): """Write lint results to stdout.""" if self.summary: @@ -358,7 +364,15 @@ class TestFailure(TestResult): """ :rtype: str """ - testing_docs_url = 'https://docs.ansible.com/ansible/devel/dev_guide/testing' + + # Use the major.minor version for the URL only if this a release that + # matches the pattern 2.4.0, otherwise, use 'devel' + ansible_version = get_ansible_version() + url_version = 'devel' + if re.search(r'^[0-9.]+$', ansible_version): + url_version = '.'.join(ansible_version.split('.')[:2]) + + testing_docs_url = 'https://docs.ansible.com/ansible/%s/dev_guide/testing' % url_version testing_docs_dir = 'docs/docsite/rst/dev_guide/testing' url = '%s/%s/' % (testing_docs_url, self.command)