This is an automated email from the ASF dual-hosted git repository. tvb pushed a commit to branch Qinusty/235-manifest in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 7e0dc95aa5a976eb2915b013070521fa958c1551 Author: Josh Smith <[email protected]> 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", +) + + [email protected](DATA_DIR) [email protected]("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 + + [email protected](DATA_DIR) [email protected]("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
