Re: [PATCH 1/4] line-log: demonstrate a bug with nearly-overlapping ranges
Jonathan Nieder wrote: > Johannes Schindelin wrote: >> It is really, really important to realize how valuable it is to have the >> regression test as an individual patch that can be used to verify that >> there is a bug, to pinpoint where it was introduced, to test alternative >> fixes, to keep records separate, and I could go on and on and on. Please >> do not ignore these very good reasons, and please refrain from >> recommending such conflation in the future. > > If you want to propose changing the project's style to always separate > tests from the patch that fixes a bug, that's a discussion we can have, > in a separate thread. By the way, don't get me wrong: I am sympathetic to the motivation for such a change. I have worked on projects where tests were in a separate repository from the application. There are costs and benefits. To support the kind of use cases you're describing, the tests would include conditionals to allow running on old versions of the application (the test expectations were based on the latest version, but setup code sometimes had to accomodate differences between versions). It worked okay and was probably worth it for that project, despite the added friction. It's not clear it would be worth it for Git. Jonathan
Re: [PATCH 1/4] line-log: demonstrate a bug with nearly-overlapping ranges
Hi Dscho, Johannes Schindelin wrote: > On Sat, 4 Aug 2018, Jonathan Nieder wrote: >> Alternatively, could it be squashed in with the patch that fixes it? > > There is this really awful trend on this mailing list to suggest > conflating the demonstration of a bug with the bug fix. > > It is really, really important to realize how valuable it is to have the > regression test as an individual patch that can be used to verify that > there is a bug, to pinpoint where it was introduced, to test alternative > fixes, to keep records separate, and I could go on and on and on. Please > do not ignore these very good reasons, and please refrain from > recommending such conflation in the future. If you want to propose changing the project's style to always separate tests from the patch that fixes a bug, that's a discussion we can have, in a separate thread. Today, we do allow and encourage putting the test with the patch that fixes it, and that has real advantages: - the tests are easier to understand when found with "git log" because they are in context - as the patch evolves, it is easier to remember to update the test at the same time - newcomers imitating existing patches have a clear hint to write tests - the beginning of a patch series can be applied and merged down while the end is still under review, without either leaving out the tests or applying a test that doesn't pass and accomplishes little I've never found it difficult to use the test from a patch to verify that there is a bug or pinpoint where it was introduced. Tests are separate from the application code since they're in the t/ directory; this is a very easy thing to do. That isn't to say that a patch that only adds a (passing or expected-failure) test isn't valuable, even without a fix. It is valuable, precisely when it is self-explanatory. More importantly, I am a bit surprised that instead of accepting the feedback, you are basically calling a reviewer complicit, for pointing out a pretty normal possible improvement that follows the project's conventions. I'm beyond words. Jonathan
Re: [PATCH 1/4] line-log: demonstrate a bug with nearly-overlapping ranges
Hi Jonathan, On Sat, 4 Aug 2018, Jonathan Nieder wrote: > Johannes Schindelin wrote: > > > Currently, this test case throws an assertion: > > > > Assertion failed! > > > > Program: git.exe > > File: line-log.c, Line 71 > > > > Signed-off-by: Johannes Schindelin > > --- > > t/t4211-line-log.sh | 17 + > > 1 file changed, 17 insertions(+) > > Thanks for finding and demonstrating it. You're welcome. > Can you say more about what is going on in the test case? Certainly. I considered writing more into the commit message, but all my attempts were really repeating what the test case does, and were therefore poor commit message material. Under certain circumstances, multiple ranges specified for the line-log were adjusted incorrectly, leading to violation of assumptions as well as to segmentation faults. This test case demonstrates this. > Alternatively, could it be squashed in with the patch that fixes it? There is this really awful trend on this mailing list to suggest conflating the demonstration of a bug with the bug fix. It is really, really important to realize how valuable it is to have the regression test as an individual patch that can be used to verify that there is a bug, to pinpoint where it was introduced, to test alternative fixes, to keep records separate, and I could go on and on and on. Please do not ignore these very good reasons, and please refrain from recommending such conflation in the future. > The below will be more nitpicky: > > [...] > > --- a/t/t4211-line-log.sh > > +++ b/t/t4211-line-log.sh > > @@ -115,4 +115,21 @@ test_expect_success 'range_set_union' ' > > git log $(for x in $(test_seq 200); do echo -L $((2*x)),+1:c.c; done) > > ' > > > > +q_to_lf () { > > + tr Q '\012' > > +} > > + > > +test_expect_failure 'close to overlapping ranges' ' > > + test_seq 5 >a1.c && > > + git add a1.c && > > + git commit -m "5 lines" a1.c && > > It would be nice to use test_tick or test_commit for a more realistic > history (with time marching forward). As far as this test is concerned, that realism is not necessary, and comes at the cost of readability. > > + sed s/3/3QaQb/ tmp && > > + mv tmp a1.c && > > + git commit -m "2 more lines" a1.c && > > It's probably just me, but the bit with Q makes it hard for me to > follow. Maybe there's a simpler way? Maybe. I did not find it, else I would have used it. > "sed -e '3aa' -e '3ab'" works here, but I don't know how portable it > is. My experience with BSD sed and the `a` command made me highly suspicious, that's why I did not go down that route. Besides, that `sed` invocation does not really look intuitive either. > I'd be more tempted to do > > test_write_lines 1 2 3 4 5 >a1.c && > ... > > test_write_lines 1 2 3 a b 4 5 >a1.c && > ... > > test_write_lines 1 2 3 a b c 4 5 >a1.c && > ... > > which is concise and has obvious behavior. That works for me! Ciao, Dscho
Re: [PATCH 1/4] line-log: demonstrate a bug with nearly-overlapping ranges
Hi, Johannes Schindelin wrote: > Currently, this test case throws an assertion: > > Assertion failed! > > Program: git.exe > File: line-log.c, Line 71 > > Signed-off-by: Johannes Schindelin > --- > t/t4211-line-log.sh | 17 + > 1 file changed, 17 insertions(+) Thanks for finding and demonstrating it. Can you say more about what is going on in the test case? Alternatively, could it be squashed in with the patch that fixes it? The below will be more nitpicky: [...] > --- a/t/t4211-line-log.sh > +++ b/t/t4211-line-log.sh > @@ -115,4 +115,21 @@ test_expect_success 'range_set_union' ' > git log $(for x in $(test_seq 200); do echo -L $((2*x)),+1:c.c; done) > ' > > +q_to_lf () { > + tr Q '\012' > +} > + > +test_expect_failure 'close to overlapping ranges' ' > + test_seq 5 >a1.c && > + git add a1.c && > + git commit -m "5 lines" a1.c && It would be nice to use test_tick or test_commit for a more realistic history (with time marching forward). > + sed s/3/3QaQb/ tmp && > + mv tmp a1.c && > + git commit -m "2 more lines" a1.c && It's probably just me, but the bit with Q makes it hard for me to follow. Maybe there's a simpler way? "sed -e '3aa' -e '3ab'" works here, but I don't know how portable it is. I'd be more tempted to do test_write_lines 1 2 3 4 5 >a1.c && ... test_write_lines 1 2 3 a b 4 5 >a1.c && ... test_write_lines 1 2 3 a b c 4 5 >a1.c && ... which is concise and has obvious behavior. Thanks and hope that helps, Jonathan
[PATCH 1/4] line-log: demonstrate a bug with nearly-overlapping ranges
From: Johannes Schindelin Currently, this test case throws an assertion: Assertion failed! Program: git.exe File: line-log.c, Line 71 Signed-off-by: Johannes Schindelin --- t/t4211-line-log.sh | 17 + 1 file changed, 17 insertions(+) diff --git a/t/t4211-line-log.sh b/t/t4211-line-log.sh index 436b13ad2..61ff37430 100755 --- a/t/t4211-line-log.sh +++ b/t/t4211-line-log.sh @@ -115,4 +115,21 @@ test_expect_success 'range_set_union' ' git log $(for x in $(test_seq 200); do echo -L $((2*x)),+1:c.c; done) ' +q_to_lf () { + tr Q '\012' +} + +test_expect_failure 'close to overlapping ranges' ' + test_seq 5 >a1.c && + git add a1.c && + git commit -m "5 lines" a1.c && + sed s/3/3QaQb/ tmp && + mv tmp a1.c && + git commit -m "2 more lines" a1.c && + sed s/4/cQ4/ tmp && + mv tmp a1.c && + git commit -m "1 more line" a1.c && + git --no-pager log -L 1,3:a1.c -L 5,8:a1.c +' + test_done -- gitgitgadget