1
|
1
|
import os
|
2
|
2
|
import shutil
|
|
3
|
+import stat
|
3
|
4
|
import pytest
|
4
|
5
|
from tests.testutils import cli, create_artifact_share, generate_junction
|
5
|
6
|
|
... |
... |
@@ -358,3 +359,50 @@ def test_pull_missing_notifies_user(caplog, cli, tmpdir, datafiles): |
358
|
359
|
|
359
|
360
|
assert "INFO Remote ({}) does not have".format(share.repo) in result.stderr
|
360
|
361
|
assert "SKIPPED Pull" in result.stderr
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+@pytest.mark.datafiles(DATA_DIR)
|
|
365
|
+def test_pull_access_rights(caplog, cli, tmpdir, datafiles):
|
|
366
|
+ project = str(datafiles)
|
|
367
|
+ checkout = os.path.join(str(tmpdir), 'checkout')
|
|
368
|
+
|
|
369
|
+ # Work-around datafiles not preserving mode
|
|
370
|
+ os.chmod(os.path.join(project, 'files/bin-files/usr/bin/hello'), 0o0755)
|
|
371
|
+
|
|
372
|
+ with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare')) as share:
|
|
373
|
+
|
|
374
|
+ cli.configure({
|
|
375
|
+ 'artifacts': {'url': share.repo, 'push': True}
|
|
376
|
+ })
|
|
377
|
+ result = cli.run(project=project, args=['build', 'compose-all.bst'])
|
|
378
|
+ result.assert_success()
|
|
379
|
+
|
|
380
|
+ result = cli.run(project=project, args=['checkout', '--hardlinks', '--no-integrate', 'compose-all.bst', checkout])
|
|
381
|
+ result.assert_success()
|
|
382
|
+
|
|
383
|
+ st = os.lstat(os.path.join(checkout, 'usr/include/pony.h'))
|
|
384
|
+ assert stat.S_ISREG(st.st_mode)
|
|
385
|
+ assert stat.S_IMODE(st.st_mode) == 0o0644
|
|
386
|
+
|
|
387
|
+ st = os.lstat(os.path.join(checkout, 'usr/bin/hello'))
|
|
388
|
+ assert stat.S_ISREG(st.st_mode)
|
|
389
|
+ assert stat.S_IMODE(st.st_mode) == 0o0755
|
|
390
|
+
|
|
391
|
+ shutil.rmtree(checkout)
|
|
392
|
+
|
|
393
|
+ artifacts = os.path.join(cli.directory, 'artifacts')
|
|
394
|
+ shutil.rmtree(artifacts)
|
|
395
|
+
|
|
396
|
+ result = cli.run(project=project, args=['pull', 'compose-all.bst'])
|
|
397
|
+ result.assert_success()
|
|
398
|
+
|
|
399
|
+ result = cli.run(project=project, args=['checkout', '--hardlinks', '--no-integrate', 'compose-all.bst', checkout])
|
|
400
|
+ result.assert_success()
|
|
401
|
+
|
|
402
|
+ st = os.lstat(os.path.join(checkout, 'usr/include/pony.h'))
|
|
403
|
+ assert stat.S_ISREG(st.st_mode)
|
|
404
|
+ assert stat.S_IMODE(st.st_mode) == 0o0644
|
|
405
|
+
|
|
406
|
+ st = os.lstat(os.path.join(checkout, 'usr/bin/hello'))
|
|
407
|
+ assert stat.S_ISREG(st.st_mode)
|
|
408
|
+ assert stat.S_IMODE(st.st_mode) == 0o0755
|