]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools:The code used to test python module is moved to edksetup
authorFan, ZhijuX <zhijux.fan@intel.com>
Tue, 30 Apr 2019 02:16:01 +0000 (10:16 +0800)
committerFeng, Bob C <bob.c.feng@intel.com>
Wed, 8 May 2019 01:41:43 +0000 (09:41 +0800)
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1582

testing for presence of python modules should be done in edksetup
to reduce impact on subsequent build times.
This code currently exists in BaseTools/Tests/RunTest.py.

This patch is going to fix this issue.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
BaseTools/Tests/RunTests.py
edksetup.sh

index 81af736cd8cf8c71af7e803b1db5d06fcd726b99..e8acf1b348b393641504af755d006d48d632d010 100644 (file)
 import os\r
 import sys\r
 import unittest\r
-\r
-try:\r
-    import distutils.util\r
-except ModuleNotFoundError:\r
-    sys.exit('''\r
-Python reported: "No module named 'distutils.util"\r
-''')\r
-\r
 import TestTools\r
 \r
 def GetCTestSuite():\r
index c7b2e1e2010aa46af1332c85281df9d0ca9bf68f..ed9ceae85d71eeb0e61acb17ed874fa93f981807 100755 (executable)
@@ -177,11 +177,22 @@ function SetupPython()
   SetupPython3
 }
 
+function TestUtilModule()
+{
+  if ( $PYTHON_COMMAND -c "import distutils.util" >/dev/null 2>&1 );then
+    return 1
+  else
+    echo Error: "No module named 'distutils.util"
+    return 0
+  fi
+}
+
 function SourceEnv()
 {
   SetWorkspace &&
-  SetupEnv
-  SetupPython
+  SetupEnv &&
+  SetupPython &&
+  TestUtilModule
 }
 
 I=$#