digitalmars.D.learn - redirecting the unittests error output
- ref2401 (1/1) Jan 14 2015 How can i redirect the unittests error output to a file?
- John Colvin (9/10) Jan 14 2015 You redirect stderr to a file using whatever tools your shell
- ref2401 (11/11) Jan 14 2015 Unfortunately i'm new to using shells.
- Mike Parker (12/23) Jan 15 2015 Open up a command prompt and execute dmd with a nonexistent file name.
- Mike Parker (4/4) Jan 15 2015 [1]
- ref2401 (1/1) Jan 15 2015 Thank you.
How can i redirect the unittests error output to a file?
Jan 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.
Jan 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.
Jan 14 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.
Jan 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
Jan 15 2015