Prevent cleanup error at end of pants test with --test-junit-html-report option, update safe_rmtree to be symlink aware
Review Request #4319 - Created Oct. 16, 2016 and submitted
If you run ./pants test in our repo twice on JVM targets without cleaning up in between you'll see this error:... File ".../pants/backend/jvm/tasks/junit_run.py", line 667, in _isolation shutil.rmtree(path) File ".../Versions/2.7/lib/python2.7/shutil.py", line 232, in rmtree onerror(os.path.islink, path, sys.exc_info()) File ".../Versions/2.7/lib/python2.7/shutil.py", line 230, in rmtree raise OSError("Cannot call rmtree on a symbolic link")
To repro in the pants repo, run:./pants clean-all ./pants test tests/java/org/pantsbuild/args4j --test-junit-html-report ./pants test tests/java/org/pantsbuild/args4j --test-junit-html-report
Fails on the second time running the test goal.
During debugging, I found the path its trying to remove is
.pants.d/test/junit/reports$ ls -l .pants.d/test/junit/reports .pants.d/test/junit/reports -> /Users/zundel/Src/pants-release/.pants.d/test/junit/_runs/68509c3d71dcf475c816117b0b4130f9547cab8b/reports
This link is safe to delete at this point, it gets recreated later.
I fixed this by substituting
shutil.rmtreeand adding symlink awareness into that library call
CI running at https://travis-ci.org/pantsbuild/pants/builds/168062004
Tested locally and the symlink is recreated and the HTML report is still available.
Update comment for safe_rmtree()
Revision 2 (+21 -4)