diff options
author | Chandan Singh <chandan@chandansingh.net> | 2020-08-11 02:10:20 +0000 |
---|---|---|
committer | Chandan Singh <chandan@chandansingh.net> | 2020-08-11 02:10:20 +0000 |
commit | 8935cbb09922178dd0636758edd3b9946b5f0026 (patch) | |
tree | 1e7cf7f258bbc07ddb7e9bfc3925be374a4e965d | |
parent | 173cd6e94b1befc2a4a9ea90e12a508f4ed0071b (diff) | |
parent | c791cd895b95533f27b742aec8152fc313b20d0e (diff) | |
download | buildstream-8935cbb09922178dd0636758edd3b9946b5f0026.tar.gz |
Merge branch 'chandan/fix-artifact-checkout' into 'master'
_frontend/cli.py: Fix `artifact checkout` with no arguments
Closes #1367
See merge request BuildStream/buildstream!2017
-rw-r--r-- | src/buildstream/_frontend/cli.py | 16 | ||||
-rw-r--r-- | tests/frontend/buildcheckout.py | 12 |
2 files changed, 20 insertions, 8 deletions
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py index 20914f15d..b41d17b5b 100644 --- a/src/buildstream/_frontend/cli.py +++ b/src/buildstream/_frontend/cli.py @@ -1234,14 +1234,6 @@ def artifact_checkout(app, force, deps, integrate, hardlinks, tar, compression, if compression: click.echo("ERROR: --compression can only be provided if --tar is provided", err=True) sys.exit(-1) - else: - if directory is None: - location = os.path.abspath(os.path.join(os.getcwd(), target)) - if location[-4:] == ".bst": - location = location[:-4] - else: - location = directory - tar = False else: location = tar try: @@ -1264,6 +1256,14 @@ def artifact_checkout(app, force, deps, integrate, hardlinks, tar, compression, if not target: raise AppError('Missing argument "ELEMENT".') + if not tar: + if directory is None: + location = os.path.abspath(os.path.join(os.getcwd(), target)) + if location[-4:] == ".bst": + location = location[:-4] + else: + location = directory + app.stream.checkout( target, location=location, diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py index ca88a1368..e613b4194 100644 --- a/tests/frontend/buildcheckout.py +++ b/tests/frontend/buildcheckout.py @@ -1072,3 +1072,15 @@ def test_partial_checkout_fail(tmpdir, datafiles, cli): res = cli.run(project=project, args=["artifact", "checkout", "--pull", build_elt, "--directory", checkout_dir]) res.assert_main_error(ErrorDomain.STREAM, "uncached-checkout-attempt") assert re.findall(r"Remote \((\S+)\) does not have artifact (\S+) cached", res.stderr) + + +# Regression test for https://gitlab.com/BuildStream/buildstream/-/issues/1367. +# Make sure that `artifact checkout` fails gracefully when no arguments are +# provided. +@pytest.mark.datafiles(DATA_DIR) +def test_fail_no_args(datafiles, cli): + project = str(datafiles) + + result = cli.run(project=project, args=["artifact", "checkout"]) + result.assert_main_error(ErrorDomain.APP, None) + assert "Missing argument" in result.stderr |