Fix a non-determinism I added in the ANTLR support

Review Request #4187 — Created Aug. 25, 2016 and submitted

jsirois, stuhood, wisechengyi
Fix a non-determinism I added in the ANTLR support

I ran the, including an updated test to check that the empty directory removal is functioning.

I also ran "pants idea" again on the test project, to make sure it is still working as desired.

Travis CI tests are in progress.

  1. The recent patch I submitted to the ANTLR support has an accidental reliance on the iteration order of os.walk. If it starts by iterating the Java files generated by ANTLR, then everything works. If it iterates them last, then there is a problem: the code will delete the target directories it is planning to move the Java files into, before it ever sees the Java files.

    This patch simplifies the logic and avoids the non-determinism. It also changes to using safe_walk, which I take to be better style.

    I’m not sure how to add a test for the problem, since it depends on non-deterministic behavior of os.walk.

  1. Ship It!
Review request changed

Status: Closed (submitted)

Change Summary:

Submitted at aa01643

  1. Must not have pushed that last change to master. Re-merged and pushed aa01643