From: Matthieu Moy <Matthieu.Moy@imag.fr>
To: git@vger.kernel.org, gitster@pobox.com
Cc: tanayabh@gmail.com, artagnon@gmail.com,
Matthieu Moy <Matthieu.Moy@imag.fr>
Subject: [PATCH 2/2] Better tests for error cases
Date: Fri, 11 Jul 2014 16:27:13 +0200 [thread overview]
Message-ID: <1405088833-5817-2-git-send-email-Matthieu.Moy@imag.fr> (raw)
In-Reply-To: <1405088833-5817-1-git-send-email-Matthieu.Moy@imag.fr>
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
Consider squashing this into PATCH 2/2
Probably not sufficient.
t/t1308-config-set.sh | 22 ++++++++++++++++++++++
test-config.c | 8 ++++++--
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh
index 87a29f1..f1e9e76 100755
--- a/t/t1308-config-set.sh
+++ b/t/t1308-config-set.sh
@@ -167,4 +167,26 @@ test_expect_success 'find value_list for a key from a configset' '
test_cmp expect actual
'
+test_expect_success 'proper error on non-existant files' '
+ echo "Error reading configuration file non-existant-file." >expect &&
+ test_must_fail test-config configset_get_value foo.bar non-existant-file 2>actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'proper error on error in default config files' '
+ cp .git/config .git/config.old &&
+ test_when_finished "mv .git/config.old .git/config" &&
+ echo "[" >> .git/config &&
+ echo "fatal: bad config file line 35 in .git/config" >expect &&
+ test_must_fail test-config get_value foo.bar 2>actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'proper error on error in custom config files' '
+ echo "[" >> syntax-error &&
+ echo "fatal: bad config file line 1 in syntax-error" >expect &&
+ test_must_fail test-config configset_get_value foo.bar syntax-error 2>actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/test-config.c b/test-config.c
index 07b61ef..49f8cd7 100644
--- a/test-config.c
+++ b/test-config.c
@@ -86,8 +86,10 @@ int main(int argc, char **argv)
}
} else if (!strcmp(argv[1], "configset_get_value")) {
for (i = 3; i < argc; i++) {
- if (git_configset_add_file(&cs, argv[i]))
+ if (git_configset_add_file(&cs, argv[i])) {
+ fprintf(stderr, "Error reading configuration file %s.\n", argv[i]);
goto exit2;
+ }
}
if (!git_configset_get_value(&cs, argv[2], &v)) {
if (!v)
@@ -101,8 +103,10 @@ int main(int argc, char **argv)
}
} else if (!strcmp(argv[1], "configset_get_value_multi")) {
for (i = 3; i < argc; i++) {
- if (git_configset_add_file(&cs, argv[i]))
+ if (git_configset_add_file(&cs, argv[i])) {
+ fprintf(stderr, "Error reading configuration file %s.\n", argv[i]);
goto exit2;
+ }
}
strptr = git_configset_get_value_multi(&cs, argv[2]);
if (strptr) {
--
2.0.0.262.gdafc651
next prev parent reply other threads:[~2014-07-11 14:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-11 3:34 [PATCH v8 0/3] git config cache & special querying api utilizing the cache Tanay Abhra
2014-07-11 3:34 ` [PATCH v8 1/2] add `config_set` API for caching config-like files Tanay Abhra
2014-07-11 14:21 ` Matthieu Moy
2014-07-11 16:31 ` Tanay Abhra
2014-07-11 16:59 ` Matthieu Moy
2014-07-15 10:54 ` Tanay Abhra
2014-07-15 11:32 ` Matthieu Moy
2014-07-11 17:25 ` Junio C Hamano
2014-07-11 3:34 ` [PATCH v8 2/2] test-config: add tests for the config_set API Tanay Abhra
2014-07-11 14:24 ` Matthieu Moy
2014-07-11 14:27 ` [fixup PATCH 1/2] Call configset_clear Matthieu Moy
2014-07-11 14:27 ` Matthieu Moy [this message]
2014-07-11 18:18 ` [PATCH v8 2/2] test-config: add tests for the config_set API Junio C Hamano
2014-07-15 11:10 ` Tanay Abhra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1405088833-5817-2-git-send-email-Matthieu.Moy@imag.fr \
--to=matthieu.moy@imag.fr \
--cc=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=tanayabh@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).