diff --git a/tests/test_pass_from_spec.py b/tests/test_pass_from_spec.py index 80f1a38405..525e5c9974 100644 --- a/tests/test_pass_from_spec.py +++ b/tests/test_pass_from_spec.py @@ -1,3 +1,4 @@ +import re from dataclasses import dataclass, field from typing import Literal @@ -82,7 +83,7 @@ def test_pass_instantiation(): (PipelinePassSpec("simple", {}), 'requires argument "a"'), ( PipelinePassSpec("simple", {"a": [1], "no": []}), - 'Unrecognised pass arguments "no"', + 'Provided arguments ["no"] not found in expected pass arguments ["a", "b"]', ), (PipelinePassSpec("simple", {"a": []}), "Argument must contain a value"), (PipelinePassSpec("simple", {"a": ["test"]}), "Incompatible types"), @@ -96,5 +97,5 @@ def test_pass_instantiation_error(spec: PipelinePassSpec, error_msg: str): """ Test all possible failure modes in pass instantiation """ - with pytest.raises(Exception, match=error_msg): + with pytest.raises(Exception, match=re.escape(error_msg)): SimplePass.from_pass_spec(spec) diff --git a/xdsl/passes.py b/xdsl/passes.py index d7a9b8a9ce..9dfe7d0cb0 100644 --- a/xdsl/passes.py +++ b/xdsl/passes.py @@ -92,7 +92,12 @@ def from_pass_spec(cls: type[ModulePassT], spec: PipelinePassSpec) -> ModulePass # if not all args were removed we raise an error if len(spec.args) != 0: - raise ValueError(f'Unrecognised pass arguments "{", ".join(spec.args)}"') + arguments_str = ", ".join(f'"{arg}"' for arg in spec.args) + fields_str = ", ".join(f'"{field.name}"' for field in fields) + raise ValueError( + f"Provided arguments [{arguments_str}] not found in expected pass " + f"arguments [{fields_str}]" + ) # instantiate the dataclass using kwargs return cls(**arg_dict)