我運行一個批處理文件:
1.進入直通ALL *用C .properties文件:\ ExecutionSDKTest_10.2.2
2.輸出的日誌,日誌參考線運行它們
3.比較線
但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
我沒有看到一個'SETLOCAL enableDelayedExpansion'任何地方,但你顯然嘗試使用延遲擴展。它可以這麼簡單嗎? – dbenham
@dbenham:可以啓用CMD命令行開關。沒有多少人可能知道它,當然... –