Skip to content

libcnb-test: Expose Pack build output as combined stdout + stderr #536

Open
@edmorley

Description

@edmorley

So in writing some libcnb-test integration tests now, I found it frustrating that there's no way to get a unified stdout+stderr output, since in most cases I don't really care about testing whether I've output to stdout vs stderr (after all, log_error will take care of that, so there isn't much room for user error).

However, I do care about how the output renders as a whole, which I can't check properly if half of it is on stdout, and the other half is on stderr. (Even if I stitch them together afterwards, the ordering will then be wrong.)

Also, relatedly, I seems to be regularly running into occasions where I'm debugging a test, and one of my output assertions is failing, but it's not clear why, because the useful part of the build log is on the other stream. But of course the test stops running after the first assertion failure (given it's a panic), and so I never get to see the assertion against the other stream. This means I then have to spend time thinking about the "sensible order" of asserting stdout vs stderr, and varying that order depending on whether the test is testing a success case, or a failure case.

All in all, it seems this is adding friction, for very little test coverage gain.

As such, I'm wondering if we shouldn't just combine the Pack CLI's stdout+stderr into one (tie the two together in the Command), and have libcnb-test only expose that as a single output?

Pros:

  • Reduced mental burden of having to think about whether one is asserting against stdout or stderr
  • Able to test visual UX of full info/warning/error output in cases that are currently untestable (if the output straddles stdout and stderr)
  • Less frustrating debugging of test failures due to the assertion issue mentioned above
  • Parity with Hatchet

Cons:

  • Not able to test that particular log output is on the expected stream. (Though IMO this isn't a significant drawback given we plan on leaning heavily on shared utils like log_error(), which will be widely used/tested, so already outputting on the correct stream)

We could also explore providing both a unified output and the original separate streams, though that does seem to increase implementation and libcnb-test public API complexity, for potentially little benefit.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions