Add --no-tests command line argument

This commit is contained in:
Mikhail Gordeev 2019-11-01 16:44:46 +03:00
parent bb2e2fbc62
commit c218219d13

View File

@ -24,8 +24,9 @@ PROG = 'cloud-build'
class CB: class CB:
"""class for building cloud images""" """class for building cloud images"""
def __init__(self, config: str, system_datadir: str) -> None: def __init__(self, args: Dict) -> None:
self.parse_config(config) self.parse_config(args.config)
self.args = args
data_dir = (Path(os.getenv('XDG_DATA_HOME', data_dir = (Path(os.getenv('XDG_DATA_HOME',
'~/.local/share')).expanduser() '~/.local/share')).expanduser()
@ -39,7 +40,7 @@ class CB:
self.images_dir = data_dir / 'images' self.images_dir = data_dir / 'images'
self.work_dir = data_dir / 'work' self.work_dir = data_dir / 'work'
self.out_dir = data_dir / 'out' self.out_dir = data_dir / 'out'
self.system_datadir = system_datadir self.system_datadir = args.data_dir
self.date = datetime.date.today().strftime('%Y%m%d') self.date = datetime.date.today().strftime('%Y%m%d')
self.service_default_state = 'enabled' self.service_default_state = 'enabled'
@ -490,6 +491,7 @@ Dir::Etc::preferencesparts "/var/empty";
) )
image_path = self.image_path(image, branch, arch, kind) image_path = self.image_path(image, branch, arch, kind)
self.copy_image(tarball, image_path) self.copy_image(tarball, image_path)
if not self.args.no_tests:
for test in self.tests_by_image(image): for test in self.tests_by_image(image):
self.info(f'Test {image} {branch} {arch}') self.info(f'Test {image} {branch} {arch}')
if not cloud_build.image_tests.test( if not cloud_build.image_tests.test(
@ -569,6 +571,11 @@ def parse_args():
default=f'/usr/share/{PROG}', default=f'/usr/share/{PROG}',
help='system data directory', help='system data directory',
) )
parser.add_argument(
'--no-tests',
action='store_true',
help='disable running tests',
)
args = parser.parse_args() args = parser.parse_args()
if not args.data_dir.endswith('/'): if not args.data_dir.endswith('/'):
@ -579,7 +586,7 @@ def parse_args():
def main(): def main():
args = parse_args() args = parse_args()
cloud_build = CB(args.config, args.data_dir) cloud_build = CB(args)
cloud_build.create_images() cloud_build.create_images()
cloud_build.sign() cloud_build.sign()
cloud_build.sync() cloud_build.sync()