blob: 6b3311d2880ddb2441cf2266c65eca8d0b870e03 [file] [log] [blame]
# -- Portage Unit Test Functionality
# Copyright 2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import os, sys
import os.path as osp
import grp
import pwd
import signal
def debug_signal(signum, frame):
import pdb
signal.signal(signal.SIGUSR1, debug_signal)
# Pretend that the current user's uid/gid are the 'portage' uid/gid,
# so things go smoothly regardless of the current user and global
# user/group configuration.
os.environ["PORTAGE_USERNAME"] = pwd.getpwuid(os.getuid()).pw_name
os.environ["PORTAGE_GRPNAME"] = grp.getgrgid(os.getgid()).gr_name
# Insert our parent dir so we can do shiny import "tests"
# This line courtesy of Marienz and Pkgcore ;)
sys.path.insert(0, osp.dirname(osp.dirname(osp.dirname(osp.abspath(__file__)))))
import portage
# Ensure that we don't instantiate portage.settings, so that tests should
# work the same regardless of global configuration file state/existence.
import portage.tests as tests
from portage.const import PORTAGE_BIN_PATH
path = os.environ.get("PATH", "").split(":")
path = [x for x in path if x]
if not path or not os.path.samefile(path[0], PORTAGE_BIN_PATH):
path.insert(0, PORTAGE_BIN_PATH)
os.environ["PATH"] = ":".join(path)
del path
if __name__ == "__main__":
result = tests.main()
if not result.wasSuccessful():