From: Bo Yang <struggleyb.nku@gmail.com>
To: git@vger.kernel.org
Subject: [WIP PATCH 12/22] Add tests for line history browser
Date: Sat, 24 Jul 2010 23:13:44 +0800 [thread overview]
Message-ID: <1279984434-28933-13-git-send-email-struggleyb.nku@gmail.com> (raw)
In-Reply-To: <1279984434-28933-1-git-send-email-struggleyb.nku@gmail.com>
t4301: for simple linear history only
t4302: for history containing merge
Signed-off-by: Bo Yang <struggleyb.nku@gmail.com>
---
t/t4301-log-line-single-history.sh | 342 ++++++++++++++++++++++++++++++++++++
t/t4302-log-line-merge-history.sh | 114 ++++++++++++
2 files changed, 456 insertions(+), 0 deletions(-)
create mode 100755 t/t4301-log-line-single-history.sh
create mode 100755 t/t4302-log-line-merge-history.sh
diff --git a/t/t4301-log-line-single-history.sh b/t/t4301-log-line-single-history.sh
new file mode 100755
index 0000000..9cf34f8
--- /dev/null
+++ b/t/t4301-log-line-single-history.sh
@@ -0,0 +1,342 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Bo Yang
+#
+
+test_description='Test git log -L with single line of history
+
+'
+. ./test-lib.sh
+. "$TEST_DIRECTORY"/diff-lib.sh
+
+echo >path0 'void func(){
+ int a = 0;
+ int b = 1;
+ int c;
+ c = a + b;
+}
+'
+
+echo >path1 'void output(){
+ printf("hello world");
+}
+'
+
+test_expect_success \
+ 'add path0/path1 and commit.' \
+ 'git add path0 path1 &&
+ git commit -m "Base commit"'
+
+echo >path0 'void func(){
+ int a = 10;
+ int b = 11;
+ int c;
+ c = a + b;
+}
+'
+
+echo >path1 'void output(){
+ const char *str = "hello world!";
+ printf("%s", str);
+}
+'
+
+test_expect_success \
+ 'Change the 2,3 lines of path0 and path1.' \
+ 'git add path0 path1 &&
+ git commit -m "Change 2,3 lines of path0 and path1"'
+
+echo >path0 'void func(){
+ int a = 10;
+ int b = 11;
+ int c;
+ c = 10 * (a + b);
+}
+'
+
+test_expect_success \
+ 'Change the 5th line of path0.' \
+ 'git add path0 &&
+ git commit -m "Change the 5th line of path0"'
+
+echo >path0 'void func(){
+ int a = 10;
+ int b = 11;
+ printf("%d", a - b);
+}
+'
+
+test_expect_success \
+ 'Final change of path0.' \
+ 'git add path0 &&
+ git commit -m "Final change of path0"'
+
+test_expect_success \
+ 'Show the line level log of path0' \
+ 'git log --pretty=format:%s%n%b -L /func/,/^}/ path0 > current-path0'
+
+test_expect_success \
+ 'Show the line level log of path1' \
+ 'git log --pretty=format:%s%n%b -L /output/,/^}/ path1 > current-path1'
+
+test_expect_success \
+ 'Show the line level log of two files' \
+ 'git log --pretty=format:%s%n%b -L /func/,/^}/ path0 -L /output/,/^}/ path1 > current-pathall'
+
+test_expect_success \
+ 'Test the line number argument' \
+ 'git log --pretty=format:%s%n%b -L 1,2 path0 > current-linenum'
+
+test_expect_success \
+ 'Test the --full-line-diff option' \
+ 'git log --pretty=format:%s%n%b --full-line-diff -L 1,2 path0 > current-always'
+
+cat >expected-path0 <<\EOF
+Final change of path0
+
+diff --git a/path0 b/path0
+index 44db133..1518c15 100644
+--- a/path0
++++ b/path0
+@@ -1,6 +1,5 @@
+ void func(){
+ int a = 10;
+ int b = 11;
+- int c;
+- c = 10 * (a + b);
++ printf("%d", a - b);
+ }
+
+Change the 5th line of path0
+
+diff --git a/path0 b/path0
+index 9ef1692..44db133 100644
+--- a/path0
++++ b/path0
+@@ -1,6 +1,6 @@
+ void func(){
+ int a = 10;
+ int b = 11;
+ int c;
+- c = a + b;
++ c = 10 * (a + b);
+ }
+
+Change 2,3 lines of path0 and path1
+
+diff --git a/path0 b/path0
+index aabffdf..9ef1692 100644
+--- a/path0
++++ b/path0
+@@ -1,6 +1,6 @@
+ void func(){
+- int a = 0;
+- int b = 1;
++ int a = 10;
++ int b = 11;
+ int c;
+ c = a + b;
+ }
+
+Base commit
+
+diff --git a/path0 b/path0
+new file mode 100644
+index 0000000..aabffdf
+--- /dev/null
++++ b/path0
+@@ -0,0 +1,6 @@
++void func(){
++ int a = 0;
++ int b = 1;
++ int c;
++ c = a + b;
++}
+EOF
+
+cat >expected-path1 <<\EOF
+Change 2,3 lines of path0 and path1
+
+diff --git a/path1 b/path1
+index 997d841..1d711b5 100644
+--- a/path1
++++ b/path1
+@@ -1,3 +1,4 @@
+ void output(){
+- printf("hello world");
++ const char *str = "hello world!";
++ printf("%s", str);
+ }
+
+Base commit
+
+diff --git a/path1 b/path1
+new file mode 100644
+index 0000000..997d841
+--- /dev/null
++++ b/path1
+@@ -0,0 +1,3 @@
++void output(){
++ printf("hello world");
++}
+EOF
+
+cat >expected-pathall <<\EOF
+Final change of path0
+
+diff --git a/path0 b/path0
+index 44db133..1518c15 100644
+--- a/path0
++++ b/path0
+@@ -1,6 +1,5 @@
+ void func(){
+ int a = 10;
+ int b = 11;
+- int c;
+- c = 10 * (a + b);
++ printf("%d", a - b);
+ }
+
+Change the 5th line of path0
+
+diff --git a/path0 b/path0
+index 9ef1692..44db133 100644
+--- a/path0
++++ b/path0
+@@ -1,6 +1,6 @@
+ void func(){
+ int a = 10;
+ int b = 11;
+ int c;
+- c = a + b;
++ c = 10 * (a + b);
+ }
+
+Change 2,3 lines of path0 and path1
+
+diff --git a/path0 b/path0
+index aabffdf..9ef1692 100644
+--- a/path0
++++ b/path0
+@@ -1,6 +1,6 @@
+ void func(){
+- int a = 0;
+- int b = 1;
++ int a = 10;
++ int b = 11;
+ int c;
+ c = a + b;
+ }
+diff --git a/path1 b/path1
+index 997d841..1d711b5 100644
+--- a/path1
++++ b/path1
+@@ -1,3 +1,4 @@
+ void output(){
+- printf("hello world");
++ const char *str = "hello world!";
++ printf("%s", str);
+ }
+
+Base commit
+
+diff --git a/path0 b/path0
+new file mode 100644
+index 0000000..aabffdf
+--- /dev/null
++++ b/path0
+@@ -0,0 +1,6 @@
++void func(){
++ int a = 0;
++ int b = 1;
++ int c;
++ c = a + b;
++}
+diff --git a/path1 b/path1
+new file mode 100644
+index 0000000..997d841
+--- /dev/null
++++ b/path1
+@@ -0,0 +1,3 @@
++void output(){
++ printf("hello world");
++}
+EOF
+
+cat >expected-linenum <<\EOF
+Change 2,3 lines of path0 and path1
+
+diff --git a/path0 b/path0
+index aabffdf..9ef1692 100644
+--- a/path0
++++ b/path0
+@@ -1,2 +1,2 @@
+ void func(){
+- int a = 0;
++ int a = 10;
+
+Base commit
+
+diff --git a/path0 b/path0
+new file mode 100644
+index 0000000..aabffdf
+--- /dev/null
++++ b/path0
+@@ -0,0 +1,2 @@
++void func(){
++ int a = 0;
+EOF
+
+cat >expected-always <<\EOF
+Final change of path0
+
+diff --git a/path0 b/path0
+index 44db133..1518c15 100644
+--- a/path0
++++ b/path0
+@@ -1,2 +1,2 @@
+ void func(){
+ int a = 10;
+
+Change the 5th line of path0
+
+diff --git a/path0 b/path0
+index 9ef1692..44db133 100644
+--- a/path0
++++ b/path0
+@@ -1,2 +1,2 @@
+ void func(){
+ int a = 10;
+
+Change 2,3 lines of path0 and path1
+
+diff --git a/path0 b/path0
+index aabffdf..9ef1692 100644
+--- a/path0
++++ b/path0
+@@ -1,2 +1,2 @@
+ void func(){
+- int a = 0;
++ int a = 10;
+
+Base commit
+
+diff --git a/path0 b/path0
+new file mode 100644
+index 0000000..aabffdf
+--- /dev/null
++++ b/path0
+@@ -0,0 +1,2 @@
++void func(){
++ int a = 0;
+EOF
+
+test_expect_success \
+ 'validate the output.' \
+ 'test_cmp current-path0 expected-path0 &&
+ test_cmp current-path1 expected-path1 &&
+ test_cmp current-pathall expected-pathall &&
+ test_cmp current-linenum expected-linenum &&
+ test_cmp current-always expected-always'
+
+test_done
diff --git a/t/t4302-log-line-merge-history.sh b/t/t4302-log-line-merge-history.sh
new file mode 100755
index 0000000..02e7439
--- /dev/null
+++ b/t/t4302-log-line-merge-history.sh
@@ -0,0 +1,114 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Bo Yang
+#
+
+test_description='Test git log -L with merge commit
+
+'
+. ./test-lib.sh
+. "$TEST_DIRECTORY"/diff-lib.sh
+
+echo >path0 'void func(){
+ printf("hello");
+}
+'
+
+test_expect_success \
+ 'Add path0 and commit.' \
+ 'git add path0 &&
+ git commit -m "Base commit"'
+
+echo >path0 'void func(){
+ printf("hello earth");
+}
+'
+
+test_expect_success \
+ 'Change path0 in master.' \
+ 'git add path0 &&
+ git commit -m "Change path0 in master"'
+
+test_expect_success \
+ 'Make a new branch from the base commit' \
+ 'git checkout -b feature master^'
+
+echo >path0 'void func(){
+ print("hello moon");
+}
+'
+
+test_expect_success \
+ 'Change path0 in feature.' \
+ 'git add path0 &&
+ git commit -m "Change path0 in feature"'
+
+test_expect_success \
+ 'Merge the master to feature' \
+ '! git merge master'
+
+echo >path0 'void func(){
+ printf("hello earth and moon");
+}
+'
+
+test_expect_success \
+ 'Resolve the conflict' \
+ 'git add path0 &&
+ git commit -m "Merge two branches"'
+
+test_expect_success \
+ 'Show the line level log of path0' \
+ 'git log --pretty=format:%s%n%b -L /func/,/^}/ path0 > current'
+
+cat >expected <<\EOF
+Merge two branches
+
+nontrivial merge found
+path0
+
+@@ 2,1 @@
+ printf("hello earth and moon");
+
+
+Change path0 in master
+
+diff --git a/path0 b/path0
+index f628dea..bef7fa3 100644
+--- a/path0
++++ b/path0
+@@ -1,3 +1,3 @@
+ void func(){
+- printf("hello");
++ printf("hello earth");
+ }
+
+Change path0 in feature
+
+diff --git a/path0 b/path0
+index f628dea..a940ef6 100644
+--- a/path0
++++ b/path0
+@@ -1,3 +1,3 @@
+ void func(){
+- printf("hello");
++ print("hello moon");
+ }
+
+Base commit
+
+diff --git a/path0 b/path0
+new file mode 100644
+index 0000000..f628dea
+--- /dev/null
++++ b/path0
+@@ -0,0 +1,3 @@
++void func(){
++ printf("hello");
++}
+EOF
+test_expect_success \
+ 'validate the output.' \
+ 'test_cmp current expected'
+
+test_done
--
1.7.0.2.273.gc2413.dirty
next prev parent reply other threads:[~2010-07-24 15:15 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-24 15:13 [WIP PATCH 00/22] Some updates since v3 Bo Yang
2010-07-24 15:13 ` [WIP PATCH 01/22] parse-options: enhance STOP_AT_NON_OPTION Bo Yang
2010-07-24 15:13 ` [WIP PATCH 02/22] parse-options: add two helper functions Bo Yang
2010-07-24 15:13 ` [WIP PATCH 03/22] Add the basic data structure for line level history Bo Yang
2010-07-24 15:13 ` [WIP PATCH 04/22] Refactor parse_loc Bo Yang
2010-07-24 15:13 ` [WIP PATCH 05/22] Parse the -L options Bo Yang
2010-07-24 15:13 ` [WIP PATCH 06/22] Export three functions from diff.c Bo Yang
2010-07-24 15:13 ` [WIP PATCH 07/22] Add range clone functions Bo Yang
2010-07-24 15:13 ` [WIP PATCH 08/22] map/take range to the parent of commits Bo Yang
2010-07-24 15:13 ` [WIP PATCH 09/22] Print the line log Bo Yang
2010-07-24 15:13 ` [WIP PATCH 10/22] Hook line history into cmd_log, ensuring a topo-ordered walk Bo Yang
2010-07-24 15:13 ` [WIP PATCH 11/22] Add --full-line-diff option Bo Yang
2010-07-24 15:13 ` Bo Yang [this message]
2010-07-24 22:14 ` [WIP PATCH 12/22] Add tests for line history browser Thomas Rast
2010-07-24 15:13 ` [WIP PATCH 13/22] Document " Bo Yang
2010-07-24 15:13 ` [WIP PATCH 14/22] Make rewrite_parents public to other part of git Bo Yang
2010-07-24 15:13 ` [WIP PATCH 15/22] Add parent rewriting to line history browser Bo Yang
2010-07-24 15:13 ` [WIP PATCH 16/22] Add --graph prefix before line history output Bo Yang
2010-07-24 15:13 ` [WIP PATCH 17/22] Add test cases for '--graph' of line level log Bo Yang
2010-07-24 15:13 ` [WIP PATCH 18/22] a fast fix Bo Yang
2010-07-24 15:13 ` [WIP PATCH 19/22] Make graph_next_line external to other part of git Bo Yang
2010-07-24 15:13 ` [WIP PATCH 20/22] some changes Bo Yang
2010-07-24 15:13 ` [WIP PATCH 21/22] commit parents prunning code Bo Yang
2010-07-24 15:13 ` [WIP PATCH 22/22] A merge should not be printed anyway Bo Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1279984434-28933-13-git-send-email-struggleyb.nku@gmail.com \
--to=struggleyb.nku@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).