[PATCH v10 02/15] contrib: related: add tests
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
contrib/related/Makefile | 17 +++++++++++++
contrib/related/test-related.t | 54 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 71 insertions(+)
create mode 100644 contrib/related/Makefile
create mode 100755 contrib/related/test-related.t
diff --git a/contrib/related/Makefile b/contrib/related/Makefile
new file mode 100644
index 0000000..1224fce
--- /dev/null
+++ b/contrib/related/Makefile
@@ -0,0 +1,17 @@
+TESTS := $(wildcard test-*.t)
+
+export T := $(addprefix $(CURDIR)/,$(TESTS))
+export MAKE := $(MAKE) -e
+export PATH := $(CURDIR):$(PATH)
+export TEST_LINT := test-lint-executable test-lint-shell-syntax
+export TEST_DIRECTORY := $(CURDIR)/../../t
+
+all:
+
+test:
+ $(MAKE) -C ../../t $@
+
+$(TESTS): all
+ $(MAKE) -C ../../t $(CURDIR)/$@
+
+.PHONY: all test $(TESTS)
diff --git a/contrib/related/test-related.t b/contrib/related/test-related.t
new file mode 100755
index 0000000..b69684d
--- /dev/null
+++ b/contrib/related/test-related.t
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+test_description="Test git related"
+
+test -z "$TEST_DIRECTORY" && TEST_DIRECTORY="$PWD/../../t"
+. "$TEST_DIRECTORY"/test-lib.sh
+
+setup() {
+ git init &&
+ echo one > content &&
+ git add content &&
+ git commit -q -m one --author='Pablo Escobar <pablo@escobar.com>' &&
+ echo two >> content &&
+ git commit -q -a -m one --author='Jon Stewart <jon@stewart.com>' &&
+ echo three >> content &&
+ git commit -q -a -m three --author='John Doe <john@doe.com>' &&
+ echo four >> content &&
+ git branch basic &&
+ git commit -q -a -F - --author='John Poppins <john@doe.com>' <<-EOF &&
+ four
+
+ Reviewed-by: Jon Stewart <jon@stewart.com>
+ EOF
+ echo five >> content &&
+ git commit -q -a -m five --author='Mary Poppins <mary@yahoo.com.uk>'
+ git checkout -b next &&
+ echo six >> content &&
+ git commit -q -a -m six --author='Ocatio Paz <octavio.paz@gmail.com>'
+}
+
+setup
+
+test_expect_success "basic" "
+ git format-patch --stdout -1 basic > patch &&
+ git related patch | sort > actual &&
+ cat > expected <<-EOF &&
+ Jon Stewart <jon@stewart.com>
+ Pablo Escobar <pablo@escobar.com>
+ EOF
+ test_cmp expected actual
+"
+
+test_expect_success "others" "
+ git format-patch --stdout -1 master > patch &&
+ git related patch | sort > actual &&
+ cat > expected <<-EOF &&
+ John Doe <john@doe.com>
+ John Poppins <john@doe.com>
+ Jon Stewart <jon@stewart.com>
+ EOF
+ test_cmp expected actual
+"
+
+test_done
--
1.8.4-fc