<div dir="ltr">I scanned that file and it seems like it collects the output at the end of the process, which isn't quite what I need. Thanks for the pointer though.<div><br></div><div>I also tried closing the ports, but that didn't help.<br>
<div><br></div><div style>I've been trying to reduce my code to a minimum working/non-working example, and it hasn't helped much. Basically I found out that every other command I tried worked fine, but the instruments one doesn't work with the copy-port stuff (it works when run by itself). For instance, I tried "raco test" on some personal code with the copy-port stuff and it logged in real-time just fine. I also tried "brew upgrade" and it logged the results in real time. But for some reason the command I'm using doesn't seem to work.</div>
<div style><br></div><div style>I think I'm just going to use the tee workaround for now.</div><div style><br></div><div style>Thanks for the time and pointers. I definitely learned a few things, so it wasn't a complete waste for me at least.</div>
<div style><br></div><div style>If there are any perfectionists that still want to figure this out, I'm just running iOS UI Automation tests as described here:</div><div style><br></div><div style><a href="http://stackoverflow.com/questions/4191945/can-the-ui-automation-instrument-be-run-from-the-command-line">http://stackoverflow.com/questions/4191945/can-the-ui-automation-instrument-be-run-from-the-command-line</a></div>
<div style><br></div><div style>Although I doubt there are many people who've been enlightened by Racket yet still stoop to writing Objective-C code...</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Thu, May 16, 2013 at 9:09 PM, Jay McCarthy <span dir="ltr"><<a href="mailto:jay.mccarthy@gmail.com" target="_blank">jay.mccarthy@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm showing up late to this party, but...<br>
<br>
DrDr has to do this in a very reliable way and it is abstracted into a<br>
fairly nice function called run/collect/wait<br>
<br>
<a href="https://github.com/plt/racket/blob/master/collects/meta/drdr/run-collect.rkt" target="_blank">https://github.com/plt/racket/blob/master/collects/meta/drdr/run-collect.rkt</a><br>
<br>
You may want to look at it a little.<br>
<br>
Jay<br>
<div class="HOEnZb"><div class="h5"><br>
On Thu, May 16, 2013 at 6:43 PM, Robby Findler<br>
<<a href="mailto:robby@eecs.northwestern.edu">robby@eecs.northwestern.edu</a>> wrote:<br>
> Oh, I meant to say that I think that process*/ports can make things easier<br>
> than system for this kind of thing. read-string-evt is more for if you want<br>
> to get good performance for high-throughput streams, which it seems like<br>
> isn't an issue here. This different seems unlikely to help with whatever is<br>
> going wrong.<br>
><br>
> I don't see that you're closing the ports anywhere, so maybe there is<br>
> something like that happening in your real script. Make sure that you close<br>
> everything as soon as you know there is no more data. Otherwise, I'm just<br>
> not sure what's going wrong.<br>
><br>
> As for process* and system*: they will work, I think, unless the strings you<br>
> put in the "~a"s are multiple arguments and you can't do that parsing<br>
> yourself. You'd do something like<br>
><br>
> (system* "/usr/bin/instruments" "-t" (path->string instruments-path)<br>
> (path->string app-path) "-e" "UIASCRIPT" (path->string script-path))<br>
><br>
> roughly.<br>
><br>
> Robby<br>
><br>
><br>
> On Thu, May 16, 2013 at 7:27 PM, Nick Shelley <<a href="mailto:nickmshelley@gmail.com">nickmshelley@gmail.com</a>><br>
> wrote:<br>
>><br>
>> I tried "file-stream-buffer-mode" on the stdout port and that didn't help.<br>
>> That seems to be the only port that will work with that method.<br>
>><br>
>> I also realize I misled you when I put "<script-that-logs-to-console>" as<br>
>> a placeholder in the code. Really it is a command of the form (format<br>
>> "instruments -t ~a \"~a\" -e UIASCRIPT ~a" ...) where two of the three ~a<br>
>> arguments are passed to Racket through the command-line. If I understand<br>
>> correctly, process* and system* won't work with this form.<br>
>><br>
>> After experimenting a bunch unsuccessfully, I tried putting the system<br>
>> call before I created the ports and without a parameterized<br>
>> current-output-port. The results I see are that for the first system call I<br>
>> get real-time logs to the console, then with the next one the tests repeat,<br>
>> but the logs don't come until the end.<br>
>><br>
>> I even tried Neil's suggested approach in case that made a difference.<br>
>> Aside from the fact that it has the same buffering problem, I never get the<br>
>> eof event, so I don't know when to terminate the sync loop. Here's the code:<br>
>><br>
>> (define-values (in out) (make-pipe))<br>
>> (define stdout (current-output-port))<br>
>> (define string-port (open-output-string))<br>
>> (process/ports out #f #f (format "instruments -t ~a \"~a\" -e UIASCRIPT<br>
>> ~a" instruments-path app-path script-path))<br>
>> (let loop ([data (sync (read-string-evt 1 in))])<br>
>> (unless (eof-object? data)<br>
>> (display (format "data: [~a]" data) stdout)<br>
>> (display data string-port)<br>
>> (loop (sync (read-string-evt 1 in)))))<br>
>> (printf "~n~nresults: ~a~n" (get-output-string string-port))<br>
>><br>
>> With this I get the delayed logs (each letter in brackets per sync event)<br>
>> and then the program hangs waiting for an eof that never comes. Out of<br>
>> curiosity, why did both of you recommend this approach over the system<br>
>> approach? Either I'm doing it completely wrong or I just can't see the<br>
>> advantage.<br>
>><br>
>><br>
>> On Thu, May 16, 2013 at 5:08 PM, Neil Van Dyke <<a href="mailto:neil@neilvandyke.org">neil@neilvandyke.org</a>><br>
>> wrote:<br>
>>><br>
>>> You can try "file-stream-buffer-mode" on the port.<br>
>>><br>
>>> Neil V.<br>
>>><br>
>><br>
>><br>
>> ____________________<br>
>> Racket Users list:<br>
>> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
>><br>
><br>
><br>
> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
><br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Jay McCarthy <<a href="mailto:jay@cs.byu.edu">jay@cs.byu.edu</a>><br>
Assistant Professor / Brigham Young University<br>
<a href="http://faculty.cs.byu.edu/~jay" target="_blank">http://faculty.cs.byu.edu/~jay</a><br>
<br>
"The glory of God is Intelligence" - D&C 93<br>
</font></span></blockquote></div><br></div>