forked from AppImageCrafters/appimage-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
appimage-tester
executable file
·60 lines (49 loc) · 2.38 KB
/
appimage-tester
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
# Copyright 2020 Alexis Lopez Zubieta
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
import argparse
import logging
from AppImageBuilder.inspector.inspector import Inspector
from AppImageBuilder.tester.tester import Tester
def configure_logging(args):
numeric_level = getattr(logging, args.loglevel.upper())
if not isinstance(numeric_level, int):
logging.error('Invalid log level: %s' % args.loglevel)
logging.basicConfig(level=numeric_level)
def __main__():
parser = argparse.ArgumentParser(description='AppImage/AppDir testing tool')
parser.add_argument('target', help='AppImage or AppDir to be tested')
parser.add_argument('--log', dest='loglevel', default="INFO", help='logging level (default: INFO)')
parser.add_argument('--docker-images', metavar="DOCKER_IMAGE", dest='docker_images', type=str, nargs='+',
required=True, help='Docker images to test on')
parser.add_argument('--test', dest='do_test', action='store_true',
help='Test running the target on given docker images')
parser.add_argument('--static-test', dest='do_static_test', action='store_true',
help='Test running the target on given docker images')
args = parser.parse_args()
configure_logging(args)
if args.do_test:
try:
tester = Tester(args.target)
for docker_image in args.docker_images:
tester.run_test(docker_image)
except Exception as e:
logging.error("Tests failed. %s" % e)
if args.do_static_test:
try:
tester = Tester(args.target)
for docker_image in args.docker_images:
tester.run_static_test(docker_image)
except Exception as e:
logging.error("Tests failed. %s" % e)
if __name__ == '__main__':
__main__()