Phillip Smyth pushed to branch bst_workspace_open_force_does_nothing at BuildStream / buildstream
Commits:
-
60290f31
by Javier Jardón at 2018-07-23T15:29:37Z
-
de162e43
by Javier Jardón at 2018-07-24T11:58:16Z
-
6106d657
by Josh Smith at 2018-07-25T10:50:14Z
-
4a637d63
by Jonathan Maw at 2018-07-25T12:05:19Z
-
a0ad985f
by Phil Dawson at 2018-07-25T13:03:23Z
-
95b4eae4
by Phil Dawson at 2018-07-25T13:03:23Z
-
889bf238
by Jim MacArthur at 2018-07-25T13:43:21Z
-
54fee6c8
by Phillip Smyth at 2018-07-25T14:15:36Z
6 changed files:
- buildstream/_artifactcache/cascache.py
- buildstream/_frontend/app.py
- buildstream/_stream.py
- doc/source/install_linux_distro.rst
- tests/frontend/show.py
- tests/frontend/workspace.py
Changes:
... | ... | @@ -240,7 +240,6 @@ class CASCache(ArtifactCache): |
240 | 240 |
|
241 | 241 |
except grpc.RpcError as e:
|
242 | 242 |
if e.code() != grpc.StatusCode.NOT_FOUND:
|
243 |
- element.info("{} not found at remote {}".format(element._get_brief_display_key(), remote.spec.url))
|
|
244 | 243 |
raise
|
245 | 244 |
|
246 | 245 |
return False
|
... | ... | @@ -270,6 +270,10 @@ class App(): |
270 | 270 |
|
271 | 271 |
# Exit with the error
|
272 | 272 |
self._error_exit(e)
|
273 |
+ except RecursionError:
|
|
274 |
+ click.echo("RecursionError: Depency depth is too large. Maximum recursion depth exceeded.",
|
|
275 |
+ err=True)
|
|
276 |
+ sys.exit(-1)
|
|
273 | 277 |
|
274 | 278 |
else:
|
275 | 279 |
# No exceptions occurred, print session time and summary
|
... | ... | @@ -476,7 +476,7 @@ class Stream(): |
476 | 476 |
|
477 | 477 |
# Check for workspace config
|
478 | 478 |
workspace = workspaces.get_workspace(target._get_full_name())
|
479 |
- if workspace:
|
|
479 |
+ if workspace and not force:
|
|
480 | 480 |
raise StreamError("Workspace '{}' is already defined at: {}"
|
481 | 481 |
.format(target.name, workspace.path))
|
482 | 482 |
|
... | ... | @@ -495,6 +495,10 @@ class Stream(): |
495 | 495 |
"fetch the latest version of the " +
|
496 | 496 |
"source.")
|
497 | 497 |
|
498 |
+ if workspace:
|
|
499 |
+ workspaces.delete_workspace(target._get_full_name())
|
|
500 |
+ workspaces.save_config()
|
|
501 |
+ shutil.rmtree(directory)
|
|
498 | 502 |
try:
|
499 | 503 |
os.makedirs(directory, exist_ok=True)
|
500 | 504 |
except OSError as e:
|
... | ... | @@ -6,10 +6,8 @@ Installing BuildStream on a Linux distro |
6 | 6 |
BuildStream requires the following base system requirements:
|
7 | 7 |
|
8 | 8 |
* python3 >= 3.5
|
9 |
-* libostree >= v2017.8 with introspection data
|
|
10 | 9 |
* bubblewrap >= 0.1.2
|
11 | 10 |
* fuse2
|
12 |
-* PyGObject introspection bindings
|
|
13 | 11 |
|
14 | 12 |
BuildStream also depends on the host tools for the :mod:`Source <buildstream.source>` plugins.
|
15 | 13 |
Refer to the respective :ref:`source plugin <plugins_sources>` documentation for host tool
|
... | ... | @@ -20,6 +18,7 @@ The default plugins with extra host dependencies are: |
20 | 18 |
* bzr
|
21 | 19 |
* deb
|
22 | 20 |
* git
|
21 |
+* ostree
|
|
23 | 22 |
* patch
|
24 | 23 |
* tar
|
25 | 24 |
|
... | ... | @@ -52,18 +51,24 @@ Arch Linux |
52 | 51 |
Install the dependencies with::
|
53 | 52 |
|
54 | 53 |
sudo pacman -S \
|
55 |
- python fuse2 ostree bubblewrap python-gobject \
|
|
54 |
+ python fuse2 bubblewrap \
|
|
56 | 55 |
python-pip git
|
57 | 56 |
|
58 | 57 |
For the default plugins::
|
59 | 58 |
|
60 | 59 |
sudo pacman -S \
|
61 |
- lzip git bzr patch python-arpy
|
|
60 |
+ bzr git lzip ostree patch python-arpy python-gobject
|
|
62 | 61 |
|
63 | 62 |
|
64 | 63 |
Debian
|
65 | 64 |
++++++
|
65 |
+Install the dependencies with::
|
|
66 |
+ |
|
67 |
+ sudo apt-get install \
|
|
68 |
+ python3 fuse bubblewrap \
|
|
69 |
+ python3-pip python3-dev git
|
|
66 | 70 |
|
71 |
+For the default plugins:
|
|
67 | 72 |
|
68 | 73 |
Stretch
|
69 | 74 |
^^^^^^^
|
... | ... | @@ -78,32 +83,20 @@ And then running:: |
78 | 83 |
|
79 | 84 |
sudo apt-get update
|
80 | 85 |
|
81 |
-At this point you should be able to get the system requirements with::
|
|
86 |
+At this point you should be able to get the system requirements for the default plugins with::
|
|
82 | 87 |
|
83 | 88 |
sudo apt-get install \
|
84 |
- python3 fuse ostree gir1.2-ostree-1.0 bubblewrap python3-gi \
|
|
85 |
- python3-pip python3-dev git
|
|
89 |
+ bzr git lzip patch python3-arpy python3-gi
|
|
86 | 90 |
sudo apt-get install -t stretch-backports \
|
87 | 91 |
gir1.2-ostree-1.0 ostree
|
88 | 92 |
|
89 |
-For the default plugins::
|
|
90 |
- |
|
91 |
- sudo apt-get install \
|
|
92 |
- lzip git bzr patch python3-arpy
|
|
93 |
- |
|
94 | 93 |
Buster or Sid
|
95 | 94 |
^^^^^^^^^^^^^
|
96 | 95 |
For debian unstable or testing, only the following line should be enough
|
97 |
-to get the base system requirements installed::
|
|
98 |
- |
|
99 |
- sudo apt-get install \
|
|
100 |
- python3 fuse ostree gir1.2-ostree-1.0 bubblewrap python3-gi \
|
|
101 |
- python3-pip python3-dev git
|
|
102 |
- |
|
103 |
-For the default plugins::
|
|
96 |
+to get the system requirements for the default plugins installed::
|
|
104 | 97 |
|
105 | 98 |
sudo apt-get install \
|
106 |
- lzip git bzr patch python3-arpy
|
|
99 |
+ lzip gir1.2-ostree-1.0 git bzr ostree patch python3-arpy python3-gi
|
|
107 | 100 |
|
108 | 101 |
|
109 | 102 |
Fedora
|
... | ... | @@ -112,13 +105,13 @@ For recent fedora systems, the following line should get you the system |
112 | 105 |
requirements you need::
|
113 | 106 |
|
114 | 107 |
dnf install -y \
|
115 |
- python3 fuse ostree bubblewrap python3-gobject \
|
|
108 |
+ python3 fuse bubblewrap \
|
|
116 | 109 |
python3-pip python3-devel git
|
117 | 110 |
|
118 | 111 |
For the default plugins::
|
119 | 112 |
|
120 | 113 |
dnf install -y \
|
121 |
- lzip git bzr patch python3-arpy
|
|
114 |
+ bzr git lzip patch ostree python3-arpy python3-gobject
|
|
122 | 115 |
|
123 | 116 |
|
124 | 117 |
Installing
|
1 | 1 |
import os
|
2 |
-import pytest
|
|
2 |
+import sys
|
|
3 |
+import shutil
|
|
3 | 4 |
import itertools
|
5 |
+import pytest
|
|
4 | 6 |
from tests.testutils import cli
|
5 |
- |
|
6 | 7 |
from buildstream import _yaml
|
7 | 8 |
from buildstream._exceptions import ErrorDomain, LoadErrorReason
|
8 | 9 |
|
... | ... | @@ -232,3 +233,58 @@ def test_fetched_junction(cli, tmpdir, datafiles, element_name): |
232 | 233 |
|
233 | 234 |
results = result.output.strip().splitlines()
|
234 | 235 |
assert 'junction.bst:import-etc.bst-buildable' in results
|
236 |
+ |
|
237 |
+ |
|
238 |
+###############################################################
|
|
239 |
+# Testing recursion depth #
|
|
240 |
+###############################################################
|
|
241 |
+@pytest.mark.parametrize("dependency_depth", [100, 500, 1200])
|
|
242 |
+def test_exceed_max_recursion_depth(cli, tmpdir, dependency_depth):
|
|
243 |
+ project_name = "recursion-test"
|
|
244 |
+ path = str(tmpdir)
|
|
245 |
+ project_path = os.path.join(path, project_name)
|
|
246 |
+ |
|
247 |
+ def setup_test():
|
|
248 |
+ """
|
|
249 |
+ Creates a bst project with dependencydepth + 1 elements, each of which
|
|
250 |
+ depends of the previous element to be created. Each element created
|
|
251 |
+ is of type import and has an empty source file.
|
|
252 |
+ """
|
|
253 |
+ os.mkdir(project_path)
|
|
254 |
+ |
|
255 |
+ result = cli.run(project=project_path, silent=True,
|
|
256 |
+ args=['init', '--project-name', project_name])
|
|
257 |
+ result.assert_success()
|
|
258 |
+ |
|
259 |
+ sourcefiles_path = os.path.join(project_path, "files")
|
|
260 |
+ os.mkdir(sourcefiles_path)
|
|
261 |
+ |
|
262 |
+ element_path = os.path.join(project_path, "elements")
|
|
263 |
+ for i in range(0, dependency_depth + 1):
|
|
264 |
+ element = {
|
|
265 |
+ 'kind': 'import',
|
|
266 |
+ 'sources': [{'kind': 'local',
|
|
267 |
+ 'path': 'files/source{}'.format(str(i))}],
|
|
268 |
+ 'depends': ['element{}.bst'.format(str(i - 1))]
|
|
269 |
+ }
|
|
270 |
+ if i == 0:
|
|
271 |
+ del element['depends']
|
|
272 |
+ _yaml.dump(element, os.path.join(element_path, "element{}.bst".format(str(i))))
|
|
273 |
+ |
|
274 |
+ source = os.path.join(sourcefiles_path, "source{}".format(str(i)))
|
|
275 |
+ open(source, 'x').close()
|
|
276 |
+ assert os.path.exists(source)
|
|
277 |
+ |
|
278 |
+ setup_test()
|
|
279 |
+ result = cli.run(project=project_path, silent=True,
|
|
280 |
+ args=['show', "element{}.bst".format(str(dependency_depth))])
|
|
281 |
+ |
|
282 |
+ recursion_limit = sys.getrecursionlimit()
|
|
283 |
+ if dependency_depth <= recursion_limit:
|
|
284 |
+ result.assert_success()
|
|
285 |
+ else:
|
|
286 |
+ # Assert exception is thown and handled
|
|
287 |
+ assert not result.unhandled_exception
|
|
288 |
+ assert result.exit_code == -1
|
|
289 |
+ |
|
290 |
+ shutil.rmtree(project_path)
|
... | ... | @@ -123,6 +123,58 @@ def test_open_force(cli, tmpdir, datafiles, kind): |
123 | 123 |
result.assert_success()
|
124 | 124 |
|
125 | 125 |
|
126 |
+@pytest.mark.datafiles(DATA_DIR)
|
|
127 |
+@pytest.mark.parametrize("kind", repo_kinds)
|
|
128 |
+def test_open_force_open(cli, tmpdir, datafiles, kind):
|
|
129 |
+ element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False)
|
|
130 |
+ |
|
131 |
+ # Assert the workspace dir exists
|
|
132 |
+ assert os.path.exists(workspace)
|
|
133 |
+ |
|
134 |
+ # Now open the workspace again with --force, this should happily succeed
|
|
135 |
+ result = cli.run(project=project, args=[
|
|
136 |
+ 'workspace', 'open', '--force', element_name, workspace
|
|
137 |
+ ])
|
|
138 |
+ result.assert_success()
|
|
139 |
+ |
|
140 |
+ |
|
141 |
+@pytest.mark.datafiles(DATA_DIR)
|
|
142 |
+@pytest.mark.parametrize("kind", repo_kinds)
|
|
143 |
+def test_open_force_different_workspace(cli, tmpdir, datafiles, kind):
|
|
144 |
+ element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False, "-alpha")
|
|
145 |
+ |
|
146 |
+ # Assert the workspace dir exists
|
|
147 |
+ assert os.path.exists(workspace)
|
|
148 |
+ |
|
149 |
+ hello_path = os.path.join(workspace, 'usr', 'bin', 'hello')
|
|
150 |
+ hello1_path = os.path.join(workspace, 'usr', 'bin', 'hello1')
|
|
151 |
+ |
|
152 |
+ tmpdir = os.path.join(str(tmpdir), "-beta")
|
|
153 |
+ shutil.move(hello_path, hello1_path)
|
|
154 |
+ element_name2, project2, workspace2 = open_workspace(cli, tmpdir, datafiles, kind, False, "-beta")
|
|
155 |
+ |
|
156 |
+ # Assert the workspace dir exists
|
|
157 |
+ assert os.path.exists(workspace2)
|
|
158 |
+ |
|
159 |
+ # Assert that workspace 1 contains the modified file
|
|
160 |
+ assert os.path.exists(hello1_path)
|
|
161 |
+ |
|
162 |
+ # Assert that workspace 2 contains the unmodified file
|
|
163 |
+ assert os.path.exists(os.path.join(workspace2, 'usr', 'bin', 'hello'))
|
|
164 |
+ |
|
165 |
+ # Now open the workspace again with --force, this should happily succeed
|
|
166 |
+ result = cli.run(project=project, args=[
|
|
167 |
+ 'workspace', 'open', '--force', element_name2, workspace
|
|
168 |
+ ])
|
|
169 |
+ |
|
170 |
+ # Assert that the file in workspace 1 has been replaced
|
|
171 |
+ # With the file from workspace 2
|
|
172 |
+ assert os.path.exists(hello_path)
|
|
173 |
+ assert not os.path.exists(hello1_path)
|
|
174 |
+ |
|
175 |
+ result.assert_success()
|
|
176 |
+ |
|
177 |
+ |
|
126 | 178 |
@pytest.mark.datafiles(DATA_DIR)
|
127 | 179 |
@pytest.mark.parametrize("kind", repo_kinds)
|
128 | 180 |
def test_close(cli, tmpdir, datafiles, kind):
|