Skip to content

ENT-12619: Reduced noise from cfbs shell test output#304

Open
larsewi wants to merge 2 commits intocfengine:masterfrom
larsewi:ENT-13699/shell-test-framework
Open

ENT-12619: Reduced noise from cfbs shell test output#304
larsewi wants to merge 2 commits intocfengine:masterfrom
larsewi:ENT-13699/shell-test-framework

Conversation

@larsewi
Copy link
Contributor

@larsewi larsewi commented Feb 17, 2026

Example output:

$ bash tests/shell/all.sh
Warning: These shell based tests use the cfbs you have installed
         If you haven't already, run: pip install .
--- PASS: 001_init (2s)
--- PASS: 002_add (2s)
--- PASS: 003_download (2s)
--- PASS: 004_build (12s)
--- PASS: 005_alias (3s)
--- PASS: 006_search (2s)
--- SKIP: 007_install (0s)
--- PASS: 008_remove (2s)
 ---snip---
--- PASS: 047_absolute_path_modules (4s)

==============================
Test Results: 46 passed, 0 failed, 1 skipped (total: 47, 156s)
==============================
All cfbs shell tests completed successfully!

@larsewi larsewi force-pushed the ENT-13699/shell-test-framework branch from ba33364 to de17ea3 Compare February 17, 2026 15:29
@larsewi
Copy link
Contributor Author

larsewi commented Feb 17, 2026

@cf-bottom Jenkins please :)

@cf-bottom
Copy link

Copy link
Contributor

@craigcomstock craigcomstock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't say I love this PR. There is a lot of change and now the scripts can't be written free-hand in bash... you must refer to the testlib often to know what functions to use.

Also, I am not sure how much is improved other than maybe silencing "good" outputs to make analysis easier... which is a welcome change so +1 on that account.

I think all the migrated commits could be squashed into one for easier review... #next-time

@larsewi
Copy link
Contributor Author

larsewi commented Feb 23, 2026

@craigcomstock Thanks for the review 🚀

I can't say I love this PR. There is a lot of change and now the scripts can't be written free-hand in bash... you must refer to the testlib often to know what functions to use.

I see your point, but I disagree to some extent. The scripts can still be written in free-hand bash. The tests still worked previous to the migration. The asserts however are easier to understand for someone who is not very proficient with bash, rather than greps and pipes on top of each other. Furthermore, the asserts print out a nice error messages like expected foo, got bar, rather than test failing because grep returned 1.

I think all the migrated commits could be squashed into one for easier review... #next-time

For me, personally, it's easier with smaller commits, rather than 600 lines of diff that I have to scroll through. You can always click the files changed tab to see everything together.

I will fix up some things. If you still think this PR is bad, I won't die on my sword.

@larsewi larsewi force-pushed the ENT-13699/shell-test-framework branch from de17ea3 to 5afaf49 Compare February 23, 2026 10:59
@olehermanse
Copy link
Member

olehermanse commented Feb 24, 2026

@larsewi Some notes:

  • It looks like you're linking to the wrong ticket, ENT-13699 is about something else.
  • As Craig notes, this goes a bit against what was the intention / advantage of these tests, being "just a bash script". Now, in order to write one "correctly" / consistently, you will have to check with what is in testlib frequently. I know you said you can still write them like before, but we shouldn't, we should aim to make them consistent.
  • I agree that it's probably easier (at least sometimes / for some people) to read and write if you're not good at bash. Might be harder in other cases if you're encountering issues with testlib.sh for example.
  • It looks like the output is better than before 👍
  • There is a big tradeoff when it comes to abstraction. For example in this case, many tests have abstracted away the 5 steps they used to set up with a 2 line "source" and "init". Before, you could see exactly what happens in setup, now it's an opaque thing you have to look up in testlib.sh. Of course the advantage is that it's a bit shorter, more standardized, less chance of error (maybe), but in this case it's questionable if it's worth it.
  • Why use a custom made testlib instead of reusing something which exists? For example this looks very similar? https://bashunit.typeddevs.com/assertions#assert-file-exists I'm not saying it's 100% wrong, but did you consider the pros and cons here?

Ticket: ENT-12619
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@larsewi larsewi force-pushed the ENT-13699/shell-test-framework branch from 5afaf49 to dec4471 Compare February 24, 2026 16:07
@larsewi larsewi changed the title ENT-13699: Add shell test framework and migrate all tests ENT-12619: Add shell test framework and migrate all tests Feb 24, 2026
@larsewi larsewi changed the title ENT-12619: Add shell test framework and migrate all tests ENT-12619: Reduced noise from cfbs shell test output Feb 24, 2026
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
@larsewi
Copy link
Contributor Author

larsewi commented Feb 24, 2026

@olehermanse, @craigcomstock removed the test framework and kept the code print nicer output. Let me know what you think 😉

Copy link
Contributor

@craigcomstock craigcomstock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty small change with some nice benefits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants