From 5a50fb35df769f5c3d4bc79fa46353dc9b1ebe87 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Fri, 9 Aug 2019 10:54:08 -0700 Subject: [PATCH] Add sanity test for obsolete files. This will help prevent accidental merging of content to recently obsoleted directories when adding new files. It may also help contributors who have modified obsolete files understand where their changes should now be made. --- .../testing/sanity/obsolete-files.rst | 14 ++++++++++++++ test/sanity/code-smell/obsolete-files.json | 16 ++++++++++++++++ test/sanity/code-smell/obsolete-files.py | 19 +++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 docs/docsite/rst/dev_guide/testing/sanity/obsolete-files.rst create mode 100644 test/sanity/code-smell/obsolete-files.json create mode 100755 test/sanity/code-smell/obsolete-files.py diff --git a/docs/docsite/rst/dev_guide/testing/sanity/obsolete-files.rst b/docs/docsite/rst/dev_guide/testing/sanity/obsolete-files.rst new file mode 100644 index 00000000000..6e2fb2a5797 --- /dev/null +++ b/docs/docsite/rst/dev_guide/testing/sanity/obsolete-files.rst @@ -0,0 +1,14 @@ +obsolete-files +============== + +Directories in the Ansible source tree are sometimes made obsolete. +Files should not exist in these directories. +The new location (if any) is dependent on which directory has been made obsolete. + +Below are some of the obsolete directories and their new locations: + +- All of ``test/runner/`` is now under ``test/lib/ansible_test/`` instead. The organization of files in the new directory has changed. +- Most subdirectories of ``test/sanity/`` (with some exceptions) are now under ``test/lib/ansible_test/_data/sanity/`` instead. + +This error occurs most frequently for open pull requests which add or modify files in directories which are now obsolete. +Make sure the branch you are working from is current so that changes can be made in the correct location. diff --git a/test/sanity/code-smell/obsolete-files.json b/test/sanity/code-smell/obsolete-files.json new file mode 100644 index 00000000000..7c527df382a --- /dev/null +++ b/test/sanity/code-smell/obsolete-files.json @@ -0,0 +1,16 @@ +{ + "prefixes": [ + "test/runner/", + "test/sanity/ansible-doc/", + "test/sanity/compile/", + "test/sanity/import/", + "test/sanity/pep8/", + "test/sanity/pslint/", + "test/sanity/pylint/", + "test/sanity/rstcheck/", + "test/sanity/shellcheck/", + "test/sanity/validate-modules/", + "test/sanity/yamllint/" + ], + "output": "path-message" +} diff --git a/test/sanity/code-smell/obsolete-files.py b/test/sanity/code-smell/obsolete-files.py new file mode 100755 index 00000000000..e9ddc8a5de4 --- /dev/null +++ b/test/sanity/code-smell/obsolete-files.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python +"""Prevent files from being added to directories that are now obsolete.""" +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import sys + + +def main(): + """Main entry point.""" + paths = sys.argv[1:] or sys.stdin.read().splitlines() + + for path in paths: + print('%s: directory "%s/" is obsolete and should not contain any files' % (path, os.path.dirname(path))) + + +if __name__ == '__main__': + main()