@ -1272,6 +1272,8 @@ class TestGitCl(unittest.TestCase):
scm . GIT . GetBranchConfig ( ' ' , ' main ' ,
git_cl . GERRIT_SQUASH_HASH_CONFIG_KEY ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_gerrit_upload_traces_no_gitcookies ( self ) :
self . _run_gerrit_upload_test (
[ ' --no-squash ' ] ,
@ -1281,6 +1283,8 @@ class TestGitCl(unittest.TestCase):
change_id = ' Ixxx ' ,
gitcookies_exists = False )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_gerrit_upload_without_change_id_nosquash ( self ) :
self . _run_gerrit_upload_test (
[ ' --no-squash ' ] ,
@ -1289,6 +1293,8 @@ class TestGitCl(unittest.TestCase):
post_amend_description = ' desc ✔ \n \n BUG= \n \n Change-Id: Ixxx ' ,
change_id = ' Ixxx ' )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_gerrit_upload_without_change_id_override_nosquash ( self ) :
self . _run_gerrit_upload_test (
[ ] ,
@ -1298,6 +1304,8 @@ class TestGitCl(unittest.TestCase):
post_amend_description = ' desc ✔ \n \n BUG= \n \n Change-Id: Ixxx ' ,
change_id = ' Ixxx ' )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_gerrit_no_reviewer ( self ) :
self . _run_gerrit_upload_test (
[ ] ,
@ -1306,6 +1314,8 @@ class TestGitCl(unittest.TestCase):
squash_mode = ' override_nosquash ' ,
change_id = ' I123456789 ' )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_gerrit_push_opts ( self ) :
self . _run_gerrit_upload_test (
[ ' -o ' , ' wip ' ] ,
@ -1315,6 +1325,8 @@ class TestGitCl(unittest.TestCase):
change_id = ' I123456789 ' ,
push_opts = [ ' -o ' , ' wip ' ] )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_gerrit_no_reviewer_non_chromium_host ( self ) :
# TODO(crbug/877717): remove this test case.
self . _run_gerrit_upload_test (
@ -1325,6 +1337,8 @@ class TestGitCl(unittest.TestCase):
short_hostname = ' other ' ,
change_id = ' I123456789 ' )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_gerrit_patchset_title_special_chars_nosquash ( self ) :
self . _run_gerrit_upload_test (
[ ' -f ' , ' -t ' , ' We \' ll escape ^_ ^ special chars...@ {u} ' ] ,
@ -1334,6 +1348,8 @@ class TestGitCl(unittest.TestCase):
change_id = ' I123456789 ' ,
title = ' We \' ll escape ^_ ^ special chars...@ {u} ' )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_gerrit_reviewers_cmd_line ( self ) :
self . _run_gerrit_upload_test (
[ ' -r ' , ' foo@example.com ' , ' --send-mail ' ] ,
@ -1346,6 +1362,8 @@ class TestGitCl(unittest.TestCase):
final_description = (
' desc ✔ \n \n BUG= \n R=foo@example.com \n \n Change-Id: I123456789 ' ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_gerrit_reviewers_cmd_line_send_email ( self ) :
self . _run_gerrit_upload_test (
[ ' -r ' , ' foo@example.com ' , ' --send-email ' ] ,
@ -2377,6 +2395,8 @@ class TestGitCl(unittest.TestCase):
} ,
}
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_patch_gerrit_default ( self ) :
self . _patch_common ( )
self . calls + = [
@ -2389,6 +2409,8 @@ class TestGitCl(unittest.TestCase):
self . assertEqual ( git_cl . main ( [ ' patch ' , ' 123456 ' ] ) , 0 )
self . assertIssueAndPatchset ( )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_patch_gerrit_new_branch ( self ) :
self . _patch_common ( )
self . calls + = [
@ -2401,6 +2423,8 @@ class TestGitCl(unittest.TestCase):
self . assertEqual ( git_cl . main ( [ ' patch ' , ' -b ' , ' feature ' , ' 123456 ' ] ) , 0 )
self . assertIssueAndPatchset ( branch = ' feature ' )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_patch_gerrit_force ( self ) :
self . _patch_common ( ' host ' )
self . calls + = [
@ -2413,6 +2437,8 @@ class TestGitCl(unittest.TestCase):
self . assertEqual ( git_cl . main ( [ ' patch ' , ' 123456 ' , ' --force ' ] ) , 0 )
self . assertIssueAndPatchset ( git_short_host = ' host ' )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_patch_gerrit_guess_by_url ( self ) :
self . _patch_common ( ' else ' )
self . calls + = [
@ -2428,6 +2454,8 @@ class TestGitCl(unittest.TestCase):
0 )
self . assertIssueAndPatchset ( patchset = ' 1 ' , git_short_host = ' else ' )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_patch_gerrit_guess_by_url_with_repo ( self ) :
self . _patch_common ( ' else ' )
self . calls + = [
@ -2444,6 +2472,8 @@ class TestGitCl(unittest.TestCase):
] ) , 0 )
self . assertIssueAndPatchset ( patchset = ' 1 ' , git_short_host = ' else ' )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
@mock.patch ( ' sys.stderr ' , io . StringIO ( ) )
def test_patch_gerrit_conflict ( self ) :
self . _patch_common ( )
@ -2459,6 +2489,8 @@ class TestGitCl(unittest.TestCase):
self . assertEqual ( ' Command " git cherry-pick FETCH_HEAD " failed. \n \n ' ,
sys . stderr . getvalue ( ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
@mock.patch ( ' gerrit_util.GetChangeDetail ' ,
side_effect = gerrit_util . GerritError ( 404 , ' ' ) )
@mock.patch ( ' sys.stderr ' , io . StringIO ( ) )
@ -2475,6 +2507,8 @@ class TestGitCl(unittest.TestCase):
scm . GIT . SetConfig ( ' ' , ' branch.ger-branch.gerritissue ' , ' 123456 ' )
scm . GIT . SetConfig ( ' ' , ' branch.gbranch654.gerritissue ' , ' 654321 ' )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_checkout_gerrit ( self ) :
""" Tests git cl checkout <issue>. """
self . _checkout_config ( )
@ -2632,18 +2666,26 @@ class TestGitCl(unittest.TestCase):
} , notify , None ) , ' ' ) ,
]
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_cmd_set_commit_gerrit_clear ( self ) :
self . _cmd_set_commit_gerrit_common ( 0 )
self . assertEqual ( 0 , git_cl . main ( [ ' set-commit ' , ' -c ' ] ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_cmd_set_commit_gerrit_dry ( self ) :
self . _cmd_set_commit_gerrit_common ( 1 , notify = False )
self . assertEqual ( 0 , git_cl . main ( [ ' set-commit ' , ' -d ' ] ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_cmd_set_commit_gerrit ( self ) :
self . _cmd_set_commit_gerrit_common ( 2 )
self . assertEqual ( 0 , git_cl . main ( [ ' set-commit ' ] ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_description_display ( self ) :
mock . patch ( ' git_cl.Changelist ' , ChangelistMock ) . start ( )
ChangelistMock . desc = ' foo \n '
@ -2651,6 +2693,8 @@ class TestGitCl(unittest.TestCase):
self . assertEqual ( 0 , git_cl . main ( [ ' description ' , ' -d ' ] ) )
self . assertEqual ( ' foo \n ' , sys . stdout . getvalue ( ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
@mock.patch ( ' sys.stderr ' , io . StringIO ( ) )
def test_StatusFieldOverrideIssueMissingArgs ( self ) :
try :
@ -2659,6 +2703,8 @@ class TestGitCl(unittest.TestCase):
self . assertIn ( ' --field must be given when --issue is set. ' ,
sys . stderr . getvalue ( ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_StatusFieldOverrideIssue ( self ) :
def assertIssue ( cl_self , * _args ) :
self . assertEqual ( cl_self . issue , 1 )
@ -2669,6 +2715,8 @@ class TestGitCl(unittest.TestCase):
git_cl . main ( [ ' status ' , ' --issue ' , ' 1 ' , ' --field ' , ' desc ' ] ) , 0 )
self . assertEqual ( sys . stdout . getvalue ( ) , ' foobar \n ' )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_SetCloseOverrideIssue ( self ) :
def assertIssue ( cl_self , * _args ) :
self . assertEqual ( cl_self . issue , 1 )
@ -2678,6 +2726,8 @@ class TestGitCl(unittest.TestCase):
mock . patch ( ' git_cl.Changelist.CloseIssue ' , lambda * _ : None ) . start ( )
self . assertEqual ( git_cl . main ( [ ' set-close ' , ' --issue ' , ' 1 ' ] ) , 0 )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_description ( self ) :
scm . GIT . SetConfig ( ' ' , ' remote.origin.url ' ,
' https://chromium.googlesource.com/my/repo ' )
@ -2700,6 +2750,8 @@ class TestGitCl(unittest.TestCase):
] ) )
self . assertEqual ( ' foobar \n ' , sys . stdout . getvalue ( ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_description_set_raw ( self ) :
mock . patch ( ' git_cl.Changelist ' , ChangelistMock ) . start ( )
mock . patch ( ' git_cl.sys.stdin ' , io . StringIO ( ' hihi ' ) ) . start ( )
@ -2707,6 +2759,8 @@ class TestGitCl(unittest.TestCase):
self . assertEqual ( 0 , git_cl . main ( [ ' description ' , ' -n ' , ' hihi ' ] ) )
self . assertEqual ( ' hihi ' , ChangelistMock . desc )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_description_appends_bug_line ( self ) :
current_desc = ' Some. \n \n Change-Id: xxx '
@ -2733,6 +2787,8 @@ class TestGitCl(unittest.TestCase):
scm . GIT . SetConfig ( ' ' , ' branch.main.gerritissue ' , ' 123 ' )
self . assertEqual ( 0 , git_cl . main ( [ ' description ' ] ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_description_does_not_append_bug_line_if_fixed_is_present ( self ) :
current_desc = ' Some. \n \n Fixed: 123 \n Change-Id: xxx '
@ -2753,6 +2809,8 @@ class TestGitCl(unittest.TestCase):
scm . GIT . SetConfig ( ' ' , ' branch.main.gerritissue ' , ' 123 ' )
self . assertEqual ( 0 , git_cl . main ( [ ' description ' ] ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_description_set_stdin ( self ) :
mock . patch ( ' git_cl.Changelist ' , ChangelistMock ) . start ( )
mock . patch ( ' git_cl.sys.stdin ' ,
@ -2761,6 +2819,8 @@ class TestGitCl(unittest.TestCase):
self . assertEqual ( 0 , git_cl . main ( [ ' description ' , ' -n ' , ' - ' ] ) )
self . assertEqual ( ' hi \n \t there \n \n man ' , ChangelistMock . desc )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_archive ( self ) :
self . calls = [
( ( [ ' git ' , ' for-each-ref ' , ' --format= % (refname) ' , ' refs/heads ' ] , ) ,
@ -2781,6 +2841,8 @@ class TestGitCl(unittest.TestCase):
self . assertEqual ( 0 , git_cl . main ( [ ' archive ' , ' -f ' ] ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_archive_tag_collision ( self ) :
self . calls = [
( ( [ ' git ' , ' for-each-ref ' , ' --format= % (refname) ' , ' refs/heads ' ] , ) ,
@ -2801,6 +2863,8 @@ class TestGitCl(unittest.TestCase):
self . assertEqual ( 0 , git_cl . main ( [ ' archive ' , ' -f ' ] ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_archive_current_branch_fails ( self ) :
self . calls = [
( ( [ ' git ' , ' for-each-ref ' , ' --format= % (refname) ' ,
@ -2817,6 +2881,8 @@ class TestGitCl(unittest.TestCase):
self . assertEqual ( 1 , git_cl . main ( [ ' archive ' , ' -f ' ] ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_archive_dry_run ( self ) :
self . calls = [
( ( [ ' git ' , ' for-each-ref ' , ' --format= % (refname) ' , ' refs/heads ' ] , ) ,
@ -2835,6 +2901,8 @@ class TestGitCl(unittest.TestCase):
self . assertEqual ( 0 , git_cl . main ( [ ' archive ' , ' -f ' , ' --dry-run ' ] ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_archive_no_tags ( self ) :
self . calls = [
( ( [ ' git ' , ' for-each-ref ' , ' --format= % (refname) ' , ' refs/heads ' ] , ) ,
@ -2853,6 +2921,8 @@ class TestGitCl(unittest.TestCase):
self . assertEqual ( 0 , git_cl . main ( [ ' archive ' , ' -f ' , ' --notags ' ] ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_archive_tag_cleanup_on_branch_deletion_error ( self ) :
self . calls = [
( ( [ ' git ' , ' for-each-ref ' , ' --format= % (refname) ' , ' refs/heads ' ] , ) ,
@ -2876,6 +2946,8 @@ class TestGitCl(unittest.TestCase):
self . assertEqual ( 0 , git_cl . main ( [ ' archive ' , ' -f ' ] ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_archive_with_format ( self ) :
self . calls = [
( ( [ ' git ' , ' for-each-ref ' , ' --format= % (refname) ' , ' refs/heads ' ] , ) ,
@ -2896,6 +2968,8 @@ class TestGitCl(unittest.TestCase):
0 , git_cl . main ( [ ' archive ' , ' -f ' , ' -p ' ,
' archived/ {issue} - {branch} ' ] ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_cmd_issue_erase_existing ( self ) :
scm . GIT . SetConfig ( ' ' , ' branch.main.gerritissue ' , ' 123 ' )
scm . GIT . SetConfig ( ' ' , ' branch.main.gerritserver ' ,
@ -2907,6 +2981,8 @@ class TestGitCl(unittest.TestCase):
self . assertIsNone ( scm . GIT . GetConfig ( ' root ' , ' branch.main.gerritissue ' ) )
self . assertIsNone ( scm . GIT . GetConfig ( ' root ' , ' branch.main.gerritserver ' ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_cmd_issue_erase_existing_with_change_id ( self ) :
scm . GIT . SetConfig ( ' ' , ' branch.main.gerritissue ' , ' 123 ' )
scm . GIT . SetConfig ( ' ' , ' branch.main.gerritserver ' ,
@ -2924,6 +3000,8 @@ class TestGitCl(unittest.TestCase):
self . assertIsNone ( scm . GIT . GetConfig ( ' root ' , ' branch.main.gerritissue ' ) )
self . assertIsNone ( scm . GIT . GetConfig ( ' root ' , ' branch.main.gerritserver ' ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_cmd_issue_json ( self ) :
scm . GIT . SetConfig ( ' ' , ' branch.main.gerritissue ' , ' 123 ' )
scm . GIT . SetConfig ( ' ' , ' branch.main.gerritserver ' ,
@ -3161,6 +3239,8 @@ class TestGitCl(unittest.TestCase):
self . assertIn ( ' However, your configured .gitcookies file is missing. ' ,
sys . stdout . getvalue ( ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_git_cl_comment_add_gerrit ( self ) :
git_new_branch . create_new_branch ( None ) # hits mock from scm_mock.GIT.
scm . GIT . SetConfig ( ' ' , ' remote.origin.url ' ,
@ -3171,6 +3251,8 @@ class TestGitCl(unittest.TestCase):
]
self . assertEqual ( 0 , git_cl . main ( [ ' comment ' , ' -i ' , ' 10 ' , ' -a ' , ' msg ' ] ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
@mock.patch ( ' git_cl.Changelist.GetBranch ' , return_value = ' foo ' )
def test_git_cl_comments_fetch_gerrit ( self , * _mocks ) :
scm . GIT . SetConfig ( ' ' , ' remote.origin.url ' ,
@ -3324,6 +3406,8 @@ class TestGitCl(unittest.TestCase):
self . assertEqual (
0 , git_cl . main ( [ ' comments ' , ' -i ' , ' 1 ' , ' -j ' , ' output.json ' ] ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_git_cl_comments_robot_comments ( self ) :
# git cl comments also fetches robot comments (which are considered a
# type of autogenerated comment), and unlike other types of comments,
@ -3531,6 +3615,8 @@ class TestGitCl(unittest.TestCase):
cl = git_cl . Changelist ( issue = 123456 )
self . assertEqual ( cl . _GerritChangeIdentifier ( ) , ' 123456 ' )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_gerrit_new_default ( self ) :
self . _run_gerrit_upload_test (
[ ] ,
@ -3540,6 +3626,8 @@ class TestGitCl(unittest.TestCase):
change_id = ' I123456789 ' ,
default_branch = ' main ' )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def test_gerrit_nosquash_with_issue ( self ) :
self . _run_gerrit_upload_test (
[ ] ,
@ -4267,6 +4355,8 @@ class CMDTestCaseBase(unittest.TestCase):
self . addCleanup ( mock . patch . stopall )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
class CMDPresubmitTestCase ( CMDTestCaseBase ) :
_RUN_HOOK_RETURN = {
' errors ' : [ ] ,
@ -4382,6 +4472,8 @@ class CMDTryResultsTestCase(CMDTestCaseBase):
' ,builds.*.createTime,builds.*.tags ' ) ,
}
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def testNoJobs ( self ) :
git_cl . _call_buildbucket . return_value = { }
@ -4391,6 +4483,8 @@ class CMDTryResultsTestCase(CMDTestCaseBase):
mock . ANY , ' cr-buildbucket.appspot.com ' , ' SearchBuilds ' ,
self . _DEFAULT_REQUEST )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def testTrivialCommits ( self ) :
self . assertEqual ( 0 , git_cl . main ( [ ' try-results ' ] ) )
git_cl . _call_buildbucket . assert_called_with (
@ -4422,6 +4516,8 @@ class CMDTryResultsTestCase(CMDTestCaseBase):
] ,
sys . stdout . getvalue ( ) . splitlines ( ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def testPrintToStdout ( self ) :
self . assertEqual ( 0 , git_cl . main ( [ ' try-results ' ] ) )
self . assertEqual ( [
@ -4446,6 +4542,8 @@ class CMDTryResultsTestCase(CMDTestCaseBase):
mock . ANY , ' cr-buildbucket.appspot.com ' , ' SearchBuilds ' ,
self . _DEFAULT_REQUEST )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
def testPrintToStdoutWithMasters ( self ) :
self . assertEqual ( 0 , git_cl . main ( [ ' try-results ' , ' --print-master ' ] ) )
self . assertEqual ( [
@ -4470,6 +4568,8 @@ class CMDTryResultsTestCase(CMDTestCaseBase):
mock . ANY , ' cr-buildbucket.appspot.com ' , ' SearchBuilds ' ,
self . _DEFAULT_REQUEST )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
@mock.patch ( ' git_cl.write_json ' )
def testWriteToJson ( self , mockJsonDump ) :
self . assertEqual ( 0 , git_cl . main ( [ ' try-results ' , ' --json ' , ' file.json ' ] ) )
@ -4529,6 +4629,8 @@ class CMDTryResultsTestCase(CMDTestCaseBase):
class CMDTryTestCase ( CMDTestCaseBase ) :
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
@mock.patch ( ' git_cl.Changelist.SetCQState ' )
def testSetCQDryRunByDefault ( self , mockSetCQState ) :
mockSetCQState . return_value = 0
@ -4538,6 +4640,8 @@ class CMDTryTestCase(CMDTestCaseBase):
sys . stdout . getvalue ( ) , ' Scheduling CQ dry run on: '
' https://chromium-review.googlesource.com/123456 \n ' )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
@mock.patch ( ' git_cl._call_buildbucket ' )
def testScheduleOnBuildbucket ( self , mockCallBuildbucket ) :
mockCallBuildbucket . return_value = { }
@ -4591,6 +4695,8 @@ class CMDTryTestCase(CMDTestCaseBase):
' cr-buildbucket.appspot.com ' ,
' Batch ' , expected_request )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
@mock.patch ( ' git_cl._call_buildbucket ' )
def testScheduleOnBuildbucketWithRevision ( self , mockCallBuildbucket ) :
mockCallBuildbucket . return_value = { }
@ -4694,6 +4800,8 @@ class CMDTryTestCase(CMDTestCaseBase):
' cr-buildbucket.appspot.com ' ,
' Batch ' , expected_request )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
@mock.patch ( ' sys.stderr ' , io . StringIO ( ) )
def testScheduleOnBuildbucket_WrongBucket ( self ) :
with self . assertRaises ( SystemExit ) :
@ -4703,6 +4811,8 @@ class CMDTryTestCase(CMDTestCaseBase):
] )
self . assertIn ( ' Invalid bucket: not-a-bucket. ' , sys . stderr . getvalue ( ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
@mock.patch ( ' git_cl._call_buildbucket ' )
@mock.patch ( ' git_cl._fetch_tryjobs ' )
def testScheduleOnBuildbucketRetryFailed ( self , mockFetchTryJobs ,
@ -5102,6 +5212,8 @@ class CMDFormatTestCase(unittest.TestCase):
self . _check_yapf_filtering ( files , expected )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
class CMDStatusTestCase ( CMDTestCaseBase ) :
# Return branch names a,..,f with comitterdates in increasing order, i.e.
# 'f' is the most-recently changed branch.
@ -5201,6 +5313,8 @@ class CMDStatusTestCase(CMDTestCaseBase):
' x \n ' )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
class CMDOwnersTestCase ( CMDTestCaseBase ) :
def setUp ( self ) :
super ( CMDOwnersTestCase , self ) . setUp ( )
@ -5284,6 +5398,8 @@ class CMDLintTestCase(CMDTestCaseBase):
self . assertIn ( ' pdf.cc:3: (cpplint) Do not indent within a namespace ' ,
git_cl . sys . stderr . getvalue ( ) )
@unittest.skipIf ( gclient_utils . IsEnvCog ( ) ,
' not supported in non-git environment ' )
@mock.patch ( ' git_cl.Changelist.GetAffectedFiles ' ,
return_value = [ ' chg-1.h ' , ' chg-2.cc ' ] )
@mock.patch ( ' git_cl.Changelist.GetCommonAncestorWithUpstream ' ,