3 # Copyright 2010 Brian Dolbec <brian.dolbec@gmail.com>
4 # Copyright 2010 Gentoo Foundation
5 # Distributed under the terms of the GNU General Public License v2
9 from __future__ import print_function
12 __author__ = "Brian Dolbec"
13 __email__ = "brian.dolbec@gmail.com"
15 from getopt import gnu_getopt, GetoptError
21 import gentoolkit.pprinter as pp
23 from test import test_support
25 from test import support as test_support
27 from gentoolkit.eclean.clean import CleanUp
30 class Controllers(object):
31 """Contains controller methods for use in testing
32 the clean module methods"""
35 self.gathered_data = []
37 self.authorize_list = []
38 self.authorize_index = 0
40 def authorize_all_controller(self, size, key, clean_list):
41 """data gatherering controller.
44 @returns: self.authorize which controls the cleaning method
46 self.gathered_data.append([size, key, clean_list])
49 def authorize_list_controller(self, size, key, clean_list):
50 """data gathering and controller which
51 authorizes acoring to a pre-determined list
54 @return self.authorize_list[self.authorize_index]"""
55 self.gathered_data.append([size, key, clean_list])
56 index = self.authorize_index
57 self.authorize_index =+ 1
58 return self.authorize_list[index]
61 #class TestCleanUp(unittest.TestCase):
62 # """Test module for the various CleanUp class methods
64 # @param options: dict of module options
65 # @param testdata: dict. of path and test parameters
66 # as created by the TestDirCreation class"""
68 # def __init__(self, options, testdata):
69 # self.options = options
70 # self.tesdata = testdata
73 # def test_symlink_clean():
74 # """Tests the symbolic link portion of the distfiles
79 # def test_dist_clean():
80 # """Test the distfiles cleaning"""
84 # def test_pkg_clean():
85 # """Test the packages cleaning"""
89 # def test_pretend_clean():
90 # """Test the pretend_clean output"""
91 # controlller = Controllers().authorize_all_controller
92 # clean = CleanUp(controller)
93 # clean.pretend_clean(self.dist_clean)
94 # data = controller.gathered_data
99 """output run options"""
100 print("Useage: test_clean [OPTONS] path=test-dir")
101 print(" where test-dir is the location to create and populate")
102 print("the testing distfiles and packages directories.")
103 print("All tests in this module test only the clean.py module functions")
106 print(" -a, --all run all tests")
107 print(" -c, --clean clean up any previous test dirs & files")
108 print(" -D, --distfiles run the distfiles cleaning test")
109 print(" -k, --keep-dirs keep the test directories and files after the test")
110 print(" -p, --pretend run the test in pretend mode only")
111 print(" -P, --packages run the packages cleaning test")
112 print(" -S, --symlinks run the symlinks test")
113 print(" --path the location to create the temporary distfiles")
114 print(" and packages directories that will be test cleaned")
115 print(" --version test module version")
120 """Parse the options dict
122 @return options: dictionary of module options"""
124 opts, args = getopt(sys.argv[1:], 'acDkpPS', ["version",
125 "help", "path=", "all", "distfiles", "packages",
126 "pretend", "symlinks", "keep-dirs", "clean"])
129 except GetoptError as e:
130 print(e.msg, file=sys.stderr)
136 def main(cmdline=False):
137 """parse options and run the tests"""
140 options = parse_opts()
143 if __name__ == "__main__":
144 """actually call main() if launched as a script"""
147 except KeyboardInterrupt: