diff --git a/tests/test-diff-ignore-whitespace.out b/tests/test-diff-ignore-whitespace.out deleted file mode 100644 --- a/tests/test-diff-ignore-whitespace.out +++ /dev/null @@ -1,281 +0,0 @@ -adding foo ->>> two diffs showing three added lines <<< -hg diff -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,5 @@ -+ - hello world -+ - goodbye world -+ -hg diff -b -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,5 @@ -+ - hello world -+ - goodbye world -+ ->>> no diffs <<< -hg diff -B -hg diff -Bb ->>> four diffs showing added space first on the first line <<< -hg diff -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,2 @@ --hello world -+ hello world - goodbye world -hg diff -b -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,2 @@ --hello world -+ hello world - goodbye world -hg diff -B -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,2 @@ --hello world -+ hello world - goodbye world -hg diff -Bb -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,2 @@ --hello world -+ hello world - goodbye world ->>> two diffs showing space appended to the first line <<< -hg diff -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,2 @@ --hello world -+hello world - goodbye world -hg diff -B -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,2 @@ --hello world -+hello world - goodbye world ->>> no diffs <<< -hg diff -b -hg diff -Bb ->>> four diffs showing space inserted into "goodbye" <<< -hg diff -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,2 @@ - hello world --goodbye world -+good bye world -hg diff -B -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,2 @@ - hello world --goodbye world -+good bye world -hg diff -b -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,2 @@ - hello world --goodbye world -+good bye world -hg diff -Bb -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,2 @@ - hello world --goodbye world -+good bye world ->>> two diffs showing changed whitespace amount in the last line <<< -hg diff -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,2 @@ - hello world --goodbye world -+goodbye world -hg diff -B -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,2 @@ - hello world --goodbye world -+goodbye world ->>> no diffs <<< -hg diff -b -hg diff -Bb ->>> four diffs showing added blank line w/horizontal space <<< -hg diff -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,3 @@ - hello world -+ - goodbye world -hg diff -B -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,3 @@ - hello world -+ - goodbye world -hg diff -b -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,3 @@ - hello world -+ - goodbye world -hg diff -Bb ->>> three diffs showing added blank line w/other space <<< -hg diff -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,3 @@ --hello world --goodbye world -+hello world -+ -+goodbye world -hg diff -B -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,3 @@ --hello world --goodbye world -+hello world -+ -+goodbye world -hg diff -b -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,3 @@ - hello world -+ - goodbye world -hg diff -Bb ->>> four diffs showing changed whitespace <<< -hg diff -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,2 @@ --hello world --goodbye world -+helloworld -+goodbye world -hg diff -B -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,2 @@ --hello world --goodbye world -+helloworld -+goodbye world -hg diff -b -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,2 @@ --hello world -+helloworld - goodbye world -hg diff -Bb -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,2 @@ --hello world -+helloworld - goodbye world -hg diff -w ->>> five diffs showing changed whitespace <<< -hg diff -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,5 @@ --hello world --goodbye world -+helloworld -+ -+ -+ -+goodbye world -hg diff -B -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,5 @@ --hello world --goodbye world -+helloworld -+ -+ -+ -+goodbye world -hg diff -b -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,5 @@ --hello world -+helloworld -+ -+ -+ - goodbye world -hg diff -Bb -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,5 @@ --hello world -+helloworld -+ -+ -+ - goodbye world -hg diff -w -diff -r 540c40a65b78 foo ---- a/foo -+++ b/foo -@@ -1,2 +1,5 @@ - hello world -+ -+ -+ - goodbye world -hg diff -wB diff --git a/tests/test-diff-ignore-whitespace b/tests/test-diff-ignore-whitespace.t old mode 100755 new mode 100644 rename from tests/test-diff-ignore-whitespace rename to tests/test-diff-ignore-whitespace.t --- a/tests/test-diff-ignore-whitespace +++ b/tests/test-diff-ignore-whitespace.t @@ -1,121 +1,392 @@ -#!/bin/sh +GNU diff is the reference for all of these results. + +Prepare tests: + + $ echo '[alias]' >> $HGRCPATH + $ echo 'ndiff = diff --nodates' >> $HGRCPATH -# GNU diff is the reference for all of these results. + $ hg init + $ printf 'hello world\ngoodbye world\n' >foo + $ hg ci -Amfoo -ufoo + adding foo + + +Test added blank lines: + + $ printf '\nhello world\n\ngoodbye world\n\n' >foo + +>>> two diffs showing three added lines <<< -hgdiff() { - echo hg diff $@ - hg diff --nodates "$@" -} + $ hg ndiff + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,5 @@ + + + hello world + + + goodbye world + + + $ hg ndiff -b + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,5 @@ + + + hello world + + + goodbye world + + -test_added_blank_lines() { - printf '\nhello world\n\ngoodbye world\n\n' >foo +>>> no diffs <<< + + $ hg ndiff -B + $ hg ndiff -Bb + - echo '>>> two diffs showing three added lines <<<' - hgdiff - hgdiff -b +Test added horizontal space first on a line(): + + $ printf '\t hello world\ngoodbye world\n' >foo + +>>> four diffs showing added space first on the first line <<< + + $ hg ndiff + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + -hello world + + hello world + goodbye world + + $ hg ndiff -b + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + -hello world + + hello world + goodbye world - echo '>>> no diffs <<<' - hgdiff -B - hgdiff -Bb -} + $ hg ndiff -B + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + -hello world + + hello world + goodbye world -test_added_horizontal_space_first_on_a_line() { - printf '\t hello world\ngoodbye world\n' >foo + $ hg ndiff -Bb + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + -hello world + + hello world + goodbye world + + +Test added horizontal space last on a line: + + $ printf 'hello world\t \ngoodbye world\n' >foo + +>>> two diffs showing space appended to the first line <<< - echo '>>> four diffs showing added space first on the first line <<<' - hgdiff - hgdiff -b - hgdiff -B - hgdiff -Bb -} + $ hg ndiff + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + -hello world + +hello world + goodbye world + + $ hg ndiff -B + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + -hello world + +hello world + goodbye world + +>>> no diffs <<< + + $ hg ndiff -b + $ hg ndiff -Bb + -test_added_horizontal_space_last_on_a_line() { - printf 'hello world\t \ngoodbye world\n' >foo +Test added horizontal space in the middle of a word: + + $ printf 'hello world\ngood bye world\n' >foo + +>>> four diffs showing space inserted into "goodbye" <<< - echo '>>> two diffs showing space appended to the first line <<<' - hgdiff - hgdiff -B + $ hg ndiff + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + hello world + -goodbye world + +good bye world + + $ hg ndiff -B + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + hello world + -goodbye world + +good bye world - echo '>>> no diffs <<<' - hgdiff -b - hgdiff -Bb -} + $ hg ndiff -b + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + hello world + -goodbye world + +good bye world -test_added_horizontal_space_in_the_middle_of_a_word() { - printf 'hello world\ngood bye world\n' >foo + $ hg ndiff -Bb + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + hello world + -goodbye world + +good bye world + + +Test increased horizontal whitespace amount: + + $ printf 'hello world\ngoodbye\t\t \tworld\n' >foo + +>>> two diffs showing changed whitespace amount in the last line <<< - echo '>>> four diffs showing space inserted into "goodbye" <<<' - hgdiff - hgdiff -B - hgdiff -b - hgdiff -Bb -} + $ hg ndiff + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + hello world + -goodbye world + +goodbye world -test_increased_horizontal_whitespace_amount() { - printf 'hello world\ngoodbye\t\t \tworld\n' >foo + $ hg ndiff -B + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + hello world + -goodbye world + +goodbye world - echo '>>> two diffs showing changed whitespace amount in the last line <<<' - hgdiff - hgdiff -B +>>> no diffs <<< + + $ hg ndiff -b + $ hg ndiff -Bb + + +Test added blank line with horizontal whitespace: + + $ printf 'hello world\n \t\ngoodbye world\n' >foo - echo '>>> no diffs <<<' - hgdiff -b - hgdiff -Bb -} +>>> three diffs showing added blank line with horizontal space <<< + + $ hg ndiff + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,3 @@ + hello world + + + goodbye world + + $ hg ndiff -B + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,3 @@ + hello world + + + goodbye world -test_added_blank_line_with_horizontal_whitespace() { - printf 'hello world\n \t\ngoodbye world\n' >foo + $ hg ndiff -b + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,3 @@ + hello world + + + goodbye world + +>>> no diffs <<< + + $ hg ndiff -Bb + + +Test added blank line with other whitespace: + + $ printf 'hello world\n \t\ngoodbye world \n' >foo + +>>> three diffs showing added blank line with other space <<< - echo '>>> four diffs showing added blank line w/horizontal space <<<' - hgdiff - hgdiff -B - hgdiff -b - hgdiff -Bb -} + $ hg ndiff + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,3 @@ + -hello world + -goodbye world + +hello world + + + +goodbye world -test_added_blank_line_with_other_whitespace() { - printf 'hello world\n \t\ngoodbye world \n' >foo + $ hg ndiff -B + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,3 @@ + -hello world + -goodbye world + +hello world + + + +goodbye world - echo '>>> three diffs showing added blank line w/other space <<<' - hgdiff - hgdiff -B - hgdiff -b - hgdiff -Bb -} + $ hg ndiff -b + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,3 @@ + hello world + + + goodbye world + +>>> no diffs <<< + + $ hg ndiff -Bb + -test_whitespace_changes() { - printf 'helloworld\ngoodbye\tworld \n' >foo +Test whitespace changes: + + $ printf 'helloworld\ngoodbye\tworld \n' >foo + +>>> four diffs showing changed whitespace <<< + + $ hg ndiff + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + -hello world + -goodbye world + +helloworld + +goodbye world - echo '>>> four diffs showing changed whitespace <<<' - hgdiff - hgdiff -B - hgdiff -b - hgdiff -Bb - hgdiff -w -} + $ hg ndiff -B + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + -hello world + -goodbye world + +helloworld + +goodbye world + + $ hg ndiff -b + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + -hello world + +helloworld + goodbye world -test_whitespace_changes_and_blank_lines() { - printf 'helloworld\n\n\n\ngoodbye\tworld \n' >foo + $ hg ndiff -Bb + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + -hello world + +helloworld + goodbye world + +>>> no diffs <<< + + $ hg ndiff -w + + +Test whitespace changes and blank lines: + + $ printf 'helloworld\n\n\n\ngoodbye\tworld \n' >foo + +>>> five diffs showing changed whitespace <<< + + $ hg ndiff + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,5 @@ + -hello world + -goodbye world + +helloworld + + + + + + + +goodbye world - echo '>>> five diffs showing changed whitespace <<<' - hgdiff - hgdiff -B - hgdiff -b - hgdiff -Bb - hgdiff -w - hgdiff -wB -} + $ hg ndiff -B + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,5 @@ + -hello world + -goodbye world + +helloworld + + + + + + + +goodbye world + + $ hg ndiff -b + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,5 @@ + -hello world + +helloworld + + + + + + + goodbye world -hg init -printf 'hello world\ngoodbye world\n' >foo -hg ci -Amfoo -ufoo + $ hg ndiff -Bb + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,5 @@ + -hello world + +helloworld + + + + + + + goodbye world -test_added_blank_lines -test_added_horizontal_space_first_on_a_line -test_added_horizontal_space_last_on_a_line -test_added_horizontal_space_in_the_middle_of_a_word -test_increased_horizontal_whitespace_amount -test_added_blank_line_with_horizontal_whitespace -test_added_blank_line_with_other_whitespace -test_whitespace_changes -test_whitespace_changes_and_blank_lines + $ hg ndiff -w + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,5 @@ + hello world + + + + + + + goodbye world + +>>> no diffs <<< + + $ hg ndiff -wB +