* [RFH] Add some very basic tests for git mergetool
@ 2008-02-17 10:35 Charles Bailey
2008-02-17 12:57 ` Alex Riesen
0 siblings, 1 reply; 3+ messages in thread
From: Charles Bailey @ 2008-02-17 10:35 UTC (permalink / raw)
To: git
---
I tried to add some basic tests for git mergetool but unfortunately I
hit a major stumbling block. I seem to have to include a delay in my
fake mergetool otherwise the cat command didn't seem to work. It was
as though the source file hadn't been writted out yet.
(Other more minor stumbling blocks are that mergetool is a fond user
of shell read and explicit /dev/tty which makes some paths not
testable.)
I'm not sure if there's a shell usleep instead of having to "sleep 1",
but to me, adding four seconds of doing nothing to a test is
completely unacceptable. Individually most of git's tests are very
fast which is very important as there are so many of them.
All suggestions are welcome, especially if they indicate a bug in my
mergetool changes, which other than in automated test, seem to work
well for me.
Charles.
t/t7610-mergetool.sh | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 57 insertions(+), 0 deletions(-)
create mode 100644 t/t7610-mergetool.sh
diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh
new file mode 100644
index 0000000..a883f03
--- /dev/null
+++ b/t/t7610-mergetool.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Charles Bailey
+#
+
+test_description='git-mergetool
+
+Testing basic merge tool invocation'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ echo master >file1 &&
+ git add file1 &&
+ git commit -m "added file1" &&
+ git checkout -b branch1 master &&
+ echo branch1 change >file1 &&
+ echo branch1 newfile >file2 &&
+ git add file1 file2 &&
+ git commit -m "branch1 changes" &&
+ git checkout -b branch2 master &&
+ echo branch2 change >file1 &&
+ echo branch2 newfile >file2 &&
+ git add file1 file2 &&
+ git commit -m "branch2 changes" &&
+ git checkout master &&
+ echo master updated >file1 &&
+ echo master new >file2 &&
+ git add file1 file2 &&
+ git commit -m "master updates"
+'
+
+test_expect_success 'custom mergetool' '
+ git config merge.tool mytool &&
+ git config mergetool.mytool.cmd "sleep 1;cat \"\$REMOTE\" >\"\$MERGED\"" &&
+ git config mergetool.mytool.trustExitCode true &&
+ git checkout branch1 &&
+ ! git merge master >/dev/null 2>&1 &&
+ ( yes "" | git mergetool file1>/dev/null 2>&1 ) &&
+ ( yes "" | git mergetool file2>/dev/null 2>&1 ) &&
+ test "$(cat file1)" = "master updated" &&
+ test "$(cat file2)" = "master new" &&
+ git commit -m "branch1 resolved with mergetool"
+'
+
+test_expect_success 'custom mergetool' '
+ git config mergetool.mytool.cmdNoBase "sleep 1;cat \"\$LOCAL\" >\"\$MERGED\"" &&
+ git checkout branch2 &&
+ ! git merge master >/dev/null 2>&1 &&
+ ( yes "" | git mergetool file1>/dev/null 2>&1 ) &&
+ ( yes "" | git mergetool file2>/dev/null 2>&1 ) &&
+ test "$(cat file1)" = "master updated" &&
+ test "$(cat file2)" = "branch2 newfile" &&
+ git commit -m "branch2 resolved with mergetool"
+'
+
+test_done
--
1.5.4.1.34.g94bf
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFH] Add some very basic tests for git mergetool
2008-02-17 10:35 [RFH] Add some very basic tests for git mergetool Charles Bailey
@ 2008-02-17 12:57 ` Alex Riesen
2008-02-17 13:10 ` Charles Bailey
0 siblings, 1 reply; 3+ messages in thread
From: Alex Riesen @ 2008-02-17 12:57 UTC (permalink / raw)
To: Charles Bailey; +Cc: git
Charles Bailey, Sun, Feb 17, 2008 11:35:45 +0100:
> I tried to add some basic tests for git mergetool but unfortunately I
> hit a major stumbling block. I seem to have to include a delay in my
> fake mergetool otherwise the cat command didn't seem to work. It was
> as though the source file hadn't been writted out yet.
I removed your delay and the test works every time.
Could you strace the test (with "-ff -e open")?
> I'm not sure if there's a shell usleep instead of having to "sleep 1",
Just FYI: coreutils' sleep allows for subsecond sleeps.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFH] Add some very basic tests for git mergetool
2008-02-17 12:57 ` Alex Riesen
@ 2008-02-17 13:10 ` Charles Bailey
0 siblings, 0 replies; 3+ messages in thread
From: Charles Bailey @ 2008-02-17 13:10 UTC (permalink / raw)
To: Alex Riesen; +Cc: git
On Sun, Feb 17, 2008 at 01:57:14PM +0100, Alex Riesen wrote:
> I removed your delay and the test works every time.
> Could you strace the test (with "-ff -e open")?
OK, I've just tried it again a few times and it now seems to work for
me with and without the delay and with and without strace. I'm not
sure what was wrong before. Sorry for wasting you time, but it
definitely was broken for me before.
> > I'm not sure if there's a shell usleep instead of having to "sleep 1",
>
> Just FYI: coreutils' sleep allows for subsecond sleeps.
Useful to know, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-02-17 13:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-17 10:35 [RFH] Add some very basic tests for git mergetool Charles Bailey
2008-02-17 12:57 ` Alex Riesen
2008-02-17 13:10 ` Charles Bailey
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).