Since our tests are dynamically created, we also need to decorate expected failures dynamically. Use the testcase options file as the source. Only pass known directive options to the directive in the cautodoc test.
Add a meta test to verify this works, with result "OK (expected failures=2)". --- test/meta-expected-failure.c | 3 +++ test/meta-expected-failure.options | 1 + test/meta-expected-failure.stdout | 3 +++ test/test_cautodoc.py | 2 +- test/testenv.py | 8 ++++++++ 5 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 test/meta-expected-failure.c create mode 100644 test/meta-expected-failure.options create mode 100644 test/meta-expected-failure.stdout diff --git a/test/meta-expected-failure.c b/test/meta-expected-failure.c new file mode 100644 index 000000000000..18065136572f --- /dev/null +++ b/test/meta-expected-failure.c @@ -0,0 +1,3 @@ +/** + * Meta test: This fails. Always. + */ diff --git a/test/meta-expected-failure.options b/test/meta-expected-failure.options new file mode 100644 index 000000000000..68c905946fce --- /dev/null +++ b/test/meta-expected-failure.options @@ -0,0 +1 @@ +test-expected-failure diff --git a/test/meta-expected-failure.stdout b/test/meta-expected-failure.stdout new file mode 100644 index 000000000000..dbd71dcb308f --- /dev/null +++ b/test/meta-expected-failure.stdout @@ -0,0 +1,3 @@ + +Meta test: This fails. + diff --git a/test/test_cautodoc.py b/test/test_cautodoc.py index 848f2105a1da..0a8e5bb2815f 100755 --- a/test/test_cautodoc.py +++ b/test/test_cautodoc.py @@ -17,7 +17,7 @@ def _get_output(input_filename, app, status, warning, **options): with open(os.path.join(app.srcdir, 'index.rst'), 'w') as file: fmt = '.. c:autodoc:: {source}\n' file.write(fmt.format(source=os.path.basename(input_filename))) - for key in options.keys(): + for key in [k for k in options.keys() if k in testenv.directive_options]: fmt = ' :{key}: {value}\n' file.write(fmt.format(key=key, value=options[key])) diff --git a/test/testenv.py b/test/testenv.py index cc80ef2218ed..b6842a81b375 100644 --- a/test/testenv.py +++ b/test/testenv.py @@ -26,6 +26,11 @@ def get_testcases(path): if f.endswith(testext): yield os.path.join(path, f) +directive_options = [ + 'compat', + 'clang', +] + def get_testcase_options(testcase): options_filename = modify_filename(testcase, ext='options') @@ -80,4 +85,7 @@ def assign_test_methods(cls, get_output, get_expected): options = get_testcase_options(f) method = _test_generator(get_output, get_expected, f, **options) + if options.get('test-expected-failure') is not None: + method = unittest.expectedFailure(method) + setattr(cls, _testcase_name(f), method) -- 2.20.1 _______________________________________________ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch