t / t0041-usage.shon commit Merge branch 'sw/git-p4-unshelve-branched-files' (e7ef93b)
   1#!/bin/sh
   2
   3test_description='Test commands behavior when given invalid argument value'
   4
   5. ./test-lib.sh
   6
   7test_expect_success 'setup ' '
   8        test_commit "v1.0"
   9'
  10
  11test_expect_success 'tag --contains <existent_tag>' '
  12        git tag --contains "v1.0" >actual 2>actual.err &&
  13        grep "v1.0" actual &&
  14        test_line_count = 0 actual.err
  15'
  16
  17test_expect_success 'tag --contains <inexistent_tag>' '
  18        test_must_fail git tag --contains "notag" >actual 2>actual.err &&
  19        test_line_count = 0 actual &&
  20        test_i18ngrep "error" actual.err &&
  21        test_i18ngrep ! "usage" actual.err
  22'
  23
  24test_expect_success 'tag --no-contains <existent_tag>' '
  25        git tag --no-contains "v1.0" >actual 2>actual.err  &&
  26        test_line_count = 0 actual &&
  27        test_line_count = 0 actual.err
  28'
  29
  30test_expect_success 'tag --no-contains <inexistent_tag>' '
  31        test_must_fail git tag --no-contains "notag" >actual 2>actual.err &&
  32        test_line_count = 0 actual &&
  33        test_i18ngrep "error" actual.err &&
  34        test_i18ngrep ! "usage" actual.err
  35'
  36
  37test_expect_success 'tag usage error' '
  38        test_must_fail git tag --noopt >actual 2>actual.err &&
  39        test_line_count = 0 actual &&
  40        test_i18ngrep "usage" actual.err
  41'
  42
  43test_expect_success 'branch --contains <existent_commit>' '
  44        git branch --contains "master" >actual 2>actual.err &&
  45        test_i18ngrep "master" actual &&
  46        test_line_count = 0 actual.err
  47'
  48
  49test_expect_success 'branch --contains <inexistent_commit>' '
  50        test_must_fail git branch --no-contains "nocommit" >actual 2>actual.err &&
  51        test_line_count = 0 actual &&
  52        test_i18ngrep "error" actual.err &&
  53        test_i18ngrep ! "usage" actual.err
  54'
  55
  56test_expect_success 'branch --no-contains <existent_commit>' '
  57        git branch --no-contains "master" >actual 2>actual.err &&
  58        test_line_count = 0 actual &&
  59        test_line_count = 0 actual.err
  60'
  61
  62test_expect_success 'branch --no-contains <inexistent_commit>' '
  63        test_must_fail git branch --no-contains "nocommit" >actual 2>actual.err &&
  64        test_line_count = 0 actual &&
  65        test_i18ngrep "error" actual.err &&
  66        test_i18ngrep ! "usage" actual.err
  67'
  68
  69test_expect_success 'branch usage error' '
  70        test_must_fail git branch --noopt >actual 2>actual.err &&
  71        test_line_count = 0 actual &&
  72        test_i18ngrep "usage" actual.err
  73'
  74
  75test_expect_success 'for-each-ref --contains <existent_object>' '
  76        git for-each-ref --contains "master" >actual 2>actual.err &&
  77        test_line_count = 2 actual &&
  78        test_line_count = 0 actual.err
  79'
  80
  81test_expect_success 'for-each-ref --contains <inexistent_object>' '
  82        test_must_fail git for-each-ref --no-contains "noobject" >actual 2>actual.err &&
  83        test_line_count = 0 actual &&
  84        test_i18ngrep "error" actual.err &&
  85        test_i18ngrep ! "usage" actual.err
  86'
  87
  88test_expect_success 'for-each-ref --no-contains <existent_object>' '
  89        git for-each-ref --no-contains "master" >actual 2>actual.err &&
  90        test_line_count = 0 actual &&
  91        test_line_count = 0 actual.err
  92'
  93
  94test_expect_success 'for-each-ref --no-contains <inexistent_object>' '
  95        test_must_fail git for-each-ref --no-contains "noobject" >actual 2>actual.err &&
  96        test_line_count = 0 actual &&
  97        test_i18ngrep "error" actual.err &&
  98        test_i18ngrep ! "usage" actual.err
  99'
 100
 101test_expect_success 'for-each-ref usage error' '
 102        test_must_fail git for-each-ref --noopt >actual 2>actual.err &&
 103        test_line_count = 0 actual &&
 104        test_i18ngrep "usage" actual.err
 105'
 106
 107test_done