Bug 1501531 - Update ccache stats parser for ccache 3.5 release. r=froydnj
authorTing-Yu Lin <tlin@mozilla.com>
Wed, 24 Oct 2018 17:33:39 +0000
changeset 491176 cc08f0f9cd01231b0b55f77cfc26b2b18c9d23bb
parent 491175 3a7ba1fe0277d580a678b86ab92d4496d4fe6681
child 491177 4f1fd54c853fd655e91975b364dd5640559f5f6e
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersfroydnj
bugs1501531
milestone65.0a1
Bug 1501531 - Update ccache stats parser for ccache 3.5 release. r=froydnj Differential Revision: https://phabricator.services.mozilla.com/D9613
python/mozbuild/mozbuild/controller/building.py
python/mozbuild/mozbuild/test/controller/test_ccachestats.py
--- a/python/mozbuild/mozbuild/controller/building.py
+++ b/python/mozbuild/mozbuild/controller/building.py
@@ -765,17 +765,18 @@ class CCacheStats(object):
     Instances can be subtracted from each other to obtain differences.
     print() or str() the object to show a ``ccache -s`` like output
     of the captured stats.
 
     """
     STATS_KEYS = [
         # (key, description)
         # Refer to stats.c in ccache project for all the descriptions.
-        ('stats_zero_time', 'stats zero time'),
+        ('stats_zeroed', 'stats zero time'), # Old name prior to ccache 3.4
+        ('stats_zeroed', 'stats zeroed'),
         ('stats_updated', 'stats updated'),
         ('cache_hit_direct', 'cache hit (direct)'),
         ('cache_hit_preprocessed', 'cache hit (preprocessed)'),
         ('cache_hit_rate', 'cache hit rate'),
         ('cache_miss', 'cache miss'),
         ('link', 'called for link'),
         ('preprocessing', 'called for preprocessing'),
         ('multiple', 'multiple source files'),
--- a/python/mozbuild/mozbuild/test/controller/test_ccachestats.py
+++ b/python/mozbuild/mozbuild/test/controller/test_ccachestats.py
@@ -194,16 +194,41 @@ class TestCcacheStats(unittest.TestCase)
     autoconf compile/link                348
     no input file                        162
     cleanups performed                    77
     files in cache                     13464
     cache size                           6.2 GB
     max cache size                       7.0 GB
     """.format(timestamp=time.strftime('%c'))
 
+    STAT9 = """
+    cache directory                     /Users/tlin/.ccache
+    primary config                      /Users/tlin/.ccache/ccache.conf
+    secondary config      (readonly)    /usr/local/Cellar/ccache/3.5/etc/ccache.conf
+    stats updated                       {timestamp}
+    stats zeroed                        {timestamp2}
+    cache hit (direct)                 80147
+    cache hit (preprocessed)           21413
+    cache miss                        191128
+    cache hit rate                     34.70 %
+    called for link                     5194
+    called for preprocessing            1721
+    compile failed                       825
+    preprocessor error                  3838
+    cache file missing                  4863
+    bad compiler arguments                32
+    autoconf compile/link               3554
+    unsupported code directive             4
+    no input file                       5545
+    cleanups performed                  3154
+    files in cache                     18525
+    cache size                          13.4 GB
+    max cache size                      15.0 GB
+    """.format(timestamp=time.strftime('%c'), timestamp2=time.strftime('%c'))
+
     def test_parse_garbage_stats_message(self):
         self.assertRaises(ValueError, CCacheStats, self.STAT_GARBAGE)
 
     def test_parse_zero_stats_message(self):
         stats = CCacheStats(self.STAT0)
         self.assertEqual(stats.cache_dir, "/home/tlin/.ccache")
         self.assertEqual(stats.hit_rates(), (0, 0, 0))
 
@@ -256,10 +281,15 @@ class TestCcacheStats(unittest.TestCase)
         stat7 = CCacheStats(self.STAT7)
         self.assertTrue(stat7)
 
     def test_stats_version34(self):
         # Test parsing 3.4 output.
         stat8 = CCacheStats(self.STAT8)
         self.assertTrue(stat8)
 
+    def test_stats_version35(self):
+        # Test parsing 3.5 output.
+        stat9 = CCacheStats(self.STAT9)
+        self.assertTrue(stat9)
+
 if __name__ == '__main__':
     main()