[scm-wrapper] Report when file wrapper did not match anything
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
3ac7148b38
commit
29a2b45fb4
@ -76,6 +76,8 @@ class FileWrapper(ScmBase):
|
|||||||
if scm_root:
|
if scm_root:
|
||||||
raise ValueError("FileWrapper: 'scm_root' should be empty.")
|
raise ValueError("FileWrapper: 'scm_root' should be empty.")
|
||||||
dirs = glob.glob(scm_dir)
|
dirs = glob.glob(scm_dir)
|
||||||
|
if not dirs:
|
||||||
|
raise RuntimeError('No directories matched, can not export.')
|
||||||
for i in dirs:
|
for i in dirs:
|
||||||
_copy_all(i, target_dir)
|
_copy_all(i, target_dir)
|
||||||
|
|
||||||
@ -83,6 +85,8 @@ class FileWrapper(ScmBase):
|
|||||||
if scm_root:
|
if scm_root:
|
||||||
raise ValueError("FileWrapper: 'scm_root' should be empty.")
|
raise ValueError("FileWrapper: 'scm_root' should be empty.")
|
||||||
files = glob.glob(scm_file)
|
files = glob.glob(scm_file)
|
||||||
|
if not files:
|
||||||
|
raise RuntimeError('No files matched, can not export.')
|
||||||
for i in files:
|
for i in files:
|
||||||
target_path = os.path.join(target_dir, os.path.basename(i))
|
target_path = os.path.join(target_dir, os.path.basename(i))
|
||||||
shutil.copy2(i, target_path)
|
shutil.copy2(i, target_path)
|
||||||
|
@ -69,6 +69,24 @@ class FileSCMTestCase(unittest.TestCase):
|
|||||||
self.assertTrue(os.path.isfile(os.path.join(self.destdir, 'first')))
|
self.assertTrue(os.path.isfile(os.path.join(self.destdir, 'first')))
|
||||||
self.assertTrue(os.path.isfile(os.path.join(self.destdir, 'second')))
|
self.assertTrue(os.path.isfile(os.path.join(self.destdir, 'second')))
|
||||||
|
|
||||||
|
def test_get_missing_file(self):
|
||||||
|
with self.assertRaises(RuntimeError) as ctx:
|
||||||
|
scm.get_file_from_scm({'scm': 'file',
|
||||||
|
'repo': None,
|
||||||
|
'file': 'this-is-really-not-here.txt'},
|
||||||
|
self.destdir)
|
||||||
|
|
||||||
|
self.assertIn('No files matched', str(ctx.exception))
|
||||||
|
|
||||||
|
def test_get_missing_dir(self):
|
||||||
|
with self.assertRaises(RuntimeError) as ctx:
|
||||||
|
scm.get_dir_from_scm({'scm': 'file',
|
||||||
|
'repo': None,
|
||||||
|
'dir': 'this-is-really-not-here'},
|
||||||
|
self.destdir)
|
||||||
|
|
||||||
|
self.assertIn('No directories matched', str(ctx.exception))
|
||||||
|
|
||||||
|
|
||||||
class GitSCMTestCase(unittest.TestCase):
|
class GitSCMTestCase(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user