summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Smith <joshsmith@codethink.co.uk>2018-08-01 17:07:46 +0100
committerJosh Smith <joshsmith@codethink.co.uk>2018-08-02 09:14:42 +0100
commit7e0dc95aa5a976eb2915b013070521fa958c1551 (patch)
tree7f496ff22233f2e1109319055bc1b18b2c06ef00
parent38d5a4cf24956c4dc573add021f513a4975ff693 (diff)
downloadbuildstream-Qinusty/235-manifest.tar.gz
tests: Add tests for build manifestsQinusty/235-manifest
Tests ensure that a build manifest is created when it should be, and isn't when it shouldn't be.
-rw-r--r--tests/manifest/manifest.py61
-rw-r--r--tests/manifest/project/elements/base.bst6
-rw-r--r--tests/manifest/project/files/hello/file.txt0
-rw-r--r--tests/manifest/project/project.conf4
4 files changed, 71 insertions, 0 deletions
diff --git a/tests/manifest/manifest.py b/tests/manifest/manifest.py
new file mode 100644
index 000000000..dbf7eab09
--- /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 000000000..a41e59aef
--- /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 000000000..e69de29bb
--- /dev/null
+++ b/tests/manifest/project/files/hello/file.txt
diff --git a/tests/manifest/project/project.conf b/tests/manifest/project/project.conf
new file mode 100644
index 000000000..854e38693
--- /dev/null
+++ b/tests/manifest/project/project.conf
@@ -0,0 +1,4 @@
+# Project config for frontend build test
+name: test
+
+element-path: elements