First of all, my Dockerfile was
FROM alpine:3.19
RUN apk update && apk add --no-cache jq wine
# Pre-initialize wine
RUN wine cmd
WORKDIR /opt/test-runner
COPY . .
ENTRYPOINT ["/opt/test-runner/bin/run.sh"]
so my folder is completely imported into <kbd>~/opt/test-runner</kbd> in alpine.
and I have two file which important,
<kbd>Success.bat</kbd>
@Echo Goodbye, Mars!
\EOL
<kbd>SuccessTest.bat</kbd>
@echo off
REM ---------------------------------------------------
REM testThatGreeterReturnsTheCorrectGreeting
REM ---------------------------------------------------
REM Initalize result variable
set "slug=Success"
set "result="
set "expected=Hello, World!"
REM Run the program and store the output in the result variable
echo Looking for "%~dp0%slug%.bat"
if exist %~dp0%slug%.bat (
REM If the file exists in the full path, run it from there
echo Found "%~dp0%slug%.bat"
for /f "delims=" %%a in ('%~dp0%slug%.bat') do set result=%%a
) else (
echo Could not find "%~dp0%slug%.bat"
echo Looking for "%slug%.bat"
if exist %slug%.bat (
REM If the file exists in the wildcard search path, run it from there
echo Found "%slug%.bat"
for /f "delims=" %%a in ('%slug%.bat') do set result=%%a
) else (
REM Errorlevel = 2: The system cannot find the file specified.
REM Indicates that the file cannot be found in specified location.
echo Could not find "%~dp0%slug%.bat" or "%slug%.bat"
exit /b 2
)
)
REM Check if the result is correct
if "%result%" == "%expected%" (
REM If the result is correct, exit with code 0
echo Test passed
exit /b 0
) else (
REM If the result is incorrect, exit with code 1
echo Expected: %expected%
echo Actually: %result%
echo Test failed
exit /b 1
)
\EOL
then I moved files with
mkdir -p ~/root/.wine/drive_c/users/root/Documents/
cp -R /opt/test-runner/tests/Success/* ~/root/.wine/drive_c/users/root/Documents/
/opt/test-runner/tests/Success # cd ~/root/.wine/drive_c/users/root/Documents/
~/root/.wine/drive_c/users/root/Documents # ls
Success.bat SuccessTest.bat expected_results.json
there is only one step left, run the script with wine.
~/root/.wine/drive_c/users/root/Documents # wine cmd /c SuccessTest.bat
Looking for "Z:\root\root\.wine\drive_c\users\root\Documents\Success.bat"
Found "Z:\root\root\.wine\drive_c\users\root\Documents\Success.bat"
Can't recognize 'CMD.EXE /C Z:\root\root\.wine\drive_c\users\root\Documents\Success.bat' as an internal or extern
al command, or batch script.
Expected: Hello, World!
Actually:
Test failed
So what I want is to process the bat file in the same folder that does not contain only the Test name, but it cannot find it and therefore cannot process it.
What did you try and what were you expecting?
I was waiting for it to find the file in the same folder.
– But strangely it can’t find it even though I’ve tried everything.