• Kai Ninomiya's avatar
    Implement FileSystem.rmtree for long paths on Windows · 2eb368c0
    Kai Ninomiya authored
    Changes blinkpy filesystem tests to use remove_contents instead of
    rmtree. remove_contents calls into rmtree, but
      (1) retries several times to delete the files, and
      (2) throws by default instead of silently swallowing errors.
    This improves all of the tests. Additionally, the retrying was
    actually necessary to pass many tests (files were otherwise still
    locked during teardown).
    
    Extends the test_long_paths test to check spaces and apostrophes.
    
    FileSystem.rmtree is now implemented on Windows by just calling
    a shell with "rmdir /s /q". This is necessary, because
    shutil.rmtree doesn't work for \\?\C:\ style "extended-length" paths
    on Windows, and several other implementations I tried didn't work:
      - Loop using os.walk. os.walk doesn't support long paths, and
        though it seemed to work on the bots, it failed tests locally.
      - Recursive using os.listdir. os.listdir also doesn't support long
        paths.
    
    Tested on dawn-win10-* try job on crrev.com/c/2050036/17.
    Found in dawn-win10-* try jobs on crrev.com/c/2050036/4.
    
    Change-Id: I7c67bb12305a41244829e35293edfc88901b76f4
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2058065
    Commit-Queue: Kai Ninomiya <kainino@chromium.org>
    Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#742961}
    2eb368c0
filesystem.py 16.9 KB