runTests: handle samefile OSError, bug #454880
authorZac Medico <zmedico@gentoo.org>
Thu, 31 Jan 2013 19:56:13 +0000 (11:56 -0800)
committerZac Medico <zmedico@gentoo.org>
Thu, 31 Jan 2013 19:56:13 +0000 (11:56 -0800)
pym/portage/tests/runTests

index 53e1b5cc456fa82ea8235f5d3dad3e0ff7e79ae9..b0069698b390c1838bc09ace2a2b3ef05e06aeab 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python -Wd
 # runTests.py -- Portage Unit Test Functionality
-# Copyright 2006-2012 Gentoo Foundation
+# Copyright 2006-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import os, sys
@@ -45,11 +45,17 @@ 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):
+
+insert_bin_path = True
+try:
+       insert_bin_path = not path or \
+               not os.path.samefile(path[0], PORTAGE_BIN_PATH)
+except OSError:
+       pass
+
+if insert_bin_path:
        path.insert(0, PORTAGE_BIN_PATH)
        os.environ["PATH"] = ":".join(path)
-del path
-
 
 if __name__ == "__main__":
        sys.exit(tests.main())