You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:06:01 UTC
[buildstream] 02/02: tests: Add tests for build manifests
This is an automated email from the ASF dual-hosted git repository.
github-bot pushed a commit to branch Qinusty/235-manifest
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 7e0dc95aa5a976eb2915b013070521fa958c1551
Author: Josh Smith <jo...@codethink.co.uk>
AuthorDate: Wed Aug 1 17:07:46 2018 +0100
tests: Add tests for build manifests
Tests ensure that a build manifest is created when it should be, and
isn't when it shouldn't be.
---
tests/manifest/manifest.py | 61 +++++++++++++++++++++++++++++
tests/manifest/project/elements/base.bst | 6 +++
tests/manifest/project/files/hello/file.txt | 0
tests/manifest/project/project.conf | 4 ++
4 files changed, 71 insertions(+)
diff --git a/tests/manifest/manifest.py b/tests/manifest/manifest.py
new file mode 100644
index 0000000..dbf7eab
--- /dev/null
+++ b/tests/manifest/manifest.py
@@ -0,0 +1,61 @@
+import pytest
+import os
+from ruamel import yaml
+
+from tests.testutils import cli
+
+# Project directory
+DATA_DIR = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ "project",
+)
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("specify_path, build_manifest", [
+ (True, True), (True, False), (False, True)
+])
+def test_manifest_created(tmpdir, cli, datafiles, specify_path, build_manifest):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+
+ manifest_path = os.path.join(str(tmpdir), "build_manifest.yaml")
+
+ args = ['build', "base.bst"]
+
+ if specify_path:
+ args += ["--manifest-path", manifest_path]
+ if build_manifest:
+ args.append("--build-manifest")
+
+ result = cli.run(project=project, args=args)
+ result.assert_success()
+
+ with open(manifest_path) as f:
+ manifest = yaml.load(f, Loader=yaml.loader.RoundTripLoader)
+
+ assert len(manifest["Elements"]["base"]["Sources"]) == 1
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("extension, valid", [
+ (".yaml", True),
+ (".yml", True),
+ (".bst", False),
+ (".ynl", False),
+ (".xml", False),
+ (".mnf", False),
+ (".txt", False),
+ (".abc", False),
+ (".json", False)
+])
+def test_manifest_extensions(tmpdir, cli, datafiles, extension, valid):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+
+ manifest_path = os.path.join(str(tmpdir), "build_manifest{}" + extension)
+
+ result = cli.run(project=project, args=['build', "base.bst", "--manifest-path", manifest_path])
+
+ if valid:
+ result.assert_success()
+ else:
+ assert result.exit_code == 2
diff --git a/tests/manifest/project/elements/base.bst b/tests/manifest/project/elements/base.bst
new file mode 100644
index 0000000..a41e59a
--- /dev/null
+++ b/tests/manifest/project/elements/base.bst
@@ -0,0 +1,6 @@
+kind: import
+description: Custom foo element
+
+sources:
+ - kind: local
+ path: files/hello
\ No newline at end of file
diff --git a/tests/manifest/project/files/hello/file.txt b/tests/manifest/project/files/hello/file.txt
new file mode 100644
index 0000000..e69de29
diff --git a/tests/manifest/project/project.conf b/tests/manifest/project/project.conf
new file mode 100644
index 0000000..854e386
--- /dev/null
+++ b/tests/manifest/project/project.conf
@@ -0,0 +1,4 @@
+# Project config for frontend build test
+name: test
+
+element-path: elements