|
| 1 | +# Helpers shared by the test scripts for comparing log graphs. |
| 2 | + |
| 3 | +sanitize_output() { |
| 4 | + sed -e 's/ *$//' \ |
| 5 | + -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \ |
| 6 | + -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \ |
| 7 | + -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \ |
| 8 | + -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \ |
| 9 | + -e 's/, 0 deletions(-)//' \ |
| 10 | + -e 's/, 0 insertions(+)//' \ |
| 11 | + -e 's/ 1 files changed, / 1 file changed, /' \ |
| 12 | + -e 's/, 1 deletions(-)/, 1 deletion(-)/' \ |
| 13 | + -e 's/, 1 insertions(+)/, 1 insertion(+)/' \ |
| 14 | + -e 's/index [0-9a-f]*\.\.[0-9a-f]*/index BEFORE..AFTER/' |
| 15 | +} |
| 16 | + |
| 17 | +# Assume expected graph is in file `expect` |
| 18 | +test_cmp_graph_file() { |
| 19 | + git log --graph "$@" >output && |
| 20 | + sanitize_output >output.trimmed <output && |
| 21 | + test_i18ncmp expect output.trimmed |
| 22 | +} |
| 23 | + |
| 24 | +test_cmp_graph() { |
| 25 | + cat >expect && |
| 26 | + test_cmp_graph_file "$@" |
| 27 | +} |
| 28 | + |
| 29 | +# Assume expected graph is in file `expect.colors` |
| 30 | +test_cmp_colored_graph_file() { |
| 31 | + git log --graph --color=always "$@" >output.colors.raw && |
| 32 | + test_decode_color <output.colors.raw | sed "s/ *\$//" >output.colors && |
| 33 | + test_cmp expect.colors output.colors |
| 34 | +} |
| 35 | + |
| 36 | +test_cmp_colored_graph() { |
| 37 | + cat >expect.colors && |
| 38 | + test_cmp_colored_graph_file "$@" |
| 39 | +} |
0 commit comments