Clean up existing tests and add new tests in t1300-config.sh.
v1 cover letter:
https://lore.kernel.org/git/20230414081352.810296-1-rybak.a.v@gmail.com/
v2 cover letter:
https://lore.kernel.org/git/20230418175034.982433-1-rybak.a.v@gmail.com/
Changes since v2:
- Patch 3 updates:
- Added missing word "are" in commit message
- Added signoff
- Wrapped $1 and $2 in double quotes for consistency with
`git grep -P 'local .*="?[$][1-9]"? &&$' -- t`
- Added &&-chainging to function "test_missing_key"
- Fixed quoting so that substitution of $key happens inside eval
- Added tests about config subsectionsChanges since v1:
- Rewritten commit message for patch 2.
- New RFC patch 3.
Andrei Rybak (3):
t1300: drop duplicate test
t1300: check stderr for "ignores pairs" tests
t1300: add tests for missing keys
t/t1300-config.sh | 33 ++++++++++++++++++++++-----------
1 file changed, 22 insertions(+), 11 deletions(-)
Range diff against v2:
1: cf812f4fa8 = 1: cf812f4fa8 t1300: drop duplicate test
2: b4132adea8 = 2: b4132adea8 t1300: check stderr for "ignores pairs" tests
3: 6126f42449 ! 3: ba536bf855 t1300: add tests for missing keys
@@ Metadata
## Commit message ##
t1300: add tests for missing keys
- There several tests in t1300-config.sh that validate failing invocations
- of "git config". However, there are no tests that check what happens
- when "git config" is asked to retrieve a value for a missing key.
+ There are several tests in t1300-config.sh that validate failing
+ invocations of "git config". However, there are no tests that check
+ what happens when "git config" is asked to retrieve a value for a
+ missing key.
- Add tests that check this for various combinations of "<section>.<key>".
+ Add tests that check this for various combinations of "<section>.<key>"
+ and "<section>.<subsection>.<key>".
+
+ Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
## t/t1300-config.sh ##
@@ t/t1300-config.sh: test_expect_success 'subsections are not canonicalized by git-config' '
@@ t/t1300-config.sh: test_expect_success 'subsections are not canonicalized by git
'
+test_missing_key () {
-+ local key=$1
-+ local title=$2
-+ test_expect_success "value for $title is not printed" "
-+ test_must_fail git config $key >out 2>err &&
++ local key="$1" &&
++ local title="$2" &&
++ test_expect_success "value for $title is not printed" '
++ test_must_fail git config "$key" >out 2>err &&
+ test_must_be_empty out &&
+ test_must_be_empty err
-+ "
++ '
+}
+
+test_missing_key 'missingsection.missingkey' 'missing section and missing key'
+test_missing_key 'missingsection.penguin' 'missing section and existing key'
+test_missing_key 'section.missingkey' 'existing section and missing key'
++test_missing_key 'section.MissingSubSection.missingkey' 'missing subsection and missing key'
++test_missing_key 'section.SubSection.missingkey' 'existing subsection and missing key'
++test_missing_key 'section.MissingSubSection.key' 'missing subsection and existing key'
+
cat > .git/config <<\EOF
[alpha]