This is an automated email from the ASF dual-hosted git repository. juergbi pushed a commit to branch juerg/cargo in repository https://gitbox.apache.org/repos/asf/buildstream-plugins.git
commit e761daf0aab50318d8836661de5a0da2445e9ed7 Author: Jürg Billeter <[email protected]> AuthorDate: Fri Aug 16 11:10:38 2024 +0200 tests: Add minimal test for the `cargo` source plugin --- tests/sources/cargo.py | 58 +++++++++++++++++++++++++ tests/sources/cargo/minimal/elements/base64.bst | 6 +++ tests/sources/cargo/minimal/files/Cargo.lock | 7 +++ 3 files changed, 71 insertions(+) diff --git a/tests/sources/cargo.py b/tests/sources/cargo.py new file mode 100644 index 0000000..6d68089 --- /dev/null +++ b/tests/sources/cargo.py @@ -0,0 +1,58 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Pylint doesn't play well with fixtures and dependency injection from pytest +# pylint: disable=redefined-outer-name + +import os +import pytest + +from buildstream import _yaml +from buildstream._testing import cli # pylint: disable=unused-import + +DATA_DIR = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "cargo", +) + + +def generate_project(project_dir): + project_file = os.path.join(project_dir, "project.conf") + _yaml.roundtrip_dump( + { + "name": "foo", + "min-version": "2.0", + "element-path": "elements", + "plugins": [ + { + "origin": "pip", + "package-name": "buildstream-plugins", + "sources": ["cargo"], + } + ], + }, + project_file, + ) + + [email protected](os.path.join(DATA_DIR, "minimal")) +def test_cargo_track_fetch_build(cli, datafiles): + project = str(datafiles) + generate_project(project) + result = cli.run(project=project, args=["source", "track", "base64.bst"]) + result.assert_success() + result = cli.run(project=project, args=["source", "fetch", "base64.bst"]) + result.assert_success() + result = cli.run(project=project, args=["build", "base64.bst"]) + result.assert_success() diff --git a/tests/sources/cargo/minimal/elements/base64.bst b/tests/sources/cargo/minimal/elements/base64.bst new file mode 100644 index 0000000..ca00749 --- /dev/null +++ b/tests/sources/cargo/minimal/elements/base64.bst @@ -0,0 +1,6 @@ +kind: import + +sources: +- kind: local + path: files/Cargo.lock +- kind: cargo diff --git a/tests/sources/cargo/minimal/files/Cargo.lock b/tests/sources/cargo/minimal/files/Cargo.lock new file mode 100644 index 0000000..520c3dd --- /dev/null +++ b/tests/sources/cargo/minimal/files/Cargo.lock @@ -0,0 +1,7 @@ +version = 3 + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
