summaryrefslogtreecommitdiffstats
path: root/BaseTools/Tests
diff options
context:
space:
mode:
authorJordan Justen <jordan.l.justen@intel.com>2015-06-23 23:34:04 +0000
committerjljusten <jljusten@Edk2>2015-06-23 23:34:04 +0000
commit53fc4ba26640fd5aab0b7480068295e72c42d435 (patch)
tree8874a521d024cafcc6cd080b33e6c7220990e1ac /BaseTools/Tests
parent94210dc95e9f7c6ff4066a9b35a288e6f1c271bf (diff)
downloadedk2-53fc4ba26640fd5aab0b7480068295e72c42d435.tar.gz
edk2-53fc4ba26640fd5aab0b7480068295e72c42d435.tar.bz2
edk2-53fc4ba26640fd5aab0b7480068295e72c42d435.zip
BaseTools/Tests: Always add BaseTools source to import path
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
Diffstat (limited to 'BaseTools/Tests')
-rw-r--r--BaseTools/Tests/RunTests.py2
-rw-r--r--BaseTools/Tests/TestTools.py9
2 files changed, 8 insertions, 3 deletions
diff --git a/BaseTools/Tests/RunTests.py b/BaseTools/Tests/RunTests.py
index e8ca2d055e..0dd65632d0 100644
--- a/BaseTools/Tests/RunTests.py
+++ b/BaseTools/Tests/RunTests.py
@@ -21,8 +21,6 @@ import unittest
import TestTools
-sys.path.append(TestTools.PythonSourceDir)
-
def GetCTestSuite():
import CToolsTests
return CToolsTests.TheTestSuite()
diff --git a/BaseTools/Tests/TestTools.py b/BaseTools/Tests/TestTools.py
index ac009db1fa..27afd79f20 100644
--- a/BaseTools/Tests/TestTools.py
+++ b/BaseTools/Tests/TestTools.py
@@ -1,7 +1,7 @@
## @file
# Utility functions and classes for BaseTools unit tests
#
-# Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -31,6 +31,13 @@ CSourceDir = os.path.join(BaseToolsDir, 'Source', 'C')
PythonSourceDir = os.path.join(BaseToolsDir, 'Source', 'Python')
TestTempDir = os.path.join(TestsDir, 'TestTempDir')
+if PythonSourceDir not in sys.path:
+ #
+ # Allow unit tests to import BaseTools python modules. This is very useful
+ # for writing unit tests.
+ #
+ sys.path.append(PythonSourceDir)
+
def MakeTheTestSuite(localItems):
tests = []
for name, item in localItems.iteritems():