You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ro...@apache.org on 2020/12/29 13:33:15 UTC
[buildstream] 04/05: frontend/buildcheckout.py: build default
element
This is an automated email from the ASF dual-hosted git repository.
root pushed a commit to branch issue_640-Build-All
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 7b257fb203bcb54af1bcaabc05382a6f84ee3a75
Author: Phillip Smyth <ph...@codethink.co.uk>
AuthorDate: Mon Nov 12 10:28:36 2018 +0000
frontend/buildcheckout.py: build default element
Added supporting files for build default element tests
---
tests/frontend/buildcheckout.py | 30 ++++++++++++++++++++++
tests/frontend/project_default/elements/target.bst | 4 +++
.../frontend/project_default/elements/target2.bst | 4 +++
tests/frontend/project_default/project.conf | 10 ++++++++
.../project_world/elements/compose-all.bst | 12 +++++++++
.../project_world/elements/compose-exclude-dev.bst | 16 ++++++++++++
.../project_world/elements/compose-include-bin.bst | 16 ++++++++++++
.../frontend/project_world/elements/import-bin.bst | 4 +++
.../frontend/project_world/elements/import-dev.bst | 4 +++
.../project_world/elements/rebuild-target.bst | 4 +++
.../elements/source-bundle/source-bundle-hello.bst | 6 +++++
tests/frontend/project_world/elements/target.bst | 8 ++++++
tests/frontend/project_world/files/bar | 0
.../project_world/files/bin-files/usr/bin/hello | 3 +++
.../files/build-files/buildstream/build/test | 1 +
.../files/dev-files/usr/include/pony.h | 12 +++++++++
tests/frontend/project_world/files/foo | 0
.../project_world/files/source-bundle/llamas.txt | 1 +
tests/frontend/project_world/project.conf | 4 +++
19 files changed, 139 insertions(+)
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py
index 03bba0b..d1440a3 100644
--- a/tests/frontend/buildcheckout.py
+++ b/tests/frontend/buildcheckout.py
@@ -2,6 +2,7 @@ import os
import tarfile
import hashlib
import pytest
+import subprocess
from tests.testutils import cli, create_repo, ALL_REPO_KINDS, generate_junction
from buildstream import _yaml
@@ -60,6 +61,35 @@ def test_build_checkout(datafiles, cli, strict, hardlinks):
assert os.path.exists(filename)
+@pytest.mark.datafiles(DATA_DIR + "_world")
+def test_build_default_all(datafiles, cli):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ result = cli.run(project=project, silent=True, args=['build'])
+
+ result.assert_success()
+ target_dir = os.path.join(cli.directory, DATA_DIR + "_world", "elements")
+ output_dir = os.path.join(cli.directory, "logs", "test")
+
+ expected = subprocess.Popen(('ls', target_dir), stdout=subprocess.PIPE)
+ expected = subprocess.check_output(("wc", "-w"), stdin=expected.stdout)
+
+ results = subprocess.Popen(('ls', output_dir), stdout=subprocess.PIPE)
+ results = subprocess.check_output(("wc", "-w"), stdin=results.stdout)
+
+ assert results == expected
+
+
+@pytest.mark.datafiles(DATA_DIR + "_default")
+def test_build_default(cli, datafiles):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ result = cli.run(project=project, silent=True, args=['build'])
+
+ result.assert_success()
+ results = cli.get_element_state(project, "target2.bst")
+ expected = "cached"
+ assert results == expected
+
+
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize("strict,hardlinks", [
("non-strict", "hardlinks"),
diff --git a/tests/frontend/project_default/elements/target.bst b/tests/frontend/project_default/elements/target.bst
new file mode 100644
index 0000000..d644c89
--- /dev/null
+++ b/tests/frontend/project_default/elements/target.bst
@@ -0,0 +1,4 @@
+kind: stack
+description: |
+
+ Main stack target for the bst build test
diff --git a/tests/frontend/project_default/elements/target2.bst b/tests/frontend/project_default/elements/target2.bst
new file mode 100644
index 0000000..d644c89
--- /dev/null
+++ b/tests/frontend/project_default/elements/target2.bst
@@ -0,0 +1,4 @@
+kind: stack
+description: |
+
+ Main stack target for the bst build test
diff --git a/tests/frontend/project_default/project.conf b/tests/frontend/project_default/project.conf
new file mode 100644
index 0000000..0b2cff7
--- /dev/null
+++ b/tests/frontend/project_default/project.conf
@@ -0,0 +1,10 @@
+# Project config for frontend build test
+name: test
+
+element-path: elements
+
+fatal-warnings:
+- bad-element-suffix
+
+defaults:
+ target-element: target2.bst
diff --git a/tests/frontend/project_world/elements/compose-all.bst b/tests/frontend/project_world/elements/compose-all.bst
new file mode 100644
index 0000000..ba47081
--- /dev/null
+++ b/tests/frontend/project_world/elements/compose-all.bst
@@ -0,0 +1,12 @@
+kind: compose
+
+depends:
+- filename: import-bin.bst
+ type: build
+- filename: import-dev.bst
+ type: build
+
+config:
+ # Dont try running the sandbox, we dont have a
+ # runtime to run anything in this context.
+ integrate: False
diff --git a/tests/frontend/project_world/elements/compose-exclude-dev.bst b/tests/frontend/project_world/elements/compose-exclude-dev.bst
new file mode 100644
index 0000000..75c1437
--- /dev/null
+++ b/tests/frontend/project_world/elements/compose-exclude-dev.bst
@@ -0,0 +1,16 @@
+kind: compose
+
+depends:
+- filename: import-bin.bst
+ type: build
+- filename: import-dev.bst
+ type: build
+
+config:
+ # Dont try running the sandbox, we dont have a
+ # runtime to run anything in this context.
+ integrate: False
+
+ # Exclude the dev domain
+ exclude:
+ - devel
diff --git a/tests/frontend/project_world/elements/compose-include-bin.bst b/tests/frontend/project_world/elements/compose-include-bin.bst
new file mode 100644
index 0000000..9571203
--- /dev/null
+++ b/tests/frontend/project_world/elements/compose-include-bin.bst
@@ -0,0 +1,16 @@
+kind: compose
+
+depends:
+- filename: import-bin.bst
+ type: build
+- filename: import-dev.bst
+ type: build
+
+config:
+ # Dont try running the sandbox, we dont have a
+ # runtime to run anything in this context.
+ integrate: False
+
+ # Only include the runtim
+ include:
+ - runtime
diff --git a/tests/frontend/project_world/elements/import-bin.bst b/tests/frontend/project_world/elements/import-bin.bst
new file mode 100644
index 0000000..a847c0c
--- /dev/null
+++ b/tests/frontend/project_world/elements/import-bin.bst
@@ -0,0 +1,4 @@
+kind: import
+sources:
+- kind: local
+ path: files/bin-files
diff --git a/tests/frontend/project_world/elements/import-dev.bst b/tests/frontend/project_world/elements/import-dev.bst
new file mode 100644
index 0000000..152a546
--- /dev/null
+++ b/tests/frontend/project_world/elements/import-dev.bst
@@ -0,0 +1,4 @@
+kind: import
+sources:
+- kind: local
+ path: files/dev-files
diff --git a/tests/frontend/project_world/elements/rebuild-target.bst b/tests/frontend/project_world/elements/rebuild-target.bst
new file mode 100644
index 0000000..49a02c2
--- /dev/null
+++ b/tests/frontend/project_world/elements/rebuild-target.bst
@@ -0,0 +1,4 @@
+kind: compose
+
+build-depends:
+- target.bst
diff --git a/tests/frontend/project_world/elements/source-bundle/source-bundle-hello.bst b/tests/frontend/project_world/elements/source-bundle/source-bundle-hello.bst
new file mode 100644
index 0000000..98c3a95
--- /dev/null
+++ b/tests/frontend/project_world/elements/source-bundle/source-bundle-hello.bst
@@ -0,0 +1,6 @@
+kind: import
+description: the kind of this element must implement generate_script() method
+
+sources:
+- kind: local
+ path: files/source-bundle
diff --git a/tests/frontend/project_world/elements/target.bst b/tests/frontend/project_world/elements/target.bst
new file mode 100644
index 0000000..b9432fa
--- /dev/null
+++ b/tests/frontend/project_world/elements/target.bst
@@ -0,0 +1,8 @@
+kind: stack
+description: |
+
+ Main stack target for the bst build test
+
+depends:
+- import-bin.bst
+- compose-all.bst
diff --git a/tests/frontend/project_world/files/bar b/tests/frontend/project_world/files/bar
new file mode 100644
index 0000000..e69de29
diff --git a/tests/frontend/project_world/files/bin-files/usr/bin/hello b/tests/frontend/project_world/files/bin-files/usr/bin/hello
new file mode 100755
index 0000000..f534a40
--- /dev/null
+++ b/tests/frontend/project_world/files/bin-files/usr/bin/hello
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+echo "Hello !"
diff --git a/tests/frontend/project_world/files/build-files/buildstream/build/test b/tests/frontend/project_world/files/build-files/buildstream/build/test
new file mode 100644
index 0000000..9daeafb
--- /dev/null
+++ b/tests/frontend/project_world/files/build-files/buildstream/build/test
@@ -0,0 +1 @@
+test
diff --git a/tests/frontend/project_world/files/dev-files/usr/include/pony.h b/tests/frontend/project_world/files/dev-files/usr/include/pony.h
new file mode 100644
index 0000000..40bd0c2
--- /dev/null
+++ b/tests/frontend/project_world/files/dev-files/usr/include/pony.h
@@ -0,0 +1,12 @@
+#ifndef __PONY_H__
+#define __PONY_H__
+
+#define PONY_BEGIN "Once upon a time, there was a pony."
+#define PONY_END "And they lived happily ever after, the end."
+
+#define MAKE_PONY(story) \
+ PONY_BEGIN \
+ story \
+ PONY_END
+
+#endif /* __PONY_H__ */
diff --git a/tests/frontend/project_world/files/foo b/tests/frontend/project_world/files/foo
new file mode 100644
index 0000000..e69de29
diff --git a/tests/frontend/project_world/files/source-bundle/llamas.txt b/tests/frontend/project_world/files/source-bundle/llamas.txt
new file mode 100644
index 0000000..f98b248
--- /dev/null
+++ b/tests/frontend/project_world/files/source-bundle/llamas.txt
@@ -0,0 +1 @@
+llamas
diff --git a/tests/frontend/project_world/project.conf b/tests/frontend/project_world/project.conf
new file mode 100644
index 0000000..854e386
--- /dev/null
+++ b/tests/frontend/project_world/project.conf
@@ -0,0 +1,4 @@
+# Project config for frontend build test
+name: test
+
+element-path: elements