Skip to content

Commit

Permalink
allow running command builders (not on source files)
Browse files Browse the repository at this point in the history
  • Loading branch information
mriehl committed Feb 25, 2015
1 parent 81e112d commit 2c5ee0c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/python/pybuilder/pluginhelper/external_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# limitations under the License.

from pybuilder.plugins.python.python_plugin_helper import execute_tool_on_source_files
from pybuilder.utils import read_file
from pybuilder.utils import read_file, execute_command


class ExternalCommandResult(object):
Expand Down Expand Up @@ -63,6 +63,9 @@ def only_if_property_is_truthy(self, property_name):
def as_string(self):
return ' '.join(self.parts)

def run(self, outfile_name):
return execute_command(self.parts, outfile_name)

def run_on_production_source_files(self, logger, include_test_sources=False, include_scripts=False):
execution_result = execute_tool_on_source_files(project=self.project,
name=self.command_name,
Expand Down
6 changes: 6 additions & 0 deletions src/unittest/python/external_command_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ def setUp(self):
self.command = ExternalCommandBuilder('command-name', self.project)
self.command.use_argument('--foo').use_argument('--bar')

@patch("pybuilder.pluginhelper.external_command.execute_command")
def test_should_execute_external_command(self, execute_command):
self.command.run("any-outfile-name")

execute_command.assert_called_with(['command-name', '--foo', '--bar'], 'any-outfile-name')

@patch('pybuilder.pluginhelper.external_command.read_file')
@patch('pybuilder.pluginhelper.external_command.execute_tool_on_source_files')
def test_should_execute_external_command_on_production_source_files(self, execution, read):
Expand Down

0 comments on commit 2c5ee0c

Please sign in to comment.