diff --git a/rust2rpm/conf.py b/rust2rpm/conf.py index 404e978..7c0c9df 100644 --- a/rust2rpm/conf.py +++ b/rust2rpm/conf.py @@ -38,15 +38,15 @@ class Rust2RpmConf: conf = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation()) confs = conf.read(filenames) - if len(confs) > 1: + if len(confs) > 1: # pragma nocover raise FileExistsError # clean up configuration files with deprecated names - if ".rust2rpm.conf" in confs: + if ".rust2rpm.conf" in confs: # pragma nocover os.rename(".rust2rpm.conf", "rust2rpm.conf") log.info("Renamed deprecated, hidden .rust2rpm.conf file to rust2rpm.conf.") - if "_rust2rpm.conf" in confs: + if "_rust2rpm.conf" in confs: # pragma nocover os.rename("_rust2rpm.conf", "rust2rpm.conf") log.info("Renamed deprecated _rust2rpm.conf file to rust2rpm.conf.") @@ -81,7 +81,8 @@ class Rust2RpmConf: # parse configuration and validate settings settings = dict() - if all_features := merged.getboolean("all-features") and all_features is not None: + all_features = merged.getboolean("all-features") + if all_features is not None: settings["all_features"] = all_features if unwanted_features := merged.get("unwanted-features"): diff --git a/rust2rpm/metadata.py b/rust2rpm/metadata.py index 0a93643..044c77e 100644 --- a/rust2rpm/metadata.py +++ b/rust2rpm/metadata.py @@ -39,7 +39,7 @@ def guess_main_package(metadata: Metadata, hint: Optional[str] = None, interacti if len(with_bin) == 1: return with_bin[0] - if interactive: + if interactive: # pragma nocover choices = [package.name for package in with_bin] + [package.name for package in with_cdylib] log.warn( 'Heuristic for determining the "main" crate of the workspace failed. ' diff --git a/rust2rpm/tests/samples/chrono-0.4.23.rust2rpm.conf b/rust2rpm/tests/samples/chrono-0.4.23.rust2rpm.conf new file mode 100644 index 0000000..a943c0d --- /dev/null +++ b/rust2rpm/tests/samples/chrono-0.4.23.rust2rpm.conf @@ -0,0 +1,4 @@ +[DEFAULT] +all-features = true +unwanted-features = + __doctest diff --git a/rust2rpm/tests/test_conf.py b/rust2rpm/tests/test_conf.py index 702bdbd..61fe180 100644 --- a/rust2rpm/tests/test_conf.py +++ b/rust2rpm/tests/test_conf.py @@ -9,6 +9,16 @@ from rust2rpm.conf import Rust2RpmConf @pytest.mark.parametrize( "filename,features,all_features,unwanted_features,buildrequires,testrequires,bin_requires,lib_requires", [ + ( + "chrono-0.4.23.rust2rpm.conf", + {"__doctest"}, + True, + ["__doctest"], + list(), + list(), + list(), + dict(), + ), ( "libsqlite3-sys-0.25.2.rust2rpm.conf", {"sqlcipher"},