You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2022/04/05 10:04:46 UTC
[buildstream-plugins] 31/49: tests/elements/meson.py: Adding meson element tests
This is an automated email from the ASF dual-hosted git repository.
tvb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/buildstream-plugins.git
commit d151fcdd0d676236b8796f4b51a3a4e87d546445
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Mon Mar 21 16:12:27 2022 +0900
tests/elements/meson.py: Adding meson element tests
---
tests/elements/meson.py | 62 +++++++++++++++++++++
tests/elements/meson/elements/base.bst | 7 +++
.../elements/meson/elements/base/alpine-image.bst | 6 ++
.../meson/elements/base/base-configure.bst | 28 ++++++++++
.../elements/meson/elements/base/install-dpkg.bst | 15 +++++
tests/elements/meson/elements/base/meson.bst | 9 +++
tests/elements/meson/elements/base/ninja.bst | 15 +++++
.../elements/meson/elements/mesonconfroothello.bst | 15 +++++
tests/elements/meson/elements/mesonhello.bst | 9 +++
tests/elements/meson/files/mesonhello.tar.gz | Bin 0 -> 1195 bytes
tests/elements/meson/project.conf | 16 ++++++
11 files changed, 182 insertions(+)
diff --git a/tests/elements/meson.py b/tests/elements/meson.py
new file mode 100644
index 0000000..ac11fab
--- /dev/null
+++ b/tests/elements/meson.py
@@ -0,0 +1,62 @@
+# Pylint doesn't play well with fixtures and dependency injection from pytest
+# pylint: disable=redefined-outer-name
+
+import os
+import pytest
+
+from buildstream._testing.runcli import cli_integration as cli # pylint: disable=unused-import
+from buildstream._testing.integration import integration_cache # pylint: disable=unused-import
+from buildstream._testing.integration import assert_contains
+from buildstream._testing._utils.site import HAVE_SANDBOX
+
+pytestmark = pytest.mark.integration
+
+
+DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "meson")
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
+def test_meson_build(cli, datafiles):
+ project = str(datafiles)
+ checkout = os.path.join(cli.directory, "checkout")
+ element_name = "mesonhello.bst"
+
+ result = cli.run(project=project, args=["build", element_name])
+ assert result.exit_code == 0
+
+ result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout],)
+ assert result.exit_code == 0
+
+ assert_contains(checkout, ["/usr", "/usr/bin", "/usr/bin/hello"])
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
+def test_meson_confroot_build(cli, datafiles):
+ project = str(datafiles)
+ checkout = os.path.join(cli.directory, "checkout")
+ element_name = "mesonconfroothello.bst"
+
+ result = cli.run(project=project, args=["build", element_name])
+ assert result.exit_code == 0
+
+ result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout],)
+ assert result.exit_code == 0
+
+ assert_contains(checkout, ["/usr", "/usr/bin", "/usr/bin/hello"])
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
+def test_meson_run(cli, datafiles):
+ project = str(datafiles)
+ element_name = "mesonhello.bst"
+
+ result = cli.run(project=project, args=["build", element_name])
+ assert result.exit_code == 0
+
+ result = cli.run(project=project, args=["shell", element_name, "/usr/bin/hello"])
+ assert result.exit_code == 0
+
+ assert result.output == """Hello, World!\n"""
diff --git a/tests/elements/meson/elements/base.bst b/tests/elements/meson/elements/base.bst
new file mode 100644
index 0000000..08f4ffd
--- /dev/null
+++ b/tests/elements/meson/elements/base.bst
@@ -0,0 +1,7 @@
+kind: stack
+depends:
+- base/install-dpkg.bst
+- base/base-configure.bst
+- base/alpine-image.bst
+- base/ninja.bst
+- base/meson.bst
diff --git a/tests/elements/meson/elements/base/alpine-image.bst b/tests/elements/meson/elements/base/alpine-image.bst
new file mode 100644
index 0000000..f8e00ba
--- /dev/null
+++ b/tests/elements/meson/elements/base/alpine-image.bst
@@ -0,0 +1,6 @@
+kind: import
+description: Import an alpine image as the platform
+sources:
+- kind: tar
+ url: alpine:integration-tests-base.v1.x86_64.tar.xz
+ ref: 3eb559250ba82b64a68d86d0636a6b127aa5f6d25d3601a79f79214dc9703639
diff --git a/tests/elements/meson/elements/base/base-configure.bst b/tests/elements/meson/elements/base/base-configure.bst
new file mode 100644
index 0000000..5323004
--- /dev/null
+++ b/tests/elements/meson/elements/base/base-configure.bst
@@ -0,0 +1,28 @@
+kind: script
+depends:
+- filename: base/install-dpkg.bst
+ type: build
+
+variables:
+ install-root: /
+
+config:
+
+ commands:
+ - |
+ # Avoid some chowns which fail at dpkg configure time
+ #
+ mv /bin/chown /bin/chown.real
+ ln -s true /bin/chown
+
+ - |
+ # This is expected to fail, but will configure everything we need
+ # at least for the purpose of building, other dpkg scripts which
+ # require real root privileges will always fail here.
+ DEBIAN_FRONTEND=noninteractive dpkg --configure -a --abort-after=100000 || exit 0
+
+ - |
+ # Restore chown
+ #
+ rm -f /bin/chown
+ mv /bin/chown.real /bin/chown
diff --git a/tests/elements/meson/elements/base/install-dpkg.bst b/tests/elements/meson/elements/base/install-dpkg.bst
new file mode 100644
index 0000000..858044a
--- /dev/null
+++ b/tests/elements/meson/elements/base/install-dpkg.bst
@@ -0,0 +1,15 @@
+kind: manual
+depends:
+- filename: base/alpine-image.bst
+ type: build
+sources:
+- kind: git
+ url: https://gitlab.com/BuildStream/buildstream-sysroots.git
+ track: dpkg-build
+ ref: ecf14954e4298ce5495f701464339162fad73f30
+config:
+ install-commands:
+ - tar xf dpkg-build-sysroot.tar.xz -C %{install-root} --no-same-owner
+ strip-commands:
+ # For some reason, the strip commands were hanging...
+ - echo "none"
diff --git a/tests/elements/meson/elements/base/meson.bst b/tests/elements/meson/elements/base/meson.bst
new file mode 100644
index 0000000..bfeb945
--- /dev/null
+++ b/tests/elements/meson/elements/base/meson.bst
@@ -0,0 +1,9 @@
+kind: setuptools
+
+depends:
+- filename: base/alpine-image.bst
+
+sources:
+- kind: git
+ url: https://github.com/mesonbuild/meson.git
+ ref: 0.51.2-0-g6857936c592d6f9608add5a74a51ee405aaddc0d
diff --git a/tests/elements/meson/elements/base/ninja.bst b/tests/elements/meson/elements/base/ninja.bst
new file mode 100644
index 0000000..74afb16
--- /dev/null
+++ b/tests/elements/meson/elements/base/ninja.bst
@@ -0,0 +1,15 @@
+kind: manual
+
+depends:
+- filename: base/alpine-image.bst
+
+config:
+ install-commands:
+ - |
+ install -D -m 0755 ninja %{install-root}%{bindir}/ninja
+
+sources:
+- kind: zip
+ url: https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-linux.zip
+ ref: 1b1235f2b0b4df55ac6d80bbe681ea3639c9d2c505c7ff2159a3daf63d196305
+ base-dir: ''
diff --git a/tests/elements/meson/elements/mesonconfroothello.bst b/tests/elements/meson/elements/mesonconfroothello.bst
new file mode 100644
index 0000000..3455f3b
--- /dev/null
+++ b/tests/elements/meson/elements/mesonconfroothello.bst
@@ -0,0 +1,15 @@
+kind: meson
+description: meson test
+
+depends:
+- base.bst
+
+sources:
+- kind: tar
+ directory: Source
+ url: project_dir:/files/mesonhello.tar.gz
+ ref: dbfa22f02c82c83493596cde465a7ed4c39d8d412da3d8ac3b24c3045781f3b2
+
+variables:
+ conf-root: "%{build-root}/Source"
+ command-subdir: build
diff --git a/tests/elements/meson/elements/mesonhello.bst b/tests/elements/meson/elements/mesonhello.bst
new file mode 100644
index 0000000..816c57c
--- /dev/null
+++ b/tests/elements/meson/elements/mesonhello.bst
@@ -0,0 +1,9 @@
+kind: meson
+
+depends:
+- filename: base.bst
+
+sources:
+- kind: tar
+ url: project_dir:/files/mesonhello.tar.gz
+ ref: dbfa22f02c82c83493596cde465a7ed4c39d8d412da3d8ac3b24c3045781f3b2
diff --git a/tests/elements/meson/files/mesonhello.tar.gz b/tests/elements/meson/files/mesonhello.tar.gz
new file mode 100644
index 0000000..32fe461
Binary files /dev/null and b/tests/elements/meson/files/mesonhello.tar.gz differ
diff --git a/tests/elements/meson/project.conf b/tests/elements/meson/project.conf
new file mode 100644
index 0000000..52ffbf0
--- /dev/null
+++ b/tests/elements/meson/project.conf
@@ -0,0 +1,16 @@
+# test project config
+name: test
+min-version: 2.0
+
+element-path: elements
+
+plugins:
+- origin: pip
+ package-name: buildstream-plugins
+ elements:
+ - meson
+ - setuptools
+
+aliases:
+ alpine: https://bst-integration-test-images.ams3.cdn.digitaloceanspaces.com/
+ project_dir: file://{project_dir}