Valentin David pushed to branch master at BuildStream / buildstream
Commits:
-
cc2e6ae5
by Valentin David at 2018-11-08T12:41:36Z
-
e578a89f
by Valentin David at 2018-11-08T13:11:10Z
6 changed files:
- buildstream/scriptelement.py
- + tests/integration/project/elements/script/corruption-2.bst
- + tests/integration/project/elements/script/marked-tmpdir.bst
- + tests/integration/project/elements/script/no-tmpdir.bst
- + tests/integration/project/elements/script/tmpdir.bst
- tests/integration/script.py
Changes:
| ... | ... | @@ -202,7 +202,7 @@ class ScriptElement(Element): |
| 202 | 202 |
sandbox.set_environment(self.get_environment())
|
| 203 | 203 |
|
| 204 | 204 |
# Tell the sandbox to mount the install root
|
| 205 |
- directories = {'/': False}
|
|
| 205 |
+ directories = {self.__install_root: False}
|
|
| 206 | 206 |
|
| 207 | 207 |
# Mark the artifact directories in the layout
|
| 208 | 208 |
for item in self.__layout:
|
| ... | ... | @@ -211,7 +211,10 @@ class ScriptElement(Element): |
| 211 | 211 |
directories[destination] = item['element'] or was_artifact
|
| 212 | 212 |
|
| 213 | 213 |
for directory, artifact in directories.items():
|
| 214 |
- sandbox.mark_directory(directory, artifact=artifact)
|
|
| 214 |
+ # Root does not need to be marked as it is always mounted
|
|
| 215 |
+ # with artifact (unless explicitly marked non-artifact)
|
|
| 216 |
+ if directory != '/':
|
|
| 217 |
+ sandbox.mark_directory(directory, artifact=artifact)
|
|
| 215 | 218 |
|
| 216 | 219 |
def stage(self, sandbox):
|
| 217 | 220 |
|
| 1 |
+kind: script
|
|
| 2 |
+ |
|
| 3 |
+depends:
|
|
| 4 |
+- filename: base.bst
|
|
| 5 |
+ type: build
|
|
| 6 |
+- filename: script/corruption-image.bst
|
|
| 7 |
+ type: build
|
|
| 8 |
+ |
|
| 9 |
+config:
|
|
| 10 |
+ commands:
|
|
| 11 |
+ - echo smashed >>/canary
|
| 1 |
+kind: compose
|
|
| 2 |
+ |
|
| 3 |
+depends:
|
|
| 4 |
+- filename: base.bst
|
|
| 5 |
+ type: build
|
|
| 6 |
+ |
|
| 7 |
+public:
|
|
| 8 |
+ bst:
|
|
| 9 |
+ split-rules:
|
|
| 10 |
+ remove:
|
|
| 11 |
+ - "/tmp/**"
|
|
| 12 |
+ - "/tmp"
|
| 1 |
+kind: filter
|
|
| 2 |
+ |
|
| 3 |
+depends:
|
|
| 4 |
+- filename: script/marked-tmpdir.bst
|
|
| 5 |
+ type: build
|
|
| 6 |
+ |
|
| 7 |
+config:
|
|
| 8 |
+ exclude:
|
|
| 9 |
+ - remove
|
|
| 10 |
+ include-orphans: True
|
|
| 11 |
+ |
|
| 12 |
+ |
| 1 |
+kind: script
|
|
| 2 |
+ |
|
| 3 |
+depends:
|
|
| 4 |
+- filename: script/no-tmpdir.bst
|
|
| 5 |
+ type: build
|
|
| 6 |
+ |
|
| 7 |
+config:
|
|
| 8 |
+ commands:
|
|
| 9 |
+ - |
|
|
| 10 |
+ mkdir -p /tmp/blah
|
| ... | ... | @@ -184,3 +184,41 @@ def test_regression_cache_corruption(cli, tmpdir, datafiles): |
| 184 | 184 |
|
| 185 | 185 |
with open(os.path.join(checkout_after, 'canary')) as f:
|
| 186 | 186 |
assert f.read() == 'alive\n'
|
| 187 |
+ |
|
| 188 |
+ |
|
| 189 |
+@pytest.mark.datafiles(DATA_DIR)
|
|
| 190 |
+def test_regression_tmpdir(cli, tmpdir, datafiles):
|
|
| 191 |
+ project = str(datafiles)
|
|
| 192 |
+ element_name = 'script/tmpdir.bst'
|
|
| 193 |
+ |
|
| 194 |
+ res = cli.run(project=project, args=['build', element_name])
|
|
| 195 |
+ assert res.exit_code == 0
|
|
| 196 |
+ |
|
| 197 |
+ |
|
| 198 |
+@pytest.mark.datafiles(DATA_DIR)
|
|
| 199 |
+def test_regression_cache_corruption_2(cli, tmpdir, datafiles):
|
|
| 200 |
+ project = str(datafiles)
|
|
| 201 |
+ checkout_original = os.path.join(cli.directory, 'checkout-original')
|
|
| 202 |
+ checkout_after = os.path.join(cli.directory, 'checkout-after')
|
|
| 203 |
+ element_name = 'script/corruption-2.bst'
|
|
| 204 |
+ canary_element_name = 'script/corruption-image.bst'
|
|
| 205 |
+ |
|
| 206 |
+ res = cli.run(project=project, args=['build', canary_element_name])
|
|
| 207 |
+ assert res.exit_code == 0
|
|
| 208 |
+ |
|
| 209 |
+ res = cli.run(project=project, args=['checkout', canary_element_name,
|
|
| 210 |
+ checkout_original])
|
|
| 211 |
+ assert res.exit_code == 0
|
|
| 212 |
+ |
|
| 213 |
+ with open(os.path.join(checkout_original, 'canary')) as f:
|
|
| 214 |
+ assert f.read() == 'alive\n'
|
|
| 215 |
+ |
|
| 216 |
+ res = cli.run(project=project, args=['build', element_name])
|
|
| 217 |
+ assert res.exit_code == 0
|
|
| 218 |
+ |
|
| 219 |
+ res = cli.run(project=project, args=['checkout', canary_element_name,
|
|
| 220 |
+ checkout_after])
|
|
| 221 |
+ assert res.exit_code == 0
|
|
| 222 |
+ |
|
| 223 |
+ with open(os.path.join(checkout_after, 'canary')) as f:
|
|
| 224 |
+ assert f.read() == 'alive\n'
|
