tests/test-diff-ignore-whitespace
changeset 4878 372d93f03d3a
parent 3192 096f1c73cdc3
equal deleted inserted replaced
4877:242026115e6a 4878:372d93f03d3a
     1 #!/bin/sh
     1 #!/bin/sh
     2 
     2 
     3 # GNU diff is the reference for all of these results.
     3 # GNU diff is the reference for all of these results.
     4 
     4 
     5 hgdiff() {
     5 hgdiff() {
       
     6     echo hg diff $@
     6     hg diff --nodates "$@"
     7     hg diff --nodates "$@"
     7 }
     8 }
     8 
     9 
     9 test_added_blank_lines() {
    10 test_added_blank_lines() {
    10     printf '\nhello world\n\ngoodbye world\n\n' >foo
    11     printf '\nhello world\n\ngoodbye world\n\n' >foo
    70     hgdiff -B
    71     hgdiff -B
    71     hgdiff -b
    72     hgdiff -b
    72     hgdiff -Bb
    73     hgdiff -Bb
    73 }
    74 }
    74 
    75 
       
    76 test_added_blank_line_with_other_whitespace() {
       
    77     printf 'hello  world\n \t\ngoodbye world \n' >foo
       
    78 
       
    79     echo '>>> three diffs showing added blank line w/other space <<<'
       
    80     hgdiff
       
    81     hgdiff -B
       
    82     hgdiff -b
       
    83     hgdiff -Bb
       
    84 }
       
    85 
       
    86 test_whitespace_changes() {
       
    87     printf 'helloworld\ngoodbye\tworld \n' >foo
       
    88 
       
    89     echo '>>> four diffs showing changed whitespace <<<'
       
    90     hgdiff
       
    91     hgdiff -B
       
    92     hgdiff -b
       
    93     hgdiff -Bb
       
    94     hgdiff -w
       
    95 }
       
    96 
       
    97 test_whitespace_changes_and_blank_lines() {
       
    98     printf 'helloworld\n\n\n\ngoodbye\tworld \n' >foo
       
    99 
       
   100     echo '>>> five diffs showing changed whitespace <<<'
       
   101     hgdiff
       
   102     hgdiff -B
       
   103     hgdiff -b
       
   104     hgdiff -Bb
       
   105     hgdiff -w
       
   106     hgdiff -wB
       
   107 }
       
   108 
    75 hg init
   109 hg init
    76 printf 'hello world\ngoodbye world\n' >foo
   110 printf 'hello world\ngoodbye world\n' >foo
    77 hg ci -Amfoo -ufoo -d '0 0'
   111 hg ci -Amfoo -ufoo -d '0 0'
    78 
   112 
    79 test_added_blank_lines
   113 test_added_blank_lines
    80 test_added_horizontal_space_first_on_a_line
   114 test_added_horizontal_space_first_on_a_line
    81 test_added_horizontal_space_last_on_a_line
   115 test_added_horizontal_space_last_on_a_line
    82 test_added_horizontal_space_in_the_middle_of_a_word
   116 test_added_horizontal_space_in_the_middle_of_a_word
    83 test_increased_horizontal_whitespace_amount
   117 test_increased_horizontal_whitespace_amount
    84 test_added_blank_line_with_horizontal_whitespace
   118 test_added_blank_line_with_horizontal_whitespace
       
   119 test_added_blank_line_with_other_whitespace
       
   120 test_whitespace_changes
       
   121 test_whitespace_changes_and_blank_lines