Jonathan Maw pushed to branch jonathan/workspace-fragment-guess-element at BuildStream / buildstream
Commits:
-
38262608
by Jonathan Maw at 2018-12-11T15:12:10Z
-
a0fb654a
by Jonathan Maw at 2018-12-11T15:12:10Z
-
853f9bee
by Jonathan Maw at 2018-12-11T15:12:10Z
7 changed files:
- NEWS
- doc/sessions/developing.run
- doc/source/developing/workspaces.rst
- + doc/source/sessions-stored/developing-build-after-changes-workspace.html
- tests/frontend/source_checkout.py
- tests/frontend/workspace.py
- tests/integration/shell.py
Changes:
... | ... | @@ -86,6 +86,11 @@ buildstream 1.3.1 |
86 | 86 |
o Opening a workspace now creates a .bstproject.yaml file that allows buildstream
|
87 | 87 |
commands to be run from a workspace that is not inside a project.
|
88 | 88 |
|
89 |
+ o Specifying an element is now optional for some commands when buildstream is run
|
|
90 |
+ from inside a workspace - the 'build', 'checkout', 'fetch', 'pull', 'push',
|
|
91 |
+ 'shell', 'show', 'source-checkout', 'track', 'workspace close' and 'workspace reset'
|
|
92 |
+ commands are affected.
|
|
93 |
+ |
|
89 | 94 |
|
90 | 95 |
=================
|
91 | 96 |
buildstream 1.1.5
|
... | ... | @@ -24,6 +24,11 @@ commands: |
24 | 24 |
output: ../source/sessions/developing-build-after-changes.html
|
25 | 25 |
command: build hello.bst
|
26 | 26 |
|
27 |
+# Rebuild, from the workspace
|
|
28 |
+- directory: ../examples/developing/workspace_hello
|
|
29 |
+ output: ../source/sessions/developing-build-after-changes-workspace.html
|
|
30 |
+ command: build
|
|
31 |
+ |
|
27 | 32 |
# Capture shell output with changes
|
28 | 33 |
- directory: ../examples/developing/
|
29 | 34 |
output: ../source/sessions/developing-shell-after-changes.html
|
... | ... | @@ -50,11 +50,16 @@ We can open workspace_hello/hello.c and make the following change: |
50 | 50 |
.. literalinclude:: ../../examples/developing/update.patch
|
51 | 51 |
:language: diff
|
52 | 52 |
|
53 |
-Now, rebuild the hello.bst element
|
|
53 |
+Now, rebuild the hello.bst element.
|
|
54 | 54 |
|
55 | 55 |
.. raw:: html
|
56 | 56 |
:file: ../sessions/developing-build-after-changes.html
|
57 | 57 |
|
58 |
+Note that if you run the command from inside the workspace, the element name is optional.
|
|
59 |
+ |
|
60 |
+.. raw:: html
|
|
61 |
+ :file: ../sessions/developing-build-after-changes-workspace.html
|
|
62 |
+ |
|
58 | 63 |
Now running the hello command using bst shell:
|
59 | 64 |
|
60 | 65 |
.. raw:: html
|
1 |
+<!--
|
|
2 |
+ WARNING: This file was generated with bst2html.py
|
|
3 |
+-->
|
|
4 |
+<div class="highlight" style="font-size:x-small"><pre>
|
|
5 |
+<span style="color:#C4A000;font-weight:bold">user@host</span>:<span style="color:#3456A4;font-weight:bold">~/workspace_hello</span>$ bst build
|
|
6 |
+ |
|
7 |
+<span style="color:#06989A"><span style="opacity:0.5">[</span></span><span style="color:#C4A000">--</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">--</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">--</span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">] </span></span><span style="color:#3465A4"><span style=""><span style="opacity:0.5">START </span></span></span><span style="color:#06989A"><span style="opacity:0.5"> </span></span>Build
|
|
8 |
+<span style="color:#06989A"><span style="opacity:0.5">[</span></span><span style="color:#C4A000">--</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">--</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">--</span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">] </span></span><span style="color:#3465A4"><span style=""><span style="opacity:0.5">START </span></span></span><span style="color:#06989A"><span style="opacity:0.5"> </span></span>Loading elements
|
|
9 |
+<span style="color:#06989A"><span style="opacity:0.5">[</span></span><span style="color:#C4A000">00</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">00</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">00</span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">] </span></span><span style="color:#4E9A06"><span style=""><span style="opacity:0.5">SUCCESS</span></span></span><span style="color:#06989A"><span style="opacity:0.5"> </span></span>Loading elements
|
|
10 |
+<span style="color:#06989A"><span style="opacity:0.5">[</span></span><span style="color:#C4A000">--</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">--</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">--</span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">] </span></span><span style="color:#3465A4"><span style=""><span style="opacity:0.5">START </span></span></span><span style="color:#06989A"><span style="opacity:0.5"> </span></span>Resolving elements
|
|
11 |
+<span style="color:#06989A"><span style="opacity:0.5">[</span></span><span style="color:#C4A000">00</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">00</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">00</span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">] </span></span><span style="color:#4E9A06"><span style=""><span style="opacity:0.5">SUCCESS</span></span></span><span style="color:#06989A"><span style="opacity:0.5"> </span></span>Resolving elements
|
|
12 |
+<span style="color:#06989A"><span style="opacity:0.5">[</span></span><span style="color:#C4A000">--</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">--</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">--</span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">] </span></span><span style="color:#3465A4"><span style=""><span style="opacity:0.5">START </span></span></span><span style="color:#06989A"><span style="opacity:0.5"> </span></span>Resolving cached state
|
|
13 |
+<span style="color:#06989A"><span style="opacity:0.5">[</span></span><span style="color:#C4A000">00</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">00</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">00</span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">] </span></span><span style="color:#4E9A06"><span style=""><span style="opacity:0.5">SUCCESS</span></span></span><span style="color:#06989A"><span style="opacity:0.5"> </span></span>Resolving cached state
|
|
14 |
+<span style="color:#06989A"><span style="opacity:0.5">[</span></span><span style="color:#C4A000">--</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">--</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">--</span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">] </span></span><span style="color:#3465A4"><span style=""><span style="opacity:0.5">START </span></span></span><span style="color:#06989A"><span style="opacity:0.5"> </span></span>Checking sources
|
|
15 |
+<span style="color:#06989A"><span style="opacity:0.5">[</span></span><span style="color:#C4A000">00</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">00</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">00</span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">] </span></span><span style="color:#4E9A06"><span style=""><span style="opacity:0.5">SUCCESS</span></span></span><span style="color:#06989A"><span style="opacity:0.5"> </span></span>Checking sources
|
|
16 |
+ |
|
17 |
+<span style="color:#C4A000"><span style="">BuildStream Version 1.3.0+1032.g41813d3a.dirty
|
|
18 |
+</span></span><span style="color:#06989A"><span style="opacity:0.5"> Session Start: </span></span><span style="color:#C4A000">Wednesday, 05-12-2018 at 16:47:38</span>
|
|
19 |
+<span style="color:#06989A"><span style="opacity:0.5"> Project: </span></span><span style="color:#C4A000">developing (/home/user/workspace/buildstream/buildstream/doc/examples/developing)</span>
|
|
20 |
+<span style="color:#06989A"><span style="opacity:0.5"> Targets: </span></span><span style="color:#C4A000">hello.bst</span>
|
|
21 |
+ |
|
22 |
+<span style="color:#C4A000"><span style="">User Configuration
|
|
23 |
+</span></span><span style="color:#06989A"><span style="opacity:0.5"> Configuration File: </span></span><span style="color:#C4A000">/home/user/workspace/buildstream/buildstream/doc/run-bst-7ocq4_a7/buildstream.conf</span>
|
|
24 |
+<span style="color:#06989A"><span style="opacity:0.5"> Log Files: </span></span><span style="color:#C4A000">/home/user/workspace/buildstream/buildstream/doc/run-bst-7ocq4_a7/logs</span>
|
|
25 |
+<span style="color:#06989A"><span style="opacity:0.5"> Source Mirrors: </span></span><span style="color:#C4A000">/home/user/workspace/buildstream/buildstream/doc/run-bst-7ocq4_a7/sources</span>
|
|
26 |
+<span style="color:#06989A"><span style="opacity:0.5"> Build Area: </span></span><span style="color:#C4A000">/home/user/workspace/buildstream/buildstream/doc/run-bst-7ocq4_a7/build</span>
|
|
27 |
+<span style="color:#06989A"><span style="opacity:0.5"> Artifact Cache: </span></span><span style="color:#C4A000">/home/user/workspace/buildstream/buildstream/doc/run-bst-7ocq4_a7/artifacts</span>
|
|
28 |
+<span style="color:#06989A"><span style="opacity:0.5"> Strict Build Plan: </span></span><span style="color:#C4A000">Yes</span>
|
|
29 |
+<span style="color:#06989A"><span style="opacity:0.5"> Maximum Fetch Tasks: </span></span><span style="color:#C4A000">10</span>
|
|
30 |
+<span style="color:#06989A"><span style="opacity:0.5"> Maximum Build Tasks: </span></span><span style="color:#C4A000">4</span>
|
|
31 |
+<span style="color:#06989A"><span style="opacity:0.5"> Maximum Push Tasks: </span></span><span style="color:#C4A000">4</span>
|
|
32 |
+<span style="color:#06989A"><span style="opacity:0.5"> Maximum Network Retries: </span></span><span style="color:#C4A000">2</span>
|
|
33 |
+ |
|
34 |
+<span style="color:#C4A000"><span style="">Pipeline
|
|
35 |
+</span></span><span style="color:#75507B"> cached</span> <span style="color:#C4A000">9afe69d645f0bee106749bc2101aae16ef437bb51e1b343ef1f16f04f0572efb</span> <span style="color:#3465A4"><span style="">base/alpine.bst</span></span>
|
|
36 |
+<span style="color:#75507B"> cached</span> <span style="color:#C4A000">19f7c50c7a1db9ae4babe9d1f34f4cdbbf2428827d48673861fd1452d6c7e16b</span> <span style="color:#3465A4"><span style="">base.bst</span></span>
|
|
37 |
+<span style="color:#75507B"> cached</span> <span style="color:#C4A000">faa419610e7309d36d15926a81a8d75bbc113443c23c8162e63843dd86b5f56a</span> <span style="color:#3465A4"><span style="">hello.bst</span></span> Workspace: /home/user/workspace/buildstream/buildstream/doc/examples/developing/workspace_hello
|
|
38 |
+<span style="color:#06989A"><span style="opacity:0.5">===============================================================================
|
|
39 |
+</span></span><span style="color:#06989A"><span style="opacity:0.5">[</span></span><span style="color:#C4A000">00</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">00</span><span style="color:#06989A"><span style="opacity:0.5">:</span></span><span style="color:#C4A000">00</span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">][</span></span><span style="color:#06989A"><span style="opacity:0.5">] </span></span><span style="color:#4E9A06"><span style=""><span style="opacity:0.5">SUCCESS</span></span></span><span style="color:#06989A"><span style="opacity:0.5"> </span></span>Build
|
|
40 |
+ |
|
41 |
+<span style="color:#C4A000"><span style="">Pipeline Summary
|
|
42 |
+</span></span><span style="color:#06989A"><span style="opacity:0.5"> Total: </span></span><span style="color:#C4A000">3</span>
|
|
43 |
+<span style="color:#06989A"><span style="opacity:0.5"> Session: </span></span><span style="color:#C4A000">0</span>
|
|
44 |
+<span style="color:#06989A"><span style="opacity:0.5"> Fetch Queue: </span></span><span style="color:#C4A000">processed </span><span style="color:#4E9A06">0</span><span style="color:#06989A"><span style="opacity:0.5">, </span></span><span style="color:#C4A000">skipped </span><span style="color:#C4A000">0</span><span style="color:#06989A"><span style="opacity:0.5">, </span></span><span style="color:#C4A000">failed </span><span style="color:#CC0000"><span style="opacity:0.5">0</span></span>
|
|
45 |
+<span style="color:#06989A"><span style="opacity:0.5"> Build Queue: </span></span><span style="color:#C4A000">processed </span><span style="color:#4E9A06">0</span><span style="color:#06989A"><span style="opacity:0.5">, </span></span><span style="color:#C4A000">skipped </span><span style="color:#C4A000">0</span><span style="color:#06989A"><span style="opacity:0.5">, </span></span><span style="color:#C4A000">failed </span><span style="color:#CC0000"><span style="opacity:0.5">0</span></span>
|
|
46 |
+</pre></div>
|
... | ... | @@ -28,19 +28,28 @@ def generate_remote_import_element(input_path, output_path): |
28 | 28 |
|
29 | 29 |
|
30 | 30 |
@pytest.mark.datafiles(DATA_DIR)
|
31 |
-@pytest.mark.parametrize('with_workspace', [('workspace'), ('no-workspace')])
|
|
32 |
-def test_source_checkout(datafiles, tmpdir_factory, cli, with_workspace):
|
|
31 |
+@pytest.mark.parametrize(
|
|
32 |
+ "with_workspace,guess_element",
|
|
33 |
+ [(True, True), (True, False), (False, False)],
|
|
34 |
+ ids=["workspace-guess", "workspace-no-guess", "no-workspace-no-guess"]
|
|
35 |
+)
|
|
36 |
+def test_source_checkout(datafiles, cli, tmpdir_factory, with_workspace, guess_element):
|
|
33 | 37 |
tmpdir = tmpdir_factory.mktemp("")
|
34 | 38 |
project = os.path.join(datafiles.dirname, datafiles.basename)
|
35 | 39 |
checkout = os.path.join(cli.directory, 'source-checkout')
|
36 | 40 |
target = 'checkout-deps.bst'
|
37 | 41 |
workspace = os.path.join(str(tmpdir), 'workspace')
|
42 |
+ elm_cmd = [target] if not guess_element else []
|
|
38 | 43 |
|
39 |
- if with_workspace == "workspace":
|
|
40 |
- result = cli.run(project=project, args=['workspace', 'open', '--directory', workspace, target])
|
|
44 |
+ if with_workspace:
|
|
45 |
+ ws_cmd = ['-C', workspace]
|
|
46 |
+ result = cli.run(project=project, args=["workspace", "open", "--directory", workspace, target])
|
|
41 | 47 |
result.assert_success()
|
48 |
+ else:
|
|
49 |
+ ws_cmd = []
|
|
42 | 50 |
|
43 |
- result = cli.run(project=project, args=['source-checkout', target, '--deps', 'none', checkout])
|
|
51 |
+ args = ws_cmd + ['source-checkout', '--deps', 'none'] + elm_cmd + [checkout]
|
|
52 |
+ result = cli.run(project=project, args=args)
|
|
44 | 53 |
result.assert_success()
|
45 | 54 |
|
46 | 55 |
assert os.path.exists(os.path.join(checkout, 'checkout-deps', 'etc', 'buildstream', 'config'))
|
... | ... | @@ -616,12 +616,16 @@ def test_list(cli, tmpdir, datafiles): |
616 | 616 |
@pytest.mark.datafiles(DATA_DIR)
|
617 | 617 |
@pytest.mark.parametrize("kind", repo_kinds)
|
618 | 618 |
@pytest.mark.parametrize("strict", [("strict"), ("non-strict")])
|
619 |
-@pytest.mark.parametrize("call_from", [("project"), ("workspace")])
|
|
620 |
-def test_build(cli, tmpdir_factory, datafiles, kind, strict, call_from):
|
|
619 |
+@pytest.mark.parametrize(
|
|
620 |
+ "from_workspace,guess_element",
|
|
621 |
+ [(False, False), (True, True), (True, False)],
|
|
622 |
+ ids=["project-no-guess", "workspace-guess", "workspace-no-guess"])
|
|
623 |
+def test_build(cli, tmpdir_factory, datafiles, kind, strict, from_workspace, guess_element):
|
|
621 | 624 |
tmpdir = tmpdir_factory.mktemp('')
|
622 | 625 |
element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False)
|
623 | 626 |
checkout = os.path.join(str(tmpdir), 'checkout')
|
624 |
- args_pre = ['-C', workspace] if call_from == "workspace" else []
|
|
627 |
+ args_dir = ['-C', workspace] if from_workspace else []
|
|
628 |
+ args_elm = [element_name] if not guess_element else []
|
|
625 | 629 |
|
626 | 630 |
# Modify workspace
|
627 | 631 |
shutil.rmtree(os.path.join(workspace, 'usr', 'bin'))
|
... | ... | @@ -644,14 +648,14 @@ def test_build(cli, tmpdir_factory, datafiles, kind, strict, call_from): |
644 | 648 |
# Build modified workspace
|
645 | 649 |
assert cli.get_element_state(project, element_name) == 'buildable'
|
646 | 650 |
assert cli.get_element_key(project, element_name) == "{:?<64}".format('')
|
647 |
- result = cli.run(project=project, args=args_pre + ['build', element_name])
|
|
651 |
+ result = cli.run(project=project, args=args_dir + ['build'] + args_elm)
|
|
648 | 652 |
result.assert_success()
|
649 | 653 |
assert cli.get_element_state(project, element_name) == 'cached'
|
650 | 654 |
assert cli.get_element_key(project, element_name) != "{:?<64}".format('')
|
651 | 655 |
|
652 | 656 |
# Checkout the result
|
653 | 657 |
result = cli.run(project=project,
|
654 |
- args=args_pre + ['checkout', element_name, checkout])
|
|
658 |
+ args=args_dir + ['checkout'] + args_elm + [checkout])
|
|
655 | 659 |
result.assert_success()
|
656 | 660 |
|
657 | 661 |
# Check that the pony.conf from the modified workspace exists
|
... | ... | @@ -1062,29 +1066,36 @@ def test_multiple_failed_builds(cli, tmpdir, datafiles): |
1062 | 1066 |
|
1063 | 1067 |
@pytest.mark.datafiles(DATA_DIR)
|
1064 | 1068 |
@pytest.mark.parametrize('subdir', [True, False], ids=["subdir", "no-subdir"])
|
1065 |
-def test_external_fetch(cli, datafiles, tmpdir_factory, subdir):
|
|
1069 |
+@pytest.mark.parametrize("guess_element", [True, False], ids=["guess", "no-guess"])
|
|
1070 |
+def test_external_fetch(cli, datafiles, tmpdir_factory, subdir, guess_element):
|
|
1066 | 1071 |
# Fetching from a workspace outside a project doesn't fail horribly
|
1067 | 1072 |
tmpdir = tmpdir_factory.mktemp('')
|
1068 | 1073 |
element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, "git", False)
|
1074 |
+ arg_elm = [element_name] if not guess_element else []
|
|
1069 | 1075 |
|
1070 | 1076 |
if subdir:
|
1071 | 1077 |
call_dir = os.path.join(workspace, 'usr')
|
1072 | 1078 |
else:
|
1073 | 1079 |
call_dir = workspace
|
1074 | 1080 |
|
1075 |
- result = cli.run(project=project, args=['-C', call_dir, 'fetch', element_name])
|
|
1081 |
+ result = cli.run(project=project, args=['-C', call_dir, 'fetch'] + arg_elm)
|
|
1076 | 1082 |
result.assert_success()
|
1077 | 1083 |
|
1078 | 1084 |
# We already fetched it by opening the workspace, but we're also checking
|
1079 | 1085 |
# `bst show` works here
|
1080 |
- assert cli.get_element_state(project, element_name) == 'buildable'
|
|
1086 |
+ result = cli.run(project=project,
|
|
1087 |
+ args=['-C', call_dir, 'show', '--deps', 'none', '--format', '%{state}'] + arg_elm)
|
|
1088 |
+ result.assert_success()
|
|
1089 |
+ assert result.output.strip() == 'buildable'
|
|
1081 | 1090 |
|
1082 | 1091 |
|
1083 | 1092 |
@pytest.mark.datafiles(DATA_DIR)
|
1084 |
-def test_external_push_pull(cli, datafiles, tmpdir_factory):
|
|
1093 |
+@pytest.mark.parametrize("guess_element", [True, False], ids=["guess", "no-guess"])
|
|
1094 |
+def test_external_push_pull(cli, datafiles, tmpdir_factory, guess_element):
|
|
1085 | 1095 |
# Pushing and pulling to/from an artifact cache works from an external workspace
|
1086 | 1096 |
tmpdir = tmpdir_factory.mktemp('')
|
1087 | 1097 |
element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, "git", False)
|
1098 |
+ arg_elm = [element_name] if not guess_element else []
|
|
1088 | 1099 |
|
1089 | 1100 |
with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare')) as share:
|
1090 | 1101 |
result = cli.run(project=project, args=['-C', workspace, 'build', element_name])
|
... | ... | @@ -1094,22 +1105,24 @@ def test_external_push_pull(cli, datafiles, tmpdir_factory): |
1094 | 1105 |
'artifacts': {'url': share.repo, 'push': True}
|
1095 | 1106 |
})
|
1096 | 1107 |
|
1097 |
- result = cli.run(project=project, args=['-C', workspace, 'push', element_name])
|
|
1108 |
+ result = cli.run(project=project, args=['-C', workspace, 'push'] + arg_elm)
|
|
1098 | 1109 |
result.assert_success()
|
1099 | 1110 |
|
1100 |
- result = cli.run(project=project, args=['-C', workspace, 'pull', '--deps', 'all', element_name])
|
|
1111 |
+ result = cli.run(project=project, args=['-C', workspace, 'pull', '--deps', 'all'] + arg_elm)
|
|
1101 | 1112 |
result.assert_success()
|
1102 | 1113 |
|
1103 | 1114 |
|
1104 | 1115 |
@pytest.mark.datafiles(DATA_DIR)
|
1105 |
-def test_external_track(cli, datafiles, tmpdir_factory):
|
|
1116 |
+@pytest.mark.parametrize("guess_element", [True, False], ids=["guess", "no-guess"])
|
|
1117 |
+def test_external_track(cli, datafiles, tmpdir_factory, guess_element):
|
|
1106 | 1118 |
# Tracking does not get horribly confused
|
1107 | 1119 |
tmpdir = tmpdir_factory.mktemp('')
|
1108 | 1120 |
element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, "git", True)
|
1121 |
+ arg_elm = [element_name] if not guess_element else []
|
|
1109 | 1122 |
|
1110 | 1123 |
# The workspace is necessarily already tracked, so we only care that
|
1111 | 1124 |
# there's no weird errors.
|
1112 |
- result = cli.run(project=project, args=['-C', workspace, 'track', element_name])
|
|
1125 |
+ result = cli.run(project=project, args=['-C', workspace, 'track'] + arg_elm)
|
|
1113 | 1126 |
result.assert_success()
|
1114 | 1127 |
|
1115 | 1128 |
|
... | ... | @@ -1147,15 +1160,17 @@ def test_external_close_other(cli, datafiles, tmpdir_factory): |
1147 | 1160 |
|
1148 | 1161 |
|
1149 | 1162 |
@pytest.mark.datafiles(DATA_DIR)
|
1150 |
-def test_external_close_self(cli, datafiles, tmpdir_factory):
|
|
1163 |
+@pytest.mark.parametrize("guess_element", [True, False], ids=["guess", "no-guess"])
|
|
1164 |
+def test_external_close_self(cli, datafiles, tmpdir_factory, guess_element):
|
|
1151 | 1165 |
# >From inside an external workspace, close it
|
1152 | 1166 |
tmpdir1 = tmpdir_factory.mktemp('')
|
1153 | 1167 |
tmpdir2 = tmpdir_factory.mktemp('')
|
1154 | 1168 |
# Making use of the assumption that it's the same project in both invocations of open_workspace
|
1155 | 1169 |
alpha_element, project, alpha_workspace = open_workspace(cli, tmpdir1, datafiles, "git", False, suffix="-alpha")
|
1156 | 1170 |
beta_element, _, beta_workspace = open_workspace(cli, tmpdir2, datafiles, "git", False, suffix="-beta")
|
1171 |
+ arg_elm = [alpha_element] if not guess_element else []
|
|
1157 | 1172 |
|
1158 |
- result = cli.run(project=project, args=['-C', alpha_workspace, 'workspace', 'close', alpha_element])
|
|
1173 |
+ result = cli.run(project=project, args=['-C', alpha_workspace, 'workspace', 'close'] + arg_elm)
|
|
1159 | 1174 |
result.assert_success()
|
1160 | 1175 |
|
1161 | 1176 |
|
... | ... | @@ -1172,11 +1187,13 @@ def test_external_reset_other(cli, datafiles, tmpdir_factory): |
1172 | 1187 |
|
1173 | 1188 |
|
1174 | 1189 |
@pytest.mark.datafiles(DATA_DIR)
|
1175 |
-def test_external_reset_self(cli, datafiles, tmpdir):
|
|
1190 |
+@pytest.mark.parametrize("guess_element", [True, False], ids=["guess", "no-guess"])
|
|
1191 |
+def test_external_reset_self(cli, datafiles, tmpdir, guess_element):
|
|
1176 | 1192 |
element, project, workspace = open_workspace(cli, tmpdir, datafiles, "git", False)
|
1193 |
+ arg_elm = [element] if not guess_element else []
|
|
1177 | 1194 |
|
1178 | 1195 |
# Command succeeds
|
1179 |
- result = cli.run(project=project, args=['-C', workspace, 'workspace', 'reset', element])
|
|
1196 |
+ result = cli.run(project=project, args=['-C', workspace, 'workspace', 'reset'] + arg_elm)
|
|
1180 | 1197 |
result.assert_success()
|
1181 | 1198 |
|
1182 | 1199 |
# Successive commands still work (i.e. .bstproject.yaml hasn't been deleted)
|
... | ... | @@ -358,13 +358,22 @@ def test_integration_devices(cli, tmpdir, datafiles): |
358 | 358 |
# Test that a shell can be opened from an external workspace
|
359 | 359 |
@pytest.mark.datafiles(DATA_DIR)
|
360 | 360 |
@pytest.mark.parametrize("build_shell", [("build"), ("nobuild")])
|
361 |
+@pytest.mark.parametrize("guess_element", [True, False], ids=["guess", "no-guess"])
|
|
361 | 362 |
@pytest.mark.skipif(IS_LINUX and not HAVE_BWRAP, reason='Only available with bubblewrap on Linux')
|
362 |
-def test_integration_external_workspace(cli, tmpdir_factory, datafiles, build_shell):
|
|
363 |
+def test_integration_external_workspace(cli, tmpdir_factory, datafiles, build_shell, guess_element):
|
|
363 | 364 |
tmpdir = tmpdir_factory.mktemp("")
|
364 | 365 |
project = os.path.join(datafiles.dirname, datafiles.basename)
|
365 | 366 |
element_name = 'autotools/amhello.bst'
|
366 | 367 |
workspace_dir = os.path.join(str(tmpdir), 'workspace')
|
367 | 368 |
|
369 |
+ if guess_element:
|
|
370 |
+ # Mutate the project.conf to use a default shell command
|
|
371 |
+ project_file = os.path.join(project, 'project.conf')
|
|
372 |
+ config_text = "shell:\n"\
|
|
373 |
+ " command: ['true']\n"
|
|
374 |
+ with open(project_file, 'a') as f:
|
|
375 |
+ f.write(config_text)
|
|
376 |
+ |
|
368 | 377 |
result = cli.run(project=project, args=[
|
369 | 378 |
'workspace', 'open', '--directory', workspace_dir, element_name
|
370 | 379 |
])
|
... | ... | @@ -373,9 +382,10 @@ def test_integration_external_workspace(cli, tmpdir_factory, datafiles, build_sh |
373 | 382 |
result = cli.run(project=project, args=['-C', workspace_dir, 'build', element_name])
|
374 | 383 |
result.assert_success()
|
375 | 384 |
|
376 |
- command = ['shell']
|
|
385 |
+ command = ['-C', workspace_dir, 'shell']
|
|
377 | 386 |
if build_shell == 'build':
|
378 | 387 |
command.append('--build')
|
379 |
- command.extend([element_name, '--', 'true'])
|
|
388 |
+ if not guess_element:
|
|
389 |
+ command.extend([element_name, '--', 'true'])
|
|
380 | 390 |
result = cli.run(project=project, cwd=workspace_dir, args=command)
|
381 | 391 |
result.assert_success()
|