Windows symlink: replace echo to python code and fix --shell command line propagation

This commit is contained in:
Dmitry Petrov
2017-04-10 12:47:03 -07:00
parent f539fa8c60
commit 376f139f81
4 changed files with 16 additions and 7 deletions
+4 -3
View File
@@ -34,7 +34,7 @@ class CmdRun(CmdBase):
help='Declare output data items for reproducible cmd')
parser.add_argument('--code', '-c', action='append',
help='Code dependencies which produce the output')
parser.add_argument('--shell', help='Shell command', action='store_false', default=False)
parser.add_argument('--shell', help='Shell command', action='store_true', default=False)
pass
@property
@@ -76,11 +76,12 @@ class CmdRun(CmdBase):
return 1
def run_command(self, cmd_args, data_items_from_args, stdout=None, stderr=None, shell=False):
Logger.debug('Run command with args: {}. Data items from args: {}. stdout={}, stderr={}'.format(
Logger.debug('Run command with args: {}. Data items from args: {}. stdout={}, stderr={}, shell={}'.format(
' '.join(cmd_args),
', '.join([x.data.dvc for x in data_items_from_args]),
stdout,
stderr))
stderr,
shell))
repo_change = RepositoryChange(cmd_args, self.settings, stdout, stderr, shell=shell)
+3 -2
View File
@@ -20,10 +20,11 @@ class RepositoryChange(object):
def __init__(self, cmd_args, settings, stdout, stderr, shell=False):
self._settings = settings
Logger.debug(u'[Repository change] Exec command: {}. stdout={}, stderr={}'.format(
Logger.debug(u'[Repository change] Exec command: {}. stdout={}, stderr={}, shell={}'.format(
u' '.join(cmd_args),
stdout,
stderr))
stderr,
shell))
Executor.exec_cmd_only_success(cmd_args, stdout, stderr, shell=shell)
self._stated_data_items = []
+4 -1
View File
@@ -33,7 +33,10 @@ class TestExecutor(TestCase):
self.assertEqual(output_set, {self.file1, self.file2})
def test_output_to_std_console(self):
output = Executor.exec_cmd_only_success([Runtime.ls_command_name(), self.test_dir], '-', '-')
output = Executor.exec_cmd_only_success([Runtime.ls_command_name(), self.test_dir],
'-',
'-',
shell=True)
self.assertEqual(output, '')
def test_custom_file_outputs(self):
+5 -1
View File
@@ -30,7 +30,11 @@ class ReproBasicEnv(RunBasicTest):
CmdRun(self.settings).run()
self.file_name2 = os.path.join('data', 'file2')
self.settings._args = ['echo', 'Bobby', '--not-repro', '--stdout', self.file_name2, '--shell']
self.file2_code_file = 'file2.py'
self.create_file_and_commit(self.file2_code_file,
'print("Bobby")')
self.settings._args = ['python', self.file2_code_file,
'--not-repro', '--stdout', self.file_name2]
CmdRun(self.settings).run()
self.file_res_code_file = 'code_res.py'