Update test_passwd.py to remove make operation

This commit is contained in:
Feng Chao 2024-11-07 15:14:47 +08:00 committed by GitHub
parent 907cbe99ed
commit 21ceac423f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 16 deletions

View File

@ -1,3 +1,4 @@
import os
import subprocess
from frame.log import *
from frame.cases import *
@ -10,11 +11,11 @@ class TDTestCase(TBase):
def apiPath(self):
apiPath = None
currentFilePath = os.path.dirname(os.path.realpath(__file__))
if ("community/tests" in currentFilePath):
testFilePath = currentFilePath[:currentFilePath.find("community/tests")]
if (os.sep.join(["community", "tests"]) in currentFilePath):
testFilePath = currentFilePath[:currentFilePath.find(os.sep.join(["community", "tests"]))]
else:
testFilePath = currentFilePath[:currentFilePath.find("TDengine/tests")]
testFilePath = currentFilePath[:currentFilePath.find(os.sep.join(["TDengine", "tests"]))]
for root, dirs, files in os.walk(testFilePath):
if ("passwdTest.c" in files):
apiPath = root
@ -25,21 +26,20 @@ class TDTestCase(TBase):
apiPath = self.apiPath()
tdLog.info(f"api path: {apiPath}")
if apiPath:
p = subprocess.Popen(f"cd {apiPath} && make", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if 0 != p.returncode:
tdLog.info(f"Test script passwdTest.c make failed with error: {err}")
test_file_cmd = os.sep.join([apiPath, "passwdTest localhost"])
try:
p = subprocess.Popen(test_file_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if 0 != p.returncode:
tdLog.exit("Failed to run passwd test with output: %s \n error: %s" % (out, err))
else:
tdLog.info(out)
tdLog.success(f"{__file__} successfully executed")
except Exception as e:
tdLog.exit(f"Failed to execute {__file__} with error: {e}")
else:
tdLog.exit("passwdTest.c not found")
try:
p = subprocess.Popen(test_file_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if 0 != p.returncode:
tdLog.exit("Failed to run passwd test with output: %s \n error: %s" % (out, err))
tdLog.success(f"{__file__} successfully executed")
except Exception as e:
tdLog.exit(f"Failed to execute {__file__} with error: {e}")
tdCases.addLinux(__file__, TDTestCase())
tdCases.addWindows(__file__, TDTestCase())