Commit 1e73c246 by Timothée Peignier Committed by GitHub

Merge pull request #590 from solkaz/master

Remove empty args from argument_list in SubprocessCompiler
parents c6067eb3 f7f6b0e7
...@@ -59,6 +59,7 @@ or just made Pipeline more awesome. ...@@ -59,6 +59,7 @@ or just made Pipeline more awesome.
* Jannis Leidel <jannis@leidel.info> * Jannis Leidel <jannis@leidel.info>
* Jared Scott <jscott@convertro.com> * Jared Scott <jscott@convertro.com>
* Jaromir Fojtu <jaromir.fojtu@gmail.com> * Jaromir Fojtu <jaromir.fojtu@gmail.com>
* Jeff Held <jheld135@gmail.com>
* Jon Dufresne <jon.dufresne@gmail.com> * Jon Dufresne <jon.dufresne@gmail.com>
* Josh Braegger <rckclmbr@gmail.com> * Josh Braegger <rckclmbr@gmail.com>
* Joshua Kehn <josh@kehn.us> * Joshua Kehn <josh@kehn.us>
......
...@@ -112,6 +112,9 @@ class SubProcessCompiler(CompilerBase): ...@@ -112,6 +112,9 @@ class SubProcessCompiler(CompilerBase):
else: else:
argument_list.extend(flattening_arg) argument_list.extend(flattening_arg)
# The first element in argument_list is the program that will be executed; if it is '', then
# a PermissionError will be raised. Thus empty arguments are filtered out from argument_list
argument_list = filter(None, argument_list)
stdout = None stdout = None
try: try:
# We always catch stdout in a file, but we may not have a use for it. # We always catch stdout in a file, but we may not have a use for it.
......
...@@ -42,6 +42,18 @@ class InvalidCompiler(SubProcessCompiler): ...@@ -42,6 +42,18 @@ class InvalidCompiler(SubProcessCompiler):
) )
return self.execute_command(command) return self.execute_command(command)
class CompilerWithEmptyFirstArg(SubProcessCompiler):
output_extension = 'junk'
def match_file(self, path):
return path.endswith('.coffee')
def compile_file(self, infile, outfile, outdated=False, force=False):
command = (
('', '/usr/bin/env', 'cat'),
infile,
)
return self.execute_command(command, stdout_captured=outfile)
class CopyingCompiler(SubProcessCompiler): class CopyingCompiler(SubProcessCompiler):
output_extension = 'junk' output_extension = 'junk'
...@@ -149,6 +161,20 @@ class CompilerSelfWriterTest(TestCase): ...@@ -149,6 +161,20 @@ class CompilerSelfWriterTest(TestCase):
default_collector.clear() default_collector.clear()
@pipeline_settings(COMPILERS=['tests.tests.test_compiler.CompilerWithEmptyFirstArg'])
class CompilerWithEmptyFirstArgTest(TestCase):
def setUp(self):
default_collector.collect()
self.compiler = Compiler()
def test_compile(self):
paths = self.compiler.compile([_('pipeline/js/dummy.coffee')])
default_collector.collect()
self.assertEqual([_('pipeline/js/dummy.junk')], list(paths))
def tearDown(self):
default_collector.clear()
@pipeline_settings(COMPILERS=['tests.tests.test_compiler.InvalidCompiler']) @pipeline_settings(COMPILERS=['tests.tests.test_compiler.InvalidCompiler'])
class InvalidCompilerTest(TestCase): class InvalidCompilerTest(TestCase):
def setUp(self): def setUp(self):
...@@ -158,7 +184,6 @@ class InvalidCompilerTest(TestCase): ...@@ -158,7 +184,6 @@ class InvalidCompilerTest(TestCase):
def test_compile(self): def test_compile(self):
with self.assertRaises(CompilerError) as cm: with self.assertRaises(CompilerError) as cm:
self.compiler.compile([_('pipeline/js/dummy.coffee')]) self.compiler.compile([_('pipeline/js/dummy.coffee')])
e = cm.exception e = cm.exception
self.assertEqual( self.assertEqual(
e.command, e.command,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment