2 # runTests.py -- Portage Unit Test Functionality
3 # Copyright 2006-2013 Gentoo Foundation
4 # Distributed under the terms of the GNU General Public License v2
13 def debug_signal(signum, frame):
17 if platform.python_implementation() == 'Jython':
18 debug_signum = signal.SIGUSR2 # bug #424259
20 debug_signum = signal.SIGUSR1
22 signal.signal(debug_signum, debug_signal)
24 # Pretend that the current user's uid/gid are the 'portage' uid/gid,
25 # so things go smoothly regardless of the current user and global
26 # user/group configuration.
27 os.environ["PORTAGE_USERNAME"] = pwd.getpwuid(os.getuid()).pw_name
28 os.environ["PORTAGE_GRPNAME"] = grp.getgrgid(os.getgid()).gr_name
30 # Insert our parent dir so we can do shiny import "tests"
31 # This line courtesy of Marienz and Pkgcore ;)
32 sys.path.insert(0, osp.dirname(osp.dirname(osp.dirname(osp.realpath(__file__)))))
35 portage._internal_caller = True
37 # Ensure that we don't instantiate portage.settings, so that tests should
38 # work the same regardless of global configuration file state/existence.
39 portage._disable_legacy_globals()
41 if os.environ.get('NOCOLOR') in ('yes', 'true'):
42 portage.output.nocolor()
44 import portage.tests as tests
45 from portage.const import PORTAGE_BIN_PATH
46 path = os.environ.get("PATH", "").split(":")
47 path = [x for x in path if x]
49 insert_bin_path = True
51 insert_bin_path = not path or \
52 not os.path.samefile(path[0], PORTAGE_BIN_PATH)
57 path.insert(0, PORTAGE_BIN_PATH)
58 os.environ["PATH"] = ":".join(path)
60 if __name__ == "__main__":
61 sys.exit(tests.main())