Mercurial > hg
changeset 12138:aff0b3947020
tests: unify test-diff-ignore-whitespace
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Mon, 30 Aug 2010 23:13:52 +0200 |
parents | e1814ff260c2 |
children | 5a69ea8d65b3 |
files | tests/test-diff-change.t tests/test-diff-hashes.t tests/test-diff-ignore-whitespace tests/test-diff-ignore-whitespace.out tests/test-diff-ignore-whitespace.t |
diffstat | 3 files changed, 392 insertions(+), 402 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test-diff-ignore-whitespace Mon Aug 30 16:52:21 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -#!/bin/sh - -# GNU diff is the reference for all of these results. - -hgdiff() { - echo hg diff $@ - hg diff --nodates "$@" -} - -test_added_blank_lines() { - printf '\nhello world\n\ngoodbye world\n\n' >foo - - echo '>>> two diffs showing three added lines <<<' - hgdiff - hgdiff -b - - echo '>>> no diffs <<<' - hgdiff -B - hgdiff -Bb -} - -test_added_horizontal_space_first_on_a_line() { - printf '\t hello world\ngoodbye world\n' >foo - - echo '>>> four diffs showing added space first on the first line <<<' - hgdiff - hgdiff -b - hgdiff -B - hgdiff -Bb -} - -test_added_horizontal_space_last_on_a_line() { - printf 'hello world\t \ngoodbye world\n' >foo - - echo '>>> two diffs showing space appended to the first line <<<' - hgdiff - hgdiff -B - - echo '>>> no diffs <<<' - hgdiff -b - hgdiff -Bb -} - -test_added_horizontal_space_in_the_middle_of_a_word() { - printf 'hello world\ngood bye world\n' >foo - - echo '>>> four diffs showing space inserted into "goodbye" <<<' - hgdiff - hgdiff -B - hgdiff -b - hgdiff -Bb -} - -test_increased_horizontal_whitespace_amount() { - printf 'hello world\ngoodbye\t\t \tworld\n' >foo - - echo '>>> two diffs showing changed whitespace amount in the last line <<<' - hgdiff - hgdiff -B - - echo '>>> no diffs <<<' - hgdiff -b - hgdiff -Bb -} - -test_added_blank_line_with_horizontal_whitespace() { - printf 'hello world\n \t\ngoodbye world\n' >foo - - echo '>>> four diffs showing added blank line w/horizontal space <<<' - hgdiff - hgdiff -B - hgdiff -b - hgdiff -Bb -} - -test_added_blank_line_with_other_whitespace() { - printf 'hello world\n \t\ngoodbye world \n' >foo - - echo '>>> three diffs showing added blank line w/other space <<<' - hgdiff - hgdiff -B - hgdiff -b - hgdiff -Bb -} - -test_whitespace_changes() { - printf 'helloworld\ngoodbye\tworld \n' >foo - - echo '>>> four diffs showing changed whitespace <<<' - hgdiff - hgdiff -B - hgdiff -b - hgdiff -Bb - hgdiff -w -} - -test_whitespace_changes_and_blank_lines() { - printf 'helloworld\n\n\n\ngoodbye\tworld \n' >foo - - echo '>>> five diffs showing changed whitespace <<<' - hgdiff - hgdiff -B - hgdiff -b - hgdiff -Bb - hgdiff -w - hgdiff -wB -} - -hg init -printf 'hello world\ngoodbye world\n' >foo -hg ci -Amfoo -ufoo - -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
--- a/tests/test-diff-ignore-whitespace.out Mon Aug 30 16:52:21 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-diff-ignore-whitespace.t Mon Aug 30 23:13:52 2010 +0200 @@ -0,0 +1,392 @@ +GNU diff is the reference for all of these results. + +Prepare tests: + + $ echo '[alias]' >> $HGRCPATH + $ echo 'ndiff = diff --nodates' >> $HGRCPATH + + $ 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 <<< + + $ 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 + + + +>>> no diffs <<< + + $ hg ndiff -B + $ hg ndiff -Bb + + +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 + + $ hg ndiff -B + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + -hello world + + hello world + goodbye world + + $ 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 <<< + + $ 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 in the middle of a word: + + $ printf 'hello world\ngood bye world\n' >foo + +>>> four diffs showing space inserted into "goodbye" <<< + + $ 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 + + $ hg ndiff -b + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + hello world + -goodbye world + +good bye world + + $ 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 <<< + + $ hg ndiff + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + hello world + -goodbye world + +goodbye world + + $ hg ndiff -B + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,2 @@ + hello world + -goodbye world + +goodbye world + +>>> no diffs <<< + + $ hg ndiff -b + $ hg ndiff -Bb + + +Test added blank line with horizontal whitespace: + + $ printf 'hello world\n \t\ngoodbye world\n' >foo + +>>> 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 + + $ 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 <<< + + $ hg ndiff + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,3 @@ + -hello world + -goodbye world + +hello world + + + +goodbye world + + $ hg ndiff -B + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,3 @@ + -hello world + -goodbye world + +hello world + + + +goodbye world + + $ 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 + +>>> 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 + + $ 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 + + $ 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 + + $ 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 ndiff -Bb + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,5 @@ + -hello world + +helloworld + + + + + + + goodbye world + + $ hg ndiff -w + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,5 @@ + hello world + + + + + + + goodbye world + +>>> no diffs <<< + + $ hg ndiff -wB +