]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/Tests: Always add BaseTools source to import path
authorJordan Justen <jordan.l.justen@intel.com>
Tue, 23 Jun 2015 23:34:04 +0000 (23:34 +0000)
committerjljusten <jljusten@Edk2>
Tue, 23 Jun 2015 23:34:04 +0000 (23:34 +0000)
This allows unit tests to easily include BaseTools python
modules. This is very useful for writing unit tests.

Actually, previously, we would do this when RunTests.py was executed,
so unit tests could easily import BaseTools modules, so long as they
were executed via RunTests.

This change allows running the unit test files individually which can
be faster for developing the new unit test cases.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Yingke Liu <yingke.d.liu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17691 6f19259b-4bc3-4df7-8a09-765794883524

BaseTools/Tests/RunTests.py
BaseTools/Tests/TestTools.py

index e8ca2d055eaca31033508ffe292085a7b0a201ad..0dd65632d0860004a22a55cbb76f5f828bf1f0dd 100644 (file)
@@ -21,8 +21,6 @@ import unittest
 \r
 import TestTools\r
 \r
-sys.path.append(TestTools.PythonSourceDir)\r
-\r
 def GetCTestSuite():\r
     import CToolsTests\r
     return CToolsTests.TheTestSuite()\r
index ac009db1fa66414e67f6dec18b84698e3c4cff9f..27afd79f2094dd742c72a2b13525bb685bc9f3b9 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Utility functions and classes for BaseTools unit tests\r
 #\r
-#  Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -31,6 +31,13 @@ CSourceDir = os.path.join(BaseToolsDir, 'Source', 'C')
 PythonSourceDir = os.path.join(BaseToolsDir, 'Source', 'Python')\r
 TestTempDir = os.path.join(TestsDir, 'TestTempDir')\r
 \r
+if PythonSourceDir not in sys.path:\r
+    #\r
+    # Allow unit tests to import BaseTools python modules. This is very useful\r
+    # for writing unit tests.\r
+    #\r
+    sys.path.append(PythonSourceDir)\r
+\r
 def MakeTheTestSuite(localItems):\r
     tests = []\r
     for name, item in localItems.iteritems():\r