I want to set level, environment and version using three environment variables to run a test multiple times with different lvl, env and ver. I already have three environment variables(array/list) from where I can read all three values to be set.
I want to iterate over three lists to get lvl, env and ver simultaneously. I want it to be LVL1, ENV1, VER1 for first run then LVL2, ENV2, VER2 for next and so on.
I have these set in command window from where I will be launching my process
set LVL_VAR=LVL1 LVL2 LVL3
set ENV_VAR=ENV1 ENV2 ENV3
set VER_VAR=VER1 VER2 VER3
I can read these three to get lvl, env, ver Then I need to set variables LVL, ENV and VER as LVL1, ENV1 and VER1 and so on before running RunTest.bat
This is what i tried, nested loop, but i dont know how to restrict 2nd and 3rd loop to set it correctly or if there is another way to do it.
@echo OFF
for %%L in (%LVL_VAR%) do call :for_lvl %%L
exit /b
:for_lvl
set LVL=%1
echo LVL %LVL%
for %%E in (%ENV_VAR%) do call :for_env %%E
exit /b
goto :cont
:cont
exit /b
:for_env
set ENV=%1
echo ENV %ENV%
for %%V in (%VER_VAR%) do call :for_ver %%V
goto :cont
:cont
exit /b
exit /b
:for_ver
set VER=%1
echo VER %VER%
echo =======================RunTest.bat===================
exit /b
The obvious output i get is
LVL LVL1
ENV ENV1
VER VER1
=======================RunTest.bat===================
VER VER2
=======================RunTest.bat===================
VER VER3
=======================RunTest.bat===================
ENV ENV2
VER VER1
=======================RunTest.bat===================
VER VER2
=======================RunTest.bat===================
VER VER3
=======================RunTest.bat===================
ENV ENV3
VER VER1
=======================RunTest.bat===================
VER VER2
=======================RunTest.bat===================
VER VER3
=======================RunTest.bat===================
LVL LVL2
ENV ENV1
VER VER1
=======================RunTest.bat===================
VER VER2
=======================RunTest.bat===================
VER VER3
=======================RunTest.bat===================
ENV ENV2
VER VER1
=======================RunTest.bat===================
VER VER2
=======================RunTest.bat===================
VER VER3
=======================RunTest.bat===================
ENV ENV3
VER VER1
=======================RunTest.bat===================
VER VER2
=======================RunTest.bat===================
VER VER3
=======================RunTest.bat===================
LVL LVL3
ENV ENV1
VER VER1
=======================RunTest.bat===================
VER VER2
=======================RunTest.bat===================
VER VER3
=======================RunTest.bat===================
ENV ENV2
VER VER1
=======================RunTest.bat===================
VER VER2
=======================RunTest.bat===================
VER VER3
=======================RunTest.bat===================
ENV ENV3
VER VER1
=======================RunTest.bat===================
VER VER2
=======================RunTest.bat===================
VER VER3
=======================RunTest.bat===================
I need it to be like this
LVL LVL1
ENV ENV1
VER VER1
=======================RunTest.bat===================
LVL LVL2
ENV ENV2
VER VER2
=======================RunTest.bat===================
LVL LVL3
ENV ENV3
VER VER3
=======================RunTest.bat===================
How do I limit my iterations or is there other way?