Skip to content

Commit ded29a6

Browse files
committed
Fix build.py for Rust tests
Incredibly, Python's `shutil.copytree` doesn't do what it says when copying a tree containing a symlink over the same tree containing the same symlink. Therefore, we remove the directory first before copying over it, and copy over it at most once per build.
1 parent 4cf6b4f commit ded29a6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/rust/build.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,23 @@ def cp(src, dst):
6565
if not args.dry_run:
6666
shutil.copy(src, dst)
6767

68+
def rm_rf(dst):
69+
if args.verbose:
70+
print(f"rm -rf {dst}")
71+
if not args.dry_run:
72+
if dst.exists():
73+
if dst.is_dir():
74+
shutil.rmtree(dst)
75+
else:
76+
dst.unlink()
77+
78+
ALREADY_COPIED = {}
6879
def cp_R(src, dst):
80+
if src in ALREADY_COPIED:
81+
return
82+
else:
83+
ALREADY_COPIED[src] = dst
84+
rm_rf(dst)
6985
if args.verbose:
7086
print(f"cp -R {src} {dst}")
7187
if not args.dry_run:

0 commit comments

Comments
 (0)