Remove old code
This commit is contained in:
parent
ebcde95d5a
commit
97255866f8
93
shlax/cli.py
93
shlax/cli.py
@ -18,99 +18,6 @@ from .shlaxfile import Shlaxfile
|
|||||||
from .targets import Localhost
|
from .targets import Localhost
|
||||||
|
|
||||||
|
|
||||||
async def runall(*args, **kwargs):
|
|
||||||
for name, action in cli.shlaxfile.actions.items():
|
|
||||||
await Localhost(action)(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
@cli2.option('debug', alias='d', help='Display debug output.')
|
|
||||||
async def test(*args, **kwargs):
|
|
||||||
"""Run podctl test over a bunch of paths."""
|
|
||||||
report = []
|
|
||||||
|
|
||||||
for arg in args:
|
|
||||||
candidates = [
|
|
||||||
os.path.join(os.getcwd(), arg, 'pod.py'),
|
|
||||||
os.path.join(os.getcwd(), arg, 'pod_test.py'),
|
|
||||||
]
|
|
||||||
for candidate in candidates:
|
|
||||||
if not os.path.exists(candidate):
|
|
||||||
continue
|
|
||||||
podfile = Podfile.factory(candidate)
|
|
||||||
|
|
||||||
# disable push
|
|
||||||
for name, container in podfile.containers.items():
|
|
||||||
commit = container.visitor('commit')
|
|
||||||
if commit:
|
|
||||||
commit.push = False
|
|
||||||
|
|
||||||
output.print(
|
|
||||||
'\n\x1b[1;38;5;160;48;5;118m BUILD START \x1b[0m'
|
|
||||||
+ ' ' + podfile.path + '\n'
|
|
||||||
)
|
|
||||||
|
|
||||||
old_exit_code = console_script.exit_code
|
|
||||||
console_script.exit_code = 0
|
|
||||||
try:
|
|
||||||
await podfile.pod.script('build')()
|
|
||||||
except Exception as e:
|
|
||||||
report.append(('build ' + candidate, False))
|
|
||||||
continue
|
|
||||||
|
|
||||||
if console_script.exit_code != 0:
|
|
||||||
report.append(('build ' + candidate, False))
|
|
||||||
continue
|
|
||||||
console_script.exit_code = old_exit_code
|
|
||||||
|
|
||||||
for name, test in podfile.tests.items():
|
|
||||||
name = '::'.join([podfile.path, name])
|
|
||||||
output.print(
|
|
||||||
'\n\x1b[1;38;5;160;48;5;118m TEST START \x1b[0m'
|
|
||||||
+ ' ' + name + '\n'
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
|
||||||
await test(podfile.pod)
|
|
||||||
except Exception as e:
|
|
||||||
report.append((name, False))
|
|
||||||
output.print('\x1b[1;38;5;15;48;5;196m TEST FAIL \x1b[0m' + name)
|
|
||||||
else:
|
|
||||||
report.append((name, True))
|
|
||||||
output.print('\x1b[1;38;5;200;48;5;44m TEST SUCCESS \x1b[0m' + name)
|
|
||||||
output.print('\n')
|
|
||||||
|
|
||||||
print('\n')
|
|
||||||
|
|
||||||
for name, success in report:
|
|
||||||
if success:
|
|
||||||
output.print('\n\x1b[1;38;5;200;48;5;44m TEST SUCCESS \x1b[0m' + name)
|
|
||||||
else:
|
|
||||||
output.print('\n\x1b[1;38;5;15;48;5;196m TEST FAIL \x1b[0m' + name)
|
|
||||||
|
|
||||||
print('\n')
|
|
||||||
|
|
||||||
success = [*filter(lambda i: i[1], report)]
|
|
||||||
failures = [*filter(lambda i: not i[1], report)]
|
|
||||||
|
|
||||||
output.print(
|
|
||||||
'\n\x1b[1;38;5;200;48;5;44m TEST TOTAL: \x1b[0m'
|
|
||||||
+ str(len(report))
|
|
||||||
)
|
|
||||||
if success:
|
|
||||||
output.print(
|
|
||||||
'\n\x1b[1;38;5;200;48;5;44m TEST SUCCESS: \x1b[0m'
|
|
||||||
+ str(len(success))
|
|
||||||
)
|
|
||||||
if failures:
|
|
||||||
output.print(
|
|
||||||
'\n\x1b[1;38;5;15;48;5;196m TEST FAIL: \x1b[0m'
|
|
||||||
+ str(len(failures))
|
|
||||||
)
|
|
||||||
|
|
||||||
if failures:
|
|
||||||
console_script.exit_code = 1
|
|
||||||
|
|
||||||
|
|
||||||
class ConsoleScript(cli2.ConsoleScript):
|
class ConsoleScript(cli2.ConsoleScript):
|
||||||
def __call__(self, *args, **kwargs):
|
def __call__(self, *args, **kwargs):
|
||||||
self.shlaxfile = None
|
self.shlaxfile = None
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user