{"thread":{"id":"12144","subject":"[RFH] Add some very basic tests for git mergetool","startedAt":"2008-02-17T10:35:45Z","lastAt":"2008-02-17T13:10:34Z","messageCount":3,"participants":["Charles Bailey","Alex Riesen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"68972","messageId":"20080217103545.GA24158@hashpling.org","threadId":"12144","inReplyTo":null,"subject":"[RFH] Add some very basic tests for git mergetool","fromName":"Charles Bailey","fromEmail":"charles@hashpling.org","sentAt":"2008-02-17T10:35:45Z","receivedAt":"2008-02-17T10:35:45Z","isPatch":false,"sender":{"key":"charles@hashpling.org","avatar":"https://avatars.githubusercontent.com/u/1668475?v=4"},"body":"---\n\nI tried to add some basic tests for git mergetool but unfortunately I\nhit a major stumbling block. I seem to have to include a delay in my\nfake mergetool otherwise the cat command didn't seem to work. It was\nas though the source file hadn't been writted out yet.\n\n(Other more minor stumbling blocks are that mergetool is a fond user\nof shell read and explicit /dev/tty which makes some paths not\ntestable.)\n\nI'm not sure if there's a shell usleep instead of having to \"sleep 1\",\nbut to me, adding four seconds of doing nothing to a test is\ncompletely unacceptable. Individually most of git's tests are very\nfast which is very important as there are so many of them.\n\nAll suggestions are welcome, especially if they indicate a bug in my\nmergetool changes, which other than in automated test, seem to work\nwell for me.\n\nCharles.\n\n t/t7610-mergetool.sh |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 57 insertions(+), 0 deletions(-)\n create mode 100644 t/t7610-mergetool.sh\n\ndiff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh\nnew file mode 100644\nindex 0000000..a883f03\n--- /dev/null\n+++ b/t/t7610-mergetool.sh\n@@ -0,0 +1,57 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2008 Charles Bailey\n+#\n+\n+test_description='git-mergetool\n+\n+Testing basic merge tool invocation'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'setup' '\n+    echo master >file1 &&\n+    git add file1 &&\n+    git commit -m \"added file1\" &&\n+    git checkout -b branch1 master &&\n+    echo branch1 change >file1 &&\n+    echo branch1 newfile >file2 &&\n+    git add file1 file2 &&\n+    git commit -m \"branch1 changes\" &&\n+    git checkout -b branch2 master &&\n+    echo branch2 change >file1 &&\n+    echo branch2 newfile >file2 &&\n+    git add file1 file2 &&\n+    git commit -m \"branch2 changes\" &&\n+    git checkout master &&\n+    echo master updated >file1 &&\n+    echo master new >file2 &&\n+    git add file1 file2 &&\n+    git commit -m \"master updates\"\n+'\n+\n+test_expect_success 'custom mergetool' '\n+    git config merge.tool mytool &&\n+    git config mergetool.mytool.cmd \"sleep 1;cat \\\"\\$REMOTE\\\" >\\\"\\$MERGED\\\"\" &&\n+    git config mergetool.mytool.trustExitCode true &&\n+    git checkout branch1 &&\n+    ! git merge master >/dev/null 2>&1 &&\n+    ( yes \"\" | git mergetool file1>/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool file2>/dev/null 2>&1 ) &&\n+    test \"$(cat file1)\" = \"master updated\" &&\n+    test \"$(cat file2)\" = \"master new\" &&\n+    git commit -m \"branch1 resolved with mergetool\"\n+'\n+\n+test_expect_success 'custom mergetool' '\n+    git config mergetool.mytool.cmdNoBase \"sleep 1;cat \\\"\\$LOCAL\\\" >\\\"\\$MERGED\\\"\" &&\n+    git checkout branch2 &&\n+    ! git merge master >/dev/null 2>&1 &&\n+    ( yes \"\" | git mergetool file1>/dev/null 2>&1 ) &&\n+    ( yes \"\" | git mergetool file2>/dev/null 2>&1 ) &&\n+    test \"$(cat file1)\" = \"master updated\" &&\n+    test \"$(cat file2)\" = \"branch2 newfile\" &&\n+    git commit -m \"branch2 resolved with mergetool\"\n+'\n+\n+test_done\n-- \n1.5.4.1.34.g94bf\n"},{"id":"68984","messageId":"20080217125714.GA3925@steel.home","threadId":"12144","inReplyTo":"20080217103545.GA24158@hashpling.org","subject":"Re: [RFH] Add some very basic tests for git mergetool","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2008-02-17T12:57:14Z","receivedAt":"2008-02-17T12:57:14Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Charles Bailey, Sun, Feb 17, 2008 11:35:45 +0100:\n> I tried to add some basic tests for git mergetool but unfortunately I\n> hit a major stumbling block. I seem to have to include a delay in my\n> fake mergetool otherwise the cat command didn't seem to work. It was\n> as though the source file hadn't been writted out yet.\n\nI removed your delay and the test works every time.\nCould you strace the test (with \"-ff -e open\")?\n\n> I'm not sure if there's a shell usleep instead of having to \"sleep 1\",\n\nJust FYI: coreutils' sleep allows for subsecond sleeps.\n"},{"id":"68985","messageId":"20080217131034.GA32254@hashpling.org","threadId":"12144","inReplyTo":"20080217125714.GA3925@steel.home","subject":"Re: [RFH] Add some very basic tests for git mergetool","fromName":"Charles Bailey","fromEmail":"charles@hashpling.org","sentAt":"2008-02-17T13:10:34Z","receivedAt":"2008-02-17T13:10:34Z","isPatch":false,"sender":{"key":"charles@hashpling.org","avatar":"https://avatars.githubusercontent.com/u/1668475?v=4"},"body":"On Sun, Feb 17, 2008 at 01:57:14PM +0100, Alex Riesen wrote:\n> I removed your delay and the test works every time.\n> Could you strace the test (with \"-ff -e open\")?\n\nOK, I've just tried it again a few times and it now seems to work for\nme with and without the delay and with and without strace.  I'm not\nsure what was wrong before.  Sorry for wasting you time, but it\ndefinitely was broken for me before.\n\n> > I'm not sure if there's a shell usleep instead of having to \"sleep 1\",\n> \n> Just FYI: coreutils' sleep allows for subsecond sleeps.\n\nUseful to know, thanks.\n"}]}