mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1105090 - Update ccache parser against version 3.2. r=gps
ccache version 3.2 adds primary config and secondary config in the statistic report. Update the ccache stats parser to support that.
This commit is contained in:
parent
e1eaa1f5df
commit
372d769fb9
@ -490,6 +490,8 @@ class CCacheStats(object):
|
||||
]
|
||||
|
||||
DIRECTORY_DESCRIPTION = "cache directory"
|
||||
PRIMARY_CONFIG_DESCRIPTION = "primary config"
|
||||
SECONDARY_CONFIG_DESCRIPTION = "secondary config (readonly)"
|
||||
ABSOLUTE_KEYS = {'cache_max_size'}
|
||||
FORMAT_KEYS = {'cache_size', 'cache_max_size'}
|
||||
|
||||
@ -501,6 +503,8 @@ class CCacheStats(object):
|
||||
"""Construct an instance from the output of ccache -s."""
|
||||
self._values = {}
|
||||
self.cache_dir = ""
|
||||
self.primary_config = ""
|
||||
self.secondary_config = ""
|
||||
|
||||
if not output:
|
||||
return
|
||||
@ -513,15 +517,20 @@ class CCacheStats(object):
|
||||
def _parse_line(self, line):
|
||||
if line.startswith(self.DIRECTORY_DESCRIPTION):
|
||||
self.cache_dir = self._strip_prefix(line, self.DIRECTORY_DESCRIPTION)
|
||||
return
|
||||
|
||||
for stat_key, stat_description in self.STATS_KEYS:
|
||||
if line.startswith(stat_description):
|
||||
raw_value = self._strip_prefix(line, stat_description)
|
||||
self._values[stat_key] = self._parse_value(raw_value)
|
||||
break
|
||||
elif line.startswith(self.PRIMARY_CONFIG_DESCRIPTION):
|
||||
self.primary_config = self._strip_prefix(
|
||||
line, self.PRIMARY_CONFIG_DESCRIPTION)
|
||||
elif line.startswith(self.SECONDARY_CONFIG_DESCRIPTION):
|
||||
self.secondary_config = self._strip_prefix(
|
||||
line, self.SECONDARY_CONFIG_DESCRIPTION)
|
||||
else:
|
||||
raise ValueError('Failed to parse ccache stats output: %s' % line)
|
||||
for stat_key, stat_description in self.STATS_KEYS:
|
||||
if line.startswith(stat_description):
|
||||
raw_value = self._strip_prefix(line, stat_description)
|
||||
self._values[stat_key] = self._parse_value(raw_value)
|
||||
break
|
||||
else:
|
||||
raise ValueError('Failed to parse ccache stats output: %s' % line)
|
||||
|
||||
@staticmethod
|
||||
def _strip_prefix(line, prefix):
|
||||
|
@ -59,6 +59,27 @@ class TestCcacheStats(unittest.TestCase):
|
||||
cache size 2.0 Gbytes
|
||||
max cache size 16.0 Gbytes"""
|
||||
|
||||
STAT3 = """
|
||||
cache directory /Users/tlin/.ccache
|
||||
primary config /Users/tlin/.ccache/ccache.conf
|
||||
secondary config (readonly) /usr/local/Cellar/ccache/3.2/etc/ccache.conf
|
||||
cache hit (direct) 12004
|
||||
cache hit (preprocessed) 1786
|
||||
cache miss 26348
|
||||
called for link 2338
|
||||
called for preprocessing 6313
|
||||
compile failed 399
|
||||
preprocessor error 390
|
||||
bad compiler arguments 86
|
||||
unsupported source language 66
|
||||
autoconf compile/link 2439
|
||||
unsupported compiler option 187
|
||||
no input file 1068
|
||||
files in cache 18044
|
||||
cache size 7.5 GB
|
||||
max cache size 8.6 GB
|
||||
"""
|
||||
|
||||
def test_parse_garbage_stats_message(self):
|
||||
self.assertRaises(ValueError, CCacheStats, self.STAT_GARBAGE)
|
||||
|
||||
@ -88,6 +109,13 @@ class TestCcacheStats(unittest.TestCase):
|
||||
self.assertFalse(stats_diff_negative1)
|
||||
self.assertFalse(stats_diff_negative2)
|
||||
|
||||
def test_stats_version32(self):
|
||||
stat2 = CCacheStats(self.STAT2)
|
||||
stat3 = CCacheStats(self.STAT3)
|
||||
stats_diff = stat3 - stat2
|
||||
self.assertTrue(stat3)
|
||||
self.assertTrue(stats_diff)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user