Commit 260e6370 authored by Klaus Weidner's avatar Klaus Weidner Committed by Commit Bot

Include filename in IDL assertion error messages

This script runs on multiple input files provided in --idl-files-list,
so an assertion error causes a generic build failure without any clear
indication which of the inputs was problematic.

This change adds the filename and additional context to the assertion
error messages.

Before/after example:

  File "../../third_party/blink/renderer/bindings/scripts/generate_origin_trial_features.py", line 72, in read_idl_file
    assert len(interfaces) == 1
AssertionError

AssertionError: Expected one interface in file '../../third_party/blink/renderer/modules/example_init.idl', found 0
Change-Id: I5de2abbec9b38a72b19b7c1598654d11ab006767
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2261266
Commit-Queue: Klaus Weidner <klausw@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782584}
parent 2116c9c5
...@@ -77,7 +77,9 @@ def read_idl_file(reader, idl_filename): ...@@ -77,7 +77,9 @@ def read_idl_file(reader, idl_filename):
interfaces = definitions.interfaces interfaces = definitions.interfaces
includes = definitions.includes includes = definitions.includes
# There should only be a single interface defined in an IDL file. Return it. # There should only be a single interface defined in an IDL file. Return it.
assert len(interfaces) == 1 assert len(interfaces) == 1, (
"Expected one interface in file %r, found %d" %
(idl_filename, len(interfaces)))
return (interfaces.values()[0], includes) return (interfaces.values()[0], includes)
...@@ -131,7 +133,9 @@ def origin_trial_features_info(info_provider, reader, idl_filenames, ...@@ -131,7 +133,9 @@ def origin_trial_features_info(info_provider, reader, idl_filenames,
# If this interface include another one, # If this interface include another one,
# it inherits any conditional features from it. # it inherits any conditional features from it.
for include in includes: for include in includes:
assert include.interface == interface.name assert include.interface == interface.name, (
"'includes' interface identifier %r in file %r should be %r" %
(include.interface, idl_filename, interface.name))
mixin, _ = read_idl_file( mixin, _ = read_idl_file(
reader, reader,
info_provider.interfaces_info[include.mixin].get('full_path')) info_provider.interfaces_info[include.mixin].get('full_path'))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment