DOS errorlevel is not being set

2007-04-22
2013-04-25
  • David Fishburn
    David Fishburn
    2007-04-22

    I am running sqlunit 4.9 on WinXP SP2.

    I can't run sqlunit 5.0 since it will not connect to my database (SQL Anywhere).  I hear that has been fixed in the 5.0 CVS version.

    Anyway, my problem is when I run a test, the sqlunit output is:

    [sqlunit] Tearing down test...
      [sqlunit] sqlunit-ant: SQLUnit Tests Failed: In file: C:\website\src\deved_registration\qa\sqlunit_verification\test_1b.xml, tests: 3, failures: 2, errors = 0
      [sqlunit] SQLUnit Tests Failed: In file: C:\website\src\deved_registration\qa\sqlunit_verification\test_1b.xml, tests: 3, failures: 2, errors = 0

    BUILD FAILED
    C:\website\src\deved_registration\qa\sqlunit-4.9\build.xml:162: SQLUnit Tests Failed: In file: C:\website\src\deved_registration\qa\sqlunit_verification\test_1b.xml, tests: 3, failures: 2, errors = 0

    So I had 2 failures.
    Yet, in the CMD file I used to run the test the %errorlevel% set by the java call is still 0.  This should be a non-zero value indicating failure.

    I was calling a CMD file originally, but then I changed this to:

    java.exe  -classpath "c:\Jakarta\apache-ant-1.6.5\lib\ant-launcher.jar" "-Dant.home=c:\Jakarta\apache-ant-1.6.5" org.apache.tools.ant.launch.Launcher  -cp "C:\sa10\java\jodbc.jar" sqlunit-flat -Dtestfile=C:\website\src\deved_registration\qa\sqlunit_verification\test_1b.xml -logfile C:\website\src\deved_registration\qa\sqlunit_verification\test_1b.txt
    Buildfile: build.xml

    After this call I print out the errorlevel:
    @echo.SQLUnit Errorlevel[%errorlevel%]

    It still reports:
    SQLUnit Errorlevel[0]

    Anyone know what java code I could change to correct this.  Or does anyone know if this is fixed in the CVS version of 5.0?

    TIA,
    Dave

     
    • David Fishburn
      David Fishburn
      2007-04-22

      I just tried this with the current 5.0 CVS version.

      a) It can connect to SQL Anywhere again (good)
      b) It does appropriately set the DOS errorlevel on failure.

      At least if other people run into this issue they will know it has been fixed.  Not sure when an official 5.1 release will make it out the door.

      Dave

       
    • David Fishburn
      David Fishburn
      2007-04-23

      A bit more information on this topic.

      If you use 4NT as your shell (at least with my ancient version, 4NT  4.01A) the ERRORLEVEL is not correctly set.

      So I have added the following code to my batch file that calls it:

      rem Need to check if we are using the 4NT shell...
      if "%@eval[2+2]" == "4" goto NO_USE_4NT

      :NO_USE_4NT
      @echo.
      @echo.************************************************************
      @echo.ERROR
      @echo.You cannot use 4NT, use CMD instead
      @echo.************************************************************
      @echo.
      set errorlevel=5
      goto END

      :END