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:49 UTC

[buildstream-plugins] 34/49: tests/elements/setuptools.py: Adding tests for setuptools element

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 810506e8cfb30508ef55ddcd3b257fe964f27ce3
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Mon Mar 21 17:04:54 2022 +0900

    tests/elements/setuptools.py: Adding tests for setuptools element
---
 tests/elements/setuptools.py                       |  46 +++++++++++++++++++++
 tests/elements/setuptools/elements/base.bst        |   3 ++
 .../setuptools/elements/base/alpine-image.bst      |   6 +++
 .../setuptools/elements/setuptoolshello.bst        |   9 ++++
 .../setuptools/files/setuptoolshello.tar.gz        | Bin 0 -> 1342 bytes
 tests/elements/setuptools/project.conf             |  15 +++++++
 6 files changed, 79 insertions(+)

diff --git a/tests/elements/setuptools.py b/tests/elements/setuptools.py
new file mode 100644
index 0000000..837aa2b
--- /dev/null
+++ b/tests/elements/setuptools.py
@@ -0,0 +1,46 @@
+# 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__)), "setuptools")
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
+def test_setuptools_build(cli, datafiles):
+    project = str(datafiles)
+    checkout = os.path.join(cli.directory, "checkout")
+    element_name = "setuptoolshello.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_setuptools_run(cli, datafiles):
+    project = str(datafiles)
+    element_name = "setuptoolshello.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/setuptools/elements/base.bst b/tests/elements/setuptools/elements/base.bst
new file mode 100644
index 0000000..da7c70b
--- /dev/null
+++ b/tests/elements/setuptools/elements/base.bst
@@ -0,0 +1,3 @@
+kind: stack
+depends:
+- base/alpine-image.bst
diff --git a/tests/elements/setuptools/elements/base/alpine-image.bst b/tests/elements/setuptools/elements/base/alpine-image.bst
new file mode 100644
index 0000000..f8e00ba
--- /dev/null
+++ b/tests/elements/setuptools/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/setuptools/elements/setuptoolshello.bst b/tests/elements/setuptools/elements/setuptoolshello.bst
new file mode 100644
index 0000000..924664d
--- /dev/null
+++ b/tests/elements/setuptools/elements/setuptoolshello.bst
@@ -0,0 +1,9 @@
+kind: setuptools
+
+depends:
+- filename: base.bst
+
+sources:
+- kind: tar
+  url: project_dir:/files/setuptoolshello.tar.gz
+  ref: c281d5650a104b624c77676c30a456ba1c670654bcf6f24edccb9b9848513cae
diff --git a/tests/elements/setuptools/files/setuptoolshello.tar.gz b/tests/elements/setuptools/files/setuptoolshello.tar.gz
new file mode 100644
index 0000000..73eba4f
Binary files /dev/null and b/tests/elements/setuptools/files/setuptoolshello.tar.gz differ
diff --git a/tests/elements/setuptools/project.conf b/tests/elements/setuptools/project.conf
new file mode 100644
index 0000000..78b079a
--- /dev/null
+++ b/tests/elements/setuptools/project.conf
@@ -0,0 +1,15 @@
+# test project config
+name: test
+min-version: 2.0
+
+element-path: elements
+
+plugins:
+- origin: pip
+  package-name: buildstream-plugins
+  elements:
+  - setuptools
+
+aliases:
+  alpine: https://bst-integration-test-images.ams3.cdn.digitaloceanspaces.com/
+  project_dir: file://{project_dir}