t9002: work around shells that are unable to set COLUMNS to 1
[gitweb.git] / t / t9002-column.sh
index a7f3cd9285fce4bccb437a9d65edb2f7a8994a75..fb71949ebd1f52b64ae82e22987e51385bb6400a 100755 (executable)
@@ -42,4 +42,91 @@ EOF
        test_cmp expected actual
 '
 
+test_expect_success '80 columns' '
+       cat >expected <<\EOF &&
+one    two    three  four   five   six    seven  eight  nine   ten    eleven
+EOF
+       COLUMNS=80 git column --mode=column <lista >actual &&
+       test_cmp expected actual
+'
+
+cat >expected <<\EOF
+one
+two
+three
+four
+five
+six
+seven
+eight
+nine
+ten
+eleven
+EOF
+
+test_expect_success COLUMNS_CAN_BE_1 'COLUMNS = 1' '
+       COLUMNS=1 git column --mode=column <lista >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'width = 1' '
+       git column --mode=column --width=1 <lista >actual &&
+       test_cmp expected actual
+'
+
+COLUMNS=20
+export COLUMNS
+
+test_expect_success '20 columns' '
+       cat >expected <<\EOF &&
+one    seven
+two    eight
+three  nine
+four   ten
+five   eleven
+six
+EOF
+       git column --mode=column <lista >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success '20 columns, padding 2' '
+       cat >expected <<\EOF &&
+one     seven
+two     eight
+three   nine
+four    ten
+five    eleven
+six
+EOF
+       git column --mode=column --padding 2 <lista >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success '20 columns, indented' '
+       cat >expected <<\EOF &&
+  one    seven
+  two    eight
+  three  nine
+  four   ten
+  five   eleven
+  six
+EOF
+       git column --mode=column --indent="  " <lista >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success '20 columns, row first' '
+       cat >expected <<\EOF &&
+one    two
+three  four
+five   six
+seven  eight
+nine   ten
+eleven
+EOF
+       git column --mode=row <lista >actual &&
+       test_cmp expected actual
+'
+
 test_done