| |
@@ -0,0 +1,151 @@
|
| |
+ def test_skip_build(evaluater):
|
| |
+ assert evaluater("%__cargo_skip_build")[0] == "0"
|
| |
+
|
| |
+
|
| |
+ def test_rust_arches(evaluater):
|
| |
+ ix86 = evaluater("%ix86")[0]
|
| |
+ assert (
|
| |
+ evaluater("%rust_arches")[0]
|
| |
+ == f"x86_64 {ix86} armv7hl aarch64 ppc64 ppc64le riscv64 s390x"
|
| |
+ )
|
| |
+
|
| |
+
|
| |
+ def strip_empty(text: str) -> str:
|
| |
+ """
|
| |
+ Remove empty lines in macro output to ease comparisons.
|
| |
+ """
|
| |
+ return "\n".join(line.strip() for line in text.splitlines() if line.strip())
|
| |
+
|
| |
+
|
| |
+ def test_cargo_feature_subpackage_simple(evaluater):
|
| |
+ output = evaluater(
|
| |
+ "%{cargo_feature_subpackage -n foo feature}",
|
| |
+ False,
|
| |
+ # Ensure that `-n foo` overrides `%{crate}`
|
| |
+ dict(version="0.0.1", summary="Hello world", crate="notfoo"),
|
| |
+ )
|
| |
+ expected = """\
|
| |
+ %package -n rust-foo+feature-devel
|
| |
+ Summary: Hello world
|
| |
+ BuildArch: noarch
|
| |
+
|
| |
+ %description -n rust-foo+feature-devel
|
| |
+ This package contains library source intended for building other packages which
|
| |
+ use the "feature" feature of the "foo" crate.
|
| |
+
|
| |
+ %files -n rust-foo+feature-devel
|
| |
+ %ghost /usr/share/cargo/registry/foo-0.0.1/Cargo.toml"""
|
| |
+ assert strip_empty(output[0]) == strip_empty(expected)
|
| |
+
|
| |
+
|
| |
+ def test_cargo_feature_subpackage_invalid(evaluater):
|
| |
+ output = evaluater("%{cargo_feature_subpackage -n testcrate}", True)
|
| |
+ assert output[1] == "error: No feature name was passed"
|
| |
+
|
| |
+
|
| |
+ def test_cargo_feature_subpackage_preamble(evaluater):
|
| |
+ output = evaluater(
|
| |
+ "%{cargo_feature_subpackage -p %{quote:Requires: python3-devel} feature}",
|
| |
+ False,
|
| |
+ dict(version="0.0.1", summary="Hello world", crate="foo"),
|
| |
+ )
|
| |
+
|
| |
+ expected = """\
|
| |
+ %package -n rust-foo+feature-devel
|
| |
+ Summary: Hello world
|
| |
+ BuildArch: noarch
|
| |
+ Requires: python3-devel
|
| |
+
|
| |
+ %description -n rust-foo+feature-devel
|
| |
+ This package contains library source intended for building other packages which
|
| |
+ use the "feature" feature of the "foo" crate.
|
| |
+
|
| |
+ %files -n rust-foo+feature-devel
|
| |
+ %ghost /usr/share/cargo/registry/foo-0.0.1/Cargo.toml"""
|
| |
+ assert strip_empty(output[0]) == strip_empty(expected)
|
| |
+
|
| |
+
|
| |
+ def test_cargo_feature_subpackage_preamble_multiline(evaluater):
|
| |
+ preamble = """\
|
| |
+ Requires: python3-devel
|
| |
+ Provides: abcd\
|
| |
+ """
|
| |
+ # %{cargo_feature_subpackage -n foo -p %{quote:PREAMBLE_HERE} feature}
|
| |
+ exp = "%{cargo_feature_subpackage -n foo"
|
| |
+ exp += " -p %{quote: " + preamble + "} feature}"
|
| |
+ output = evaluater(
|
| |
+ exp,
|
| |
+ False,
|
| |
+ dict(version="0.0.1", summary="Hello world"),
|
| |
+ )
|
| |
+
|
| |
+ expected = """\
|
| |
+ %package -n rust-foo+feature-devel
|
| |
+ Summary: Hello world
|
| |
+ BuildArch: noarch
|
| |
+ Requires: python3-devel
|
| |
+ Provides: abcd
|
| |
+
|
| |
+ %description -n rust-foo+feature-devel
|
| |
+ This package contains library source intended for building other packages which
|
| |
+ use the "feature" feature of the "foo" crate.
|
| |
+
|
| |
+ %files -n rust-foo+feature-devel
|
| |
+ %ghost /usr/share/cargo/registry/foo-0.0.1/Cargo.toml"""
|
| |
+ assert strip_empty(output[0]) == strip_empty(expected)
|
| |
+
|
| |
+
|
| |
+ def test_cargo_devel_subpackage(evaluater):
|
| |
+ output = evaluater(
|
| |
+ "%cargo_devel_subpackage",
|
| |
+ False,
|
| |
+ dict(
|
| |
+ version="1.0.1",
|
| |
+ summary="Hopefully, this code doesn't get too rusty",
|
| |
+ crate="abc",
|
| |
+ ),
|
| |
+ )
|
| |
+ expected = """
|
| |
+ %package -n rust-abc-devel
|
| |
+ Summary: Hopefully, this code doesn't get too rusty
|
| |
+ BuildArch: noarch
|
| |
+
|
| |
+
|
| |
+ %description -n rust-abc-devel %{_description}
|
| |
+
|
| |
+
|
| |
+ This package contains library source intended for building other packages which
|
| |
+ use the "abc" crate.
|
| |
+
|
| |
+ %files -n rust-abc-devel
|
| |
+ /usr/share/cargo/registry/abc-1.0.1/
|
| |
+ """
|
| |
+ assert strip_empty(output[0]) == strip_empty(expected)
|
| |
+
|
| |
+
|
| |
+ def test_cargo_devel_subpackagen(evaluater):
|
| |
+ _description = "\\\nBeep boop is the best piece of software since sliced bread."
|
| |
+ output = evaluater(
|
| |
+ "%cargo_devel_subpackage -n xyz -p %{quote:Provides: beep-boop}",
|
| |
+ False,
|
| |
+ dict(
|
| |
+ version="1.0.1", summary="Beep boop", crate="abc", _description=_description
|
| |
+ ),
|
| |
+ )
|
| |
+ expected = """
|
| |
+ %package -n rust-xyz-devel
|
| |
+ Summary: Beep boop
|
| |
+ BuildArch: noarch
|
| |
+ Provides: beep-boop
|
| |
+
|
| |
+
|
| |
+ %description -n rust-xyz-devel
|
| |
+ Beep boop is the best piece of software since sliced bread.
|
| |
+
|
| |
+ This package contains library source intended for building other packages which
|
| |
+ use the "xyz" crate.
|
| |
+
|
| |
+ %files -n rust-xyz-devel
|
| |
+ /usr/share/cargo/registry/xyz-1.0.1/
|
| |
+ """
|
| |
+ assert strip_empty(output[0]) == strip_empty(expected)
|
| |
Add devel and feature subpackage generation
%cargo_feature_subpackage
Simplest invocation:
Explicitly specify the crate name instead of using %{crate}:
Add extra preamble from a macro:
Add extra preamble inline:
Add extra multiline preamble inline:
%cargo_devel_subpackage
Simplest invocation:
Extra preamble and overriding the crate name work the same way.