def assertMesonRaises(self, contents: str,
                          match: T.Union[str, T.Pattern[str]], *,
                          extra_args: T.Optional[T.List[str]] = None,
                          langs: T.Optional[T.List[str]] = None,
                          meson_version: T.Optional[str] = None,
                          options: T.Optional[str] = None,
                          override_envvars: T.Optional[T.MutableMapping[str, str]] = None) -> None:
        '''
        Assert that running meson configure on the specified @contents raises
        a error message matching regex @match.
        '''
        if langs is None:
            langs = []
        with open(self.mbuild, 'w', encoding='utf-8') as f:
            f.write("project('failure test', 'c', 'cpp'")
            if meson_version:
                f.write(f", meson_version: '{meson_version}'")
            f.write(")\n")
            for lang in langs:
                f.write(f"add_languages('{lang}', required : false)\n")
            f.write(contents)
        if options is not None:
            with open(self.moptions, 'w', encoding='utf-8') as f:
                f.write(options)
        o = {'MESON_FORCE_BACKTRACE': '1'}
        if override_envvars is None:
            override_envvars = o
        else:
            override_envvars.update(o)
        # Force tracebacks so we can detect them properly
        with self.assertRaisesRegex(MesonException, match, msg=contents):
            # Must run in-process or we'll get a generic CalledProcessError
            self.init(self.srcdir, extra_args=extra_args,
                      inprocess=True,
                      override_envvars = override_envvars)

        Assert that running meson configure on the specified @contents raises
        a error message matching regex @match.
        
unittests/failuretests.py