Merge "Don't test candidate files if they're removed"
This commit is contained in:
commit
bd41d79fb0
|
@ -76,7 +76,7 @@ def check_for_changes(projects, filepath, limit, verbose=0):
|
||||||
|
|
||||||
|
|
||||||
def find_modified_candidate_files():
|
def find_modified_candidate_files():
|
||||||
"Return a list of files modified by the most recent commit."
|
"Return a list of non-removed files modified by the most recent commit."
|
||||||
results = subprocess.check_output(
|
results = subprocess.check_output(
|
||||||
['git', 'diff', '--name-only', '--pretty=format:', 'HEAD^']
|
['git', 'diff', '--name-only', '--pretty=format:', 'HEAD^']
|
||||||
).decode('utf-8')
|
).decode('utf-8')
|
||||||
|
@ -84,6 +84,7 @@ def find_modified_candidate_files():
|
||||||
li.strip()
|
li.strip()
|
||||||
for li in results.splitlines()
|
for li in results.splitlines()
|
||||||
if (li.startswith(utils.CANDIDATE_PATH + '/') and
|
if (li.startswith(utils.CANDIDATE_PATH + '/') and
|
||||||
|
os.path.exists(li) and
|
||||||
not li.endswith('.placeholder'))
|
not li.endswith('.placeholder'))
|
||||||
]
|
]
|
||||||
return filenames
|
return filenames
|
||||||
|
|
|
@ -37,8 +37,10 @@ class TestFindModifiedCandidateFiles(base.ElectionTestCase):
|
||||||
ci_check_all_candidate_files.find_modified_candidate_files()
|
ci_check_all_candidate_files.find_modified_candidate_files()
|
||||||
self.assertEqual(expected_filenames, filenames)
|
self.assertEqual(expected_filenames, filenames)
|
||||||
|
|
||||||
|
@mock.patch('os.path.exists', return_value=True)
|
||||||
@mock.patch('subprocess.check_output')
|
@mock.patch('subprocess.check_output')
|
||||||
def test_find_modified_candidate_files_all_good(self, mock_check_output):
|
def test_find_modified_candidate_files_all_good(
|
||||||
|
self, mock_check_output, mock_path_exists):
|
||||||
check_output = (('configuration.yaml\n'
|
check_output = (('configuration.yaml\n'
|
||||||
'openstack_election/__init__py\n'
|
'openstack_election/__init__py\n'
|
||||||
'%(path)s/candidate\n'
|
'%(path)s/candidate\n'
|
||||||
|
|
Loading…
Reference in New Issue