fix: support error return to vlist

This commit is contained in:
Alex Duan 2025-02-25 14:02:38 +08:00
parent 100aa30eab
commit aff92b763c
3 changed files with 29 additions and 25 deletions

View File

@ -89,12 +89,16 @@ def run(command, show = True):
# return list after run
def runRetList(command, show = True, checkRun = False):
def runRetList(command, show = True, checkRun = False, retFail = False):
output, error, code = run(command, show)
if checkRun and code != 0:
print(f"eos.runRetList checkRun return code failed. code={code} error={error}")
assert code == 0
return output.splitlines()
assert code == 0
rList = output.splitlines()
if retFail and error != "":
rList += error.splitlines()
return rList
#
# file

View File

@ -66,7 +66,7 @@ def curFile(fullPath, filename):
# run build/bin file
def runBinFile(fname, command, show = True, checkRun = False):
def runBinFile(fname, command, show = True, checkRun = False, retFail = False ):
binFile = frame.epath.binFile(fname)
if frame.eos.isWin():
binFile += ".exe"
@ -74,7 +74,7 @@ def runBinFile(fname, command, show = True, checkRun = False):
cmd = f"{binFile} {command}"
if show:
tdLog.info(cmd)
return frame.eos.runRetList(cmd, show, checkRun)
return frame.eos.runRetList(cmd, show, checkRun, retFail)
# exe build/bin file
def exeBinFile(fname, command, wait=True, show=True):

View File

@ -157,21 +157,21 @@ class TDTestCase(TBase):
def basicCommandLine(self, tmpdir):
#command and check result
checkItems = [
f"-h 127.0.0.1 -P 6030 -uroot -ptaosdata -A -N -o {tmpdir}", ["OK: Database test dumped", "OK: 200 row(s) dumped out!"],
f"-r result -gg -a -e test d0 -o {tmpdir}", ["OK: table: d0 dumped", "OK: 100 row(s) dumped out!"],
f"-n -D test -o {tmpdir}", ["OK: Database test dumped", "OK: 200 row(s) dumped out!"],
f"-L -D test -o {tmpdir}", ["OK: Database test dumped", "OK: 200 row(s) dumped out!"],
f"-s -D test -o {tmpdir}", ["dumping out schema: 1 from meters.d0", "OK: Database test dumped", "OK: 0 row(s) dumped out!"],
f"-N -d deflate -S '2022-10-01 00:00:50.000' test meters -o {tmpdir}",["OK: table: meters dumped", "OK: 100 row(s) dumped out!"],
f"-N -d lzma -S '2022-10-01 00:00:50.000' test meters -o {tmpdir}",["OK: table: meters dumped", "OK: 100 row(s) dumped out!"],
f"-N -d snappy -S '2022-10-01 00:00:50.000' test meters -o {tmpdir}",["OK: table: meters dumped", "OK: 100 row(s) dumped out!"],
f" -S '2022-10-01 00:00:50.000' -E '2022-10-01 00:00:60.000' test meters -o {tmpdir}",["OK: table: meters dumped", "OK: 100 row(s) dumped out!"],
f"-T 2 -B 1000 -S '2022-10-01 00:00:50.000' -E '2022-10-01 00:00:60.000' test meters -o {tmpdir}", ["OK: table: meters dumped", "OK: 22 row(s) dumped out!"],
f"-g -E '2022-10-01 00:00:60.000' test -o {tmpdir}", ["OK: Database test dumped", "OK: 122 row(s) dumped out!"],
f"--help", ["Report bugs to"],
f"-?", ["Report bugs to"],
f"-V", ["version:"],
f"--usage", ["taosdump [OPTION...] -o outpath"]
[f"-h 127.0.0.1 -P 6030 -uroot -ptaosdata -A -N -o {tmpdir}", ["OK: Database test dumped", "OK: 200 row(s) dumped out!"]],
[f"-r result -gg -a -e test d0 -o {tmpdir}", ["OK: table: d0 dumped", "OK: 100 row(s) dumped out!"]],
[f"-n -D test -o {tmpdir}", ["OK: Database test dumped", "OK: 200 row(s) dumped out!"]],
[f"-L -D test -o {tmpdir}", ["OK: Database test dumped", "OK: 200 row(s) dumped out!"]],
[f"-s -D test -o {tmpdir}", ["dumping out schema: 1 from meters.d0", "OK: Database test dumped", "OK: 0 row(s) dumped out!"]],
[f"-N -d deflate -S '2022-10-01 00:00:50.000' test meters -o {tmpdir}",["OK: table: meters dumped", "OK: 100 row(s) dumped out!"]],
[f"-N -d lzma -S '2022-10-01 00:00:50.000' test meters -o {tmpdir}",["OK: table: meters dumped", "OK: 100 row(s) dumped out!"]],
[f"-N -d snappy -S '2022-10-01 00:00:50.000' test meters -o {tmpdir}",["OK: table: meters dumped", "OK: 100 row(s) dumped out!"]],
[f" -S '2022-10-01 00:00:50.000' -E '2022-10-01 00:00:60.000' test meters -o {tmpdir}",["OK: table: meters dumped", "OK: 100 row(s) dumped out!"]],
[f"-T 2 -B 1000 -S '2022-10-01 00:00:50.000' -E '2022-10-01 00:00:60.000' test meters -o {tmpdir}", ["OK: table: meters dumped", "OK: 22 row(s) dumped out!"]],
[f"-g -E '2022-10-01 00:00:60.000' test -o {tmpdir}", ["OK: Database test dumped", "OK: 122 row(s) dumped out!"]],
[f"--help", ["Report bugs to"]],
[f"-?", ["Report bugs to"]],
[f"-V", ["version:"]],
[f"--usage", ["taosdump [OPTION...] -o outpath"]]
]
# executes
@ -180,7 +180,7 @@ class TDTestCase(TBase):
results = item[1]
rlist = self.taosdump(command)
for result in results:
self.checkListString(result)
self.checkListString(rlist, result)
# clear tmp
self.clearPath(tmpdir)
@ -197,7 +197,7 @@ class TDTestCase(TBase):
# except commandline
def exceptCommandLine(self, taosdump, tmpdir):
def exceptCommandLine(self, taosdump, db, stb, tmpdir):
# -o
self.checkExcept(taosdump + " -o= ")
self.checkExcept(taosdump + " -o")
@ -220,14 +220,14 @@ class TDTestCase(TBase):
json = "./tools/taosdump/native/json/insertFullType.json"
# insert data with taosBenchmark
db, stb, child_count, insert_rows = self.insertData(benchmark, json)
db, stb, child_count, insert_rows = self.insertData(json)
newdb = "new" + db
# basic commandline
self.basicCommandLine(db, stb, tmpdir)
self.basicCommandLine(tmpdir)
# except commandline
self.exceptCommandLine(db, stb, tmpdir)
self.exceptCommandLine(taosdump, db, stb, tmpdir)
# dump out
#self.dumpOut(taosdump, db, tmpdir)