diff options
author | David Neto <dneto@google.com> | 2016-10-05 14:32:04 -0400 |
---|---|---|
committer | David Neto <dneto@google.com> | 2016-10-07 11:01:19 -0400 |
commit | 868ead3c89e47108b96c1acb620a361c64824191 (patch) | |
tree | 50db0e92cfce4b38a55f99a7aa8c3d37b6d9030c | |
parent | b2248ab0d7b21a9793d7aa9c2b1b742e81c3e13b (diff) | |
download | shaderc-868ead3c89e47108b96c1acb620a361c64824191.tar.gz |
When copying tests, only catch ENOENT exception
Before, we were catching too-broad a set of exceptions.
On Windows sometimes you might not be able to remove the
original directory, e.g. since a process might be running
in that directory. That can lead to spurious test failures where
tests would run but compare to stale base results.
Also:
- sort the test file list, for nicer debugging.
- fix linting warnings for unused variables.
-rwxr-xr-x | utils/copy-tests-if-necessary.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/utils/copy-tests-if-necessary.py b/utils/copy-tests-if-necessary.py index 575b03b..f47e816 100755 --- a/utils/copy-tests-if-necessary.py +++ b/utils/copy-tests-if-necessary.py @@ -23,6 +23,7 @@ intermediate-dir is optional, it specifies that there the additional directory between the root, and the tests/binary. """ +import errno import os import shutil import sys @@ -33,13 +34,13 @@ def get_modified_times(path): filename:last_modified_time pairs for all files rooted at path. """ output = [] - for root, dirnames, filenames in os.walk(path): + for root, _, filenames in os.walk(path): for filename in filenames: fullpath = os.path.join(root, filename) output.append( filename + ":" + - str(os.path.getmtime(os.path.join(root, filename))) + "\n") - return "".join(output) + str(os.path.getmtime(fullpath)) + "\n") + return "".join(sorted(output)) def read_file(path): @@ -73,8 +74,7 @@ def substitute_file(path, substitution): def substitute_files(path, substitution): """Runs substitute_file() on all files rooted at path.""" - f_input = "" - for root, dirnames, filenames in os.walk(path): + for root, _, filenames in os.walk(path): for filename in filenames: substitute_file(os.path.join(root, filename), substitution) @@ -85,9 +85,12 @@ def setup_directory(source, dest): """ try: shutil.rmtree(dest) - except: + except OSError as e: # shutil will throw if it could not find the directory. - pass + if e.errno == errno.ENOENT: + pass + else: + raise shutil.copytree(source, dest) |