-
Notifications
You must be signed in to change notification settings - Fork 93
Test postinst scripts #1193
base: main
Are you sure you want to change the base?
Test postinst scripts #1193
Conversation
034334f
to
8d28888
Compare
Apparently, this worked locally only because I happened to have |
Hi @jpnurmi Thank you for using Bach Testing Framework. It's pity that Bach Testing Framework canot intercept I/O redirector due to the limitation of Bash. But we can use Apply this patch, and all tests work as expected.
|
I recommend not ignoring the
|
Hi @chaifeng, thanks for chiming in and taking the time to come up with suggestions! We're definitely going to give it a try. 👍 |
Everyone contributing to this PR have now signed the CLA. Thanks! |
Hi @jpnurmi Could you re-run the cla-check again? I just noticed that I used a different email address on launchpad.net |
It might take a day or two to get accepted and synced across the systems. I'll check back later! |
Hi @jpnurmi I just released a new version of Bach Testing Framework. It supports mocking the left square bracket command With this version, we don't need to replace So I checkout snap/local/postinst.d/10_* to the commit I'm not sure the correct way to update this PR, so post the patch again. Sorry ;-P
|
The latest Bach can mock `[`.
f923595
to
de8bb14
Compare
Thank you, @chaifeng! This is getting better and better. :)
I was originally hoping to:
Do you think something like that would be doable? |
Hi @jpnurmi Yes, it's doable, but test cases may not be stable. They may fail due to permission, network, file system, different versions of commands, etc. In this case, the sed command is going to modify a file that has an absolute path. It will definitely fail if the absolute path doesn't exist or we don't have permission to change it. Without considering this absolute path problem, we can use a real sed command, for example:
In order to get the correct output values that will be written to the final files, there are two key inputs. One is the output of For the output of For the sed regular expressions. If we manually test a regular expression from the command line, it works. It should also work in a script file. we don't have to verify if the same regular expression produces the same output every time. If a command with specified parameters and options works on the command line, then it should work in the script as well. So from my point of view that the key point in writing script tests is should verify the behavior of our scripts. What is the command sequence in the test case? What parameters and options are passed to each command? etc. Thank you. |
Based on the Bach unit testing framework for Bash - https://bach.sh/