8486.12.1
by Celso Providelo
Fixing the 'fixable' scripts and adding a checker with the really-broken ones blacklisted. |
1 |
#! /usr/bin/python2.4
|
8687.15.4
by Karl Fogel
Add the copyright header block to more files; tweak format in a few files. |
2 |
#
|
3 |
# Copyright 2009 Canonical Ltd. This software is licensed under the
|
|
4 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
5 |
||
8486.12.1
by Celso Providelo
Fixing the 'fixable' scripts and adding a checker with the really-broken ones blacklisted. |
6 |
"""Check that all the launchpad scripts and cronscripts run.
|
7 |
||
8 |
Usage hint:
|
|
9 |
||
10 |
% utilities/check-scripts.py
|
|
11 |
"""
|
|
8847.1.1
by Celso Providelo
Integrating the tree script checker into the test suite. |
12 |
# pylint: disable-msg=W0403
|
8486.12.1
by Celso Providelo
Fixing the 'fixable' scripts and adding a checker with the really-broken ones blacklisted. |
13 |
import os |
14 |
import sys |
|
15 |
||
8847.1.1
by Celso Providelo
Integrating the tree script checker into the test suite. |
16 |
import _pythonpath |
17 |
from lp.services.scripts.tests import find_lp_scripts |
|
18 |
from lp.testing import run_script |
|
8486.12.1
by Celso Providelo
Fixing the 'fixable' scripts and adding a checker with the really-broken ones blacklisted. |
19 |
|
20 |
||
21 |
def check_script(script_path): |
|
22 |
"""Run the given script in a subprocess and report its result.
|
|
23 |
||
24 |
Check if the script successfully runs if 'help' is requested via
|
|
25 |
command line argument ('-h').
|
|
26 |
"""
|
|
27 |
sys.stdout.write('Checking: %s ' % script_path) |
|
28 |
sys.stdout.flush() |
|
8847.1.1
by Celso Providelo
Integrating the tree script checker into the test suite. |
29 |
cmd_line = script_path + " -h" |
30 |
out, err, returncode = run_script(cmd_line) |
|
31 |
if returncode != os.EX_OK: |
|
8486.12.1
by Celso Providelo
Fixing the 'fixable' scripts and adding a checker with the really-broken ones blacklisted. |
32 |
sys.stdout.write('... FAILED\n') |
8847.1.1
by Celso Providelo
Integrating the tree script checker into the test suite. |
33 |
sys.stdout.write('%s\n' % err) |
8486.12.1
by Celso Providelo
Fixing the 'fixable' scripts and adding a checker with the really-broken ones blacklisted. |
34 |
else: |
35 |
sys.stdout.write('... OK\n') |
|
36 |
sys.stdout.flush() |
|
37 |
||
38 |
||
39 |
def main(): |
|
40 |
"""Walk over the specified script locations and check them."""
|
|
8847.1.1
by Celso Providelo
Integrating the tree script checker into the test suite. |
41 |
for script_path in find_lp_scripts(): |
42 |
check_script(script_path) |
|
8486.12.1
by Celso Providelo
Fixing the 'fixable' scripts and adding a checker with the really-broken ones blacklisted. |
43 |
|
44 |
||
45 |
if __name__ == '__main__': |
|
46 |
sys.exit(main()) |