diff mbox series

[3/3] t1300: add tests for internal whitespace and inline comments

Message ID 292ab942c38de44476c6c5bf045c375bf4f6a70d.1710258538.git.dsimic@manjaro.org (mailing list archive)
State New
Headers show
Series Improve the documentation and test coverage for whitespace and comments | expand

Commit Message

Dragan Simic March 12, 2024, 3:55 p.m. UTC
Add a couple of additional automated tests, to improve the coverage of
configuration file entries whose values contain internal whitespace, or have
an additional inline comment.

Signed-off-by: Dragan Simic <dsimic@manjaro.org>
---
 t/t1300-config.sh | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Junio C Hamano March 14, 2024, 2:18 a.m. UTC | #1
Dragan Simic <dsimic@manjaro.org> writes:

> Add a couple of additional automated tests, to improve the coverage of
> configuration file entries whose values contain internal whitespace, or have
> an additional inline comment.

While this may document the current behaviour, I am not sure of the
value of carving the current behaviour in stone, especially after
checking if the current behaviour is a bug.

> Signed-off-by: Dragan Simic <dsimic@manjaro.org>
> ---
>  t/t1300-config.sh | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
>
> diff --git a/t/t1300-config.sh b/t/t1300-config.sh
> index 31c387868708..589af5e81d61 100755
> --- a/t/t1300-config.sh
> +++ b/t/t1300-config.sh
> @@ -11,6 +11,26 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
>  TEST_PASSES_SANITIZE_LEAK=true
>  . ./test-lib.sh
>  
> +cat > .git/config << EOF
> +[section]
> +	sparse = big 		 blue
> +	annotated = big blue	# to be discarded
> +EOF
> +
> +echo 'big    blue' > expect
> +
> +test_expect_success 'internal whitespace' '
> +	git config --get section.sparse > output &&
> +	test_cmp expect output
> +'
> +
> +echo 'big blue' > expect
> +
> +test_expect_success 'inline comment' '
> +	git config --get section.annotated > output &&
> +	test_cmp expect output
> +'
> +
>  test_expect_success 'clear default config' '
>  	rm -f .git/config
>  '
Dragan Simic March 14, 2024, 6:20 a.m. UTC | #2
On 2024-03-14 03:18, Junio C Hamano wrote:
> Dragan Simic <dsimic@manjaro.org> writes:
> 
>> Add a couple of additional automated tests, to improve the coverage of
>> configuration file entries whose values contain internal whitespace, 
>> or have
>> an additional inline comment.
> 
> While this may document the current behaviour, I am not sure of the
> value of carving the current behaviour in stone, especially after
> checking if the current behaviour is a bug.

Please see my comments for the first patch in the series.
diff mbox series

Patch

diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index 31c387868708..589af5e81d61 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -11,6 +11,26 @@  export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
+cat > .git/config << EOF
+[section]
+	sparse = big 		 blue
+	annotated = big blue	# to be discarded
+EOF
+
+echo 'big    blue' > expect
+
+test_expect_success 'internal whitespace' '
+	git config --get section.sparse > output &&
+	test_cmp expect output
+'
+
+echo 'big blue' > expect
+
+test_expect_success 'inline comment' '
+	git config --get section.annotated > output &&
+	test_cmp expect output
+'
+
 test_expect_success 'clear default config' '
 	rm -f .git/config
 '