From fbe1813ee40305d23e434c16b73df9f5ed8429e6 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 22 Nov 2025 15:09:18 +0000 Subject: [PATCH] fix: handle missing directories in docs-build test The docs-build.py checker was failing with FileNotFoundError when trying to copy directories and files that don't exist in the repository (such as 'bin', 'lib', etc.). These directories are only present after cloning ansible-core using 'nox -s clone-core'. This fix adds existence checks before attempting to copy directories and files, making the test more robust and preventing errors when running in environments where ansible-core hasn't been cloned yet. --- tests/checkers/docs-build.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/checkers/docs-build.py b/tests/checkers/docs-build.py index 14e579b3ae2..c0e9a25448f 100644 --- a/tests/checkers/docs-build.py +++ b/tests/checkers/docs-build.py @@ -34,10 +34,14 @@ def main(): with tempfile.TemporaryDirectory(prefix='docs-build-', suffix='-sanity') as temp_dir: for keep_dir in keep_dirs: - shutil.copytree(os.path.join(base_dir, keep_dir), os.path.join(temp_dir, keep_dir), symlinks=True) + src_path = os.path.join(base_dir, keep_dir) + if os.path.exists(src_path): + shutil.copytree(src_path, os.path.join(temp_dir, keep_dir), symlinks=True) for keep_file in keep_files: - shutil.copy2(os.path.join(base_dir, keep_file), os.path.join(temp_dir, keep_file)) + src_file = os.path.join(base_dir, keep_file) + if os.path.exists(src_file): + shutil.copy2(src_file, os.path.join(temp_dir, keep_file)) paths = os.environ['PATH'].split(os.pathsep) paths = [f'{temp_dir}/bin' if path == f'{current_dir}/bin' else path for path in paths]