diff options
author | Chandan Singh <chandan@chandansingh.net> | 2020-08-04 21:37:28 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2020-08-11 01:02:07 +0000 |
commit | c791cd895b95533f27b742aec8152fc313b20d0e (patch) | |
tree | 1e7cf7f258bbc07ddb7e9bfc3925be374a4e965d /tests | |
parent | 173cd6e94b1befc2a4a9ea90e12a508f4ed0071b (diff) | |
download | buildstream-c791cd895b95533f27b742aec8152fc313b20d0e.tar.gz |
_frontend/cli.py: Fix `artifact checkout` with no arguments
When no arguments are passed to `artifact checkout` command, it
currently crashes. We actually have a check of this, but we crash before
that becasue this method tries to read the value of `target` before
we've had time to check for it.
That can only be done correctly after the app has been initialized. So,
refactor that bit of the method to run after we've checked that we are
working with a non-empty target.
Also, add a regression test for it.
Fixes #1367.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/frontend/buildcheckout.py | 12 |
1 files changed, 12 insertions, 0 deletions
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 |