t / t9804-git-p4-label.shon commit Merge branch 'ar/i18n-no-gettext' (2a2aa8e)
   1test_description='git-p4 p4 label tests'
   2
   3. ./lib-git-p4.sh
   4
   5test_expect_success 'start p4d' '
   6        start_p4d
   7'
   8
   9# Basic p4 label tests.
  10#
  11# Note: can't have more than one label per commit - others
  12# are silently discarded.
  13#
  14test_expect_success 'basic p4 labels' '
  15        test_when_finished cleanup_git &&
  16        (
  17                cd "$cli" &&
  18                mkdir -p main &&
  19
  20                echo f1 >main/f1 &&
  21                p4 add main/f1 &&
  22                p4 submit -d "main/f1" &&
  23
  24                echo f2 >main/f2 &&
  25                p4 add main/f2 &&
  26                p4 submit -d "main/f2" &&
  27
  28                echo f3 >main/file_with_\$metachar &&
  29                p4 add main/file_with_\$metachar &&
  30                p4 submit -d "file with metachar" &&
  31
  32                p4 tag -l tag_f1_only main/f1 &&
  33                p4 tag -l tag_with\$_shell_char main/... &&
  34
  35                echo f4 >main/f4 &&
  36                p4 add main/f4 &&
  37                p4 submit -d "main/f4" &&
  38
  39                p4 label -i <<-EOF &&
  40                Label: long_label
  41                Description:
  42                   A Label first line
  43                   A Label second line
  44                View:   //depot/...
  45                EOF
  46
  47                p4 tag -l long_label ... &&
  48
  49                p4 labels ... &&
  50
  51                "$GITP4" clone --dest="$git" --detect-labels //depot@all &&
  52                cd "$git" &&
  53
  54                git tag &&
  55                git tag >taglist &&
  56                test_line_count = 3 taglist &&
  57
  58                cd main &&
  59                git checkout tag_tag_f1_only &&
  60                ! test -f f2 &&
  61                git checkout tag_tag_with\$_shell_char &&
  62                test -f f1 && test -f f2 && test -f file_with_\$metachar &&
  63
  64                git show tag_long_label | grep -q "A Label second line"
  65        )
  66'
  67
  68# Test some label corner cases:
  69#
  70# - two tags on the same file; both should be available
  71# - a tag that is only on one file; this kind of tag
  72#   cannot be imported (at least not easily).
  73
  74test_expect_failure 'two labels on the same changelist' '
  75        test_when_finished cleanup_git &&
  76        (
  77                cd "$cli" &&
  78                mkdir -p main &&
  79
  80                p4 edit main/f1 main/f2 &&
  81                echo "hello world" >main/f1 &&
  82                echo "not in the tag" >main/f2 &&
  83                p4 submit -d "main/f[12]: testing two labels" &&
  84
  85                p4 tag -l tag_f1_1 main/... &&
  86                p4 tag -l tag_f1_2 main/... &&
  87
  88                p4 labels ... &&
  89
  90                "$GITP4" clone --dest="$git" --detect-labels //depot@all &&
  91                cd "$git" &&
  92
  93                git tag | grep tag_f1 &&
  94                git tag | grep -q tag_f1_1 &&
  95                git tag | grep -q tag_f1_2 &&
  96
  97                cd main &&
  98
  99                git checkout tag_tag_f1_1 &&
 100                ls &&
 101                test -f f1 &&
 102
 103                git checkout tag_tag_f1_2 &&
 104                ls &&
 105                test -f f1
 106        )
 107'
 108
 109test_expect_success 'kill p4d' '
 110        kill_p4d
 111'
 112
 113test_done