Skip to content

Commit fbe1813

Browse files
committed
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.
1 parent 06716c7 commit fbe1813

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tests/checkers/docs-build.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@ def main():
3434

3535
with tempfile.TemporaryDirectory(prefix='docs-build-', suffix='-sanity') as temp_dir:
3636
for keep_dir in keep_dirs:
37-
shutil.copytree(os.path.join(base_dir, keep_dir), os.path.join(temp_dir, keep_dir), symlinks=True)
37+
src_path = os.path.join(base_dir, keep_dir)
38+
if os.path.exists(src_path):
39+
shutil.copytree(src_path, os.path.join(temp_dir, keep_dir), symlinks=True)
3840

3941
for keep_file in keep_files:
40-
shutil.copy2(os.path.join(base_dir, keep_file), os.path.join(temp_dir, keep_file))
42+
src_file = os.path.join(base_dir, keep_file)
43+
if os.path.exists(src_file):
44+
shutil.copy2(src_file, os.path.join(temp_dir, keep_file))
4145

4246
paths = os.environ['PATH'].split(os.pathsep)
4347
paths = [f'{temp_dir}/bin' if path == f'{current_dir}/bin' else path for path in paths]

0 commit comments

Comments
 (0)