diff options
author | Phillip Smyth <phillipsmyth@Nexus-x240.dyn.ducie.codethink.co.uk> | 2018-05-29 14:16:02 +0100 |
---|---|---|
committer | knownexus <phillip.smyth@codethink.co.uk> | 2018-08-03 16:25:16 +0100 |
commit | 8b8d06d635c294a868c33654924b928d28a4a775 (patch) | |
tree | 1327520bd9209b5406304e0b14d2f158ffbad3ef | |
parent | f1fac4d42466958022ba5758b3759b108938693d (diff) | |
download | buildstream-caching_build_trees.tar.gz |
tests/integration/workspace.py: Adding tests for caching of build tree and using them in a workspacecaching_build_trees
Adding Makefiles
Updating expected keys
3 files changed, 121 insertions, 0 deletions
diff --git a/tests/integration/project/files/workspace-no-existing-cached-buildtree/Makefile b/tests/integration/project/files/workspace-no-existing-cached-buildtree/Makefile new file mode 100644 index 000000000..ff3fb1e64 --- /dev/null +++ b/tests/integration/project/files/workspace-no-existing-cached-buildtree/Makefile @@ -0,0 +1,2 @@ +test: + touch test.o diff --git a/tests/integration/project/files/workspace-use-cached-buildtree/Makefile b/tests/integration/project/files/workspace-use-cached-buildtree/Makefile new file mode 100644 index 000000000..ff3fb1e64 --- /dev/null +++ b/tests/integration/project/files/workspace-use-cached-buildtree/Makefile @@ -0,0 +1,2 @@ +test: + touch test.o diff --git a/tests/integration/workspace.py b/tests/integration/workspace.py index 102d053fc..83d1e4d7c 100644 --- a/tests/integration/workspace.py +++ b/tests/integration/workspace.py @@ -5,6 +5,7 @@ from buildstream import _yaml from tests.testutils import cli_integration as cli from tests.testutils.site import IS_LINUX from tests.testutils.integration import walk_dir +from tests.frontend import configure_project pytestmark = pytest.mark.integration @@ -255,3 +256,119 @@ def test_incremental_configure_commands_run_only_once(cli, tmpdir, datafiles): res = cli.run(project=project, args=['build', element_name]) res.assert_success() assert not os.path.exists(os.path.join(workspace, 'prepared-again')) + + +@pytest.mark.integration +@pytest.mark.datafiles(DATA_DIR) +def test_use_cached_buildtree(cli, tmpdir, datafiles): + project = os.path.join(datafiles.dirname, datafiles.basename) + workspace = os.path.join(cli.directory, 'workspace') + element_path = os.path.join(project, 'elements') + element_name = 'workspace/workspace-use-cached-buildtree.bst' + + element = { + 'kind': 'manual', + 'depends': [{ + 'filename': 'base.bst', + 'type': 'build' + }], + 'sources': [{ + 'kind': 'local', + 'path': 'files/workspace-use-cached-buildtree' + }], + 'config': { + 'build-commands': [ + 'make' + ] + } + } + os.makedirs(os.path.dirname(os.path.join(element_path, element_name)), exist_ok=True) + _yaml.dump(element, os.path.join(element_path, element_name)) + + res = cli.run(project=project, args=['build', element_name]) + res.assert_success() + + res = cli.run(project=project, args=['workspace', 'open', element_name, workspace]) + res.assert_success() + assert os.path.isdir(workspace) + assert os.path.exists(os.path.join(workspace, "test.o")) + + +@pytest.mark.integration +@pytest.mark.datafiles(DATA_DIR) +def test_dont_use_cached_buildtree(cli, tmpdir, datafiles): + project = os.path.join(datafiles.dirname, datafiles.basename) + workspace = os.path.join(cli.directory, 'workspace') + element_path = os.path.join(project, 'elements') + element_name = 'workspace/workspace-use-cached-buildtree.bst' + + element = { + 'kind': 'manual', + 'depends': [{ + 'filename': 'base.bst', + 'type': 'build' + }], + 'sources': [{ + 'kind': 'local', + 'path': 'files/workspace-use-cached-buildtree' + }], + 'config': { + 'build-commands': [ + 'make' + ] + } + } + os.makedirs(os.path.dirname(os.path.join(element_path, element_name)), exist_ok=True) + _yaml.dump(element, os.path.join(element_path, element_name)) + + res = cli.run(project=project, args=['build', element_name]) + res.assert_success() + + res = cli.run(project=project, args=['workspace', 'open', + '--use-cached-buildtree=ignore-cached', + element_name, workspace]) + res.assert_success() + assert os.path.isdir(workspace) + assert not os.path.exists(os.path.join(workspace, "test.o")) + + +@pytest.mark.integration +@pytest.mark.datafiles(DATA_DIR) +# This tests the output if a build is done with the caching of build trees disabled +# and then is reenabled and a workspace is opened +def test_no_existing_cached_buildtree(cli, tmpdir, datafiles): + project = os.path.join(datafiles.dirname, datafiles.basename) + workspace = os.path.join(cli.directory, 'workspace') + element_path = os.path.join(project, 'elements') + element_name = 'workspace/workspace-no-existing-cached-buildtree.bst' + + element = { + 'kind': 'manual', + 'depends': [{ + 'filename': 'base.bst', + 'type': 'build' + }], + 'sources': [{ + 'kind': 'local', + 'path': 'files/workspace-no-existing-cached-buildtree' + }], + 'config': { + 'build-commands': [ + 'make' + ] + } + } + os.makedirs(os.path.dirname(os.path.join(element_path, element_name)), exist_ok=True) + _yaml.dump(element, os.path.join(element_path, element_name)) + + res = cli.run(project=project, + project_config={'variables': {'cache-buildtree': False}}, + args=['build', element_name]) + res.assert_success() + + res = cli.run(project=project, + project_config={'variables': {'cache-buildtrees': True}}, + args=['workspace', 'open', element_name, workspace]) + res.assert_success() + assert os.path.isdir(workspace) + assert not os.path.exists(os.path.join(workspace, "test.o")) |