Browse Source

* Also read stderr while executing the compiler. This way
linker (ld) errors are also shown

git-svn-id: trunk@25363 -

joost 12 years ago
parent
commit
fa0c4da914
1 changed files with 13 additions and 4 deletions
  1. 13 4
      packages/fpmkunit/src/fpmkunit.pp

+ 13 - 4
packages/fpmkunit/src/fpmkunit.pp

@@ -1510,7 +1510,7 @@ var
   P: TProcess;
   BytesRead: longint;
 
-  function ReadFromStream: longint;
+  function ReadFromStream(const ReadFromStdErr: boolean): longint;
 
   const
     READ_BYTES = 2048;
@@ -1534,7 +1534,10 @@ var
     ConsoleOutput.SetSize(BytesRead + READ_BYTES);
 
     // try reading it
-    n := P.Output.Read((ConsoleOutput.Memory + BytesRead)^, READ_BYTES);
+    if ReadFromStdErr then
+      n := P.Stderr.Read((ConsoleOutput.Memory + BytesRead)^, READ_BYTES)
+    else
+      n := P.Output.Read((ConsoleOutput.Memory + BytesRead)^, READ_BYTES);
     if n > 0 then
     begin
       Inc(BytesRead, n);
@@ -1602,11 +1605,17 @@ begin
 
     P.Execute;
     while P.Running do
-      ReadFromStream;
+      ReadFromStream(false);
 
     // read last part
     repeat
-    until ReadFromStream = 0;
+    until ReadFromStream(false)=0;
+
+    // read stderr
+    // JvdS: Note that this way stderr is added to the end of the stream. But I
+    // see no way showing the stderr output at the place it was actually written
+    repeat
+    until ReadFromStream(true)=0;
     ConsoleOutput.SetSize(BytesRead);
 
     result := P.ExitStatus;