From f972a189b386455d8967a611b40767d575aff78a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Billeter?= Date: Wed, 14 Oct 2020 18:45:01 +0200 Subject: _frontend/cli.py: Drop support for bst shell --use-buildtree=try `--use-buildtree` is now a boolean option for `bst shell`. If no buildtree is available, an error is raised. --- tests/integration/shellbuildtrees.py | 86 +++++------------------------------- tests/integration/workspace.py | 10 ++--- tests/remoteexecution/buildtree.py | 4 +- tests/remoteexecution/workspace.py | 3 +- 4 files changed, 18 insertions(+), 85 deletions(-) (limited to 'tests') diff --git a/tests/integration/shellbuildtrees.py b/tests/integration/shellbuildtrees.py index f4f13268a..5164c0209 100644 --- a/tests/integration/shellbuildtrees.py +++ b/tests/integration/shellbuildtrees.py @@ -46,7 +46,7 @@ def test_buildtree_staged_forced_true(cli_integration, datafiles): res.assert_success() res = cli_integration.run( - project=project, args=["shell", "--build", "--use-buildtree", "always", element_name, "--", "cat", "test"] + project=project, args=["shell", "--build", "--use-buildtree", element_name, "--", "cat", "test"] ) res.assert_success() assert "Hi" in res.output @@ -67,54 +67,11 @@ def test_buildtree_staged_warn_empty_cached(cli_integration, tmpdir, datafiles): res.assert_success() res = cli_integration.run( - project=project, args=["shell", "--build", "--use-buildtree", "always", element_name, "--", "cat", "test"] + project=project, args=["shell", "--build", "--use-buildtree", element_name, "--", "cat", "test"] ) res.assert_main_error(ErrorDomain.APP, None) assert "Error launching shell: Artifact was created without buildtree" in res.stderr - # Now attempt the same with the try option, this should not attempt to find a buildtree - # and just launch the shell, however the cat should still fail. - res = cli_integration.run( - project=project, args=["shell", "--build", "--use-buildtree", "try", element_name, "--", "cat", "test"] - ) - assert "Artifact was created without buildtree, shell will be loaded without it" in res.stderr - assert "Hi" not in res.output - - -@pytest.mark.datafiles(DATA_DIR) -@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox") -def test_buildtree_staged_if_available(cli_integration, datafiles): - # Test that a build tree can be correctly detected. - project = str(datafiles) - element_name = "build-shell/buildtree.bst" - - res = cli_integration.run(project=project, args=["--cache-buildtrees", "always", "build", element_name]) - res.assert_success() - - res = cli_integration.run( - project=project, args=["shell", "--build", "--use-buildtree", "try", element_name, "--", "cat", "test"] - ) - res.assert_success() - assert "Hi" in res.output - - -@pytest.mark.datafiles(DATA_DIR) -@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox") -def test_buildtree_staged_forced_false(cli_integration, datafiles): - # Test that if we ask not to have a build tree it is not there - project = str(datafiles) - element_name = "build-shell/buildtree.bst" - - res = cli_integration.run(project=project, args=["--cache-buildtrees", "always", "build", element_name]) - res.assert_success() - - res = cli_integration.run( - project=project, args=["shell", "--build", "--use-buildtree", "never", element_name, "--", "cat", "test"] - ) - res.assert_shell_error() - - assert "Hi" not in res.output - @pytest.mark.datafiles(DATA_DIR) @pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox") @@ -128,7 +85,7 @@ def test_buildtree_from_failure(cli_integration, datafiles): # Assert that file has expected contents res = cli_integration.run( - project=project, args=["shell", "--build", element_name, "--use-buildtree", "always", "--", "cat", "test"] + project=project, args=["shell", "--build", element_name, "--use-buildtree", "--", "cat", "test"] ) res.assert_success() assert "WARNING using a buildtree from a failed build" in res.stderr @@ -150,7 +107,7 @@ def test_buildtree_from_failure_option_never(cli_integration, tmpdir, datafiles) res.assert_main_error(ErrorDomain.STREAM, None) res = cli_integration.run( - project=project, args=["shell", "--build", element_name, "--use-buildtree", "always", "--", "cat", "test"] + project=project, args=["shell", "--build", element_name, "--use-buildtree", "--", "cat", "test"] ) res.assert_main_error(ErrorDomain.APP, None) assert "Error launching shell: Artifact was created without buildtree" in res.stderr @@ -172,7 +129,7 @@ def test_buildtree_from_failure_option_always(cli_integration, tmpdir, datafiles res.assert_main_error(ErrorDomain.STREAM, None) res = cli_integration.run( - project=project, args=["shell", "--build", element_name, "--use-buildtree", "always", "--", "cat", "test"] + project=project, args=["shell", "--build", element_name, "--use-buildtree", "--", "cat", "test"] ) res.assert_success() assert "WARNING using a buildtree from a failed build" in res.stderr @@ -206,9 +163,7 @@ def test_buildtree_pulled(cli, tmpdir, datafiles): result.assert_success() # Check it's using the cached build tree - res = cli.run( - project=project, args=["shell", "--build", element_name, "--use-buildtree", "always", "--", "cat", "test"] - ) + res = cli.run(project=project, args=["shell", "--build", element_name, "--use-buildtree", "--", "cat", "test"]) res.assert_success() @@ -237,9 +192,7 @@ def test_buildtree_options(cli, tmpdir, datafiles): result.assert_success() # Check it's not using the cached build tree - res = cli.run( - project=project, args=["shell", "--build", element_name, "--use-buildtree", "never", "--", "cat", "test"] - ) + res = cli.run(project=project, args=["shell", "--build", element_name, "--", "cat", "test"]) res.assert_shell_error() assert "Hi" not in res.output @@ -249,17 +202,7 @@ def test_buildtree_options(cli, tmpdir, datafiles): res.assert_shell_error() assert "Hi" not in res.output - # Check correctly handling the lack of buildtree, with 'try' not attempting to - # pull the buildtree as the user context is by default set to not pull them - # and --pull not given - res = cli.run( - project=project, args=["shell", "--build", element_name, "--use-buildtree", "try", "--", "cat", "test"] - ) - assert "Hi" not in res.output - assert "Attempting to fetch missing artifact buildtrees" not in res.stderr - assert "WARNING Buildtree is not cached locally" in res.stderr - - # Check correctly handling the lack of buildtree, with 'try' attempting and succeeding + # Check correctly handling the lack of buildtree, with '--use-buildtree' attempting and succeeding # to pull the buildtree as the user context allow the pulling of buildtrees and it is # available in the remote and --pull given res = cli.run( @@ -271,7 +214,6 @@ def test_buildtree_options(cli, tmpdir, datafiles): element_name, "--pull", "--use-buildtree", - "try", "--", "cat", "test", @@ -282,19 +224,17 @@ def test_buildtree_options(cli, tmpdir, datafiles): shutil.rmtree(os.path.join(os.path.join(str(tmpdir), "cache", "artifacts"))) assert cli.get_element_state(project, element_name) != "cached" - # Check it's not loading the shell at all with always set for the buildtree, when the + # Check it's not loading the shell at all with `--use-buildtree`, when the # user context does not allow for buildtree pulling and --pull is not given result = cli.run(project=project, args=["artifact", "pull", "--deps", "all", element_name]) result.assert_success() - res = cli.run( - project=project, args=["shell", "--build", element_name, "--use-buildtree", "always", "--", "cat", "test"] - ) + res = cli.run(project=project, args=["shell", "--build", element_name, "--use-buildtree", "--", "cat", "test"]) res.assert_main_error(ErrorDomain.APP, None) assert "Buildtree is not cached locally" in res.stderr assert "Hi" not in res.output # Check that when user context is set to pull buildtrees and a remote has the buildtree, - # 'always' will attempt and succeed at pulling the missing buildtree with --pull set. + # '--use-buildtree' will attempt and succeed at pulling the missing buildtree with --pull set. res = cli.run( project=project, args=[ @@ -304,7 +244,6 @@ def test_buildtree_options(cli, tmpdir, datafiles): element_name, "--pull", "--use-buildtree", - "always", "--", "cat", "test", @@ -337,7 +276,7 @@ def test_pull_buildtree_pulled(cli, tmpdir, datafiles): # and pull-buildtrees were not both set res = cli.run( project=project, - args=["shell", "--build", element_name, "--pull", "--use-buildtree", "always", "--", "cat", "test",], + args=["shell", "--build", element_name, "--pull", "--use-buildtree", "--", "cat", "test",], ) res.assert_main_error(ErrorDomain.APP, None) assert "Buildtree is not cached locally" in res.stderr @@ -353,7 +292,6 @@ def test_pull_buildtree_pulled(cli, tmpdir, datafiles): element_name, "--pull", "--use-buildtree", - "always", "--", "cat", "test", diff --git a/tests/integration/workspace.py b/tests/integration/workspace.py index a2ea4841a..fab45b123 100644 --- a/tests/integration/workspace.py +++ b/tests/integration/workspace.py @@ -80,7 +80,7 @@ def test_workspace_commanddir(cli, datafiles): # using the cached buildtree. res = cli.run( project=project, - args=["shell", "--build", element_name, "--use-buildtree", "always", "--", "find", "..", "-mindepth", "1",], + args=["shell", "--build", element_name, "--use-buildtree", "--", "find", "..", "-mindepth", "1",], ) res.assert_success() @@ -290,7 +290,7 @@ def test_incremental_configure_commands_run_only_once(cli, datafiles): # the configure should have been run in the sandbox, so check the buildtree res = cli.run( project=project, - args=["shell", "--build", element_name, "--use-buildtree", "always", "--", "find", ".", "-mindepth", "1",], + args=["shell", "--build", element_name, "--use-buildtree", "--", "find", ".", "-mindepth", "1",], ) res.assert_success() @@ -311,7 +311,7 @@ def test_incremental_configure_commands_run_only_once(cli, datafiles): assert not os.path.exists(os.path.join(workspace, "prepared-again")) res = cli.run( project=project, - args=["shell", "--build", element_name, "--use-buildtree", "always", "--", "find", ".", "-mindepth", "1",], + args=["shell", "--build", element_name, "--use-buildtree", "--", "find", ".", "-mindepth", "1",], ) res.assert_success() @@ -382,9 +382,7 @@ def test_workspace_failed_logs(cli, datafiles): def get_buildtree_file_contents(cli, project, element_name, filename): - res = cli.run( - project=project, args=["shell", "--build", element_name, "--use-buildtree", "always", "--", "cat", filename,], - ) + res = cli.run(project=project, args=["shell", "--build", element_name, "--use-buildtree", "--", "cat", filename,],) res.assert_success() return res.output diff --git a/tests/remoteexecution/buildtree.py b/tests/remoteexecution/buildtree.py index 57e25cd14..317747fe8 100644 --- a/tests/remoteexecution/buildtree.py +++ b/tests/remoteexecution/buildtree.py @@ -63,8 +63,6 @@ def test_buildtree_remote(cli, tmpdir, datafiles): res.assert_success() # check it works this time - res = cli.run( - project=project, args=["shell", "--build", element_name, "--use-buildtree", "always", "--", "cat", "test"] - ) + res = cli.run(project=project, args=["shell", "--build", element_name, "--use-buildtree", "--", "cat", "test"]) res.assert_success() assert "Hi" in res.output diff --git a/tests/remoteexecution/workspace.py b/tests/remoteexecution/workspace.py index b525cefcd..cf8587230 100644 --- a/tests/remoteexecution/workspace.py +++ b/tests/remoteexecution/workspace.py @@ -115,7 +115,6 @@ def check_buildtree( "--build", element_name, "--use-buildtree", - "always", "--", "find", ".", @@ -176,7 +175,7 @@ def check_buildtree( def get_timemark(cli, project, element_name, marker): result = cli.run( - project=project, args=["shell", "--build", element_name, "--use-buildtree", "always", "--", "cat", marker[1:]], + project=project, args=["shell", "--build", element_name, "--use-buildtree", "--", "cat", marker[1:]], ) result.assert_success() marker_time = int(result.output) -- cgit v1.2.1