我正在运行一个批处理文件:
1. 遍历 C:\ExecutionSDKTest_10.2.2 中的所有 *.properties 文件
2. 运行它们
3. 逐行比较输出日志与 ref log
但是 cmd.exe 一直在抛出我此错误:“!fileName!此时出乎意料。有什么想法吗?
CALL ant clean build compile
REM Run ENG-zzz.properties --> output to ENG-zzz.properties.log in Logs dir
REM loop thru/Run ALL .properties file names from "ExecutionSDKTest_10.2.2" folder
FOR %%G in (C:\ExecutionSDKTest_10.2.2\*.properties) DO (
set flag=true
Set fileName=%%~nxG
set testNum=!fileName:~0,7!
echo Running:!fileName!
java -jar Test.jar !fileName! > Logs\!fileName!.log
ECHO Create: Ref!fileName!.log at C:\ExecutionSDKTest_10.2.2\Logs
set logPath=C:\ExecutionSDKTest_10.2.2\Logs\!fileName!.log
set refLogPath=C:\ExecutionSDKTest_10.2.2\Logs\!testNum!-Ref.properties.txt
set lnCorrect=true
set errorLnCount=0
REM if ...Ref.txt doesnt Exist --> check certain lines of the log
REM assume ref.txt exists
<!logPath! (
For /F "tokens=*" %%R in (!refLogPath!) DO (
set logLine=
set /p logLine=
set refLogLine=%%R
REM Check line by line of log against refLog
REM assume ALL times have been replaced with: "xx:xx:xx"
REM if corresponding lines mismatch
if NOT !logLine!==!refLogLine! Do (
set lnCorrect=false
REM output to command line: can be put into .log/.txt later
if errorLnCount==1 AND lnCorrect==false DO (
ECHO The following line(s) !fileName! are incorrect against corresponding line(s) in !testNum!-Ref.properties.txt
)
ECHO !logLine!
)
)
)
if lnCorrect=true Do Echo !fileName! Passed
)
Pause