diff options
Diffstat (limited to 'tests')
65 files changed, 161 insertions, 198 deletions
diff --git a/tests/artifactcache/config.py b/tests/artifactcache/config.py index 64e6c6a30..a42d1e487 100644 --- a/tests/artifactcache/config.py +++ b/tests/artifactcache/config.py @@ -11,7 +11,7 @@ from buildstream._artifactcache import ArtifactCache from buildstream._project import Project from buildstream.utils import _deduplicate from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing.runcli import cli # pylint: disable=unused-import diff --git a/tests/artifactcache/expiry.py b/tests/artifactcache/expiry.py index 83577f0c6..1474cecf6 100644 --- a/tests/artifactcache/expiry.py +++ b/tests/artifactcache/expiry.py @@ -26,7 +26,7 @@ import time import pytest from buildstream._cas import CASCache -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing import cli # pylint: disable=unused-import from tests.testutils import create_element_size, wait_for_cache_granularity diff --git a/tests/elements/filter.py b/tests/elements/filter.py index 3b38094dc..2f16270d8 100644 --- a/tests/elements/filter.py +++ b/tests/elements/filter.py @@ -8,7 +8,7 @@ import pytest from buildstream.testing import create_repo from buildstream.testing import cli # pylint: disable=unused-import -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream import _yaml DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "filter",) diff --git a/tests/format/assertion.py b/tests/format/assertion.py index 67436250a..3ca50726c 100644 --- a/tests/format/assertion.py +++ b/tests/format/assertion.py @@ -3,7 +3,7 @@ import os import pytest -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing.runcli import cli # pylint: disable=unused-import # Project directory diff --git a/tests/format/dependencies.py b/tests/format/dependencies.py index e54b9b2d5..b1a684081 100644 --- a/tests/format/dependencies.py +++ b/tests/format/dependencies.py @@ -4,7 +4,7 @@ import os import pytest -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing import cli # pylint: disable=unused-import DATA_DIR = os.path.dirname(os.path.realpath(__file__)) diff --git a/tests/format/include.py b/tests/format/include.py index 5efbc62a9..3e7e0abf0 100644 --- a/tests/format/include.py +++ b/tests/format/include.py @@ -5,7 +5,7 @@ import os import textwrap import pytest from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing import cli # pylint: disable=unused-import from buildstream.testing import create_repo from tests.testutils import generate_junction diff --git a/tests/format/invalid_keys.py b/tests/format/invalid_keys.py index ce1e2e487..b2bab194e 100644 --- a/tests/format/invalid_keys.py +++ b/tests/format/invalid_keys.py @@ -3,7 +3,7 @@ import os import pytest -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing.runcli import cli # pylint: disable=unused-import # Project directory diff --git a/tests/format/junctions.py b/tests/format/junctions.py index 43cd3f7ba..581e7442f 100644 --- a/tests/format/junctions.py +++ b/tests/format/junctions.py @@ -7,7 +7,7 @@ import shutil import pytest from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing import cli # pylint: disable=unused-import from buildstream.testing import create_repo from buildstream.testing._utils.site import HAVE_GIT diff --git a/tests/format/listdirectiveerrors.py b/tests/format/listdirectiveerrors.py index 79102cb02..77d9b3f55 100644 --- a/tests/format/listdirectiveerrors.py +++ b/tests/format/listdirectiveerrors.py @@ -3,7 +3,7 @@ import os import pytest -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing.runcli import cli # pylint: disable=unused-import # Project directory diff --git a/tests/format/optionarch.py b/tests/format/optionarch.py index 75cae9abe..4f7084b11 100644 --- a/tests/format/optionarch.py +++ b/tests/format/optionarch.py @@ -6,7 +6,7 @@ import os import pytest from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing.runcli import cli # pylint: disable=unused-import from tests.testutils import override_platform_uname diff --git a/tests/format/optionbool.py b/tests/format/optionbool.py index 3b05aafa1..6f5624926 100644 --- a/tests/format/optionbool.py +++ b/tests/format/optionbool.py @@ -4,7 +4,7 @@ import os import pytest from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing.runcli import cli # pylint: disable=unused-import # Project directory diff --git a/tests/format/optioneltmask.py b/tests/format/optioneltmask.py index 399b37b97..c5b32d127 100644 --- a/tests/format/optioneltmask.py +++ b/tests/format/optioneltmask.py @@ -4,7 +4,7 @@ import os import pytest from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing.runcli import cli # pylint: disable=unused-import # Project directory diff --git a/tests/format/optionenum.py b/tests/format/optionenum.py index ba79bea79..b525347f8 100644 --- a/tests/format/optionenum.py +++ b/tests/format/optionenum.py @@ -4,7 +4,7 @@ import os import pytest from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing.runcli import cli # pylint: disable=unused-import # Project directory diff --git a/tests/format/optionflags.py b/tests/format/optionflags.py index 53e674919..a3c310f05 100644 --- a/tests/format/optionflags.py +++ b/tests/format/optionflags.py @@ -4,7 +4,7 @@ import os import pytest from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing.runcli import cli # pylint: disable=unused-import # Project directory diff --git a/tests/format/optionos.py b/tests/format/optionos.py index 16177c4fb..46ec22de5 100644 --- a/tests/format/optionos.py +++ b/tests/format/optionos.py @@ -6,7 +6,7 @@ import os import pytest from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing.runcli import cli # pylint: disable=unused-import from tests.testutils import override_platform_uname diff --git a/tests/format/options.py b/tests/format/options.py index aa0854e96..4af3495b4 100644 --- a/tests/format/options.py +++ b/tests/format/options.py @@ -4,7 +4,7 @@ import os import pytest from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing.runcli import cli # pylint: disable=unused-import # Project directory diff --git a/tests/format/project.py b/tests/format/project.py index e6bc6a5cd..3d0931b86 100644 --- a/tests/format/project.py +++ b/tests/format/project.py @@ -4,7 +4,7 @@ import os import pytest from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing import cli # pylint: disable=unused-import from tests.testutils import filetypegenerator diff --git a/tests/format/userconfig.py b/tests/format/userconfig.py index 9b514cc3d..134327bad 100644 --- a/tests/format/userconfig.py +++ b/tests/format/userconfig.py @@ -5,7 +5,7 @@ import os import pytest -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing.runcli import cli # pylint: disable=unused-import # Project directory diff --git a/tests/format/variables.py b/tests/format/variables.py index 1d8b5aff9..11a34ee07 100644 --- a/tests/format/variables.py +++ b/tests/format/variables.py @@ -7,7 +7,7 @@ import sys import pytest from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing.runcli import cli # pylint: disable=unused-import diff --git a/tests/frontend/artifact_delete.py b/tests/frontend/artifact_delete.py index a93d99ef6..2651f567e 100644 --- a/tests/frontend/artifact_delete.py +++ b/tests/frontend/artifact_delete.py @@ -22,7 +22,7 @@ import os import pytest from buildstream.element import _get_normal_name -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream.testing import cli # pylint: disable=unused-import from tests.testutils import create_artifact_share diff --git a/tests/frontend/artifact_show.py b/tests/frontend/artifact_show.py index 6f824c0e4..de9b78c45 100644 --- a/tests/frontend/artifact_show.py +++ b/tests/frontend/artifact_show.py @@ -21,7 +21,7 @@ import os import pytest -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream.testing import cli # pylint: disable=unused-import from tests.testutils import create_artifact_share diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py index d6a216daf..512c6c151 100644 --- a/tests/frontend/buildcheckout.py +++ b/tests/frontend/buildcheckout.py @@ -12,7 +12,7 @@ from buildstream.testing import cli # pylint: disable=unused-import from buildstream.testing import create_repo from buildstream.testing._utils.site import IS_WINDOWS, CASD_SEPARATE_USER from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream import utils from tests.testutils import generate_junction, create_artifact_share diff --git a/tests/frontend/configurable_warnings.py b/tests/frontend/configurable_warnings.py index 488dab233..be0706360 100644 --- a/tests/frontend/configurable_warnings.py +++ b/tests/frontend/configurable_warnings.py @@ -6,7 +6,7 @@ import os import pytest from buildstream.plugin import CoreWarnings -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream import _yaml from buildstream.testing.runcli import cli # pylint: disable=unused-import diff --git a/tests/frontend/fetch.py b/tests/frontend/fetch.py index 8bd54ccc1..d6b28c589 100644 --- a/tests/frontend/fetch.py +++ b/tests/frontend/fetch.py @@ -6,7 +6,7 @@ import pytest from buildstream.testing import cli # pylint: disable=unused-import from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from tests.testutils import generate_junction diff --git a/tests/frontend/init.py b/tests/frontend/init.py index 3b9a95c34..78aa3eb19 100644 --- a/tests/frontend/init.py +++ b/tests/frontend/init.py @@ -7,7 +7,7 @@ from buildstream.testing import cli # pylint: disable=unused-import from buildstream import _yaml from buildstream._frontend.app import App -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream._versions import BST_FORMAT_VERSION diff --git a/tests/frontend/logging.py b/tests/frontend/logging.py index 27ff88352..7db37fa4c 100644 --- a/tests/frontend/logging.py +++ b/tests/frontend/logging.py @@ -9,7 +9,7 @@ import pytest from buildstream.testing import create_repo from buildstream import _yaml -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream.testing import cli # pylint: disable=unused-import # Project directory diff --git a/tests/frontend/overlaps.py b/tests/frontend/overlaps.py index e1c5a7c94..d734a3781 100644 --- a/tests/frontend/overlaps.py +++ b/tests/frontend/overlaps.py @@ -4,7 +4,7 @@ import os import pytest from buildstream.testing.runcli import cli # pylint: disable=unused-import -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream import _yaml from buildstream.plugin import CoreWarnings from tests.testutils import generate_junction diff --git a/tests/frontend/progress.py b/tests/frontend/progress.py index 45cba0b50..5d446bb10 100644 --- a/tests/frontend/progress.py +++ b/tests/frontend/progress.py @@ -6,7 +6,7 @@ import pytest from buildstream.testing import cli # pylint: disable=unused-import from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from tests.testutils import generate_junction diff --git a/tests/frontend/push.py b/tests/frontend/push.py index 583b57399..e9dfa2c6a 100644 --- a/tests/frontend/push.py +++ b/tests/frontend/push.py @@ -26,7 +26,7 @@ import os import pytest -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream.testing import cli # pylint: disable=unused-import from tests.testutils import ( create_artifact_share, diff --git a/tests/frontend/show.py b/tests/frontend/show.py index 94b94a058..17931ffe3 100644 --- a/tests/frontend/show.py +++ b/tests/frontend/show.py @@ -8,7 +8,7 @@ import itertools import pytest from buildstream.testing import cli # pylint: disable=unused-import from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from tests.testutils import generate_junction diff --git a/tests/frontend/track.py b/tests/frontend/track.py index 477c81556..07a89d428 100644 --- a/tests/frontend/track.py +++ b/tests/frontend/track.py @@ -7,7 +7,7 @@ import pytest from buildstream.testing import create_repo from buildstream.testing import cli # pylint: disable=unused-import -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream import _yaml from tests.testutils import generate_junction from . import configure_project diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py index eabaca68c..e05b6bd1f 100644 --- a/tests/frontend/workspace.py +++ b/tests/frontend/workspace.py @@ -37,7 +37,7 @@ import pytest from buildstream.testing import create_repo, ALL_REPO_KINDS from buildstream.testing import cli # pylint: disable=unused-import from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream._workspaces import BST_WORKSPACE_FORMAT_VERSION from tests.testutils import create_artifact_share, create_element_size, wait_for_cache_granularity diff --git a/tests/integration/cachedfail.py b/tests/integration/cachedfail.py index 9d68635e8..da764bbd2 100644 --- a/tests/integration/cachedfail.py +++ b/tests/integration/cachedfail.py @@ -21,7 +21,7 @@ import os import pytest from buildstream import utils, _yaml -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream.testing import cli_integration as cli # pylint: disable=unused-import from buildstream.testing._utils.site import HAVE_SANDBOX diff --git a/tests/integration/messages.py b/tests/integration/messages.py index f35b778d6..1a324a61f 100644 --- a/tests/integration/messages.py +++ b/tests/integration/messages.py @@ -24,7 +24,7 @@ import os import pytest from buildstream import _yaml -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream.testing import cli_integration as cli # pylint: disable=unused-import from buildstream.testing._utils.site import HAVE_SANDBOX diff --git a/tests/integration/pullbuildtrees.py b/tests/integration/pullbuildtrees.py index b43a07121..6d9eefb26 100644 --- a/tests/integration/pullbuildtrees.py +++ b/tests/integration/pullbuildtrees.py @@ -8,7 +8,7 @@ import pytest from buildstream.testing import cli, cli_integration as cli2 # pylint: disable=unused-import from buildstream.testing._utils.site import HAVE_SANDBOX -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from tests.testutils import create_artifact_share diff --git a/tests/integration/sandbox-bwrap.py b/tests/integration/sandbox-bwrap.py index a6312914b..3bf734edb 100644 --- a/tests/integration/sandbox-bwrap.py +++ b/tests/integration/sandbox-bwrap.py @@ -4,7 +4,7 @@ import os import pytest -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream.testing import cli_integration as cli # pylint: disable=unused-import from buildstream.testing._utils.site import HAVE_SANDBOX, HAVE_BWRAP_JSON_STATUS diff --git a/tests/integration/shell.py b/tests/integration/shell.py index 040ae53a5..5e35d550c 100644 --- a/tests/integration/shell.py +++ b/tests/integration/shell.py @@ -7,7 +7,7 @@ import pytest from buildstream import _yaml from buildstream.testing import cli_integration as cli # pylint: disable=unused-import from buildstream.testing._utils.site import HAVE_SANDBOX, BUILDBOX_RUN -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream import utils from tests.testutils import create_artifact_share diff --git a/tests/integration/shellbuildtrees.py b/tests/integration/shellbuildtrees.py index a3e7da1c2..0d80c1640 100644 --- a/tests/integration/shellbuildtrees.py +++ b/tests/integration/shellbuildtrees.py @@ -7,7 +7,7 @@ import shutil import pytest from buildstream.testing import cli, cli_integration # pylint: disable=unused-import -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream.testing._utils.site import HAVE_SANDBOX from tests.testutils import create_artifact_share diff --git a/tests/integration/workspace.py b/tests/integration/workspace.py index 776a1a1a6..7e84b690b 100644 --- a/tests/integration/workspace.py +++ b/tests/integration/workspace.py @@ -7,7 +7,7 @@ import pytest from buildstream import _yaml from buildstream.testing import cli_integration as cli # pylint: disable=unused-import from buildstream.testing._utils.site import HAVE_SANDBOX -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain pytestmark = pytest.mark.integration diff --git a/tests/internals/context.py b/tests/internals/context.py index c2ee1efb5..a8b9f6dd3 100644 --- a/tests/internals/context.py +++ b/tests/internals/context.py @@ -5,7 +5,8 @@ import os import pytest from buildstream._context import Context -from buildstream._exceptions import LoadError, LoadErrorReason +from buildstream._exceptions import LoadError +from buildstream.exceptions import LoadErrorReason DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "context",) diff --git a/tests/internals/loader.py b/tests/internals/loader.py index 781d144ae..6fdd9fc3a 100644 --- a/tests/internals/loader.py +++ b/tests/internals/loader.py @@ -2,7 +2,8 @@ from contextlib import contextmanager import os import pytest -from buildstream._exceptions import LoadError, LoadErrorReason +from buildstream.exceptions import LoadErrorReason +from buildstream._exceptions import LoadError from buildstream._project import Project from buildstream._loader import MetaElement from buildstream._loader.loader import _NO_PROGRESS diff --git a/tests/internals/pluginloading.py b/tests/internals/pluginloading.py index 83944bbd9..0685b09da 100644 --- a/tests/internals/pluginloading.py +++ b/tests/internals/pluginloading.py @@ -3,7 +3,8 @@ import os import pytest from buildstream._project import Project -from buildstream._exceptions import LoadError, LoadErrorReason +from buildstream._exceptions import LoadError +from buildstream.exceptions import LoadErrorReason from buildstream._pipeline import Pipeline from tests.testutils import dummy_context diff --git a/tests/internals/yaml.py b/tests/internals/yaml.py index 7b711575c..a4f8d08cc 100644 --- a/tests/internals/yaml.py +++ b/tests/internals/yaml.py @@ -4,7 +4,8 @@ from io import StringIO import pytest from buildstream import _yaml, Node, ProvenanceInformation, SequenceNode -from buildstream._exceptions import LoadError, LoadErrorReason +from buildstream.exceptions import LoadErrorReason +from buildstream._exceptions import LoadError DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "yaml",) diff --git a/tests/remoteexecution/buildfail.py b/tests/remoteexecution/buildfail.py index 22d9c825f..37f4dcafa 100644 --- a/tests/remoteexecution/buildfail.py +++ b/tests/remoteexecution/buildfail.py @@ -21,7 +21,7 @@ import os import pytest -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream import _yaml from buildstream.testing import cli_remote_execution as cli # pylint: disable=unused-import diff --git a/tests/remoteexecution/partial.py b/tests/remoteexecution/partial.py index a452d6613..ec5fabedb 100644 --- a/tests/remoteexecution/partial.py +++ b/tests/remoteexecution/partial.py @@ -4,7 +4,7 @@ import os import pytest -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream.testing import cli_remote_execution as cli # pylint: disable=unused-import from buildstream.testing.integration import assert_contains diff --git a/tests/sandboxes/fallback.py b/tests/sandboxes/fallback.py index 948e3a6de..0fd8ed4aa 100644 --- a/tests/sandboxes/fallback.py +++ b/tests/sandboxes/fallback.py @@ -20,7 +20,7 @@ import os import pytest from buildstream import _yaml -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream.testing import cli # pylint: disable=unused-import pytestmark = pytest.mark.integration diff --git a/tests/sandboxes/missing-command.py b/tests/sandboxes/missing-command.py index 87e668966..ec6ba184b 100644 --- a/tests/sandboxes/missing-command.py +++ b/tests/sandboxes/missing-command.py @@ -4,7 +4,7 @@ import os import pytest -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream.testing import cli # pylint: disable=unused-import diff --git a/tests/sandboxes/missing_dependencies.py b/tests/sandboxes/missing_dependencies.py index 722cfc647..2e96a1b1f 100644 --- a/tests/sandboxes/missing_dependencies.py +++ b/tests/sandboxes/missing_dependencies.py @@ -6,7 +6,7 @@ import os import pytest from buildstream import utils, _yaml -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream.testing._utils.site import IS_LINUX from buildstream.testing import cli # pylint: disable=unused-import diff --git a/tests/sandboxes/remote-exec-config.py b/tests/sandboxes/remote-exec-config.py index 7066ddeab..a6297834b 100644 --- a/tests/sandboxes/remote-exec-config.py +++ b/tests/sandboxes/remote-exec-config.py @@ -6,7 +6,7 @@ import os import pytest from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing.runcli import cli # pylint: disable=unused-import DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "remote-exec-config") diff --git a/tests/sandboxes/selection.py b/tests/sandboxes/selection.py index a338fe0bb..daee6dcdd 100644 --- a/tests/sandboxes/selection.py +++ b/tests/sandboxes/selection.py @@ -20,7 +20,7 @@ import os import pytest from buildstream import utils, _yaml -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream.testing import cli # pylint: disable=unused-import pytestmark = pytest.mark.integration diff --git a/tests/sourcecache/config.py b/tests/sourcecache/config.py index 9233e9f44..0c11a2726 100644 --- a/tests/sourcecache/config.py +++ b/tests/sourcecache/config.py @@ -25,7 +25,7 @@ import os import pytest from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing.runcli import cli # pylint: disable=unused-import diff --git a/tests/sourcecache/fetch.py b/tests/sourcecache/fetch.py index e21f84c89..889de62f0 100644 --- a/tests/sourcecache/fetch.py +++ b/tests/sourcecache/fetch.py @@ -24,7 +24,7 @@ import os import shutil import pytest -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream._project import Project from buildstream import _yaml from buildstream.testing import cli # pylint: disable=unused-import diff --git a/tests/sourcecache/push.py b/tests/sourcecache/push.py index 210bbfcff..9f8663a4a 100644 --- a/tests/sourcecache/push.py +++ b/tests/sourcecache/push.py @@ -25,7 +25,7 @@ from contextlib import contextmanager, ExitStack import pytest -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream._project import Project from buildstream import _yaml from buildstream.testing import cli # pylint: disable=unused-import diff --git a/tests/sourcecache/source-checkout.py b/tests/sourcecache/source-checkout.py index f1e0706a7..8abceadbd 100644 --- a/tests/sourcecache/source-checkout.py +++ b/tests/sourcecache/source-checkout.py @@ -26,7 +26,7 @@ import shutil import pytest -from buildstream._exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain from buildstream.testing.runcli import cli # pylint: disable=unused-import from tests.testutils.element_generators import create_element_size diff --git a/tests/sources/bzr.py b/tests/sources/bzr.py index ca727c793..2dcacfef5 100644 --- a/tests/sources/bzr.py +++ b/tests/sources/bzr.py @@ -4,10 +4,9 @@ import os import pytest -from buildstream import _yaml - from buildstream.testing import cli # pylint: disable=unused-import from buildstream.testing import create_repo +from buildstream.testing import generate_element from buildstream.testing._utils.site import HAVE_BZR DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "bzr") @@ -24,7 +23,7 @@ def test_fetch_checkout(cli, tmpdir, datafiles): # Write out our test target element = {"kind": "import", "sources": [repo.source_config(ref=ref)]} - _yaml.roundtrip_dump(element, os.path.join(project, "target.bst")) + generate_element(project, "target.bst", element) # Fetch, build, checkout result = cli.run(project=project, args=["source", "fetch", "target.bst"]) diff --git a/tests/sources/git.py b/tests/sources/git.py index 25976ffca..25ec49347 100644 --- a/tests/sources/git.py +++ b/tests/sources/git.py @@ -29,10 +29,11 @@ import shutil import pytest -from buildstream._exceptions import ErrorDomain -from buildstream import _yaml, Node +from buildstream import Node +from buildstream.exceptions import ErrorDomain from buildstream.plugin import CoreWarnings from buildstream.testing import cli # pylint: disable=unused-import +from buildstream.testing import generate_project, generate_element, load_yaml from buildstream.testing import create_repo from buildstream.testing._utils.site import HAVE_GIT, HAVE_OLD_GIT @@ -50,7 +51,7 @@ def test_fetch_bad_ref(cli, tmpdir, datafiles): # Write out our test target with a bad ref element = {"kind": "import", "sources": [repo.source_config(ref="5")]} - _yaml.roundtrip_dump(element, os.path.join(project, "target.bst")) + generate_element(project, "target.bst", element) # Assert that fetch raises an error here result = cli.run(project=project, args=["source", "fetch", "target.bst"]) @@ -77,7 +78,7 @@ def test_submodule_fetch_checkout(cli, tmpdir, datafiles): # Write out our test target element = {"kind": "import", "sources": [repo.source_config(ref=ref)]} - _yaml.roundtrip_dump(element, os.path.join(project, "target.bst")) + generate_element(project, "target.bst", element) # Fetch, build, checkout result = cli.run(project=project, args=["source", "fetch", "target.bst"]) @@ -116,7 +117,7 @@ def test_recursive_submodule_fetch_checkout(cli, tmpdir, datafiles): # Write out our test target element = {"kind": "import", "sources": [repo.source_config(ref=ref)]} - _yaml.roundtrip_dump(element, os.path.join(project, "target.bst")) + generate_element(project, "target.bst", element) # Fetch, build, checkout result = cli.run(project=project, args=["source", "fetch", "target.bst"]) @@ -151,7 +152,7 @@ def test_submodule_fetch_source_enable_explicit(cli, tmpdir, datafiles): # Write out our test target element = {"kind": "import", "sources": [repo.source_config_extra(ref=ref, checkout_submodules=True)]} - _yaml.roundtrip_dump(element, os.path.join(project, "target.bst")) + generate_element(project, "target.bst", element) # Fetch, build, checkout result = cli.run(project=project, args=["source", "fetch", "target.bst"]) @@ -185,7 +186,7 @@ def test_submodule_fetch_source_disable(cli, tmpdir, datafiles): # Write out our test target element = {"kind": "import", "sources": [repo.source_config_extra(ref=ref, checkout_submodules=False)]} - _yaml.roundtrip_dump(element, os.path.join(project, "target.bst")) + generate_element(project, "target.bst", element) # Fetch, build, checkout result = cli.run(project=project, args=["source", "fetch", "target.bst"]) @@ -219,7 +220,7 @@ def test_submodule_fetch_submodule_does_override(cli, tmpdir, datafiles): # Write out our test target element = {"kind": "import", "sources": [repo.source_config_extra(ref=ref, checkout_submodules=False)]} - _yaml.roundtrip_dump(element, os.path.join(project, "target.bst")) + generate_element(project, "target.bst", element) # Fetch, build, checkout result = cli.run(project=project, args=["source", "fetch", "target.bst"]) @@ -258,7 +259,7 @@ def test_submodule_fetch_submodule_individual_checkout(cli, tmpdir, datafiles): # Write out our test target element = {"kind": "import", "sources": [repo.source_config_extra(ref=ref, checkout_submodules=True)]} - _yaml.roundtrip_dump(element, os.path.join(project, "target.bst")) + generate_element(project, "target.bst", element) # Fetch, build, checkout result = cli.run(project=project, args=["source", "fetch", "target.bst"]) @@ -298,7 +299,7 @@ def test_submodule_fetch_submodule_individual_checkout_explicit(cli, tmpdir, dat # Write out our test target element = {"kind": "import", "sources": [repo.source_config_extra(ref=ref, checkout_submodules=True)]} - _yaml.roundtrip_dump(element, os.path.join(project, "target.bst")) + generate_element(project, "target.bst", element) # Fetch, build, checkout result = cli.run(project=project, args=["source", "fetch", "target.bst"]) @@ -333,7 +334,7 @@ def test_submodule_fetch_project_override(cli, tmpdir, datafiles): # Write out our test target element = {"kind": "import", "sources": [repo.source_config(ref=ref)]} - _yaml.roundtrip_dump(element, os.path.join(project, "target.bst")) + generate_element(project, "target.bst", element) # Fetch, build, checkout result = cli.run(project=project, args=["source", "fetch", "target.bst"]) @@ -359,7 +360,7 @@ def test_submodule_track_ignore_inconsistent(cli, tmpdir, datafiles): # Write out our test target element = {"kind": "import", "sources": [repo.source_config(ref=ref)]} - _yaml.roundtrip_dump(element, os.path.join(project, "target.bst")) + generate_element(project, "target.bst", element) # Now add a .gitmodules file with an inconsistent submodule, # we are calling this inconsistent because the file was created @@ -393,8 +394,7 @@ def test_submodule_track_no_ref_or_track(cli, tmpdir, datafiles): gitsource = repo.source_config(ref=None) gitsource.pop("track") element = {"kind": "import", "sources": [gitsource]} - - _yaml.roundtrip_dump(element, os.path.join(project, "target.bst")) + generate_element(project, "target.bst", element) # Track will encounter an inconsistent submodule without any ref result = cli.run(project=project, args=["show", "target.bst"]) @@ -410,8 +410,7 @@ def test_ref_not_in_track(cli, tmpdir, datafiles, fail): # Make the warning an error if we're testing errors if fail == "error": - project_template = {"name": "foo", "fatal-warnings": [CoreWarnings.REF_NOT_IN_TRACK]} - _yaml.roundtrip_dump(project_template, os.path.join(project, "project.conf")) + generate_project(project, config={"fatal-warnings": [CoreWarnings.REF_NOT_IN_TRACK]}) # Create the repo from 'repofiles', create a branch without latest commit repo = create_repo("git", str(tmpdir)) @@ -424,7 +423,7 @@ def test_ref_not_in_track(cli, tmpdir, datafiles, fail): # Write out our test target element = {"kind": "import", "sources": [gitsource]} - _yaml.roundtrip_dump(element, os.path.join(project, "target.bst")) + generate_element(project, "target.bst", element) result = cli.run(project=project, args=["build", "target.bst"]) @@ -445,8 +444,7 @@ def test_unlisted_submodule(cli, tmpdir, datafiles, fail): # Make the warning an error if we're testing errors if fail == "error": - project_template = {"name": "foo", "fatal-warnings": ["git:unlisted-submodule"]} - _yaml.roundtrip_dump(project_template, os.path.join(project, "project.conf")) + generate_project(project, config={"fatal-warnings": ["git:unlisted-submodule"]}) # Create the submodule first from the 'subrepofiles' subdir subrepo = create_repo("git", str(tmpdir), "subrepo") @@ -470,7 +468,7 @@ def test_unlisted_submodule(cli, tmpdir, datafiles, fail): # Write out our test target element = {"kind": "import", "sources": [gitsource]} - _yaml.roundtrip_dump(element, os.path.join(project, "target.bst")) + generate_element(project, "target.bst", element) # We will not see the warning or error before the first fetch, because # we don't have the repository yet and so we have no knowledge of @@ -512,8 +510,7 @@ def test_track_unlisted_submodule(cli, tmpdir, datafiles, fail): # Make the warning an error if we're testing errors if fail == "error": - project_template = {"name": "foo", "fatal-warnings": ["git:unlisted-submodule"]} - _yaml.roundtrip_dump(project_template, os.path.join(project, "project.conf")) + generate_project(project, config={"fatal-warnings": ["git:unlisted-submodule"]}) # Create the submodule first from the 'subrepofiles' subdir subrepo = create_repo("git", str(tmpdir), "subrepo") @@ -534,7 +531,7 @@ def test_track_unlisted_submodule(cli, tmpdir, datafiles, fail): # Write out our test target element = {"kind": "import", "sources": [gitsource]} - _yaml.roundtrip_dump(element, os.path.join(project, "target.bst")) + generate_element(project, "target.bst", element) # Fetch the repo, we will not see the warning because we # are still pointing to a ref which predates the submodules @@ -567,8 +564,7 @@ def test_invalid_submodule(cli, tmpdir, datafiles, fail): # Make the warning an error if we're testing errors if fail == "error": - project_template = {"name": "foo", "fatal-warnings": ["git:invalid-submodule"]} - _yaml.roundtrip_dump(project_template, os.path.join(project, "project.conf")) + generate_project(project, config={"fatal-warnings": ["git:invalid-submodule"]}) # Create the repo from 'repofiles' subdir repo = create_repo("git", str(tmpdir)) @@ -586,7 +582,7 @@ def test_invalid_submodule(cli, tmpdir, datafiles, fail): # Write out our test target element = {"kind": "import", "sources": [gitsource]} - _yaml.roundtrip_dump(element, os.path.join(project, "target.bst")) + generate_element(project, "target.bst", element) # We will not see the warning or error before the first fetch, because # we don't have the repository yet and so we have no knowledge of @@ -629,8 +625,7 @@ def test_track_invalid_submodule(cli, tmpdir, datafiles, fail): # Make the warning an error if we're testing errors if fail == "error": - project_template = {"name": "foo", "fatal-warnings": ["git:invalid-submodule"]} - _yaml.roundtrip_dump(project_template, os.path.join(project, "project.conf")) + generate_project(project, config={"fatal-warnings": ["git:invalid-submodule"]}) # Create the submodule first from the 'subrepofiles' subdir subrepo = create_repo("git", str(tmpdir), "subrepo") @@ -652,7 +647,7 @@ def test_track_invalid_submodule(cli, tmpdir, datafiles, fail): # Write out our test target element = {"kind": "import", "sources": [gitsource]} - _yaml.roundtrip_dump(element, os.path.join(project, "target.bst")) + generate_element(project, "target.bst", element) # Fetch the repo, we will not see the warning because we # are still pointing to a ref which predates the submodules @@ -692,14 +687,14 @@ def test_track_fetch(cli, tmpdir, datafiles, ref_format, tag, extra_commit): # Write out our test target element = {"kind": "import", "sources": [repo.source_config()]} element["sources"][0]["ref-format"] = ref_format + generate_element(project, "target.bst", element) element_path = os.path.join(project, "target.bst") - _yaml.roundtrip_dump(element, element_path) # Track it result = cli.run(project=project, args=["source", "track", "target.bst"]) result.assert_success() - element = _yaml.load(element_path) + element = load_yaml(element_path) new_ref = element.get_sequence("sources").mapping_at(0).get_str("ref") if ref_format == "git-describe" and tag: @@ -724,9 +719,9 @@ def test_track_fetch(cli, tmpdir, datafiles, ref_format, tag, extra_commit): def test_git_describe(cli, tmpdir, datafiles, ref_storage, tag_type): project = str(datafiles) - project_config = _yaml.load(os.path.join(project, "project.conf")) + project_config = load_yaml(os.path.join(project, "project.conf")) project_config["ref-storage"] = ref_storage - _yaml.roundtrip_dump(project_config, os.path.join(project, "project.conf")) + generate_project(project, config=project_config) repofiles = os.path.join(str(tmpdir), "repofiles") os.makedirs(repofiles, exist_ok=True) @@ -775,8 +770,8 @@ def test_git_describe(cli, tmpdir, datafiles, ref_storage, tag_type): "kind": "import", "sources": [config], } + generate_element(project, "target.bst", element) element_path = os.path.join(project, "target.bst") - _yaml.roundtrip_dump(element, element_path) if ref_storage == "inline": result = cli.run(project=project, args=["source", "track", "target.bst"]) @@ -786,7 +781,7 @@ def test_git_describe(cli, tmpdir, datafiles, ref_storage, tag_type): result.assert_success() if ref_storage == "inline": - element = _yaml.load(element_path) + element = load_yaml(element_path) tags = element.get_sequence("sources").mapping_at(0).get_sequence("tags") assert len(tags) == 2 for tag in tags: @@ -834,9 +829,9 @@ def test_git_describe(cli, tmpdir, datafiles, ref_storage, tag_type): def test_git_describe_head_is_tagged(cli, tmpdir, datafiles, ref_storage, tag_type): project = str(datafiles) - project_config = _yaml.load(os.path.join(project, "project.conf")) + project_config = load_yaml(os.path.join(project, "project.conf")) project_config["ref-storage"] = ref_storage - _yaml.roundtrip_dump(project_config, os.path.join(project, "project.conf")) + generate_project(project, config=project_config) repofiles = os.path.join(str(tmpdir), "repofiles") os.makedirs(repofiles, exist_ok=True) @@ -884,8 +879,8 @@ def test_git_describe_head_is_tagged(cli, tmpdir, datafiles, ref_storage, tag_ty "kind": "import", "sources": [config], } + generate_element(project, "target.bst", element) element_path = os.path.join(project, "target.bst") - _yaml.roundtrip_dump(element, element_path) if ref_storage == "inline": result = cli.run(project=project, args=["source", "track", "target.bst"]) @@ -895,7 +890,7 @@ def test_git_describe_head_is_tagged(cli, tmpdir, datafiles, ref_storage, tag_ty result.assert_success() if ref_storage == "inline": - element = _yaml.load(element_path) + element = load_yaml(element_path) source = element.get_sequence("sources").mapping_at(0) tags = source.get_sequence("tags") assert len(tags) == 1 @@ -941,9 +936,9 @@ def test_git_describe_head_is_tagged(cli, tmpdir, datafiles, ref_storage, tag_ty def test_git_describe_relevant_history(cli, tmpdir, datafiles): project = str(datafiles) - project_config = _yaml.load(os.path.join(project, "project.conf")) + project_config = load_yaml(os.path.join(project, "project.conf")) project_config["ref-storage"] = "project.refs" - _yaml.roundtrip_dump(project_config, os.path.join(project, "project.conf")) + generate_project(project, config=project_config) repofiles = os.path.join(str(tmpdir), "repofiles") os.makedirs(repofiles, exist_ok=True) @@ -989,8 +984,7 @@ def test_git_describe_relevant_history(cli, tmpdir, datafiles): "kind": "import", "sources": [config], } - element_path = os.path.join(project, "target.bst") - _yaml.roundtrip_dump(element, element_path) + generate_element(project, "target.bst", element) result = cli.run(project=project, args=["source", "track", "target.bst", "--deps", "all"]) result.assert_success() @@ -1015,9 +1009,9 @@ def test_git_describe_relevant_history(cli, tmpdir, datafiles): def test_default_do_not_track_tags(cli, tmpdir, datafiles): project = str(datafiles) - project_config = _yaml.load(os.path.join(project, "project.conf")) + project_config = load_yaml(os.path.join(project, "project.conf")) project_config["ref-storage"] = "inline" - _yaml.roundtrip_dump(project_config, os.path.join(project, "project.conf")) + generate_project(project, config=project_config) repofiles = os.path.join(str(tmpdir), "repofiles") os.makedirs(repofiles, exist_ok=True) @@ -1038,13 +1032,13 @@ def test_default_do_not_track_tags(cli, tmpdir, datafiles): "kind": "import", "sources": [config], } + generate_element(project, "target.bst", element) element_path = os.path.join(project, "target.bst") - _yaml.roundtrip_dump(element, element_path) result = cli.run(project=project, args=["source", "track", "target.bst"]) result.assert_success() - element = _yaml.load(element_path) + element = load_yaml(element_path) source = element.get_sequence("sources").mapping_at(0) assert "tags" not in source @@ -1070,10 +1064,10 @@ def test_overwrite_rogue_tag_multiple_remotes(cli, tmpdir, datafiles): top_commit = repo.create(repofiles) repodir, reponame = os.path.split(repo.repo) - project_config = _yaml.load(os.path.join(project, "project.conf")) + project_config = load_yaml(os.path.join(project, "project.conf")) project_config["aliases"] = Node.from_dict({"repo": "http://example.com/"}) project_config["mirrors"] = [{"name": "middle-earth", "aliases": {"repo": ["file://{}/".format(repodir)]}}] - _yaml.roundtrip_dump(project_config, os.path.join(project, "project.conf")) + generate_project(project, config=project_config) repo.add_annotated_tag("tag", "tag") @@ -1092,8 +1086,7 @@ def test_overwrite_rogue_tag_multiple_remotes(cli, tmpdir, datafiles): "kind": "import", "sources": [config], } - element_path = os.path.join(project, "target.bst") - _yaml.roundtrip_dump(element, element_path) + generate_element(project, "target.bst", element) result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() @@ -1116,7 +1109,7 @@ def test_overwrite_rogue_tag_multiple_remotes(cli, tmpdir, datafiles): repodir, reponame = os.path.split(repo.repo) - _yaml.roundtrip_dump(project_config, os.path.join(project, "project.conf")) + generate_project(project, config=project_config) config = repo.source_config(ref=new_ref) del config["track"] @@ -1126,7 +1119,7 @@ def test_overwrite_rogue_tag_multiple_remotes(cli, tmpdir, datafiles): "kind": "import", "sources": [config], } - _yaml.roundtrip_dump(element, element_path) + generate_element(project, "target.bst", element) result = cli.run(project=project, args=["build", "target.bst"]) result.assert_success() diff --git a/tests/sources/keytest.py b/tests/sources/keytest.py index 46d0d07fe..70e01f60f 100644 --- a/tests/sources/keytest.py +++ b/tests/sources/keytest.py @@ -24,7 +24,7 @@ import os import pytest -from buildstream._exceptions import ErrorDomain +from buildstream.testing import ErrorDomain from buildstream.testing import cli # pylint: disable=unused-import DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project_key_test") diff --git a/tests/sources/local.py b/tests/sources/local.py index 92313ca7f..2b0155107 100644 --- a/tests/sources/local.py +++ b/tests/sources/local.py @@ -5,7 +5,7 @@ import os import pytest from buildstream import _yaml -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing import cli # pylint: disable=unused-import from buildstream.testing._utils.site import HAVE_SANDBOX from tests.testutils import filetypegenerator diff --git a/tests/sources/no_fetch_cached.py b/tests/sources/no_fetch_cached.py index 1ee3dd7bd..4984f5326 100644 --- a/tests/sources/no_fetch_cached.py +++ b/tests/sources/no_fetch_cached.py @@ -4,10 +4,9 @@ import os import pytest -from buildstream import _yaml - from buildstream.testing import cli # pylint: disable=unused-import from buildstream.testing import create_repo +from buildstream.testing import generate_element from buildstream.testing._utils.site import HAVE_GIT DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "no-fetch-cached") @@ -28,7 +27,7 @@ def test_no_fetch_cached(cli, tmpdir, datafiles): # Write out test target with a cached and a non-cached source element = {"kind": "import", "sources": [repo.source_config(ref=ref), {"kind": "always_cached"}]} - _yaml.roundtrip_dump(element, os.path.join(project, "target.bst")) + generate_element(project, "target.bst", element) # Test fetch of target with a cached and a non-cached source result = cli.run(project=project, args=["source", "fetch", "target.bst"]) diff --git a/tests/sources/patch.py b/tests/sources/patch.py index 2b80a7055..5392a64cb 100644 --- a/tests/sources/patch.py +++ b/tests/sources/patch.py @@ -4,7 +4,7 @@ import os import pytest -from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing import cli # pylint: disable=unused-import from tests.testutils import filetypegenerator diff --git a/tests/sources/pip.py b/tests/sources/pip.py index aafdfaf1c..1eacb4462 100644 --- a/tests/sources/pip.py +++ b/tests/sources/pip.py @@ -4,19 +4,13 @@ import os import pytest -from buildstream._exceptions import ErrorDomain -from buildstream import _yaml +from buildstream.exceptions import ErrorDomain from buildstream.plugins.sources.pip import _match_package_name -from buildstream.testing import cli # pylint: disable=unused-import +from buildstream.testing import cli, generate_project # pylint: disable=unused-import DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "pip",) -def generate_project(project_dir): - project_file = os.path.join(project_dir, "project.conf") - _yaml.roundtrip_dump({"name": "foo"}, project_file) - - # Test that without ref, consistency is set appropriately. @pytest.mark.datafiles(os.path.join(DATA_DIR, "no-ref")) def test_no_ref(cli, datafiles): diff --git a/tests/sources/previous_source_access.py b/tests/sources/previous_source_access.py index fadf6710c..3c95d77e2 100644 --- a/tests/sources/previous_source_access.py +++ b/tests/sources/previous_source_access.py @@ -4,7 +4,7 @@ import os import pytest -from buildstream import _yaml +from buildstream.testing import generate_project, load_yaml from buildstream.testing import cli # pylint: disable=unused-import DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "previous_source_access") @@ -20,10 +20,10 @@ def test_custom_transform_source(cli, datafiles): # Set the project_dir alias in project.conf to the path to the tested project project_config_path = os.path.join(project, "project.conf") - project_config = _yaml.load(project_config_path) + project_config = load_yaml(project_config_path) aliases = project_config.get_mapping("aliases") aliases["project_dir"] = "file://{}".format(project) - _yaml.roundtrip_dump(project_config, project_config_path) + generate_project(project, project_config) # Ensure we can track result = cli.run(project=project, args=["source", "track", "target.bst"]) diff --git a/tests/sources/remote.py b/tests/sources/remote.py index 76e469c60..d546c6131 100644 --- a/tests/sources/remote.py +++ b/tests/sources/remote.py @@ -5,29 +5,19 @@ import os import stat import pytest -from buildstream._exceptions import ErrorDomain -from buildstream import _yaml +from buildstream.testing import ErrorDomain +from buildstream.testing import generate_project from buildstream.testing import cli # pylint: disable=unused-import from tests.testutils.file_server import create_file_server DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "remote",) -def generate_project(project_dir, tmpdir): - project_file = os.path.join(project_dir, "project.conf") - _yaml.roundtrip_dump({"name": "foo", "aliases": {"tmpdir": "file:///" + str(tmpdir)}}, project_file) - - -def generate_project_file_server(server, project_dir): - project_file = os.path.join(project_dir, "project.conf") - _yaml.roundtrip_dump({"name": "foo", "aliases": {"tmpdir": server.base_url()}}, project_file) - - # Test that without ref, consistency is set appropriately. @pytest.mark.datafiles(os.path.join(DATA_DIR, "no-ref")) def test_no_ref(cli, tmpdir, datafiles): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, {"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) assert cli.get_element_state(project, "target.bst") == "no reference" @@ -36,7 +26,7 @@ def test_no_ref(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, "missing-file")) def test_missing_file(cli, tmpdir, datafiles): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, {"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) # Try to fetch it result = cli.run(project=project, args=["source", "fetch", "target.bst"]) @@ -48,7 +38,7 @@ def test_missing_file(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, "path-in-filename")) def test_path_in_filename(cli, tmpdir, datafiles): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, {"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) # Try to fetch it result = cli.run(project=project, args=["source", "fetch", "target.bst"]) @@ -60,7 +50,8 @@ def test_path_in_filename(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, "single-file")) def test_simple_file_build(cli, tmpdir, datafiles): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, {"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) + checkoutdir = os.path.join(str(tmpdir), "checkout") # Try to fetch it @@ -87,7 +78,8 @@ def test_simple_file_build(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, "single-file-custom-name")) def test_simple_file_custom_name_build(cli, tmpdir, datafiles): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, {"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) + checkoutdir = os.path.join(str(tmpdir), "checkout") # Try to fetch it @@ -109,7 +101,8 @@ def test_unique_key(cli, tmpdir, datafiles): to generating a cache key for the source. """ project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, {"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) + states = cli.get_element_states(project, ["target.bst", "target-custom.bst", "target-custom-executable.bst"]) assert states["target.bst"] == "fetch needed" assert states["target-custom.bst"] == "fetch needed" @@ -118,7 +111,7 @@ def test_unique_key(cli, tmpdir, datafiles): # Try to fetch it cli.run(project=project, args=["source", "fetch", "target.bst"]) - # We should download the file only once + # We should download_yaml the file only once states = cli.get_element_states(project, ["target.bst", "target-custom.bst", "target-custom-executable.bst"]) assert states["target.bst"] == "buildable" assert states["target-custom.bst"] == "buildable" @@ -137,7 +130,8 @@ def test_executable(cli, tmpdir, datafiles): """This test confirms that the 'ecxecutable' parameter is honoured. """ project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, {"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) + checkoutdir = os.path.join(str(tmpdir), "checkout") assert cli.get_element_state(project, "target-custom-executable.bst") == "fetch needed" # Try to fetch it @@ -167,7 +161,7 @@ def test_use_netrc(cli, datafiles, server_type, tmpdir): with create_file_server(server_type) as server: server.add_user("testuser", "12345", project) - generate_project_file_server(server, project) + generate_project(project, {"aliases": {"tmpdir": server.base_url()}}) server.start() diff --git a/tests/sources/tar.py b/tests/sources/tar.py index c3621c152..8ac627492 100644 --- a/tests/sources/tar.py +++ b/tests/sources/tar.py @@ -11,8 +11,8 @@ import urllib.parse import pytest from buildstream import utils -from buildstream._exceptions import ErrorDomain -from buildstream import _yaml +from buildstream.exceptions import ErrorDomain +from buildstream.testing import generate_project, generate_element from buildstream.testing import cli # pylint: disable=unused-import from buildstream.testing._utils.site import HAVE_LZIP from tests.testutils.file_server import create_file_server @@ -41,21 +41,11 @@ def _assemble_tar_lz(workingdir, srcdir, dstfile): os.chdir(old_dir) -def generate_project(project_dir, tmpdir): - project_file = os.path.join(project_dir, "project.conf") - _yaml.roundtrip_dump({"name": "foo", "aliases": {"tmpdir": "file:///" + str(tmpdir)}}, project_file) - - -def generate_project_file_server(base_url, project_dir): - project_file = os.path.join(project_dir, "project.conf") - _yaml.roundtrip_dump({"name": "foo", "aliases": {"tmpdir": base_url}}, project_file) - - # Test that without ref, consistency is set appropriately. @pytest.mark.datafiles(os.path.join(DATA_DIR, "no-ref")) def test_no_ref(cli, tmpdir, datafiles): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) assert cli.get_element_state(project, "target.bst") == "no reference" @@ -63,7 +53,7 @@ def test_no_ref(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, "fetch")) def test_fetch_bad_url(cli, tmpdir, datafiles): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) # Try to fetch it result = cli.run(project=project, args=["source", "fetch", "target.bst"]) @@ -76,7 +66,7 @@ def test_fetch_bad_url(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, "fetch")) def test_fetch_bad_ref(cli, tmpdir, datafiles): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) # Create a local tar src_tar = os.path.join(str(tmpdir), "a.tar.gz") @@ -92,7 +82,7 @@ def test_fetch_bad_ref(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, "fetch")) def test_track_warning(cli, tmpdir, datafiles): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) # Create a local tar src_tar = os.path.join(str(tmpdir), "a.tar.gz") @@ -109,7 +99,7 @@ def test_track_warning(cli, tmpdir, datafiles): @pytest.mark.parametrize("srcdir", ["a", "./a"]) def test_stage_default_basedir(cli, tmpdir, datafiles, srcdir): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) checkoutdir = os.path.join(str(tmpdir), "checkout") # Create a local tar @@ -138,7 +128,7 @@ def test_stage_default_basedir(cli, tmpdir, datafiles, srcdir): @pytest.mark.parametrize("srcdir", ["a", "./a"]) def test_stage_no_basedir(cli, tmpdir, datafiles, srcdir): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) checkoutdir = os.path.join(str(tmpdir), "checkout") # Create a local tar @@ -167,7 +157,7 @@ def test_stage_no_basedir(cli, tmpdir, datafiles, srcdir): @pytest.mark.parametrize("srcdir", ["a", "./a"]) def test_stage_explicit_basedir(cli, tmpdir, datafiles, srcdir): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) checkoutdir = os.path.join(str(tmpdir), "checkout") # Create a local tar @@ -196,7 +186,7 @@ def test_stage_explicit_basedir(cli, tmpdir, datafiles, srcdir): @pytest.mark.datafiles(os.path.join(DATA_DIR, "contains-links")) def test_stage_contains_links(cli, tmpdir, datafiles): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) checkoutdir = os.path.join(str(tmpdir), "checkout") # Create a local tar @@ -232,7 +222,7 @@ def test_stage_contains_links(cli, tmpdir, datafiles): @pytest.mark.parametrize("srcdir", ["a", "./a"]) def test_stage_default_basedir_lzip(cli, tmpdir, datafiles, srcdir): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) checkoutdir = os.path.join(str(tmpdir), "checkout") # Create a local tar @@ -265,17 +255,17 @@ def test_stage_default_basedir_lzip(cli, tmpdir, datafiles, srcdir): def test_read_only_dir(cli, tmpdir, datafiles, tar_name, base_dir): try: project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) - bst_path = os.path.join(project, "target.bst") tar_file = "{}.tar.gz".format(tar_name) - _yaml.roundtrip_dump( + generate_element( + project, + "target.bst", { "kind": "import", "sources": [{"kind": "tar", "url": "tmpdir:/{}".format(tar_file), "ref": "foo", "base-dir": base_dir}], }, - bst_path, ) # Get the tarball in tests/sources/tar/read-only/content @@ -326,7 +316,7 @@ def test_use_netrc(cli, datafiles, server_type, tmpdir): with create_file_server(server_type) as server: server.add_user("testuser", "12345", file_server_files) - generate_project_file_server(server.base_url(), project) + generate_project(project, config={"aliases": {"tmpdir": server.base_url()}}) src_tar = os.path.join(file_server_files, "a.tar.gz") _assemble_tar(os.path.join(str(datafiles), "content"), "a", src_tar) @@ -368,7 +358,7 @@ def test_netrc_already_specified_user(cli, datafiles, server_type, tmpdir): server.add_user("otheruser", "12345", file_server_files) parts = urllib.parse.urlsplit(server.base_url()) base_url = urllib.parse.urlunsplit([parts[0], "otheruser@{}".format(parts[1]), *parts[2:]]) - generate_project_file_server(base_url, project) + generate_project(project, config={"aliases": {"tmpdir": base_url}}) src_tar = os.path.join(file_server_files, "a.tar.gz") _assemble_tar(os.path.join(str(datafiles), "content"), "a", src_tar) @@ -385,7 +375,7 @@ def test_netrc_already_specified_user(cli, datafiles, server_type, tmpdir): @pytest.mark.datafiles(os.path.join(DATA_DIR, "fetch")) def test_homeless_environment(cli, tmpdir, datafiles): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) # Create a local tar src_tar = os.path.join(str(tmpdir), "a.tar.gz") @@ -407,7 +397,7 @@ def test_out_of_basedir_hardlinks(cli, tmpdir, datafiles): return member project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) checkoutdir = os.path.join(str(tmpdir), "checkout") # Create a tarball with an odd hardlink @@ -445,7 +435,7 @@ def test_out_of_basedir_hardlinks(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, "out-of-basedir-hardlinks")) def test_malicious_out_of_basedir_hardlinks(cli, tmpdir, datafiles): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) # Create a maliciously-hardlinked tarball def ensure_link(member): diff --git a/tests/sources/zip.py b/tests/sources/zip.py index dcb1e2637..201271fe0 100644 --- a/tests/sources/zip.py +++ b/tests/sources/zip.py @@ -6,8 +6,8 @@ import zipfile import pytest -from buildstream._exceptions import ErrorDomain -from buildstream import _yaml +from buildstream.exceptions import ErrorDomain +from buildstream.testing import generate_project from buildstream.testing import cli # pylint: disable=unused-import from tests.testutils.file_server import create_file_server from . import list_dir_contents @@ -27,21 +27,11 @@ def _assemble_zip(workingdir, dstfile): os.chdir(old_dir) -def generate_project(project_dir, tmpdir): - project_file = os.path.join(project_dir, "project.conf") - _yaml.roundtrip_dump({"name": "foo", "aliases": {"tmpdir": "file:///" + str(tmpdir)}}, project_file) - - -def generate_project_file_server(server, project_dir): - project_file = os.path.join(project_dir, "project.conf") - _yaml.roundtrip_dump({"name": "foo", "aliases": {"tmpdir": server.base_url()}}, project_file) - - # Test that without ref, consistency is set appropriately. @pytest.mark.datafiles(os.path.join(DATA_DIR, "no-ref")) def test_no_ref(cli, tmpdir, datafiles): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) assert cli.get_element_state(project, "target.bst") == "no reference" @@ -49,7 +39,7 @@ def test_no_ref(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, "fetch")) def test_fetch_bad_url(cli, tmpdir, datafiles): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) # Try to fetch it result = cli.run(project=project, args=["source", "fetch", "target.bst"]) @@ -62,7 +52,7 @@ def test_fetch_bad_url(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, "fetch")) def test_fetch_bad_ref(cli, tmpdir, datafiles): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) # Create a local tar src_zip = os.path.join(str(tmpdir), "a.zip") @@ -78,7 +68,7 @@ def test_fetch_bad_ref(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, "fetch")) def test_track_warning(cli, tmpdir, datafiles): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) # Create a local tar src_zip = os.path.join(str(tmpdir), "a.zip") @@ -94,7 +84,7 @@ def test_track_warning(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, "fetch")) def test_stage_default_basedir(cli, tmpdir, datafiles): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) checkoutdir = os.path.join(str(tmpdir), "checkout") # Create a local tar @@ -122,7 +112,7 @@ def test_stage_default_basedir(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, "no-basedir")) def test_stage_no_basedir(cli, tmpdir, datafiles): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) checkoutdir = os.path.join(str(tmpdir), "checkout") # Create a local tar @@ -150,7 +140,7 @@ def test_stage_no_basedir(cli, tmpdir, datafiles): @pytest.mark.datafiles(os.path.join(DATA_DIR, "explicit-basedir")) def test_stage_explicit_basedir(cli, tmpdir, datafiles): project = str(datafiles) - generate_project(project, tmpdir) + generate_project(project, config={"aliases": {"tmpdir": "file:///" + str(tmpdir)}}) checkoutdir = os.path.join(str(tmpdir), "checkout") # Create a local tar @@ -193,7 +183,7 @@ def test_use_netrc(cli, datafiles, server_type, tmpdir): with create_file_server(server_type) as server: server.add_user("testuser", "12345", file_server_files) - generate_project_file_server(server, project) + generate_project(project, config={"aliases": {"tmpdir": server.base_url()}}) src_zip = os.path.join(file_server_files, "a.zip") _assemble_zip(os.path.join(str(datafiles), "content"), src_zip) |