Re: [PATCH v1 6/6] Unit tests for V2 porcelain status
Hi, On Wed, 20 Jul 2016, Jakub Narębski wrote: > On 20 July 2016 at 17:47, Jeff Hostetlerwrote: > > On 07/20/2016 11:30 AM, Jakub Narębski wrote: > >> W dniu 2016-07-20 o 00:10, Jeff Hostetler pisze: > >>> > >>> +test_expect_success pre_initial_commit_0 ' > >>> + printf "## branch: (initial) master\n" >expected && > >>> + printf "?? actual\n" >>expected && > >>> + printf "?? dir1/\n" >>expected && > >>> + printf "?? expected\n" >>expected && > >>> + printf "?? file_x\n" >>expected && > >>> + printf "?? file_y\n" >>expected && > >>> + printf "?? file_z\n" >>expected && > >> > >> Why not use heredoc syntax (cat <<\EOF), or prepare a file > >> with expected output in the testsuite? > > > > The tests involving renames needed to embed a tab character > > in the output and hiding a tab character in a heredoc seemed > > error prone. So to be consistent I made them all printf-style. > > Ah, so that's the case for series of printf. I think in some other > cases the Git testsuite simply uses HT variable for the TAB > character. Yeah, it would be more pleasant to read echo >expected <<-EOF ## branch: (initial) master ?? actual ?? dir1/ ?? expected ?? file_x ?? file_y ?? file_z EOF And it is also easy to use $HT in there (unless you want to use <<-\EOF). Actually, even if you want to use \EOF, you can easily use `sed` to expand, say, "Q" to tabs, such as was done here: https://github.com/git/git/blob/v2.9.2/t/t4213-log-tabexpand.sh#L88-L92 Ciao, Dscho
Re: [PATCH v1 6/6] Unit tests for V2 porcelain status
On 20 July 2016 at 17:47, Jeff Hostetlerwrote: > On 07/20/2016 11:30 AM, Jakub Narębski wrote: >> W dniu 2016-07-20 o 00:10, Jeff Hostetler pisze: >>> >>> +test_expect_success pre_initial_commit_0 ' >>> + printf "## branch: (initial) master\n" >expected && >>> + printf "?? actual\n" >>expected && >>> + printf "?? dir1/\n" >>expected && >>> + printf "?? expected\n" >>expected && >>> + printf "?? file_x\n" >>expected && >>> + printf "?? file_y\n" >>expected && >>> + printf "?? file_z\n" >>expected && >> >> Why not use heredoc syntax (cat <<\EOF), or prepare a file >> with expected output in the testsuite? > > The tests involving renames needed to embed a tab character > in the output and hiding a tab character in a heredoc seemed > error prone. So to be consistent I made them all printf-style. Ah, so that's the case for series of printf. I think in some other cases the Git testsuite simply uses HT variable for the TAB character. I guess that "\t" for TAB is available in POSIX and all shells that Git is run on? See t3300-funny-names.sh, t3902-quoted.sh, t4213-log-tabexpand.sh > Also, some of the tests include SHAs for the commit and for > file content, so having pre-computed expected output is awkward. > Granted we could hard code the file SHAs, but not the commits. Right... but heredoc can include variable expansion (or rather it includes variable expansion by default, and you can prevent it by quoting end-of-heredoc marker). -- Jakub Narębski -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v1 6/6] Unit tests for V2 porcelain status
On 07/20/2016 11:30 AM, Jakub Narębski wrote: W dniu 2016-07-20 o 00:10, Jeff Hostetler pisze: +test_expect_success pre_initial_commit_0 ' + printf "## branch: (initial) master\n" >expected && + printf "?? actual\n" >>expected && + printf "?? dir1/\n" >>expected && + printf "?? expected\n" >>expected && + printf "?? file_x\n" >>expected && + printf "?? file_y\n" >>expected && + printf "?? file_z\n" >>expected && Why not use heredoc syntax (cat <<\EOF), or prepare a file with expected output in the testsuite? The tests involving renames needed to embed a tab character in the output and hiding a tab character in a heredoc seemed error prone. So to be consistent I made them all printf-style. Also, some of the tests include SHAs for the commit and for file content, so having pre-computed expected output is awkward. Granted we could hard code the file SHAs, but not the commits. Jeff -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v1 6/6] Unit tests for V2 porcelain status
W dniu 2016-07-20 o 00:10, Jeff Hostetler pisze: > +test_expect_success pre_initial_commit_0 ' > + printf "## branch: (initial) master\n" >expected && > + printf "?? actual\n" >>expected && > + printf "?? dir1/\n" >>expected && > + printf "?? expected\n" >>expected && > + printf "?? file_x\n" >>expected && > + printf "?? file_y\n" >>expected && > + printf "?? file_z\n" >>expected && Why not use heredoc syntax (cat <<\EOF), or prepare a file with expected output in the testsuite? -- Jakub Narębski -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 6/6] Unit tests for V2 porcelain status
This commit contains unit tests to exercise the V2 porcelain status format. Signed-off-by: Jeff Hostetler--- t/t7064-wtstatus-pv2.sh | 461 t/t7501-commit.sh | 9 + 2 files changed, 470 insertions(+) create mode 100755 t/t7064-wtstatus-pv2.sh diff --git a/t/t7064-wtstatus-pv2.sh b/t/t7064-wtstatus-pv2.sh new file mode 100755 index 000..1f4252a --- /dev/null +++ b/t/t7064-wtstatus-pv2.sh @@ -0,0 +1,461 @@ +#!/bin/sh + +test_description='git status --porcelain=2 + +This test exercises porcelain V2 output for git status.' + + +. ./test-lib.sh + +test_expect_success setup ' + test_tick && + git config --local core.autocrlf false && + echo x >file_x && + echo y >file_y && + echo z >file_z && + mkdir dir1 && + echo a >dir1/file_a && + echo b >dir1/file_b +' + + +## +## Confirm VVP output prior to initial commit. +## + +test_expect_success pre_initial_commit_0 ' + printf "## branch: (initial) master\n" >expected && + printf "?? actual\n" >>expected && + printf "?? dir1/\n" >>expected && + printf "?? expected\n" >>expected && + printf "?? file_x\n" >>expected && + printf "?? file_y\n" >>expected && + printf "?? file_z\n" >>expected && + + git status --porcelain=2 --branch --ignored --untracked-files=normal >actual && + test_cmp expected actual +' + + +test_expect_success pre_initial_commit_1 ' + git add file_x file_y file_z dir1 && + SHA_A=`git hash-object -t blob -- dir1/file_a` && + SHA_B=`git hash-object -t blob -- dir1/file_b` && + SHA_X=`git hash-object -t blob -- file_x` && + SHA_Y=`git hash-object -t blob -- file_y` && + SHA_Z=`git hash-object -t blob -- file_z` && + SHA_ZERO= && + printf "## branch: (initial) master\n" >expected && + printf "A. N 00 100644 100644 00 $SHA_ZERO $SHA_A $SHA_ZERO R0 dir1/file_a\n" >>expected && + printf "A. N 00 100644 100644 00 $SHA_ZERO $SHA_B $SHA_ZERO R0 dir1/file_b\n" >>expected && + printf "A. N 00 100644 100644 00 $SHA_ZERO $SHA_X $SHA_ZERO R0 file_x\n" >>expected && + printf "A. N 00 100644 100644 00 $SHA_ZERO $SHA_Y $SHA_ZERO R0 file_y\n" >>expected && + printf "A. N 00 100644 100644 00 $SHA_ZERO $SHA_Z $SHA_ZERO R0 file_z\n" >>expected && + printf "?? actual\n" >>expected && + printf "?? expected\n" >>expected && + + git status --porcelain=2 --branch --ignored --untracked-files=all >actual && + test_cmp expected actual +' + + +## +## Create first commit. Confirm commit sha in new track header. +## Then make some changes on top of it. +## + +test_expect_success initial_commit_0 ' + git commit -m initial && + H0=`git rev-parse HEAD` && + printf "## branch: $H0 master\n" >expected && + printf "?? actual\n" >>expected && + printf "?? expected\n" >>expected && + + git status --porcelain=2 --branch --ignored --untracked-files=all >actual && + test_cmp expected actual +' + + +test_expect_success initial_commit_1 ' + echo x >>file_x && + SHA_X1=`git hash-object -t blob -- file_x` && + rm file_z && + H0=`git rev-parse HEAD` && + printf "## branch: $H0 master\n" >expected && + printf ".M N 100644 100644 100644 00 $SHA_X $SHA_X $SHA_ZERO R0 file_x\n" >>expected && + printf ".D N 100644 100644 00 00 $SHA_Z $SHA_Z $SHA_ZERO R0 file_z\n" >>expected && + printf "?? actual\n" >>expected && + printf "?? expected\n" >>expected && + + git status --porcelain=2 --branch --ignored --untracked-files=all >actual && + test_cmp expected actual +' + + +test_expect_success initial_commit_2 ' + git add file_x && + git rm file_z && + H0=`git rev-parse HEAD` && + printf "## branch: $H0 master\n" >expected && + printf "M. N 100644 100644 100644 00 $SHA_X $SHA_X1 $SHA_ZERO R0 file_x\n" >>expected && + printf "D. N 100644 00 00 00 $SHA_Z $SHA_ZERO $SHA_ZERO R0 file_z\n" >>expected && + printf "?? actual\n" >>expected && + printf "?? expected\n" >>expected && + + git status --porcelain=2 --branch --ignored --untracked-files=all >actual && + test_cmp expected actual +' + + +test_expect_success initial_commit_3 ' + git mv file_y renamed_y && + H0=`git rev-parse HEAD` && + printf "## branch: $H0 master\n" >expected && + printf "M. N 100644 100644 100644 00 $SHA_X $SHA_X1 $SHA_ZERO R0 file_x\n" >>expected && + printf "D. N 100644 00 00