[Notes] [Git][BuildStream/buildstream][willsalmon/log_formating] 3 commits: tests/cachekey: Test cache keys are independent of target elements



Title: GitLab

Will Salmon pushed to branch willsalmon/log_formating at BuildStream / buildstream

Commits:

8 changed files:

Changes:

  • buildstream/_frontend/widget.py
    ... ... @@ -8,7 +8,7 @@
    8 8
     #
    
    9 9
     #  This library is distributed in the hope that it will be useful,
    
    10 10
     #  but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    11
    -#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
    
    11
    +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    
    12 12
     #  Lesser General Public License for more details.
    
    13 13
     #
    
    14 14
     #  You should have received a copy of the GNU Lesser General Public
    
    ... ... @@ -94,12 +94,24 @@ class FixedText(Widget):
    94 94
     
    
    95 95
     # Used to add the wallclock time this message was created at
    
    96 96
     class WallclockTime(Widget):
    
    97
    +    def __init__(self, context, content_profile, format_profile, output_format=False):
    
    98
    +        self._output_format = output_format
    
    99
    +        super(WallclockTime, self).__init__(context, content_profile, format_profile)
    
    100
    +
    
    97 101
         def render(self, message):
    
    102
    +
    
    98 103
             fields = [self.content_profile.fmt("{:02d}".format(x)) for x in
    
    99 104
                       [message.creation_time.hour,
    
    100 105
                        message.creation_time.minute,
    
    101
    -                   message.creation_time.second]]
    
    102
    -        return self.format_profile.fmt(":").join(fields)
    
    106
    +                   message.creation_time.second,
    
    107
    +                   ]
    
    108
    +                  ]
    
    109
    +        text = self.format_profile.fmt(":").join(fields)
    
    110
    +
    
    111
    +        if self._output_format == 'us':
    
    112
    +            text += self.format_profile.fmt(".{:06d}".format(message.creation_time.microsecond))
    
    113
    +
    
    114
    +        return text
    
    103 115
     
    
    104 116
     
    
    105 117
     # A widget for rendering the debugging column
    
    ... ... @@ -326,6 +338,8 @@ class LogLine(Widget):
    326 338
                 "elapsed": TimeCode(context, content_profile, format_profile, microseconds=False),
    
    327 339
                 "elapsed-us": TimeCode(context, content_profile, format_profile, microseconds=True),
    
    328 340
                 "wallclock": WallclockTime(context, content_profile, format_profile),
    
    341
    +            "wallclock-us": WallclockTime(context, content_profile, format_profile, output_format='us'),
    
    342
    +            "wallclock-base64": WallclockTime(context, content_profile, format_profile, output_format='base64'),
    
    329 343
                 "key": CacheKey(context, content_profile, format_profile, err_profile),
    
    330 344
                 "element": ElementName(context, content_profile, format_profile),
    
    331 345
                 "action": TypeName(context, content_profile, format_profile),
    

  • tests/cachekey/cachekey.py
    ... ... @@ -214,3 +214,41 @@ def test_cache_key_fatal_warnings(cli, tmpdir, first_warnings, second_warnings,
    214 214
         second_keys = run_get_cache_key("second", second_warnings)
    
    215 215
     
    
    216 216
         assert compare_cache_keys(first_keys, second_keys) == identical_keys
    
    217
    +
    
    218
    +
    
    219
    +@pytest.mark.datafiles(DATA_DIR)
    
    220
    +def test_keys_stable_over_targets(cli, datafiles):
    
    221
    +    root_element = 'elements/key-stability/top-level.bst'
    
    222
    +    target1 = 'elements/key-stability/t1.bst'
    
    223
    +    target2 = 'elements/key-stability/t2.bst'
    
    224
    +
    
    225
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    226
    +    full_graph_result = cli.run(project=project, args=[
    
    227
    +        'show',
    
    228
    +        '--format', '%{name}::%{full-key}',
    
    229
    +        root_element
    
    230
    +    ])
    
    231
    +    full_graph_result.assert_success()
    
    232
    +    all_cache_keys = parse_output_keys(full_graph_result.output)
    
    233
    +
    
    234
    +    ordering1_result = cli.run(project=project, args=[
    
    235
    +        'show',
    
    236
    +        '--format', '%{name}::%{full-key}',
    
    237
    +        target1,
    
    238
    +        target2
    
    239
    +    ])
    
    240
    +    ordering1_result.assert_success()
    
    241
    +    ordering1_cache_keys = parse_output_keys(ordering1_result.output)
    
    242
    +
    
    243
    +    ordering2_result = cli.run(project=project, args=[
    
    244
    +        'show',
    
    245
    +        '--format', '%{name}::%{full-key}',
    
    246
    +        target2,
    
    247
    +        target1
    
    248
    +    ])
    
    249
    +    ordering2_result.assert_success()
    
    250
    +    ordering2_cache_keys = parse_output_keys(ordering2_result.output)
    
    251
    +
    
    252
    +    for element in ordering1_cache_keys:
    
    253
    +        assert ordering1_cache_keys[element] == ordering2_cache_keys[element]
    
    254
    +        assert ordering1_cache_keys[element] == all_cache_keys[element]

  • tests/cachekey/project/elements/key-stability/aaa.bst
    1
    +kind: import
    
    2
    +sources:
    
    3
    +- kind: local
    
    4
    +  path: elements/key-stability/aaa.bst

  • tests/cachekey/project/elements/key-stability/t1.bst
    1
    +kind: import
    
    2
    +sources:
    
    3
    +- kind: local
    
    4
    +  path: elements/key-stability/t1.bst
    
    5
    +depends:
    
    6
    +- elements/key-stability/zzz.bst

  • tests/cachekey/project/elements/key-stability/t2.bst
    1
    +kind: import
    
    2
    +sources:
    
    3
    +- kind: local
    
    4
    +  path: elements/key-stability/t2.bst
    
    5
    +depends:
    
    6
    +- elements/key-stability/aaa.bst
    
    7
    +- elements/key-stability/zzz.bst

  • tests/cachekey/project/elements/key-stability/top-level.bst
    1
    +kind: import
    
    2
    +sources:
    
    3
    +- kind: local
    
    4
    +  path: elements/key-stability/top-level.bst
    
    5
    +depends:
    
    6
    +- elements/key-stability/t1.bst
    
    7
    +- elements/key-stability/t2.bst

  • tests/cachekey/project/elements/key-stability/zzz.bst
    1
    +kind: import
    
    2
    +sources:
    
    3
    +- kind: local
    
    4
    +  path: elements/key-stability/zzz.bst

  • tests/frontend/logging.py
    ... ... @@ -52,7 +52,8 @@ def test_custom_logging(cli, tmpdir, datafiles):
    52 52
         element_path = os.path.join(project, 'elements')
    
    53 53
         element_name = 'fetch-test-git.bst'
    
    54 54
     
    
    55
    -    custom_log_format = '%{elapsed},%{elapsed-us},%{wallclock},%{key},%{element},%{action},%{message}'
    
    55
    +    custom_log_format = ('%{elapsed},%{elapsed-us},%{wallclock},%{wallclock-us},'
    
    56
    +                         '%{key},%{element},%{action},%{message}')
    
    56 57
         user_config = {'logging': {'message-format': custom_log_format}}
    
    57 58
         cli.configure(user_config)
    
    58 59
     
    
    ... ... @@ -77,7 +78,8 @@ def test_custom_logging(cli, tmpdir, datafiles):
    77 78
         result = cli.run(project=project, args=['source', 'fetch', element_name])
    
    78 79
         result.assert_success()
    
    79 80
     
    
    80
    -    m = re.search(r"\d\d:\d\d:\d\d,\d\d:\d\d:\d\d.\d{6},\d\d:\d\d:\d\d,\s*,.*,SUCCESS,Checking sources", result.stderr)
    
    81
    +    m = re.search(r"\d\d:\d\d:\d\d,\d\d:\d\d:\d\d.\d{6},\d\d:\d\d:\d\d,\d\d:\d\d:\d\d.\d{6}\s*,.*"
    
    82
    +                  r",SUCCESS,Checking sources", result.stderr)
    
    81 83
         assert(m is not None)
    
    82 84
     
    
    83 85
     
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]