def test_output_diffs(self):
        # Test to ensure that we don't generate -pretty.html if PrettyPatch isn't available.
        host = MockHost()
        _, err, _ = logging_run(['--pixel-tests', 'failures/unexpected/text-image-checksum.html'], tests_included=True, host=host)
        written_files = host.filesystem.written_files
        self.assertTrue(any(path.endswith('-diff.txt') for path in written_files.keys()))
        self.assertFalse(any(path.endswith('-pretty-diff.html') for path in written_files.keys()))

        full_results_text = host.filesystem.read_text_file('/tmp/layout-test-results/full_results.json')
        full_results = json.loads(full_results_text.replace("ADD_RESULTS(", "").replace(");", ""))
        self.assertEqual(full_results['has_pretty_patch'], False)
    def test_output_diffs(self):
        # Test to ensure that we don't generate -pretty.html if PrettyPatch isn't available.
        host = MockHost()
        _, err, _ = logging_run(['--pixel-tests', 'failures/unexpected/text-image-checksum.html'], tests_included=True, host=host)
        written_files = host.filesystem.written_files
        self.assertTrue(any(path.endswith('-diff.txt') for path in written_files.keys()))
        self.assertFalse(any(path.endswith('-pretty-diff.html') for path in written_files.keys()))

        full_results_text = host.filesystem.read_text_file('/tmp/layout-test-results/full_results.json')
        full_results = json.loads(full_results_text.replace("ADD_RESULTS(", "").replace(");", ""))
        self.assertEqual(full_results['has_pretty_patch'], False)
Esempio n. 3
0
    def files_under(self, path, dirs_to_skip=[], file_filter=None):
        def filter_all(fs, dirpath, basename):
            return True

        file_filter = file_filter or filter_all
        files = []
        if self.isfile(path):
            if file_filter(self, self.dirname(path), self.basename(path)) and self.files[path] is not None:
                files.append(path)
            return files

        if self.basename(path) in dirs_to_skip:
            return []

        if not path.endswith(self.sep):
            path += self.sep

        dir_substrings = [self.sep + d + self.sep for d in dirs_to_skip]
        for filename in self.files:
            if not filename.startswith(path):
                continue

            suffix = filename[len(path) - 1:]
            if any(dir_substring in suffix for dir_substring in dir_substrings):
                continue

            dirpath, basename = self._split(filename)
            if file_filter(self, dirpath, basename) and self.files[filename] is not None:
                files.append(filename)

        return files
Esempio n. 4
0
    def files_under(self, path, dirs_to_skip=[], file_filter=None):
        def filter_all(fs, dirpath, basename):
            return True

        file_filter = file_filter or filter_all
        files = []
        if self.isfile(path):
            if file_filter(self, self.dirname(path), self.basename(path)):
                files.append(path)
            return files

        if self.basename(path) in dirs_to_skip:
            return []

        if not path.endswith(self.sep):
            path += self.sep

        dir_substrings = [self.sep + d + self.sep for d in dirs_to_skip]
        for filename in self.files:
            if not filename.startswith(path):
                continue

            suffix = filename[len(path) - 1:]
            if any(dir_substring in suffix for dir_substring in dir_substrings):
                continue

            dirpath, basename = self._split(filename)
            if file_filter(self, dirpath, basename):
                files.append(filename)

        return files
Esempio n. 5
0
    def rmtree(self, path):
        if not path.endswith(self.sep):
            path += self.sep

        for f in self.files:
            if f.startswith(path):
                self.files[f] = None
Esempio n. 6
0
    def rmtree(self, path):
        if not path.endswith(self.sep):
            path += self.sep

        for f in self.files:
            if f.startswith(path):
                self.files[f] = None
Esempio n. 7
0
 def normpath(self, path):
     # This function is called a lot, so we try to optimize the common cases
     # instead of always calling _slow_but_correct_normpath(), above.
     if '..' in path or '/./' in path:
         # This doesn't happen very often; don't bother trying to optimize it.
         return self._slow_but_correct_normpath(path)
     if not path:
         return '.'
     if path == '/':
         return path
     if path == '/.':
         return '/'
     if path.endswith('/.'):
         return path[:-2]
     if path.endswith('/'):
         return path[:-1]
     return path
 def normpath(self, path):
     # This function is called a lot, so we try to optimize the common cases
     # instead of always calling _slow_but_correct_normpath(), above.
     if '..' in path or '/./' in path:
         # This doesn't happen very often; don't bother trying to optimize it.
         return self._slow_but_correct_normpath(path)
     if not path:
         return '.'
     if path == '/':
         return path
     if path == '/.':
         return '/'
     if path.endswith('/.'):
         return path[:-2]
     if path.endswith('/'):
         return path[:-1]
     return path
Esempio n. 9
0
 def normpath(self, path):
     # This function is called a lot, so we try to optimize the common cases
     # instead of always calling _slow_but_correct_normpath(), above.
     if ".." in path or "/./" in path:
         # This doesn't happen very often; don't bother trying to optimize it.
         return self._slow_but_correct_normpath(path)
     if not path:
         return "."
     if path == "/":
         return path
     if path == "/.":
         return "/"
     if path.endswith("/."):
         return path[:-2]
     if path.endswith("/"):
         return path[:-1]
     return path
Esempio n. 10
0
    def isdir(self, path):
        if path in self.files:
            return False
        if not path.endswith(self.sep):
            path += self.sep

        # We need to use a copy of the keys here in order to avoid switching
        # to a different thread and potentially modifying the dict in
        # mid-iteration.
        files = self.files.keys()[:]
        return any(f.startswith(path) for f in files)
Esempio n. 11
0
    def isdir(self, path):
        if path in self.files:
            return False
        if not path.endswith(self.sep):
            path += self.sep

        # We need to use a copy of the keys here in order to avoid switching
        # to a different thread and potentially modifying the dict in
        # mid-iteration.
        files = self.files.keys()[:]
        return any(f.startswith(path) for f in files)
Esempio n. 12
0
    def listdir(self, path):
        if not self.isdir(path):
            raise OSError("%s is not a directory" % path)

        if not path.endswith(self.sep):
            path += self.sep

        dirs = []
        files = []
        for f in self.files:
            if self.exists(f) and f.startswith(path):
                remaining = f[len(path):]
                if self.sep in remaining:
                    dir = remaining[:remaining.index(self.sep)]
                    if not dir in dirs:
                        dirs.append(dir)
                else:
                    files.append(remaining)
        return dirs + files
Esempio n. 13
0
    def listdir(self, path):
        if not self.isdir(path):
            raise OSError("%s is not a directory" % path)

        if not path.endswith(self.sep):
            path += self.sep

        dirs = []
        files = []
        for f in self.files:
            if self.exists(f) and f.startswith(path):
                remaining = f[len(path):]
                if self.sep in remaining:
                    dir = remaining[:remaining.index(self.sep)]
                    if not dir in dirs:
                        dirs.append(dir)
                else:
                    files.append(remaining)
        return dirs + files
Esempio n. 14
0
 def abspath(self, path):
     if path.endswith(self.sep):
         return path[:-1]
     return path
Esempio n. 15
0
 def abspath(self, path):
     if path.endswith(self.sep):
         return path[:-1]
     return path