Beispiel #1
0
    def test_get_build_environment(self):
        plugin = RustPlugin(part_name="my-part", options=lambda: None)

        self.assertThat(
            plugin.get_build_environment(),
            Equals({"PATH": "${HOME}/.cargo/bin:${PATH}"}),
        )
Beispiel #2
0
    def test_get_install_command_with_features(self):
        class Options:
            rust_channel = ""
            rust_path = ["path"]
            rust_features = ["my-feature", "your-feature"]

        plugin = RustPlugin(part_name="my-part", options=Options())

        self.assertThat(
            plugin._get_install_command(),
            Equals(
                "cargo install --locked --path path --root \"${SNAPCRAFT_PART_INSTALL}\" --force --features 'my-feature your-feature'"
            ),
        )
Beispiel #3
0
    def test_schema(self):
        schema = RustPlugin.get_schema()

        self.assertThat(
            schema,
            Equals({
                "$schema": "http://json-schema.org/draft-04/schema#",
                "additionalProperties": False,
                "properties": {
                    "rust-features": {
                        "default": [],
                        "items": {
                            "type": "string"
                        },
                        "type": "array",
                        "uniqueItems": True,
                    },
                    "rust-path": {
                        "default": ["."],
                        "items": {
                            "type": "string"
                        },
                        "maxItems": 1,
                        "minItems": 1,
                        "type": "array",
                        "uniqueItems": True,
                    },
                },
                "required": ["source"],
                "type": "object",
            }),
        )
Beispiel #4
0
    def test_get_build_commands(self):
        class Options:
            rust_channel = ""
            rust_path = ["."]
            rust_features = []

        plugin = RustPlugin(part_name="my-part", options=Options())

        self.assertThat(
            plugin.get_build_commands(),
            Equals([
                dedent("""\
                    if ! command -v rustup 2>/dev/null; then
                        curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile=minimal
                        export PATH="${HOME}/.cargo/bin:${PATH}"
                    fi
                        """),
                'cargo install --locked --path . --root "${SNAPCRAFT_PART_INSTALL}" --force',
            ]),
        )
Beispiel #5
0
    def test_get_build_packages(self):
        plugin = RustPlugin(part_name="my-part", options=lambda: None)

        self.assertThat(plugin.get_build_packages(),
                        Equals({"curl", "gcc", "git"}))