Skip to content

Commit f7f6b0e

Browse files
committed
Added CompilerWithEmptyFirstArg testcase
1 parent c351c35 commit f7f6b0e

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ def execute_command(self, command, cwd=None, stdout_captured=None):
112112
else:
113113
argument_list.extend(flattening_arg)
114114

115-
# Filter out empty elements in argument_list
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
116117
argument_list = filter(None, argument_list)
117118
stdout = None
118119
try:

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)