Stop integration tests from running every ninja invocation. It was previously running (in integration_tests/simple) rm -rf out && gn gen out. This changed the mtime of the integration_tests/simple directory, triggering a rebuild. By instead doing rm -rf out/*, we prevent the mtime of the integration test source code from changing. Change-Id: I3cdc6c2822819ea7bb0835b025c38da86a6a6964 Reviewed-on: https://gn-review.googlesource.com/c/gn/+/27980 Reviewed-by: Takuto Ikuta <tikuta@google.com> Commit-Queue: Matt Stark <msta@google.com>
diff --git a/tools/clean.py b/tools/clean.py index 48be64d..88c1ca2 100644 --- a/tools/clean.py +++ b/tools/clean.py
@@ -3,11 +3,20 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -"""A cross-platform rm -rf""" +"""A cross-platform rm -rf path/to/dir/*. + +We specifically don't do rm -rf path/to/dir, because that would change the +mtime of path/to, triggering ninja to rebuild. +""" import os import shutil import sys -if os.path.exists(sys.argv[1]): - shutil.rmtree(sys.argv[1]) +target = sys.argv[1] +if os.path.isdir(target): + for entry in os.scandir(target): + if entry.is_dir(follow_symlinks=False): + shutil.rmtree(entry.path) + else: + os.unlink(entry.path)