| Index: tools/telemetry/telemetry/unittest_util/system_stub.py
|
| diff --git a/tools/telemetry/telemetry/unittest_util/system_stub.py b/tools/telemetry/telemetry/unittest_util/system_stub.py
|
| index 634431e3c545b21823c18246f62f39601d52069f..e0073ca22b9560df6a63c45cd28a04715f67518f 100644
|
| --- a/tools/telemetry/telemetry/unittest_util/system_stub.py
|
| +++ b/tools/telemetry/telemetry/unittest_util/system_stub.py
|
| @@ -291,6 +291,17 @@ class CloudStorageModuleStub(object):
|
| self, self.INTERNAL_BUCKET, remote_path, local_path, True)
|
| return result
|
|
|
| + def GetFilesInDirectoryIfChanged(self, directory, bucket):
|
| + if os.path.dirname(directory) == directory: # If in the root dir.
|
| + raise ValueError('Trying to serve root directory from HTTP server.')
|
| + for dirpath, _, filenames in os.walk(directory):
|
| + for filename in filenames:
|
| + path, extension = os.path.splitext(
|
| + os.path.join(dirpath, filename))
|
| + if extension != '.sha1':
|
| + continue
|
| + self.GetIfChanged(path, bucket)
|
| +
|
| def CalculateHash(self, file_path):
|
| return self.local_file_hashes[file_path]
|
|
|
| @@ -355,6 +366,7 @@ class OsModuleStub(object):
|
| def __init__(self, sys_module):
|
| self.sys = sys_module
|
| self.files = []
|
| + self.dirs = []
|
|
|
| def exists(self, path):
|
| return path in self.files
|
| @@ -362,6 +374,9 @@ class OsModuleStub(object):
|
| def isfile(self, path):
|
| return path in self.files
|
|
|
| + def isdir(self, path):
|
| + return path in self.dirs
|
| +
|
| def join(self, *paths):
|
| def IsAbsolutePath(path):
|
| if self.sys.platform.startswith('win'):
|
| @@ -384,6 +399,10 @@ class OsModuleStub(object):
|
| return tmp.replace('\\', '/')
|
|
|
| @staticmethod
|
| + def abspath(path):
|
| + return os.path.abspath(path)
|
| +
|
| + @staticmethod
|
| def expanduser(path):
|
| return os.path.expanduser(path)
|
|
|
| @@ -395,8 +414,13 @@ class OsModuleStub(object):
|
| def splitext(path):
|
| return os.path.splitext(path)
|
|
|
| + @staticmethod
|
| + def splitdrive(path):
|
| + return os.path.splitdrive(path)
|
| +
|
| X_OK = os.X_OK
|
|
|
| + sep = os.sep
|
| pathsep = os.pathsep
|
|
|
| def __init__(self, sys_module=sys):
|
| @@ -408,6 +432,7 @@ class OsModuleStub(object):
|
| self.program_files = None
|
| self.program_files_x86 = None
|
| self.devnull = os.devnull
|
| + self._directory = {}
|
|
|
| def access(self, path, _):
|
| return path in self.path.files
|
| @@ -430,6 +455,10 @@ class OsModuleStub(object):
|
| def chdir(self, path):
|
| pass
|
|
|
| + def walk(self, top):
|
| + for dir_name in self._directory:
|
| + yield top, dir_name, self._directory[dir_name]
|
| +
|
|
|
| class PerfControlModuleStub(object):
|
| class PerfControlStub(object):
|
|
|