conf: fix undefined variable and improve test coverage
This commit is contained in:
parent
a0e869199f
commit
bd09ff4106
4 changed files with 20 additions and 5 deletions
|
@ -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"):
|
||||
|
|
|
@ -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. '
|
||||
|
|
4
rust2rpm/tests/samples/chrono-0.4.23.rust2rpm.conf
Normal file
4
rust2rpm/tests/samples/chrono-0.4.23.rust2rpm.conf
Normal file
|
@ -0,0 +1,4 @@
|
|||
[DEFAULT]
|
||||
all-features = true
|
||||
unwanted-features =
|
||||
__doctest
|
|
@ -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"},
|
||||
|
|
Loading…
Reference in a new issue