t.bat 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. set FILE=%~n1
  2. set DIR=%RANDOM%
  3. md %DIR%
  4. pushd %DIR%
  5. md old
  6. md new
  7. copy ..\files\%1 old\%1
  8. copy ..\files\%1 new\%1
  9. if not "%2"=="" copy ..\files\%2 %2
  10. if not "%3"=="" copy ..\files\%3 %3
  11. if not "%4"=="" copy ..\files\%4 %4
  12. copy ..\old\testlib.h old\testlib.h
  13. if not exist ..\old-bin md ..\old-bin
  14. if exist ..\old-bin\%FILE%.exe (
  15. echo copying
  16. copy ..\old-bin\%FILE%.exe old\%FILE%.exe
  17. ) else (
  18. echo compiling
  19. pushd old
  20. g++ -O2 -Wall -o %FILE% %1
  21. copy %FILE%.exe ..\..\old-bin\%FILE%.exe
  22. popd
  23. )
  24. if not exist old\%FILE%.exe pause
  25. old\%FILE%.exe %2 %3 %4 1>old.output 2>old.error
  26. set OLD_ERRORLEVEL=%ERRORLEVEL%
  27. copy ..\new\testlib.h new\testlib.h
  28. if not exist ..\new-bin md ..\new-bin
  29. if exist ..\new-bin\%FILE%.exe (
  30. echo copying
  31. copy ..\new-bin\%FILE%.exe new\%FILE%.exe
  32. ) else (
  33. echo compiling
  34. pushd new
  35. g++ -O2 -Wall -o %FILE% %1
  36. copy %FILE%.exe ..\..\new-bin\%FILE%.exe
  37. popd
  38. )
  39. if not exist new\%FILE%.exe pause
  40. new\%FILE%.exe %2 %3 %4 1>new.output 2>new.error
  41. set NEW_ERRORLEVEL=%ERRORLEVEL%
  42. fc new.error old.error
  43. if errorlevel 1 pause
  44. fc new.output old.output
  45. if errorlevel 1 pause
  46. if not "%OLD_ERRORLEVEL%"=="%NEW_ERRORLEVEL%" pause
  47. popd
  48. rd /S /Q %DIR%