Browse Source
Revamping of the advise API to allow more systematic enumeration of advice knobs in the future. * hw/advise-ng: tag: use new advice API to check visibility advice: revamp advise API advice: change "setupStreamFailure" to "setUpstreamFailure" advice: extract vadvise() from advise()maint
![gitster@pobox.com](/assets/img/avatar_default.png)
9 changed files with 200 additions and 12 deletions
@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
#include "test-tool.h" |
||||
#include "cache.h" |
||||
#include "advice.h" |
||||
#include "config.h" |
||||
|
||||
int cmd__advise_if_enabled(int argc, const char **argv) |
||||
{ |
||||
if (!argv[1]) |
||||
die("usage: %s <advice>", argv[0]); |
||||
|
||||
setup_git_directory(); |
||||
git_config(git_default_config, NULL); |
||||
|
||||
/* |
||||
* Any advice type can be used for testing, but NESTED_TAG was |
||||
* selected here and in t0018 where this command is being |
||||
* executed. |
||||
*/ |
||||
advise_if_enabled(ADVICE_NESTED_TAG, argv[1]); |
||||
|
||||
return 0; |
||||
} |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh |
||||
|
||||
test_description='Test advise_if_enabled functionality' |
||||
|
||||
. ./test-lib.sh |
||||
|
||||
test_expect_success 'advice should be printed when config variable is unset' ' |
||||
cat >expect <<-\EOF && |
||||
hint: This is a piece of advice |
||||
hint: Disable this message with "git config advice.nestedTag false" |
||||
EOF |
||||
test-tool advise "This is a piece of advice" 2>actual && |
||||
test_i18ncmp expect actual |
||||
' |
||||
|
||||
test_expect_success 'advice should be printed when config variable is set to true' ' |
||||
cat >expect <<-\EOF && |
||||
hint: This is a piece of advice |
||||
hint: Disable this message with "git config advice.nestedTag false" |
||||
EOF |
||||
test_config advice.nestedTag true && |
||||
test-tool advise "This is a piece of advice" 2>actual && |
||||
test_i18ncmp expect actual |
||||
' |
||||
|
||||
test_expect_success 'advice should not be printed when config variable is set to false' ' |
||||
test_config advice.nestedTag false && |
||||
test-tool advise "This is a piece of advice" 2>actual && |
||||
test_must_be_empty actual |
||||
' |
||||
|
||||
test_done |
Loading…
Reference in new issue