Valentin David pushed to branch valentindavid/script-artifact-corruption at BuildStream / buildstream
Commits:
-
a9618e26
by Valentin David at 2018-11-06T18:00:35Z
6 changed files:
- buildstream/scriptelement.py
- + tests/integration/project/elements/script/corruption-image.bst
- + tests/integration/project/elements/script/corruption-integration.bst
- + tests/integration/project/elements/script/corruption.bst
- + tests/integration/project/files/canary
- tests/integration/script.py
Changes:
| ... | ... | @@ -201,16 +201,17 @@ class ScriptElement(Element): |
| 201 | 201 |
# Setup environment
|
| 202 | 202 |
sandbox.set_environment(self.get_environment())
|
| 203 | 203 |
|
| 204 |
+ # Tell the sandbox to mount the install root
|
|
| 205 |
+ directories = {'/': False}
|
|
| 206 |
+ |
|
| 204 | 207 |
# Mark the artifact directories in the layout
|
| 205 | 208 |
for item in self.__layout:
|
| 206 |
- if item['destination'] != '/':
|
|
| 207 |
- if item['element']:
|
|
| 208 |
- sandbox.mark_directory(item['destination'], artifact=True)
|
|
| 209 |
- else:
|
|
| 210 |
- sandbox.mark_directory(item['destination'])
|
|
| 209 |
+ destination = item['destination']
|
|
| 210 |
+ was_artifact = directories.get(destination, False)
|
|
| 211 |
+ directories[destination] = item['element'] or was_artifact
|
|
| 211 | 212 |
|
| 212 |
- # Tell the sandbox to mount the install root
|
|
| 213 |
- sandbox.mark_directory(self.__install_root)
|
|
| 213 |
+ for directory, artifact in directories.items():
|
|
| 214 |
+ sandbox.mark_directory(directory, artifact=artifact)
|
|
| 214 | 215 |
|
| 215 | 216 |
def stage(self, sandbox):
|
| 216 | 217 |
|
| 1 |
+kind: import
|
|
| 2 |
+sources:
|
|
| 3 |
+- kind: local
|
|
| 4 |
+ path: files/canary
|
| 1 |
+kind: stack
|
|
| 2 |
+ |
|
| 3 |
+public:
|
|
| 4 |
+ bst:
|
|
| 5 |
+ integration-commands:
|
|
| 6 |
+ - echo smashed >>/canary
|
|
| 7 |
+ |
| 1 |
+kind: script
|
|
| 2 |
+ |
|
| 3 |
+depends:
|
|
| 4 |
+- filename: base.bst
|
|
| 5 |
+ type: build
|
|
| 6 |
+- filename: script/corruption-image.bst
|
|
| 7 |
+ type: build
|
|
| 8 |
+- filename: script/corruption-integration.bst
|
|
| 9 |
+ type: build
|
|
| 10 |
+ |
|
| 11 |
+variables:
|
|
| 12 |
+ install-root: "/"
|
|
| 13 |
+ |
|
| 14 |
+config:
|
|
| 15 |
+ layout:
|
|
| 16 |
+ - element: base.bst
|
|
| 17 |
+ destination: "/"
|
|
| 18 |
+ - element: script/corruption-image.bst
|
|
| 19 |
+ destination: "/"
|
|
| 20 |
+ - element: script/corruption-integration.bst
|
|
| 21 |
+ destination: "/"
|
| 1 |
+alive
|
| ... | ... | @@ -155,3 +155,32 @@ def test_script_layout(cli, tmpdir, datafiles): |
| 155 | 155 |
text = f.read()
|
| 156 | 156 |
|
| 157 | 157 |
assert text == "Hi\n"
|
| 158 |
+ |
|
| 159 |
+ |
|
| 160 |
+@pytest.mark.datafiles(DATA_DIR)
|
|
| 161 |
+def test_regression_cache_corruption(cli, tmpdir, datafiles):
|
|
| 162 |
+ project = str(datafiles)
|
|
| 163 |
+ checkout_original = os.path.join(cli.directory, 'checkout-original')
|
|
| 164 |
+ checkout_after = os.path.join(cli.directory, 'checkout-after')
|
|
| 165 |
+ element_name = 'script/corruption.bst'
|
|
| 166 |
+ canary_element_name = 'script/corruption-image.bst'
|
|
| 167 |
+ |
|
| 168 |
+ res = cli.run(project=project, args=['build', canary_element_name])
|
|
| 169 |
+ assert res.exit_code == 0
|
|
| 170 |
+ |
|
| 171 |
+ res = cli.run(project=project, args=['checkout', canary_element_name,
|
|
| 172 |
+ checkout_original])
|
|
| 173 |
+ assert res.exit_code == 0
|
|
| 174 |
+ |
|
| 175 |
+ with open(os.path.join(checkout_original, 'canary')) as f:
|
|
| 176 |
+ assert f.read() == 'alive\n'
|
|
| 177 |
+ |
|
| 178 |
+ res = cli.run(project=project, args=['build', element_name])
|
|
| 179 |
+ assert res.exit_code == 0
|
|
| 180 |
+ |
|
| 181 |
+ res = cli.run(project=project, args=['checkout', canary_element_name,
|
|
| 182 |
+ checkout_after])
|
|
| 183 |
+ assert res.exit_code == 0
|
|
| 184 |
+ |
|
| 185 |
+ with open(os.path.join(checkout_after, 'canary')) as f:
|
|
| 186 |
+ assert f.read() == 'alive\n'
|
