Add no_delete parameter to config
This commit is contained in:
parent
71c3caae2e
commit
4db286412b
@ -166,6 +166,8 @@ class CB:
|
||||
|
||||
self.try_build_all = cfg.get('try_build_all', False)
|
||||
|
||||
self.no_delete = cfg.get('no_delete', True)
|
||||
|
||||
self.bad_arches = cfg.get('bad_arches', [])
|
||||
|
||||
self.external_files = cfg.get('external_files')
|
||||
@ -678,9 +680,10 @@ Dir::Etc::preferencesparts "/var/empty";
|
||||
'rsync',
|
||||
f'{self.images_dir}/{branch}/',
|
||||
'-rv',
|
||||
'--delete',
|
||||
remote,
|
||||
]
|
||||
if not self.no_delete:
|
||||
cmd.append('--delete')
|
||||
self.call(cmd)
|
||||
|
||||
self.kick()
|
||||
|
@ -4,6 +4,7 @@ key: 0x00000000
|
||||
try_build_all: False
|
||||
repository_url: http://mirror.yandex.ru/altlinux/{branch}/branch
|
||||
log_level: info
|
||||
no_delete: True
|
||||
bad_arches:
|
||||
- armh
|
||||
|
||||
|
55
tests/test_no_delete.py
Normal file
55
tests/test_no_delete.py
Normal file
@ -0,0 +1,55 @@
|
||||
from pathlib import Path
|
||||
from unittest import TestCase
|
||||
from unittest import mock
|
||||
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
from cloud_build import CB
|
||||
|
||||
import tests.call as call
|
||||
|
||||
|
||||
class TestNoDelete(TestCase):
|
||||
def setUp(self):
|
||||
self.data_dir = Path(tempfile.mkdtemp(prefix='cloud_build'))
|
||||
self.images_dir = Path('/tmp/cloud-build-test_no_delete/')
|
||||
self.images_dir.mkdir()
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.data_dir)
|
||||
shutil.rmtree(self.images_dir)
|
||||
|
||||
@mock.patch('subprocess.call', call.Call())
|
||||
def test_no_delete_false(self):
|
||||
cb = CB(
|
||||
config='tests/test_no_delete_false.yaml',
|
||||
data_dir=self.data_dir,
|
||||
no_tests=True,
|
||||
create_remote_dirs=True,
|
||||
)
|
||||
other_file = self.images_dir / 'other_file.txt'
|
||||
other_file.write_text('Some text')
|
||||
cb.create_images()
|
||||
cb.sync()
|
||||
del cb
|
||||
msg = 'Other files shoud be deleted if not no_delete'
|
||||
if other_file.exists():
|
||||
self.fail(msg)
|
||||
|
||||
@mock.patch('subprocess.call', call.Call())
|
||||
def test_no_delete_true(self):
|
||||
cb = CB(
|
||||
config='tests/test_no_delete_true.yaml',
|
||||
data_dir=self.data_dir,
|
||||
no_tests=True,
|
||||
create_remote_dirs=True,
|
||||
)
|
||||
other_file = self.images_dir / 'other_file.txt'
|
||||
other_file.write_text('Some text')
|
||||
cb.create_images()
|
||||
cb.sync()
|
||||
del cb
|
||||
msg = 'Other files shoud not be deleted if no_delete'
|
||||
if not other_file.exists():
|
||||
self.fail(msg)
|
16
tests/test_no_delete_false.yaml
Normal file
16
tests/test_no_delete_false.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
remote: '/tmp/cloud-build-test_no_delete'
|
||||
key: 0x00000000
|
||||
no_delete: False
|
||||
|
||||
images:
|
||||
rootfs-minimal:
|
||||
target: ve/docker
|
||||
kinds:
|
||||
- tar.xz
|
||||
|
||||
branches:
|
||||
Sisyphus:
|
||||
arches:
|
||||
x86_64:
|
||||
...
|
16
tests/test_no_delete_true.yaml
Normal file
16
tests/test_no_delete_true.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
remote: '/tmp/cloud-build-test_no_delete'
|
||||
key: 0x00000000
|
||||
no_delete: True
|
||||
|
||||
images:
|
||||
rootfs-minimal:
|
||||
target: ve/docker
|
||||
kinds:
|
||||
- tar.xz
|
||||
|
||||
branches:
|
||||
Sisyphus:
|
||||
arches:
|
||||
x86_64:
|
||||
...
|
Loading…
Reference in New Issue
Block a user