autotest: Not raise error when there's no commmited autotest changes.
BUG=chromium:707490
TEST=Ran unittest.
Change-Id: I5a71e471ace4e08af078480e68b8f4381a5a725f
Reviewed-on: https://chromium-review.googlesource.com/544120
Commit-Ready: Xixuan Wu <xixuan@chromium.org>
Tested-by: Xixuan Wu <xixuan@chromium.org>
Reviewed-by: Shuqian Zhao <shuqianz@chromium.org>
diff --git a/site_utils/automated_deploy.py b/site_utils/automated_deploy.py
index 770d9a1..e0ad0de 100755
--- a/site_utils/automated_deploy.py
+++ b/site_utils/automated_deploy.py
@@ -150,9 +150,17 @@
with infra.chdir(repo_dir):
get_commits_cmd = 'git log --oneline %s' % pushed_commits_range
+
+ pushed_commits = infra.local_runner(
+ get_commits_cmd, stream_output=True)
if repo == 'autotest':
- get_commits_cmd += '|grep autotest'
- pushed_commits = infra.local_runner(get_commits_cmd, stream_output=True)
+ autotest_commits = ''
+ for cl in pushed_commits.splitlines():
+ if 'autotest' in cl:
+ autotest_commits += '%s\n' % cl
+
+ pushed_commits = autotest_commits
+
print 'Successfully got pushed CLs for %s repo!\n' % repo
return '\n%s:\n%s\n%s\n' % (repo, get_commits_cmd, pushed_commits)
diff --git a/site_utils/automated_deploy_unittest.py b/site_utils/automated_deploy_unittest.py
index 6e73d39..2e826c2 100644
--- a/site_utils/automated_deploy_unittest.py
+++ b/site_utils/automated_deploy_unittest.py
@@ -104,25 +104,27 @@
@param run_cmd: Mock of infra.local_runner call used.
"""
- fake_commits_logs = '123 Test_change_1\n456 Test_change_2'
+ autotest_commits_logs = '123: autotest: cl_1\n456: autotest: cl_2\n'
+ chromite_commits_logs = '789: test_cl_1\n'
+ fake_commits_logs = autotest_commits_logs + chromite_commits_logs
run_cmd.return_value = fake_commits_logs
#Test to get pushed commits for autotest repo.
repo = 'autotest'
- expect_git_log_cmd = 'git log --oneline 123..456|grep autotest'
+ expect_git_log_cmd = 'git log --oneline 123..789'
expect_return = ('\n%s:\n%s\n%s\n' %
- (repo, expect_git_log_cmd, fake_commits_logs))
- actual_return = ad.get_pushed_commits(repo, 'test', '123..456')
+ (repo, expect_git_log_cmd, autotest_commits_logs))
+ actual_return = ad.get_pushed_commits(repo, 'test', '123..789')
run_cmd.assert_called_with(expect_git_log_cmd, stream_output=True)
self.assertEqual(expect_return, actual_return)
#Test to get pushed commits for chromite repo.
repo = 'chromite'
- expect_git_log_cmd = 'git log --oneline 123..456'
+ expect_git_log_cmd = 'git log --oneline 123..789'
expect_return = ('\n%s:\n%s\n%s\n' %
(repo, expect_git_log_cmd, fake_commits_logs))
- actual_return = ad.get_pushed_commits(repo, 'test', '123..456')
+ actual_return = ad.get_pushed_commits(repo, 'test', '123..789')
run_cmd.assert_called_with(expect_git_log_cmd, stream_output=True)
self.assertEqual(expect_return, actual_return)