Reputation: 21453
I want to open a file and tail -f
the output. I'd like to be able to open the file at the beginning of my test in a subprocess, execute the test, then process the output starting from the beginning of the tail.
I've tried using Run Process
, but that just spins, as the process never terminates. I tried using Start Process
followed by Get Process Result
, but I get an error saying Getting results of unfinished processes is not supported.
Is this possible?
Upvotes: 2
Views: 1641
Reputation: 457
The tail -F command won't finish until it is terminated, so you cannot get result then. You have 2 ways to accomplish your need.
First, terminate tail process before getting it's stdout:
${result} = start Process tail -F tailtest alias=tail
#test case stuff starts here
#...
#test case stuff ends here
terminate process tail
${result} Get Process Result tail stdout=True
log ${result}
You can do "start process" and terminate it&get results in test setup/teardown.
The other option is to redirect output to a file, and get this file content:
${result} = start Process tail -F tailtest stdout=tailoutput alias=tail
#test case stuff starts here
#...
#test case stuff ends here
${result} get file tailoutput
log ${result}
It would be cleaner solution if you anyway terminate the tail process.
The second approach is better when tail output is big - avoiding the problem when: "the output buffers may get full and the program can hang".
Upvotes: 0
Reputation: 385980
There's no need to do tail -f
. At the start of your test you can get the number of bytes in the file. Let the test run, and then read the file starting at the byte offset that you calculated earlier (or read the whole file, and use a slice to look at the new data)
Upvotes: 3