if exist "./snapshots/!filename!.txt"
is true, thus enters the clause,
but the fc
(and other commands) fail to find the file anyway, printing out:
FC: cannot open ./SNAPSHOTS/*filename*.TXT - No such file or folder
@echo off
setlocal enabledelayedexpansion
set passed=0
set failed=0
set nosnaps=0
for %%i in (./tests/*) do (
set "filename=%%~ni"
dune exec ../_build/default/bin/main.exe ./tests/%%i > "./results/!filename!.txt" 2> nul
if exist "./snapshots/!filename!.txt" (
fc "./snapshots/!filename!.txt" "./results/!filename!.txt" > nul
if !errorlevel! == 0 (
echo PASSED TEST: !filename!
set /a passed+=1
) else (
echo FAILED TEST: !filename!
set /a failed+=1
)
) else (
echo NOSNAP TEST: !filename!
set /a nosnaps+=1
)
)
echo --------
echo PASSED: !passed!
echo FAILED: !failed!
echo NOSNAP: !nosnaps!
endlocal
The solution is enormously simple:
@ECHO OFF
SETLOCAL
FC "u:/testing/q79095787/file1.txt" "u:/testing/q79095787/file2.txt"
FC "u:\testing\q79095787\file1.txt" "u:\testing\q79095787\file2.txt"
GOTO :EOF
where "file1/2" are simply identical copies of a random file.
Results:
FC: cannot open U:/TESTING/Q79095787/FILE1.TXT - No such file or folder
Comparing files U:\TESTING\Q79095787\file1.txt and U:\TESTING\Q79095787\FILE2.TXT
FC: no differences encountered
Conclusion:
\
is the correct separator for windows directories. /
sometimes works, but inconsistently.
Hence - use the correct separator.