Comments (5)
Yeah, in general I would say that using test_cmp
is probably more flexible, as it works for example with multi-line output, and more helpful when debugging as both the expected and actual ouputs are in some files and the diff is shown if the comparison fails.
I agree that it might not be as convenient as a special function though, but you might want to create one based on test_cmp
. See for example https://github.com/git/git/blob/master/t/t6101-rev-parse-parents.sh#L10-L14 which contains:
test_cmp_rev_output () {
git rev-parse --verify "$1" >expect &&
eval "$2" >actual &&
test_cmp expect actual
}
in your case you can create for example:
test_cmp_output () {
echo "$1" >expect &&
eval "$2" >actual &&
test_cmp expect actual
}
and use that in your tests.
About the test_expect_equal_stdout
you suggest, I wonder what the test description would be when the tests are run? Could you show how it would be implemented (maybe using the above test_cmp_output
)?
See https://github.com/git/git/blob/master/t/t5001-archive-attr.sh#L9-L11 for an example of how such a function is implemented in Git.
Thanks!
from sharness.
In the case of the debian bug, I think the test could contain something like:
printf "%s\n" list quit | nc localhost munin | grep -v "^#" >all_plugins &&
sed "s/if_\w\+//g" all_plugins >all_plugins_wo_if &&
printf "%s\n" $(echo "cpu df df_inode entropy forks fw_packets interrupts irqstats load memory netstat open_files open_inodes proc_pri processes swap threads uptime users vmstat") >expected &&
test_cmp expected all_plugins_wo_if
See also #14 that I would like to work on soon.
from sharness.
Thank you for this hint - indeed this sounds like a good approach.
Just one detail: this would require the creation of temporary files in the current directory, which would need to be removed afterwards, or? How do you usually handle this?
from sharness.
Each test script is run in a directory named "trash directory.$script" where $script is the test script name (or some part of it). When a test fails this directory is not removed so one can cd into it and debug what happened.
For example if you modify one test in https://github.com/chriscool/sharness/blob/master/test/simple.t so that it fails, you will find a "trash directory.simple" directory.
When tests succeed, the directory is removed, so there is no need to clean up the temporary files.
from sharness.
Great - thank you!
In this case your proposed solution is indeed just the proper one - thus I think, there is no need for a new function.
from sharness.
Related Issues (20)
- SHARNESS_TEST_SRCDIR and extensions HOT 3
- Sharness self-test fails HOT 2
- Can't locate object method "follower" via package "IO::Pty"
- test_expect_failure test 2 = 2 does not fail with prove HOT 4
- trash dir as home dir when run on Windows HOT 1
- testing scripts with sourced functions HOT 1
- Make a release v1.2 HOT 1
- Usage with `prove` would need more documentation HOT 6
- Calling functions from Git submodule fails with v1.2.0 release (Regression) HOT 8
- make test fails with unliked SHELL_PATH HOT 9
- add --tee option from git test-lib.sh HOT 1
- sharness.sh is executable? HOT 3
- Release tarballs are not signed HOT 4
- Clarify purpose of "aggregate-results.sh" HOT 12
- Cleanup actions are only run if no tests failed HOT 8
- Document usage of "trash" directory HOT 2
- Document how to release a new Sharness version HOT 2
- Line feed regression HOT 3
- Lots of dangling branches HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sharness.