From 3a06b7e2bc9f3e63a6401dabd0aec4fb1758773d Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Fri, 6 Oct 2023 19:29:27 +0200 Subject: [PATCH] conf: add settings for running and skipping specific tests --- rust2rpm/conf.py | 69 +++++++++++++++++++ .../samples/dotenvy-0.15.7.rust2rpm.toml | 3 + .../samples/reqwest-0.11.20.rust2rpm.toml | 8 +++ rust2rpm/tests/test_conf.py | 36 ++++++++++ 4 files changed, 116 insertions(+) create mode 100644 rust2rpm/tests/samples/dotenvy-0.15.7.rust2rpm.toml create mode 100644 rust2rpm/tests/samples/reqwest-0.11.20.rust2rpm.toml diff --git a/rust2rpm/conf.py b/rust2rpm/conf.py index 9b7b299..71b50b1 100644 --- a/rust2rpm/conf.py +++ b/rust2rpm/conf.py @@ -12,6 +12,7 @@ from rust2rpm import log TOML_SCHEMA = { "type": "object", "properties": { + # package properties "package": { "type": "object", "properties": { @@ -28,11 +29,44 @@ TOML_SCHEMA = { "type": "array", "items": { "type": "string", + "uniqueItems": True, }, }, }, "additionalProperties": False, }, + # configure which tests are run + "tests": { + "type": "object", + "properties": { + "run": { + "type": "array", + "items": { + "type": "string", + "enum": ["none", "all", "lib", "bin", "doc", "bins", "tests"], + "uniqueItems": True, + }, + }, + "skip": { + "type": "array", + "items": { + "type": "string", + "uniqueItems": True, + }, + }, + "skip-exact": { + "type": "boolean", + }, + "comments": { + "type": "array", + "items": { + "type": "string", + }, + }, + }, + "additionalProperties": False, + "required": ["comments"], + }, # feature flags passed to cargo "features": { "type": "object", @@ -46,6 +80,7 @@ TOML_SCHEMA = { "type": "array", "items": { "type": "string", + "uniqueItems": True, }, }, # hide feature subpackages @@ -53,6 +88,7 @@ TOML_SCHEMA = { "type": "array", "items": { "type": "string", + "uniqueItems": True, }, }, }, @@ -67,6 +103,7 @@ TOML_SCHEMA = { "type": "array", "items": { "type": "string", + "uniqueItems": True, }, }, # additional BuildRequires gated by the "check" bconf @@ -74,6 +111,7 @@ TOML_SCHEMA = { "type": "array", "items": { "type": "string", + "uniqueItems": True, }, }, # additional Requires for the -devel subpackage @@ -81,6 +119,7 @@ TOML_SCHEMA = { "type": "array", "items": { "type": "string", + "uniqueItems": True, }, }, # additional Requires for the binary subpackage @@ -88,6 +127,7 @@ TOML_SCHEMA = { "type": "array", "items": { "type": "string", + "uniqueItems": True, }, }, # additional Requires for feature subpackages @@ -98,6 +138,7 @@ TOML_SCHEMA = { "type": "array", "items": { "type": "string", + "uniqueItems": True, }, }, }, @@ -309,6 +350,34 @@ class TomlConf: else: return None + @property + def _tests(self) -> Optional[dict[str, Any]]: + return self._data.get("tests") + + @property + def tests_run(self) -> Optional[list[str]]: + if tests := self._tests: + return tests.get("run") + return None + + @property + def tests_skip(self) -> Optional[list[str]]: + if tests := self._tests: + return tests.get("skip") + return None + + @property + def tests_skip_exact(self) -> Optional[bool]: + if tests := self._tests: + return tests.get("skip-exact") + return None + + @property + def tests_comments(self) -> Optional[list[str]]: + if tests := self._tests: + return tests.get("comments") + return None + @property def _features(self) -> Optional[dict]: return self._data.get("features") diff --git a/rust2rpm/tests/samples/dotenvy-0.15.7.rust2rpm.toml b/rust2rpm/tests/samples/dotenvy-0.15.7.rust2rpm.toml new file mode 100644 index 0000000..cbb4bbd --- /dev/null +++ b/rust2rpm/tests/samples/dotenvy-0.15.7.rust2rpm.toml @@ -0,0 +1,3 @@ +[tests] +run = ["lib", "tests"] +comments = ["files required by doctests are not included in published crates"] diff --git a/rust2rpm/tests/samples/reqwest-0.11.20.rust2rpm.toml b/rust2rpm/tests/samples/reqwest-0.11.20.rust2rpm.toml new file mode 100644 index 0000000..c3d6f36 --- /dev/null +++ b/rust2rpm/tests/samples/reqwest-0.11.20.rust2rpm.toml @@ -0,0 +1,8 @@ +[tests] +skip = [ + "test_allowed_methods", + "test_badssl_modern", + "test_badssl_self_signed", +] +skip-exact = true +comments = ["skip tests which require internet access"] diff --git a/rust2rpm/tests/test_conf.py b/rust2rpm/tests/test_conf.py index 5d03ce4..fcbd3a5 100644 --- a/rust2rpm/tests/test_conf.py +++ b/rust2rpm/tests/test_conf.py @@ -104,6 +104,23 @@ def test_ini_conf_load( }, ), ), + ( + "dotenvy-0.15.7.rust2rpm.toml", + set(), + TomlConf( + { + "tests": { + "run": [ + "lib", + "tests", + ], + "comments": [ + "files required by doctests are not included in published crates", + ], + }, + }, + ), + ), ( "glib-sys-0.17.2.rust2rpm.toml", {"v2_58", "v2_60", "v2_62", "v2_64", "v2_66", "v2_68", "v2_70", "v2_72", "v2_74", "v2_76"}, @@ -156,6 +173,25 @@ def test_ini_conf_load( }, ), ), + ( + "reqwest-0.11.20.rust2rpm.toml", + set(), + TomlConf( + { + "tests": { + "skip": [ + "test_allowed_methods", + "test_badssl_modern", + "test_badssl_self_signed", + ], + "skip-exact": True, + "comments": [ + "skip tests which require internet access", + ], + }, + }, + ), + ), ], ) def test_toml_conf_load(