(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'git p4 tests'>)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./lib-git-p4.sh)})
    (C {(test_expect_success)} {(SQ <'start p4d'>)} {(SQ <'\n'> <'\tstart_p4d\n'>)})
    (C {(test_expect_success)} {(SQ <'add p4 files'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> <'\t\techo file1 >file1 &&\n'> 
          <'\t\tp4 add file1 &&\n'> <'\t\tp4 submit -d "file1" &&\n'> <'\t\techo file2 >file2 &&\n'> <'\t\tp4 add file2 &&\n'> 
          <'\t\tp4 submit -d "file2"\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'basic git p4 clone'>)} 
      {
        (SQ <'\n'> <'\tgit p4 clone --dest="$git" //depot &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\t\tgit log --oneline >lines &&\n'> 
          <'\t\ttest_line_count = 1 lines\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'depot typo error'>)} 
      {
        (SQ <'\n'> <'\ttest_must_fail git p4 clone --dest="$git" /depot 2>errs &&\n'> 
          <'\tgrep "Depot paths must start with" errs\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'git p4 clone @all'>)} 
      {
        (SQ <'\n'> <'\tgit p4 clone --dest="$git" //depot@all &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\t\tgit log --oneline >lines &&\n'> 
          <'\t\ttest_line_count = 2 lines\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'git p4 sync uninitialized repo'>)} 
      {
        (SQ <'\n'> <'\ttest_create_repo "$git" &&\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\t\ttest_must_fail git p4 sync 2>errs &&\n'> 
          <'\t\ttest_i18ngrep "Perhaps you never did" errs\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'git p4 sync new branch'>)} 
      {
        (SQ <'\n'> <'\ttest_create_repo "$git" &&\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\t\ttest_commit head &&\n'> 
          <'\t\tgit p4 sync --branch=refs/remotes/p4/depot //depot@all &&\n'> <'\t\tgit log --oneline p4/depot >lines &&\n'> <'\t\ttest_line_count = 2 lines\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'clone two dirs'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> <'\t\tmkdir sub1 sub2 &&\n'> 
          <'\t\techo sub1/f1 >sub1/f1 &&\n'> <'\t\techo sub2/f2 >sub2/f2 &&\n'> <'\t\tp4 add sub1/f1 &&\n'> <'\t\tp4 submit -d "sub1/f1" &&\n'> 
          <'\t\tp4 add sub2/f2 &&\n'> <'\t\tp4 submit -d "sub2/f2"\n'> <'\t) &&\n'> 
          <'\tgit p4 clone --dest="$git" //depot/sub1 //depot/sub2 &&\n'> <'\ttest_when_finished cleanup_git &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> 
          <'\t\tgit ls-files >lines &&\n'> <'\t\ttest_line_count = 2 lines &&\n'> <'\t\tgit log --oneline p4/master >lines &&\n'> 
          <'\t\ttest_line_count = 1 lines\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'clone two dirs, @all'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> <'\t\techo sub1/f3 >sub1/f3 &&\n'> 
          <'\t\tp4 add sub1/f3 &&\n'> <'\t\tp4 submit -d "sub1/f3"\n'> <'\t) &&\n'> 
          <'\tgit p4 clone --dest="$git" //depot/sub1@all //depot/sub2@all &&\n'> <'\ttest_when_finished cleanup_git &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> 
          <'\t\tgit ls-files >lines &&\n'> <'\t\ttest_line_count = 3 lines &&\n'> <'\t\tgit log --oneline p4/master >lines &&\n'> 
          <'\t\ttest_line_count = 3 lines\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'clone two dirs, @all, conflicting files'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> <'\t\techo sub2/f3 >sub2/f3 &&\n'> 
          <'\t\tp4 add sub2/f3 &&\n'> <'\t\tp4 submit -d "sub2/f3"\n'> <'\t) &&\n'> 
          <'\tgit p4 clone --dest="$git" //depot/sub1@all //depot/sub2@all &&\n'> <'\ttest_when_finished cleanup_git &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> 
          <'\t\tgit ls-files >lines &&\n'> <'\t\ttest_line_count = 3 lines &&\n'> <'\t\tgit log --oneline p4/master >lines &&\n'> 
          <'\t\ttest_line_count = 4 lines &&\n'> <'\t\techo sub2/f3 >expected &&\n'> <'\t\ttest_cmp expected f3\n'> <'\t)\n'>
        )
      }
    )
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:revision_ranges)
          op: Equal
          rhs: 
            {
              (DQ ('2000/01/01,#head ') ('\t\t 1,2080/01/01 ') ('\t\t 2000/01/01,2080/01/01 ') 
                ('\t\t 2000/01/01,1000 ') ('\t\t 1,1000')
              )
            }
          spids: [230]
        )
      ]
      spids: [230]
    )
    (C {(test_expect_success)} {(SQ <'clone using non-numeric revision ranges'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished cleanup_git &&\n'> <'\tfor r in $revision_ranges\n'> 
          <'\tdo\n'> <'\t\trm -fr "$git" &&\n'> <'\t\ttest ! -d "$git" &&\n'> 
          <'\t\tgit p4 clone --dest="$git" //depot@$r &&\n'> <'\t\t(\n'> <'\t\t\tcd "$git" &&\n'> <'\t\t\tgit ls-files >lines &&\n'> 
          <'\t\t\ttest_line_count = 6 lines\n'> <'\t\t)\n'> <'\tdone\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'clone with date range, excluding some changes'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\tbefore=$(date +%Y/%m/%d:%H:%M:%S) &&\n'> <'\tsleep 2 &&\n'> <'\t(\n'> <'\t\tcd "$cli" &&\n'> <'\t\t:>date_range_test &&\n'> 
          <'\t\tp4 add date_range_test &&\n'> <'\t\tp4 submit -d "Adding file"\n'> <'\t) &&\n'> 
          <'\tgit p4 clone --dest="$git" //depot@1,$before &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\t\ttest_path_is_missing date_range_test\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'exit when p4 fails to produce marshaled output'>)} 
      {
        (SQ <'\n'> <'\tmkdir badp4dir &&\n'> 
          <'\ttest_when_finished "rm badp4dir/p4 && rmdir badp4dir" &&\n'> <'\tcat >badp4dir/p4 <<-EOF &&\n'> <'\t#!$SHELL_PATH\n'> <'\texit 1\n'> <'\tEOF\n'> 
          <'\tchmod 755 badp4dir/p4 &&\n'> <'\t(\n'> <'\t\tPATH="$TRASH_DIRECTORY/badp4dir:$PATH" &&\n'> <'\t\texport PATH &&\n'> 
          <'\t\ttest_expect_code 1 git p4 clone --dest="$git" //depot >errs 2>&1\n'> <'\t) &&\n'> <'\tcat errs &&\n'> <'\ttest_i18ngrep ! Traceback errs\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'exit gracefully for p4 server errors'>)} 
      {
        (SQ <'\n'> 
          <'\ttest_when_finished "mv \\"$db\\"/depot/file1,v,hidden \\"$db\\"/depot/file1,v" &&\n'> <'\tmv "$db"/depot/file1,v "$db"/depot/file1,v,hidden &&\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\ttest_expect_code 1 git p4 clone --dest="$git" //depot@1 >out 2>err &&\n'> <'\ttest_i18ngrep "Error from p4 print" err\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'clone --bare should make a bare repository'>)} 
      {
        (SQ <'\n'> <'\trm -rf "$git" &&\n'> <'\tgit p4 clone --dest="$git" --bare //depot &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\t\ttest_path_is_missing .git &&\n'> 
          <'\t\tgit config --get --bool core.bare true &&\n'> <'\t\tgit rev-parse --verify refs/remotes/p4/master &&\n'> 
          <'\t\tgit rev-parse --verify refs/remotes/p4/HEAD &&\n'> <'\t\tgit rev-parse --verify refs/heads/master &&\n'> <'\t\tgit rev-parse --verify HEAD\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'initial import time from top change time'>)} 
      {
        (SQ <'\n'> <'\tp4change=$(p4 -G changes -m 1 //depot/... | marshal_dump change) &&\n'> 
          <'\tp4time=$(p4 -G changes -m 1 //depot/... | marshal_dump time) &&\n'> <'\tsleep 3 &&\n'> <'\tgit p4 clone --dest="$git" //depot &&\n'> 
          <'\ttest_when_finished cleanup_git &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\t\tgittime=$(git show -s --raw --pretty=format:%at HEAD) &&\n'> 
          <'\t\techo $p4time $gittime &&\n'> <'\t\ttest $p4time = $gittime\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'unresolvable host in P4PORT should display error'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\tgit p4 clone --dest="$git" //depot &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\t\tP4PORT=nosuchhost:65537 &&\n'> <'\t\texport P4PORT &&\n'> 
          <'\t\ttest_expect_code 1 git p4 sync >out 2>err &&\n'> <'\t\tgrep "connect to nosuchhost" err\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'submit from detached head'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished cleanup_git &&\n'> 
          <'\tgit p4 clone --dest="$git" //depot &&\n'> <'\t(\n'> <'\t\tcd "$git" &&\n'> <'\t\tgit checkout p4/master &&\n'> <'\t\t>detached_head_test &&\n'> 
          <'\t\tgit add detached_head_test &&\n'> <'\t\tgit commit -m "add detached_head" &&\n'> <'\t\tgit config git-p4.skipSubmitEdit true &&\n'> 
          <'\t\tgit p4 submit &&\n'> <'\t\tgit p4 rebase &&\n'> <'\t\tgit log p4/master | grep detached_head\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'kill p4d'>)} {(SQ <'\n'> <'\tkill_p4d\n'>)})
    (C {(test_done)})
  ]
)