~pwlars/lava-test/fixtures

« back to all changes in this revision

Viewing changes to abrek/builtins.py

  • Committer: Paul Larson
  • Date: 2010-07-13 20:38:01 UTC
  • mfrom: (13.1.6 list-tests)
  • Revision ID: paul.larson@canonical.com-20100713203801-sxs10ua02psduf9v
* Add list-installed to list installed tests
* Add list-tests command to list all known tests
* Add list-results command to list saved results
* Unit tests added

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
1
2
import sys
2
3
 
3
4
import abrek.command
82
83
        except Exception as strerror:
83
84
            print "Test uninstall error: %s" % strerror
84
85
            sys.exit(1)
 
86
 
 
87
class cmd_list_installed(abrek.command.AbrekCmd):
 
88
    """
 
89
    List tests that are currently installed
 
90
    """
 
91
    def run(self, argv):
 
92
        from abrek.config import get_config
 
93
        config = get_config()
 
94
        print "Installed tests:"
 
95
        try:
 
96
            for dir in os.listdir(config.installdir):
 
97
                print dir
 
98
        except OSError:
 
99
            print "No tests installed"
 
100
 
 
101
class cmd_list_tests(abrek.command.AbrekCmd):
 
102
    """
 
103
    List all known tests
 
104
    """
 
105
    def run(self, argv):
 
106
        from abrek import test_definitions
 
107
        from pkgutil import walk_packages
 
108
        print "Known tests:"
 
109
        for importer, mod, ispkg in walk_packages(test_definitions.__path__):
 
110
            print mod
 
111
 
 
112
class cmd_list_results(abrek.command.AbrekCmd):
 
113
    """
 
114
    List results of previous runs
 
115
    """
 
116
    def run(self, argv):
 
117
        from abrek.config import get_config
 
118
        config = get_config()
 
119
        print "Saved results:"
 
120
        try:
 
121
            for dir in os.listdir(config.resultsdir):
 
122
                print dir
 
123
        except OSError:
 
124
            print "No results found"