未设置环境变量值,但为什么?

时间:2016-12-05 11:28:38

标签: batch-file scope automated-tests

为什么批处理变量TESTTYPE没有传递给调用批处理文件(Windows 7计算机)?

我通过SVN提交消息触发测试系统。鉴于例如这个SVN消息:

  

这应该会触发我的测试系统进行长时间的测试。

     

测试RunTest #longtest

问题:内部批处理文件末尾的命令set正确输出longtest,但外部批处理文件意外输出smoketest

这是调用批处理文件test.bat

call %~dp0gettype.bat trunk 12345
echo %TESTTYPE%

这是执行工作的被调用批处理文件gettype.bat

set TESTTYPE=smoketest

::find all lines in the string which contain the keyword "RunTest#"
setlocal EnableDelayedExpansion
set "cmd=svn log -r %2 -v | findstr /r "RunTest#""

::for all words in that found line call the subroutine "handleElement"
for /F "tokens=*" %%a in ('!cmd!') do (
    if "%%a" NEQ "" for %%b in (%%a) do call:handleElement %%b
)
goto ende

::split on hashtag char and handle the keyword after the hashtag (and find the type)
:handleElement
set TMPSTR=%1
set TAGNAME=%TMPSTR:~0,8%
if "%TAGNAME%"=="RunTest#" call:getSpecialType %TMPSTR:~8%
goto:eof

:getSpecialType
set TESTTYPE=%1
goto:eof

:ende
set

0 个答案:

没有答案