Skip to content

Commit 1e73c24

Browse files
authored
Merge pull request jazzband#590 from solkaz/master
Remove empty args from argument_list in SubprocessCompiler
2 parents c6067eb + f7f6b0e commit 1e73c24

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ or just made Pipeline more awesome.
5959
* Jannis Leidel <[email protected]>
6060
* Jared Scott <[email protected]>
6161
* Jaromir Fojtu <[email protected]>
62+
* Jeff Held <[email protected]>
6263
* Jon Dufresne <[email protected]>
6364
* Josh Braegger <[email protected]>
6465
* Joshua Kehn <[email protected]>

pipeline/compilers/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ def execute_command(self, command, cwd=None, stdout_captured=None):
112112
else:
113113
argument_list.extend(flattening_arg)
114114

115+
# The first element in argument_list is the program that will be executed; if it is '', then
116+
# a PermissionError will be raised. Thus empty arguments are filtered out from argument_list
117+
argument_list = filter(None, argument_list)
115118
stdout = None
116119
try:
117120
# We always catch stdout in a file, but we may not have a use for it.

tests/tests/test_compiler.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ def compile_file(self, infile, outfile, outdated=False, force=False):
4242
)
4343
return self.execute_command(command)
4444

45+
class CompilerWithEmptyFirstArg(SubProcessCompiler):
46+
output_extension = 'junk'
47+
48+
def match_file(self, path):
49+
return path.endswith('.coffee')
50+
51+
def compile_file(self, infile, outfile, outdated=False, force=False):
52+
command = (
53+
('', '/usr/bin/env', 'cat'),
54+
infile,
55+
)
56+
return self.execute_command(command, stdout_captured=outfile)
4557

4658
class CopyingCompiler(SubProcessCompiler):
4759
output_extension = 'junk'
@@ -149,6 +161,20 @@ def tearDown(self):
149161
default_collector.clear()
150162

151163

164+
@pipeline_settings(COMPILERS=['tests.tests.test_compiler.CompilerWithEmptyFirstArg'])
165+
class CompilerWithEmptyFirstArgTest(TestCase):
166+
def setUp(self):
167+
default_collector.collect()
168+
self.compiler = Compiler()
169+
170+
def test_compile(self):
171+
paths = self.compiler.compile([_('pipeline/js/dummy.coffee')])
172+
default_collector.collect()
173+
self.assertEqual([_('pipeline/js/dummy.junk')], list(paths))
174+
175+
def tearDown(self):
176+
default_collector.clear()
177+
152178
@pipeline_settings(COMPILERS=['tests.tests.test_compiler.InvalidCompiler'])
153179
class InvalidCompilerTest(TestCase):
154180
def setUp(self):
@@ -158,7 +184,6 @@ def setUp(self):
158184
def test_compile(self):
159185
with self.assertRaises(CompilerError) as cm:
160186
self.compiler.compile([_('pipeline/js/dummy.coffee')])
161-
162187
e = cm.exception
163188
self.assertEqual(
164189
e.command,

0 commit comments

Comments
 (0)