t / t9002-column.shon commit t9002: work around shells that are unable to set COLUMNS to 1 (f78b1c5)
   1#!/bin/sh
   2
   3test_description='git column'
   4. ./test-lib.sh
   5
   6test_expect_success 'setup' '
   7        cat >lista <<\EOF
   8one
   9two
  10three
  11four
  12five
  13six
  14seven
  15eight
  16nine
  17ten
  18eleven
  19EOF
  20'
  21
  22test_expect_success 'never' '
  23        git column --indent=Z --mode=never <lista >actual &&
  24        test_cmp lista actual
  25'
  26
  27test_expect_success 'always' '
  28        cat >expected <<\EOF &&
  29Zone
  30Ztwo
  31Zthree
  32Zfour
  33Zfive
  34Zsix
  35Zseven
  36Zeight
  37Znine
  38Zten
  39Zeleven
  40EOF
  41        git column --indent=Z --mode=plain <lista >actual &&
  42        test_cmp expected actual
  43'
  44
  45test_expect_success '80 columns' '
  46        cat >expected <<\EOF &&
  47one    two    three  four   five   six    seven  eight  nine   ten    eleven
  48EOF
  49        COLUMNS=80 git column --mode=column <lista >actual &&
  50        test_cmp expected actual
  51'
  52
  53cat >expected <<\EOF
  54one
  55two
  56three
  57four
  58five
  59six
  60seven
  61eight
  62nine
  63ten
  64eleven
  65EOF
  66
  67test_expect_success COLUMNS_CAN_BE_1 'COLUMNS = 1' '
  68        COLUMNS=1 git column --mode=column <lista >actual &&
  69        test_cmp expected actual
  70'
  71
  72test_expect_success 'width = 1' '
  73        git column --mode=column --width=1 <lista >actual &&
  74        test_cmp expected actual
  75'
  76
  77COLUMNS=20
  78export COLUMNS
  79
  80test_expect_success '20 columns' '
  81        cat >expected <<\EOF &&
  82one    seven
  83two    eight
  84three  nine
  85four   ten
  86five   eleven
  87six
  88EOF
  89        git column --mode=column <lista >actual &&
  90        test_cmp expected actual
  91'
  92
  93test_expect_success '20 columns, padding 2' '
  94        cat >expected <<\EOF &&
  95one     seven
  96two     eight
  97three   nine
  98four    ten
  99five    eleven
 100six
 101EOF
 102        git column --mode=column --padding 2 <lista >actual &&
 103        test_cmp expected actual
 104'
 105
 106test_expect_success '20 columns, indented' '
 107        cat >expected <<\EOF &&
 108  one    seven
 109  two    eight
 110  three  nine
 111  four   ten
 112  five   eleven
 113  six
 114EOF
 115        git column --mode=column --indent="  " <lista >actual &&
 116        test_cmp expected actual
 117'
 118
 119test_expect_success '20 columns, row first' '
 120        cat >expected <<\EOF &&
 121one    two
 122three  four
 123five   six
 124seven  eight
 125nine   ten
 126eleven
 127EOF
 128        git column --mode=row <lista >actual &&
 129        test_cmp expected actual
 130'
 131
 132test_done