diff --git a/dvc/command/run.py b/dvc/command/run.py index 9c6647ff1..d6ffb29b6 100644 --- a/dvc/command/run.py +++ b/dvc/command/run.py @@ -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) diff --git a/dvc/repository_change.py b/dvc/repository_change.py index cc1d089c6..fa8879619 100644 --- a/dvc/repository_change.py +++ b/dvc/repository_change.py @@ -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 = [] diff --git a/tests/test_executor.py b/tests/test_executor.py index b48f5b087..ef8ae2c99 100644 --- a/tests/test_executor.py +++ b/tests/test_executor.py @@ -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): diff --git a/tests/test_repro.py b/tests/test_repro.py index 8cfd55f22..64cf3dbb5 100644 --- a/tests/test_repro.py +++ b/tests/test_repro.py @@ -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'