main: unif/refactor std{out,err} test handling#450
main: unif/refactor std{out,err} test handling#450lzap wants to merge 4 commits intoosbuild:mainfrom
Conversation
|
TestManifestIntegrationSmoke fails, need to take a look. |
|
Rebased, fixed the test, it seems unrelated so something wrong was merged? I do not think it is worth implementing any complex JSON testing for these smoke tests, at least for now. |
For historic reasons we have two way to test the std{out,err}
output. One is to just monkey patch `var osStdout = os.Stdout`
and then replace it in the tests, the other to have a helper
that works like a `with` in python that replaces the stdout/stderr
dynamically, e.g.:
```
stdout, stderr := testutil.CaptureStdio(t, func() {
err = main.Run()
require.NoError(t, err)
})
```
The trouble is that they are not quite compatible. In places
where we use the monkey patches `osStdout` the
testutil.CaptureStdio() will not work as it (temporarely)
replaces the "real" `os.Stdout` (and vice-versa).
So this commit unifies all tests to use testutil.CaptureStdio()
which feels slightly nicer than the other approach in the
sense that one does not need to remember to use `osStdout` in
the code. Its mostly mechanical.
Co-authored-by: Lukas Zapletal <lzap+git@redhat.com>
These smoke tests do JSON matching on the pretty-printed manifest which is not ideal, but it is pretty effective for smoke tests. This fixes a bug that is unrelated to the previous commit.
|
Done. |
|
Weird, all passes locally but on CICD: Ha this must be a different osbuild version that I have vs what is in here. The failing line is: Smoke tests run in Fedora 43. |
Locally, I see manifest output indented. Changing to regexp to match the expected format.
|
I had to add |
|
Oh wait I think I fixed the issue by the previous commit already but there is a different one: |
|
This PR is stale because it had no activity for the past 30 days. Remove the "Stale" label or add a comment, otherwise this PR will be closed in 7 days. |
For historic reasons we have two way to test the std{out,err} output. One is to just monkey patch
var osStdout = os.Stdoutand then replace it in the tests, the other to have a helper that works like awithin python that replaces the stdout/stderr dynamically, e.g.:The trouble is that they are not quite compatible. In places where we use the monkey patches
osStdoutthetestutil.CaptureStdio() will not work as it (temporarely) replaces the "real"
os.Stdout(and vice-versa).So this commit unifies all tests to use testutil.CaptureStdio() which feels slightly nicer than the other approach in the sense that one does not need to remember to use
osStdoutin the code. Its mostly mechanical.I rebased #416 on top of
main, review carefully thanks :)