Closed dustmop closed 5 years ago
This was fixed a long time ago, in commit https://github.com/qri-io/qri/commit/585b58cf4a521771f627acf5d4ee095b5fca00fc. The actual problem was how the tests were attempting to get output, by calling root.SetOutput(buf) before root.ExecuteC then returning buf.String(). The correct way to get the output from stdout was the new GetOutput
command, which retrieves the ioestreams object's value that was piped into NewQriCommand. Nothing really to do with the pager.
While trying to test
qri diff
, I ran into multiple problems with trying to get output from running qri commands.The tests in cmd_test use ExecuteC to run commands, but stdout is not being properly captured. It seems that SetOutput isn't doing the right thing. The fix might be to upgrade the cobra library?
There's also some kind of conflict with the output buffering that qri is already doing when printing in the cmd package. I originally thought that disabling the pager would properly get stdout up to ExecuteC, so tried replacing print* calls with fmt.Printf, but that just ended up with output being displayed on my terminal, and still not captured by ExecuteC. More research is needed to figure out exactly what is going on.