summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cachekey/project/sources/pip1.bst12
-rw-r--r--tests/cachekey/project/sources/pip1.expected1
-rw-r--r--tests/cachekey/project/target.bst1
-rw-r--r--tests/cachekey/project/target.expected2
-rw-r--r--tests/integration/pip_source.py177
-rw-r--r--tests/sources/pip.py58
-rw-r--r--tests/sources/pip/first-source-pip/target.bst6
-rw-r--r--tests/sources/pip/no-packages/file1
-rw-r--r--tests/sources/pip/no-packages/target.bst6
-rw-r--r--tests/sources/pip/no-ref/file1
-rw-r--r--tests/sources/pip/no-ref/target.bst8
11 files changed, 1 insertions, 272 deletions
diff --git a/tests/cachekey/project/sources/pip1.bst b/tests/cachekey/project/sources/pip1.bst
deleted file mode 100644
index ee69efad6..000000000
--- a/tests/cachekey/project/sources/pip1.bst
+++ /dev/null
@@ -1,12 +0,0 @@
-kind: import
-
-sources:
-- kind: git
- url: https://example.com/foo/foobar.git
- ref: b99955530263172ed1beae52aed7a33885ef781f
-- kind: pip
- url: https://pypi.example.com/simple
- packages:
- - horses
- - ponies
- ref: 'horses==0.0.1\nponies==0.0.2'
diff --git a/tests/cachekey/project/sources/pip1.expected b/tests/cachekey/project/sources/pip1.expected
deleted file mode 100644
index 844f4c54c..000000000
--- a/tests/cachekey/project/sources/pip1.expected
+++ /dev/null
@@ -1 +0,0 @@
-70870ffa81e4527a2d812c809b1e99025c72d1ae289be38e45a5b22dc0262eac \ No newline at end of file
diff --git a/tests/cachekey/project/target.bst b/tests/cachekey/project/target.bst
index cabf3f7bf..1c6331754 100644
--- a/tests/cachekey/project/target.bst
+++ b/tests/cachekey/project/target.bst
@@ -13,7 +13,6 @@ depends:
- sources/patch1.bst
- sources/patch2.bst
- sources/patch3.bst
-- sources/pip1.bst
- sources/remote1.bst
- sources/remote2.bst
- sources/tar1.bst
diff --git a/tests/cachekey/project/target.expected b/tests/cachekey/project/target.expected
index cf38ddcfe..7f861c605 100644
--- a/tests/cachekey/project/target.expected
+++ b/tests/cachekey/project/target.expected
@@ -1 +1 @@
-a57f84353d1528b3ecbd9993ac02a20d0355f2451e19700172c95575af9a5b48 \ No newline at end of file
+fbf0b4dfc7d28cc4b534ea1c0d8af38a72a51d540cf903bca2c04389aadbe135
diff --git a/tests/integration/pip_source.py b/tests/integration/pip_source.py
deleted file mode 100644
index 5d314974d..000000000
--- a/tests/integration/pip_source.py
+++ /dev/null
@@ -1,177 +0,0 @@
-# Pylint doesn't play well with fixtures and dependency injection from pytest
-# pylint: disable=redefined-outer-name
-
-import os
-import pytest
-
-from buildstream import _yaml
-
-from buildstream.testing import cli_integration as cli # pylint: disable=unused-import
-from buildstream.testing.integration import assert_contains
-from buildstream.testing._utils.site import HAVE_SANDBOX
-
-from tests.testutils.python_repo import setup_pypi_repo # pylint: disable=unused-import
-
-
-pytestmark = pytest.mark.integration
-
-
-DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project")
-
-
-@pytest.mark.datafiles(DATA_DIR)
-def test_pip_source_import_packages(cli, datafiles, setup_pypi_repo):
- project = str(datafiles)
- checkout = os.path.join(cli.directory, "checkout")
- element_path = os.path.join(project, "elements")
- element_name = "pip/hello.bst"
-
- # check that exotically named packages are imported correctly
- myreqs_packages = "hellolib"
- dependencies = ["app2", "app.3", "app-4", "app_5", "app.no.6", "app-no-7", "app_no_8"]
- mock_packages = {myreqs_packages: {package: {} for package in dependencies}}
-
- # create mock pypi repository
- pypi_repo = os.path.join(project, "files", "pypi-repo")
- os.makedirs(pypi_repo, exist_ok=True)
- setup_pypi_repo(mock_packages, pypi_repo)
-
- element = {
- "kind": "import",
- "sources": [
- {"kind": "local", "path": "files/pip-source"},
- {"kind": "pip", "url": "file://{}".format(os.path.realpath(pypi_repo)), "packages": [myreqs_packages]},
- ],
- }
- os.makedirs(os.path.dirname(os.path.join(element_path, element_name)), exist_ok=True)
- _yaml.roundtrip_dump(element, os.path.join(element_path, element_name))
-
- result = cli.run(project=project, args=["source", "track", element_name])
- assert result.exit_code == 0
-
- 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,
- [
- "/.bst_pip_downloads",
- "/.bst_pip_downloads/hellolib-0.1.tar.gz",
- "/.bst_pip_downloads/app2-0.1.tar.gz",
- "/.bst_pip_downloads/app.3-0.1.tar.gz",
- "/.bst_pip_downloads/app-4-0.1.tar.gz",
- "/.bst_pip_downloads/app_5-0.1.tar.gz",
- "/.bst_pip_downloads/app.no.6-0.1.tar.gz",
- "/.bst_pip_downloads/app-no-7-0.1.tar.gz",
- "/.bst_pip_downloads/app_no_8-0.1.tar.gz",
- ],
- )
-
-
-@pytest.mark.datafiles(DATA_DIR)
-def test_pip_source_import_requirements_files(cli, datafiles, setup_pypi_repo):
- project = str(datafiles)
- checkout = os.path.join(cli.directory, "checkout")
- element_path = os.path.join(project, "elements")
- element_name = "pip/hello.bst"
-
- # check that exotically named packages are imported correctly
- myreqs_packages = "hellolib"
- dependencies = ["app2", "app.3", "app-4", "app_5", "app.no.6", "app-no-7", "app_no_8"]
- mock_packages = {myreqs_packages: {package: {} for package in dependencies}}
-
- # create mock pypi repository
- pypi_repo = os.path.join(project, "files", "pypi-repo")
- os.makedirs(pypi_repo, exist_ok=True)
- setup_pypi_repo(mock_packages, pypi_repo)
-
- element = {
- "kind": "import",
- "sources": [
- {"kind": "local", "path": "files/pip-source"},
- {
- "kind": "pip",
- "url": "file://{}".format(os.path.realpath(pypi_repo)),
- "requirements-files": ["myreqs.txt"],
- },
- ],
- }
- os.makedirs(os.path.dirname(os.path.join(element_path, element_name)), exist_ok=True)
- _yaml.roundtrip_dump(element, os.path.join(element_path, element_name))
-
- result = cli.run(project=project, args=["source", "track", element_name])
- assert result.exit_code == 0
-
- 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,
- [
- "/.bst_pip_downloads",
- "/.bst_pip_downloads/hellolib-0.1.tar.gz",
- "/.bst_pip_downloads/app2-0.1.tar.gz",
- "/.bst_pip_downloads/app.3-0.1.tar.gz",
- "/.bst_pip_downloads/app-4-0.1.tar.gz",
- "/.bst_pip_downloads/app_5-0.1.tar.gz",
- "/.bst_pip_downloads/app.no.6-0.1.tar.gz",
- "/.bst_pip_downloads/app-no-7-0.1.tar.gz",
- "/.bst_pip_downloads/app_no_8-0.1.tar.gz",
- ],
- )
-
-
-@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
-def test_pip_source_build(cli, datafiles, setup_pypi_repo):
- project = str(datafiles)
- element_path = os.path.join(project, "elements")
- element_name = "pip/hello.bst"
-
- # check that exotically named packages are imported correctly
- myreqs_packages = "hellolib"
- dependencies = ["app2", "app.3", "app-4", "app_5", "app.no.6", "app-no-7", "app_no_8"]
- mock_packages = {myreqs_packages: {package: {} for package in dependencies}}
-
- # create mock pypi repository
- pypi_repo = os.path.join(project, "files", "pypi-repo")
- os.makedirs(pypi_repo, exist_ok=True)
- setup_pypi_repo(mock_packages, pypi_repo)
-
- element = {
- "kind": "manual",
- "depends": ["base.bst"],
- "sources": [
- {"kind": "local", "path": "files/pip-source"},
- {
- "kind": "pip",
- "url": "file://{}".format(os.path.realpath(pypi_repo)),
- "requirements-files": ["myreqs.txt"],
- "packages": dependencies,
- },
- ],
- "config": {
- "install-commands": [
- "pip3 install --no-index --prefix %{install-root}/usr .bst_pip_downloads/*.tar.gz",
- "install app1.py %{install-root}/usr/bin/",
- ]
- },
- }
- os.makedirs(os.path.dirname(os.path.join(element_path, element_name)), exist_ok=True)
- _yaml.roundtrip_dump(element, os.path.join(element_path, element_name))
-
- result = cli.run(project=project, args=["source", "track", element_name])
- assert result.exit_code == 0
-
- 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/app1.py"])
- assert result.exit_code == 0
- assert result.output == "Hello App1! This is hellolib\n"
diff --git a/tests/sources/pip.py b/tests/sources/pip.py
deleted file mode 100644
index 1eacb4462..000000000
--- a/tests/sources/pip.py
+++ /dev/null
@@ -1,58 +0,0 @@
-# Pylint doesn't play well with fixtures and dependency injection from pytest
-# pylint: disable=redefined-outer-name
-
-import os
-import pytest
-
-from buildstream.exceptions import ErrorDomain
-from buildstream.plugins.sources.pip import _match_package_name
-from buildstream.testing import cli, generate_project # pylint: disable=unused-import
-
-DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "pip",)
-
-
-# Test that without ref, consistency is set appropriately.
-@pytest.mark.datafiles(os.path.join(DATA_DIR, "no-ref"))
-def test_no_ref(cli, datafiles):
- project = str(datafiles)
- generate_project(project)
- assert cli.get_element_state(project, "target.bst") == "no reference"
-
-
-# Test that pip is not allowed to be the first source
-@pytest.mark.datafiles(os.path.join(DATA_DIR, "first-source-pip"))
-def test_first_source(cli, datafiles):
- project = str(datafiles)
- generate_project(project)
- result = cli.run(project=project, args=["show", "target.bst"])
- result.assert_main_error(ErrorDomain.ELEMENT, None)
-
-
-# Test that error is raised when neither packges nor requirements files
-# have been specified
-@pytest.mark.datafiles(os.path.join(DATA_DIR, "no-packages"))
-def test_no_packages(cli, datafiles):
- project = str(datafiles)
- generate_project(project)
- result = cli.run(project=project, args=["show", "target.bst"])
- result.assert_main_error(ErrorDomain.SOURCE, None)
-
-
-# Test that pip source parses tar ball names correctly for the ref
-@pytest.mark.parametrize(
- "tarball, expected_name, expected_version",
- [
- ("dotted.package-0.9.8.tar.gz", "dotted.package", "0.9.8"),
- ("hyphenated-package-2.6.0.tar.gz", "hyphenated-package", "2.6.0"),
- ("underscore_pkg-3.1.0.tar.gz", "underscore_pkg", "3.1.0"),
- ("numbers2and5-1.0.1.tar.gz", "numbers2and5", "1.0.1"),
- ("multiple.dots.package-5.6.7.tar.gz", "multiple.dots.package", "5.6.7"),
- ("multiple-hyphens-package-1.2.3.tar.gz", "multiple-hyphens-package", "1.2.3"),
- ("multiple_underscore_pkg-3.4.5.tar.gz", "multiple_underscore_pkg", "3.4.5"),
- ("shortversion-1.0.tar.gz", "shortversion", "1.0"),
- ("longversion-1.2.3.4.tar.gz", "longversion", "1.2.3.4"),
- ],
-)
-def test_match_package_name(tarball, expected_name, expected_version):
- name, version = _match_package_name(tarball)
- assert (expected_name, expected_version) == (name, version)
diff --git a/tests/sources/pip/first-source-pip/target.bst b/tests/sources/pip/first-source-pip/target.bst
deleted file mode 100644
index e5f20ab0b..000000000
--- a/tests/sources/pip/first-source-pip/target.bst
+++ /dev/null
@@ -1,6 +0,0 @@
-kind: import
-description: pip should not be allowed to be the first source
-sources:
-- kind: pip
- packages:
- - flake8
diff --git a/tests/sources/pip/no-packages/file b/tests/sources/pip/no-packages/file
deleted file mode 100644
index 980a0d5f1..000000000
--- a/tests/sources/pip/no-packages/file
+++ /dev/null
@@ -1 +0,0 @@
-Hello World!
diff --git a/tests/sources/pip/no-packages/target.bst b/tests/sources/pip/no-packages/target.bst
deleted file mode 100644
index 0d8b948c4..000000000
--- a/tests/sources/pip/no-packages/target.bst
+++ /dev/null
@@ -1,6 +0,0 @@
-kind: import
-description: The kind of this element is irrelevant.
-sources:
-- kind: local
- path: file
-- kind: pip
diff --git a/tests/sources/pip/no-ref/file b/tests/sources/pip/no-ref/file
deleted file mode 100644
index 980a0d5f1..000000000
--- a/tests/sources/pip/no-ref/file
+++ /dev/null
@@ -1 +0,0 @@
-Hello World!
diff --git a/tests/sources/pip/no-ref/target.bst b/tests/sources/pip/no-ref/target.bst
deleted file mode 100644
index ec450b7ef..000000000
--- a/tests/sources/pip/no-ref/target.bst
+++ /dev/null
@@ -1,8 +0,0 @@
-kind: import
-description: The kind of this element is irrelevant.
-sources:
-- kind: local
- path: file
-- kind: pip
- packages:
- - flake8