Commit f7f6b0e7 by Solkaz

Added CompilerWithEmptyFirstArg testcase

parent c351c350
......@@ -59,6 +59,7 @@ or just made Pipeline more awesome.
* Jannis Leidel <jannis@leidel.info>
* Jared Scott <jscott@convertro.com>
* Jaromir Fojtu <jaromir.fojtu@gmail.com>
* Jeff Held <jheld135@gmail.com>
* Jon Dufresne <jon.dufresne@gmail.com>
* Josh Braegger <rckclmbr@gmail.com>
* Joshua Kehn <josh@kehn.us>
......
......@@ -112,7 +112,8 @@ class SubProcessCompiler(CompilerBase):
else:
argument_list.extend(flattening_arg)
# Filter out empty elements in argument_list
# 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
try:
......
......@@ -42,6 +42,18 @@ class InvalidCompiler(SubProcessCompiler):
)
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):
output_extension = 'junk'
......@@ -149,6 +161,20 @@ class CompilerSelfWriterTest(TestCase):
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'])
class InvalidCompilerTest(TestCase):
def setUp(self):
......@@ -158,7 +184,6 @@ class InvalidCompilerTest(TestCase):
def test_compile(self):
with self.assertRaises(CompilerError) as cm:
self.compiler.compile([_('pipeline/js/dummy.coffee')])
e = cm.exception
self.assertEqual(
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