Thread overview
redirecting the unittests error output
Jan 14, 2015
ref2401
Jan 14, 2015
John Colvin
Jan 14, 2015
ref2401
Jan 15, 2015
Mike Parker
Jan 15, 2015
Mike Parker
Jan 15, 2015
ref2401
January 14, 2015
How can i redirect the unittests error output to a file?
January 14, 2015
On Wednesday, 14 January 2015 at 18:50:04 UTC, ref2401 wrote:
> How can i redirect the unittests error output to a file?

You redirect stderr to a file using whatever tools your shell provides you. In anything related to unix sh you would do something like this:

./run_unittests 2>errorFile

where 2 stands for stderr (1 is for stdout). This would create a new file (or overwrite an existing file) called errorFile with whatever run_unittests prints to stderr, which would include unittest errors.
January 14, 2015
Unfortunately i'm new to using shells.

I use standard windows cmd. Here is my script:

dmd main.d -debug -unittest -wi

if %errorLevel% equ 0 (
	start main.exe
) else (
	echo --- Building failed! ---
	pause
)

I wrote "start main.exe 2> errorFile" but it doesn't work. errorFile is empty.

January 15, 2015
On 1/15/2015 4:32 AM, ref2401 wrote:
> Unfortunately i'm new to using shells.
>
> I use standard windows cmd. Here is my script:
>
> dmd main.d -debug -unittest -wi
>
> if %errorLevel% equ 0 (
>      start main.exe
> ) else (
>      echo --- Building failed! ---
>      pause
> )
>
> I wrote "start main.exe 2> errorFile" but it doesn't work. errorFile is
> empty.
>

Open up a command prompt and execute dmd with a nonexistent file name.

dmd foo.d 2> err.txt

You will find that dmd prints an error to err.txt, specifically that it can't find foo.d. (You can find more info about stdio handles and the command line at [1]).

Now execute it like this:

start dmd foo.d 2> err.txt

And you will find an empty err.txt. This is because you are redirecting the output of stderr from the *start* program, and not from dmd (you can read more about the start command at [2]). I'm not aware of anyway to redirect the output of a command or program executed by start.
January 15, 2015
[1] http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true
[2] https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/start.mspx?mfr=true
January 15, 2015
Thank you.