summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Grayson <becky.grayson1@hotmail.co.uk>2019-07-15 13:23:11 +0100
committerRebecca Grayson <becky.grayson1@hotmail.co.uk>2019-07-16 09:52:04 +0100
commite5ac9599e89b834f45f2990cf4cb60f052dc9b1a (patch)
tree5b4c7bbed6064f6496ac3eedf75d976ea708b595
parent385e3719c7e6dc15f72c0acaca54622b3c073ecc (diff)
downloadbuildstream-becky/artifact_checkout_directory.tar.gz
Checkout to default dir if no tar or directory:becky/artifact_checkout_directory
When neither --tar nor --directory are provided, bst artifact checkout will no longer error out. Defaults to a suitable directory, consistent with bst workspace open. Test for new feature has been added
-rw-r--r--src/buildstream/_frontend/cli.py11
-rw-r--r--tests/frontend/buildcheckout.py18
2 files changed, 24 insertions, 5 deletions
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py
index 1f5d500a8..8fd834825 100644
--- a/src/buildstream/_frontend/cli.py
+++ b/src/buildstream/_frontend/cli.py
@@ -991,10 +991,6 @@ def artifact_checkout(app, force, deps, integrate, hardlinks, tar, pull_, direct
click.echo("ERROR: options --hardlinks and --tar conflict", err=True)
sys.exit(-1)
- if tar is None and directory is None:
- click.echo("ERROR: One of --directory or --tar must be provided", err=True)
- sys.exit(-1)
-
if tar is not None and directory is not None:
click.echo("ERROR: options --directory and --tar conflict", err=True)
sys.exit(-1)
@@ -1003,7 +999,12 @@ def artifact_checkout(app, force, deps, integrate, hardlinks, tar, pull_, direct
location = tar
tar = True
else:
- location = os.getcwd() if directory is None else directory
+ if directory is None:
+ location = os.path.abspath(os.path.join(os.getcwd(), element))
+ else:
+ location = directory
+ if location[-4:] == '.bst':
+ location = location[:-4]
tar = False
if deps == "build":
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py
index d3eec0d21..4e651d70d 100644
--- a/tests/frontend/buildcheckout.py
+++ b/tests/frontend/buildcheckout.py
@@ -233,6 +233,24 @@ def test_build_checkout_tarball(datafiles, cli):
@pytest.mark.datafiles(DATA_DIR)
+def test_build_checkout_no_tar_no_directory(datafiles, cli, tmpdir):
+ project = str(datafiles)
+
+ result = cli.run(project=project, args=['build', 'target.bst'])
+ result.assert_success()
+
+ checkout_args = ['artifact', 'checkout', 'target.bst']
+
+ runtestdir = os.path.join(tmpdir.dirname, tmpdir.basename)
+ result = cli.run(cwd=runtestdir, project=project, args=checkout_args)
+ result.assert_success()
+ filename = os.path.join(runtestdir, 'target', 'usr', 'bin', 'hello')
+ assert os.path.exists(filename)
+ filename = os.path.join(runtestdir, 'target', 'usr', 'include', 'pony.h')
+ assert os.path.exists(filename)
+
+
+@pytest.mark.datafiles(DATA_DIR)
def test_build_checkout_tarball_stdout(datafiles, cli):
project = str(datafiles)
tarball = os.path.join(cli.directory, 'tarball.tar')