* [PATCH RFC] t0027: check the eol conversion warnings
@ 2014-11-20 21:29 Torsten Bögershausen
2014-11-20 22:37 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Torsten Bögershausen @ 2014-11-20 21:29 UTC (permalink / raw)
To: git; +Cc: tboegi
Add tests to check the warnings when adding file with eol=lf and eol=crlf.
Add a function check_warning() to check the warnings on stderr
"CRLF will be replaced..." or "LF will be replaced..."
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
---
t/t0027-auto-crlf.sh | 103 +++++++++++++++++++++++++++++++++++++++------------
1 file changed, 80 insertions(+), 23 deletions(-)
diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh
index 2a4a6c1..9570947 100755
--- a/t/t0027-auto-crlf.sh
+++ b/t/t0027-auto-crlf.sh
@@ -55,16 +55,36 @@ create_gitattributes () {
esac
}
-create_file_in_repo () {
+check_warning () {
+ case "$1" in
+ LF_CRLF) grep "LF will be replaced by CRLF" $2;;
+ CRLF_LF) grep "CRLF will be replaced by LF" $2;;
+ *) test_cmp /dev/null $2;;
+ esac
+}
+
+add_check_warn () {
crlf=$1
attr=$2
+ lfname=$3
+ crlfname=$4
+ lfmixcrlf=$5
+ lfmixcr=$6
+ crlfnul=$7
create_gitattributes "$attr" &&
+ pfx=crlf_${crlf}_attr_${attr}
for f in LF CRLF LF_mix_CR CRLF_mix_LF CRLF_nul
do
- pfx=crlf_${crlf}_attr_${attr}_$f.txt &&
- cp $f $pfx && git -c core.autocrlf=$crlf add $pfx
+ fname=${pfx}_$f.txt &&
+ cp $f $fname &&
+ git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err"
done &&
- git commit -m "core.autocrlf $crlf"
+ git commit -m "core.autocrlf $crlf" &&
+ check_warning "$lfname" ${pfx}_LF.err &&
+ check_warning "$crlfname" ${pfx}_CRLF.err &&
+ check_warning "$lfmixcrlf" ${pfx}_LF_mix_CR.err &&
+ check_warning "$lfmixcr" ${pfx}_LF_mix_CR.err &&
+ check_warning "$crlfnul" ${pfx}_CRLF_nul.err
}
check_files_in_repo () {
@@ -140,50 +160,87 @@ test_expect_success 'setup master' '
'
-test_expect_success 'create files' '
- create_file_in_repo false "" &&
- create_file_in_repo true "" &&
- create_file_in_repo input "" &&
- create_file_in_repo false "auto" &&
- create_file_in_repo true "auto" &&
- create_file_in_repo input "auto" &&
+warn_LF_CRLF="LF will be replaced by CRLF"
+warn_CRLF_LF="CRLF will be replaced by LF"
+
+test_expect_success 'add files empty attr' '
+ add_check_warn false "" "" "" "" "" "" &&
+ add_check_warn true "" "LF_CRLF" "" "" "" "" &&
+ add_check_warn input "" "" "CRLF_LF" "" "" ""
+'
- create_file_in_repo false "text" &&
- create_file_in_repo true "text" &&
- create_file_in_repo input "text" &&
+test_expect_success 'add files attr=auto' '
+ add_check_warn false "auto" "" "CRLF_LF" "" "" "" &&
+ add_check_warn true "auto" "LF_CRLF" "" "" "" "" &&
+ add_check_warn input "auto" "" "CRLF_LF" "" "" ""
+'
- create_file_in_repo false "-text" &&
- create_file_in_repo true "-text" &&
- create_file_in_repo input "-text" &&
+test_expect_success 'add files attr=text' '
+ add_check_warn false "text" "" "CRLF_LF" "" "" "CRLF_LF" &&
+ add_check_warn true "text" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" &&
+ add_check_warn input "text" "" "CRLF_LF" "" "" "CRLF_LF"
+'
+
+test_expect_success 'add files attr=-text' '
+ add_check_warn false "-text" "" "" "" "" "" &&
+ add_check_warn true "-text" "" "" "" "" "" &&
+ add_check_warn input "-text" "" "" "" "" ""
+'
+
+test_expect_success 'add files attr=lf' '
+ add_check_warn false "lf" "" "CRLF_LF" "" "" "CRLF_LF" &&
+ add_check_warn true "lf" "" "CRLF_LF" "" "" "CRLF_LF" &&
+ add_check_warn input "lf" "" "CRLF_LF" "" "" "CRLF_LF"
+'
+
+test_expect_success 'add files attr=crlf' '
+ add_check_warn false "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" &&
+ add_check_warn true "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" &&
+ add_check_warn input "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" ""
+'
+
+test_expect_success 'create files cleanup' '
rm -f *.txt &&
git reset --hard
'
-test_expect_success 'commit empty gitattribues' '
+test_expect_success 'check file in repo empty gitattribues' '
check_files_in_repo false "" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
check_files_in_repo true "" LF LF LF LF_mix_CR CRLF_nul &&
check_files_in_repo input "" LF LF LF LF_mix_CR CRLF_nul
'
-test_expect_success 'commit text=auto' '
+test_expect_success 'check file in repo text=auto' '
check_files_in_repo false "auto" LF LF LF LF_mix_CR CRLF_nul &&
check_files_in_repo true "auto" LF LF LF LF_mix_CR CRLF_nul &&
check_files_in_repo input "auto" LF LF LF LF_mix_CR CRLF_nul
'
-test_expect_success 'commit text' '
+test_expect_success 'check file in repo text' '
check_files_in_repo false "text" LF LF LF LF_mix_CR LF_nul &&
check_files_in_repo true "text" LF LF LF LF_mix_CR LF_nul &&
check_files_in_repo input "text" LF LF LF LF_mix_CR LF_nul
'
-test_expect_success 'commit -text' '
+test_expect_success 'check file in repo -text' '
check_files_in_repo false "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
check_files_in_repo true "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
check_files_in_repo input "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
'
+test_expect_success 'check file in repo lf' '
+ check_files_in_repo false "lf" LF LF LF LF_mix_CR LF_nul &&
+ check_files_in_repo true "lf" LF LF LF LF_mix_CR LF_nul &&
+ check_files_in_repo input "lf" LF LF LF LF_mix_CR LF_nul
+'
+
+test_expect_success 'check file in repo crlf' '
+ check_files_in_repo false "crlf" LF LF LF LF_mix_CR LF_nul &&
+ check_files_in_repo true "crlf" LF LF LF LF_mix_CR LF_nul &&
+ check_files_in_repo input "crlf" LF LF LF LF_mix_CR LF_nul
+'
+
################################################################################
# Check how files in the repo are changed when they are checked out
# How to read the table below:
@@ -199,8 +256,8 @@ test_expect_success 'commit -text' '
# - parameter $8 : reference for a file with CRLF and a NUL (should be handled as binary when auto)
# What we have in the repo:
-# ----------------- EOL in repo ----------------
-# LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
+# ----------------- EOL in repo ----------------
+# LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
# settings with checkout:
# core. core. .gitattr
# eol acrlf
--
1.9.1.dirty
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RFC] t0027: check the eol conversion warnings
2014-11-20 21:29 [PATCH RFC] t0027: check the eol conversion warnings Torsten Bögershausen
@ 2014-11-20 22:37 ` Junio C Hamano
2014-11-21 12:37 ` Torsten Bögershausen
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2014-11-20 22:37 UTC (permalink / raw)
To: Torsten Bögershausen; +Cc: git
Torsten Bögershausen <tboegi@web.de> writes:
> Add tests to check the warnings when adding file with eol=lf and eol=crlf.
>
> Add a function check_warning() to check the warnings on stderr
> "CRLF will be replaced..." or "LF will be replaced..."
>
> Signed-off-by: Torsten Bögershausen <tboegi@web.de>
> ---
At a glance it is very hard to see what we might be _losing_ with this
change that claims to "add" new kinds of tests on top of existing ones.
I am guessing that add-check-warn roughly corresponds to the old
create-file-in-repo but they have different calling conventions, or
something?
Perhaps split it into two patches (or more), each of which does one
thing and one thing well? I suspect that even with a two-patch
split (e.g. the first of which only renames the function without
adding the new "grep in error messages that could be localized and
give false failures" code, and the second adds the lf/crlf stuff)
might make this at least readable.
I dunno.
> t/t0027-auto-crlf.sh | 103 +++++++++++++++++++++++++++++++++++++++------------
> 1 file changed, 80 insertions(+), 23 deletions(-)
>
> diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh
> index 2a4a6c1..9570947 100755
> --- a/t/t0027-auto-crlf.sh
> +++ b/t/t0027-auto-crlf.sh
> @@ -55,16 +55,36 @@ create_gitattributes () {
> esac
> }
>
> -create_file_in_repo () {
> +check_warning () {
> + case "$1" in
> + LF_CRLF) grep "LF will be replaced by CRLF" $2;;
> + CRLF_LF) grep "CRLF will be replaced by LF" $2;;
> + *) test_cmp /dev/null $2;;
> + esac
> +}
> +
> +add_check_warn () {
> crlf=$1
> attr=$2
> + lfname=$3
> + crlfname=$4
> + lfmixcrlf=$5
> + lfmixcr=$6
> + crlfnul=$7
> create_gitattributes "$attr" &&
> + pfx=crlf_${crlf}_attr_${attr}
> for f in LF CRLF LF_mix_CR CRLF_mix_LF CRLF_nul
> do
> - pfx=crlf_${crlf}_attr_${attr}_$f.txt &&
> - cp $f $pfx && git -c core.autocrlf=$crlf add $pfx
> + fname=${pfx}_$f.txt &&
> + cp $f $fname &&
> + git -c core.autocrlf=$crlf add $fname 2>"${pfx}_$f.err"
> done &&
> - git commit -m "core.autocrlf $crlf"
> + git commit -m "core.autocrlf $crlf" &&
> + check_warning "$lfname" ${pfx}_LF.err &&
> + check_warning "$crlfname" ${pfx}_CRLF.err &&
> + check_warning "$lfmixcrlf" ${pfx}_LF_mix_CR.err &&
> + check_warning "$lfmixcr" ${pfx}_LF_mix_CR.err &&
> + check_warning "$crlfnul" ${pfx}_CRLF_nul.err
> }
>
> check_files_in_repo () {
> @@ -140,50 +160,87 @@ test_expect_success 'setup master' '
> '
>
>
> -test_expect_success 'create files' '
> - create_file_in_repo false "" &&
> - create_file_in_repo true "" &&
> - create_file_in_repo input "" &&
>
> - create_file_in_repo false "auto" &&
> - create_file_in_repo true "auto" &&
> - create_file_in_repo input "auto" &&
> +warn_LF_CRLF="LF will be replaced by CRLF"
> +warn_CRLF_LF="CRLF will be replaced by LF"
> +
> +test_expect_success 'add files empty attr' '
> + add_check_warn false "" "" "" "" "" "" &&
> + add_check_warn true "" "LF_CRLF" "" "" "" "" &&
> + add_check_warn input "" "" "CRLF_LF" "" "" ""
> +'
>
> - create_file_in_repo false "text" &&
> - create_file_in_repo true "text" &&
> - create_file_in_repo input "text" &&
> +test_expect_success 'add files attr=auto' '
> + add_check_warn false "auto" "" "CRLF_LF" "" "" "" &&
> + add_check_warn true "auto" "LF_CRLF" "" "" "" "" &&
> + add_check_warn input "auto" "" "CRLF_LF" "" "" ""
> +'
>
> - create_file_in_repo false "-text" &&
> - create_file_in_repo true "-text" &&
> - create_file_in_repo input "-text" &&
> +test_expect_success 'add files attr=text' '
> + add_check_warn false "text" "" "CRLF_LF" "" "" "CRLF_LF" &&
> + add_check_warn true "text" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" &&
> + add_check_warn input "text" "" "CRLF_LF" "" "" "CRLF_LF"
> +'
> +
> +test_expect_success 'add files attr=-text' '
> + add_check_warn false "-text" "" "" "" "" "" &&
> + add_check_warn true "-text" "" "" "" "" "" &&
> + add_check_warn input "-text" "" "" "" "" ""
> +'
> +
> +test_expect_success 'add files attr=lf' '
> + add_check_warn false "lf" "" "CRLF_LF" "" "" "CRLF_LF" &&
> + add_check_warn true "lf" "" "CRLF_LF" "" "" "CRLF_LF" &&
> + add_check_warn input "lf" "" "CRLF_LF" "" "" "CRLF_LF"
> +'
> +
> +test_expect_success 'add files attr=crlf' '
> + add_check_warn false "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" &&
> + add_check_warn true "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" "" &&
> + add_check_warn input "crlf" "LF_CRLF" "" "LF_CRLF" "LF_CRLF" ""
> +'
> +
> +test_expect_success 'create files cleanup' '
> rm -f *.txt &&
> git reset --hard
> '
>
> -test_expect_success 'commit empty gitattribues' '
> +test_expect_success 'check file in repo empty gitattribues' '
> check_files_in_repo false "" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
> check_files_in_repo true "" LF LF LF LF_mix_CR CRLF_nul &&
> check_files_in_repo input "" LF LF LF LF_mix_CR CRLF_nul
> '
>
> -test_expect_success 'commit text=auto' '
> +test_expect_success 'check file in repo text=auto' '
> check_files_in_repo false "auto" LF LF LF LF_mix_CR CRLF_nul &&
> check_files_in_repo true "auto" LF LF LF LF_mix_CR CRLF_nul &&
> check_files_in_repo input "auto" LF LF LF LF_mix_CR CRLF_nul
> '
>
> -test_expect_success 'commit text' '
> +test_expect_success 'check file in repo text' '
> check_files_in_repo false "text" LF LF LF LF_mix_CR LF_nul &&
> check_files_in_repo true "text" LF LF LF LF_mix_CR LF_nul &&
> check_files_in_repo input "text" LF LF LF LF_mix_CR LF_nul
> '
>
> -test_expect_success 'commit -text' '
> +test_expect_success 'check file in repo -text' '
> check_files_in_repo false "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
> check_files_in_repo true "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul &&
> check_files_in_repo input "-text" LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
> '
>
> +test_expect_success 'check file in repo lf' '
> + check_files_in_repo false "lf" LF LF LF LF_mix_CR LF_nul &&
> + check_files_in_repo true "lf" LF LF LF LF_mix_CR LF_nul &&
> + check_files_in_repo input "lf" LF LF LF LF_mix_CR LF_nul
> +'
> +
> +test_expect_success 'check file in repo crlf' '
> + check_files_in_repo false "crlf" LF LF LF LF_mix_CR LF_nul &&
> + check_files_in_repo true "crlf" LF LF LF LF_mix_CR LF_nul &&
> + check_files_in_repo input "crlf" LF LF LF LF_mix_CR LF_nul
> +'
> +
> ################################################################################
> # Check how files in the repo are changed when they are checked out
> # How to read the table below:
> @@ -199,8 +256,8 @@ test_expect_success 'commit -text' '
> # - parameter $8 : reference for a file with CRLF and a NUL (should be handled as binary when auto)
>
> # What we have in the repo:
> -# ----------------- EOL in repo ----------------
> -# LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
> +# ----------------- EOL in repo ----------------
> +# LF CRLF CRLF_mix_LF LF_mix_CR CRLF_nul
> # settings with checkout:
> # core. core. .gitattr
> # eol acrlf
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RFC] t0027: check the eol conversion warnings
2014-11-20 22:37 ` Junio C Hamano
@ 2014-11-21 12:37 ` Torsten Bögershausen
0 siblings, 0 replies; 3+ messages in thread
From: Torsten Bögershausen @ 2014-11-21 12:37 UTC (permalink / raw)
To: Junio C Hamano, Torsten Bögershausen; +Cc: git
On 20.11.14 23:37, Junio C Hamano wrote:
>
> ---
> At a glance it is very hard to see what we might be _losing_ with this
> change that claims to "add" new kinds of tests on top of existing ones.
>
> I am guessing that add-check-warn roughly corresponds to the old
> create-file-in-repo but they have different calling conventions, or
> something?
>
> Perhaps split it into two patches (or more), each of which does one
> thing and one thing well? I suspect that even with a two-patch
> split (e.g. the first of which only renames the function without
> adding the new "grep in error messages that could be localized and
> give false failures" code, and the second adds the lf/crlf stuff)
> might make this at least readable.
>
> I dunno.
>
We shouldn't loose anything.
The diff is hard to read, as some code
is re-defined and re-used (and a diff side-by-side looks nicer than the patch)
I will come back with a new commit message, which should explain things better
( or a 2-stepped patch)
The long term idea is to improve the gray areas in convert.c, and to do that we need a reliable
test frame work, to see what is improved or broken.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-21 12:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-20 21:29 [PATCH RFC] t0027: check the eol conversion warnings Torsten Bögershausen
2014-11-20 22:37 ` Junio C Hamano
2014-11-21 12:37 ` Torsten Bögershausen
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).