examples: a test, for rev-list This test file could probably be improved by a framework like the one in git.git:t/, or by using a language like Python instead of shell. The other examples would benefit from tests too. Probably best to settle on a framework to write them in, then add more tests. Signed-off-by: Greg Price <price@mit.edu>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
diff --git a/examples/test/test-rev-list.sh b/examples/test/test-rev-list.sh
new file mode 100755
index 0000000..bc0eea7
--- /dev/null
+++ b/examples/test/test-rev-list.sh
@@ -0,0 +1,95 @@
+#!/bin/bash
+
+THIS_FILE="$(readlink -f "$0")"
+ROOT="$(dirname "$(dirname "$(dirname "$THIS_FILE")")")"
+PROGRAM="$ROOT"/examples/rev-list
+LIBDIR="$ROOT"/build
+REPO="$ROOT"/tests-clar/resources/testrepo.git
+
+cd "$REPO"
+
+run () {
+ LD_LIBRARY_PATH="$LIBDIR" "$PROGRAM" "$@"
+}
+
+diff -u - <(run --date-order a4a7dce) <<EOF
+a4a7dce85cf63874e984719f4fdd239f5145052f
+c47800c7266a2be04c571c04d5a6614691ea99bd
+9fd738e8f7967c078dceed8190330fc8648ee56a
+4a202b346bb0fb0db7eff3cffeb3c70babbd2045
+5b5b025afb0b4c913b4c338a42934a3863bf3644
+8496071c1b46c854b31185ea97743be6a8774479
+EOF
+
+out="$(run --topo-order a4a7dce)"
+diff -q - <(echo -n "$out") <<EOF >/dev/null ||
+a4a7dce85cf63874e984719f4fdd239f5145052f
+c47800c7266a2be04c571c04d5a6614691ea99bd
+9fd738e8f7967c078dceed8190330fc8648ee56a
+4a202b346bb0fb0db7eff3cffeb3c70babbd2045
+5b5b025afb0b4c913b4c338a42934a3863bf3644
+8496071c1b46c854b31185ea97743be6a8774479
+EOF
+diff -u - <(echo "$out") <<EOF
+a4a7dce85cf63874e984719f4fdd239f5145052f
+9fd738e8f7967c078dceed8190330fc8648ee56a
+4a202b346bb0fb0db7eff3cffeb3c70babbd2045
+c47800c7266a2be04c571c04d5a6614691ea99bd
+5b5b025afb0b4c913b4c338a42934a3863bf3644
+8496071c1b46c854b31185ea97743be6a8774479
+EOF
+
+diff -u - <(run --date-order --reverse a4a7dce) <<EOF
+8496071c1b46c854b31185ea97743be6a8774479
+5b5b025afb0b4c913b4c338a42934a3863bf3644
+4a202b346bb0fb0db7eff3cffeb3c70babbd2045
+9fd738e8f7967c078dceed8190330fc8648ee56a
+c47800c7266a2be04c571c04d5a6614691ea99bd
+a4a7dce85cf63874e984719f4fdd239f5145052f
+EOF
+
+out=$(run --topo-order --reverse a4a7dce)
+diff -q - <(echo -n "$out") <<EOF >/dev/null ||
+8496071c1b46c854b31185ea97743be6a8774479
+5b5b025afb0b4c913b4c338a42934a3863bf3644
+4a202b346bb0fb0db7eff3cffeb3c70babbd2045
+9fd738e8f7967c078dceed8190330fc8648ee56a
+c47800c7266a2be04c571c04d5a6614691ea99bd
+a4a7dce85cf63874e984719f4fdd239f5145052f
+EOF
+diff -u - <(echo "$out") <<EOF
+8496071c1b46c854b31185ea97743be6a8774479
+5b5b025afb0b4c913b4c338a42934a3863bf3644
+c47800c7266a2be04c571c04d5a6614691ea99bd
+4a202b346bb0fb0db7eff3cffeb3c70babbd2045
+9fd738e8f7967c078dceed8190330fc8648ee56a
+a4a7dce85cf63874e984719f4fdd239f5145052f
+EOF
+
+out="$(run --date-order --topo-order --reverse --reverse a4a7dce)"
+diff -q - <(echo -n "$out") <<EOF >/dev/null ||
+a4a7dce85cf63874e984719f4fdd239f5145052f
+c47800c7266a2be04c571c04d5a6614691ea99bd
+9fd738e8f7967c078dceed8190330fc8648ee56a
+4a202b346bb0fb0db7eff3cffeb3c70babbd2045
+5b5b025afb0b4c913b4c338a42934a3863bf3644
+8496071c1b46c854b31185ea97743be6a8774479
+EOF
+diff -u - <(echo "$out") <<EOF
+a4a7dce85cf63874e984719f4fdd239f5145052f
+9fd738e8f7967c078dceed8190330fc8648ee56a
+4a202b346bb0fb0db7eff3cffeb3c70babbd2045
+c47800c7266a2be04c571c04d5a6614691ea99bd
+5b5b025afb0b4c913b4c338a42934a3863bf3644
+8496071c1b46c854b31185ea97743be6a8774479
+EOF
+
+diff -u - <(run ^9fd738e~2 9fd738e) <<EOF
+9fd738e8f7967c078dceed8190330fc8648ee56a
+4a202b346bb0fb0db7eff3cffeb3c70babbd2045
+EOF
+
+diff -u - <(run --not 9fd738e..9fd738e~2) <<EOF
+9fd738e8f7967c078dceed8190330fc8648ee56a
+4a202b346bb0fb0db7eff3cffeb3c70babbd2045
+EOF