www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - redirecting the unittests error output

reply "ref2401" <refactor24 gmail.com> writes:
How can i redirect the unittests error output to a file?
Jan 14 2015
parent reply "John Colvin" <john.loughran.colvin gmail.com> writes:
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.
Jan 14 2015
parent reply "ref2401" <refactor24 gmail.com> writes:
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.
Jan 14 2015
parent reply Mike Parker <aldacron gmail.com> writes:
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.
Jan 15 2015
parent reply Mike Parker <aldacron gmail.com> writes:
[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
Jan 15 2015
parent "ref2401" <refactor24 gmail.com> writes:
Thank you.
Jan 15 2015